Notify clients when output scale changes
48e74466b72579d0ec08b0e55ffb86b89ba7fe24
1 parent
d8086fde
swm.c
+7 -6
| 1991 | 1991 | switch (event->state) { |
|
| 1992 | 1992 | case WL_POINTER_BUTTON_STATE_PRESSED: |
|
| 1993 | 1993 | if (cursor_mode != CURSOR_NORMAL && cursor_mode != CURSOR_PRESSED) |
|
| 1994 | 1994 | break; |
|
| 1995 | 1995 | pressed_button = event->button; |
|
| 1996 | - | cursor_mode = CURSOR_PRESSED; |
|
| 1997 | - | selmon = point_to_monitor(cursor->x, cursor->y); |
|
| 1996 | + | cursor_mode = CURSOR_PRESSED; |
|
| 1997 | + | selmon = point_to_monitor(cursor->x, cursor->y); |
|
| 1998 | 1998 | ||
| 1999 | 1999 | if (locked) |
|
| 2000 | 2000 | break; |
|
| 2001 | 2001 | ||
| 2002 | 2002 | /* Focus a window when a button is pressed over it. */ |
| 2019 | 2019 | tiled_resize_boundary( |
|
| 2020 | 2020 | selmon, (int)round(cursor->x), (int)round(cursor->y), &grab_horizontal |
|
| 2021 | 2021 | )) { |
|
| 2022 | 2022 | grabws = selmon->ws; |
|
| 2023 | 2023 | cursor_mode = CURSOR_TILE_RESIZE; |
|
| 2024 | - | grab_button = event->button; |
|
| 2024 | + | grab_button = event->button; |
|
| 2025 | 2025 | tiled_resize_cursor(true, grab_horizontal); |
|
| 2026 | 2026 | return; |
|
| 2027 | 2027 | } |
|
| 2028 | 2028 | tiled_resize_cursor(false, false); |
|
| 2029 | 2029 |
| 3825 | 3825 | if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { |
|
| 3826 | 3826 | for (i = 0; i < nsyms; i++) |
|
| 3827 | 3827 | handled |= key_binding(mods, syms[i], 0); |
|
| 3828 | 3828 | } |
|
| 3829 | 3829 | if ((handled & 2) && group->wlr_group->keyboard.repeat_info.delay > 0) { |
|
| 3830 | - | group->mods = mods; |
|
| 3830 | + | group->mods = mods; |
|
| 3831 | 3831 | wl_event_source_timer_update( |
|
| 3832 | 3832 | group->key_repeat_source, group->wlr_group->keyboard.repeat_info.delay |
|
| 3833 | 3833 | ); |
|
| 3834 | 3834 | } else { |
|
| 3835 | 3835 | group->nsyms = 0; |
| 4552 | 4552 | ||
| 4553 | 4553 | restore_max_stack(grabc->mon); |
|
| 4554 | 4554 | ||
| 4555 | 4555 | /* Float the window and let pointer motion move or resize it. */ |
|
| 4556 | 4556 | grabc->persist_float = 1; |
|
| 4557 | - | grab_button = pressed_button; |
|
| 4557 | + | grab_button = pressed_button; |
|
| 4558 | 4558 | set_floating(grabc, 1); |
|
| 4559 | 4559 | ||
| 4560 | 4560 | switch (cursor_mode = arg->u) { |
|
| 4561 | 4561 | case CURSOR_MOVE: |
|
| 4562 | 4562 | grabcx = (int)round(cursor->x) - grabc->geom.x; |
| 5350 | 5350 | client_assign_monitor(c, m); |
|
| 5351 | 5351 | ||
| 5352 | 5352 | if (!c->is_fullscreen) |
|
| 5353 | 5353 | c->prev = c->geom; |
|
| 5354 | 5354 | resize(c, c->geom, 0); |
|
| 5355 | - | } |
|
| 5355 | + | } else |
|
| 5356 | + | client_set_scale(client_surface(c), m->wlr_output->scale); |
|
| 5356 | 5357 | if (c->is_fullscreen) |
|
| 5357 | 5358 | resize(c, m->m, 0); |
|
| 5358 | 5359 | } |
|
| 5359 | 5360 | } |
|
| 5360 | 5361 |
test/unit.c
+43 -17
| 303 | 303 | static void test_workspace_scale(void) { |
|
| 304 | 304 | client_t client; |
|
| 305 | 305 | struct wlr_surface surface = {}; |
|
| 306 | 306 | struct wlr_xdg_surface xdg; |
|
| 307 | 307 | struct wlr_xdg_toplevel toplevel; |
|
| 308 | - | struct wlr_output output = { .scale = 2.0f }; |
|
| 309 | - | monitor_t monitor = { .wlr_output = &output }; |
|
| 308 | + | struct wlr_output output = { .scale = 2.0f }; |
|
| 309 | + | monitor_t monitor = { .wlr_output = &output }; |
|
| 310 | 310 | workspace_t workspace = {}; |
|
| 311 | 311 | ||
| 312 | 312 | init_xdg_client(&client, &xdg, &toplevel, "app", "Window"); |
|
| 313 | - | scaled_surface = nullptr; |
|
| 313 | + | scaled_surface = nullptr; |
|
| 314 | 314 | fractional_scale = 0; |
|
| 315 | - | buffer_scale = 0; |
|
| 316 | - | xdg.surface = &surface; |
|
| 317 | - | client.ws = &workspace; |
|
| 315 | + | buffer_scale = 0; |
|
| 316 | + | xdg.surface = &surface; |
|
| 317 | + | client.ws = &workspace; |
|
| 318 | 318 | wl_list_init(&clients); |
|
| 319 | 319 | wl_list_insert(&clients, &client.link); |
|
| 320 | 320 | assign_workspace(&workspace, &monitor); |
|
| 321 | 321 | assert(client.mon == &monitor); |
|
| 322 | 322 | assert(scaled_surface == &surface); |
|
| 323 | 323 | assert(fractional_scale == 2.0f); |
|
| 324 | 324 | assert(buffer_scale == 2); |
|
| 325 | 325 | wl_list_remove(&client.link); |
|
| 326 | 326 | } |
|
| 327 | 327 | ||
| 328 | + | /* Verify a scale change is sent to clients that stay on the same output. */ |
|
| 329 | + | static void test_output_scale_change(void) { |
|
| 330 | + | client_t client; |
|
| 331 | + | struct wlr_surface surface = {}; |
|
| 332 | + | struct wlr_xdg_surface xdg; |
|
| 333 | + | struct wlr_xdg_toplevel toplevel; |
|
| 334 | + | struct wlr_output output = { .scale = 2.5f }; |
|
| 335 | + | monitor_t monitor = { .wlr_output = &output }; |
|
| 336 | + | workspace_t workspace = { .mon = &monitor }; |
|
| 337 | + | ||
| 338 | + | init_xdg_client(&client, &xdg, &toplevel, "app", "Window"); |
|
| 339 | + | xdg.surface = &surface; |
|
| 340 | + | client.ws = &workspace; |
|
| 341 | + | client.mon = &monitor; |
|
| 342 | + | wl_list_init(&clients); |
|
| 343 | + | wl_list_insert(&clients, &client.link); |
|
| 344 | + | scaled_surface = nullptr; |
|
| 345 | + | fractional_scale = 0; |
|
| 346 | + | buffer_scale = 0; |
|
| 347 | + | assign_workspace(&workspace, &monitor); |
|
| 348 | + | assert(scaled_surface == &surface); |
|
| 349 | + | assert(fractional_scale == 2.5f); |
|
| 350 | + | assert(buffer_scale == 3); |
|
| 351 | + | wl_list_remove(&client.link); |
|
| 352 | + | } |
|
| 353 | + | ||
| 328 | 354 | /* Verify matching rules update client state and workspace assignment. */ |
|
| 329 | 355 | static void test_rule_application(void) { |
|
| 330 | 356 | client_t client; |
|
| 331 | 357 | struct wlr_xdg_surface surface; |
|
| 332 | 358 | struct wlr_xdg_toplevel toplevel; |
| 745 | 771 | struct wlr_pointer_swipe_end_event swipe_end = { .time_msec = 3, .cancelled = false }; |
|
| 746 | 772 | struct wlr_pointer_pinch_begin_event pinch_begin = { .time_msec = 4, .fingers = 2 }; |
|
| 747 | 773 | struct wlr_pointer_pinch_update_event pinch_update = { |
|
| 748 | 774 | .time_msec = 5, |
|
| 749 | 775 | .dx = 1, |
|
| 750 | - | ||
| 751 | 776 | .dy = 2, |
|
| 752 | 777 | .scale = 1.1, |
|
| 753 | 778 | .rotation = 3, |
|
| 754 | 779 | }; |
|
| 755 | 780 | struct wlr_pointer_pinch_end_event pinch_end = { .time_msec = 6, .cancelled = true }; |
| 780 | 805 | .state = WL_POINTER_BUTTON_STATE_RELEASED, |
|
| 781 | 806 | }; |
|
| 782 | 807 | struct wlr_cursor fake_cursor = {}; |
|
| 783 | 808 | client_t client = {}; |
|
| 784 | 809 | ||
| 785 | - | cursor = &fake_cursor; |
|
| 786 | - | grabc = &client; |
|
| 787 | - | grab_button = BTN_LEFT; |
|
| 788 | - | cursor_mode = CURSOR_MOVE; |
|
| 789 | - | client.type = XDG_SHELL; |
|
| 790 | - | client.mon = nullptr; |
|
| 791 | - | client.ws = nullptr; |
|
| 810 | + | cursor = &fake_cursor; |
|
| 811 | + | grabc = &client; |
|
| 812 | + | grab_button = BTN_LEFT; |
|
| 813 | + | cursor_mode = CURSOR_MOVE; |
|
| 814 | + | client.type = XDG_SHELL; |
|
| 815 | + | client.mon = nullptr; |
|
| 816 | + | client.ws = nullptr; |
|
| 792 | 817 | client.persist_float = 0; |
|
| 793 | 818 | button_press(nullptr, &event); |
|
| 794 | 819 | ||
| 795 | 820 | assert(cursor_mode == CURSOR_MOVE); |
|
| 796 | 821 | assert(grabc == &client); |
|
| 797 | 822 | } |
|
| 798 | 823 | /* Verify an implicit-output panel keeps its assigned output when it unmaps. */ |
|
| 799 | 824 | static void test_layer_unmap_monitor(void) { |
|
| 800 | - | struct wlr_layer_surface_v1 layer = {}; |
|
| 825 | + | struct wlr_layer_surface_v1 layer = {}; |
|
| 801 | 826 | monitor_t monitor = {}; |
|
| 802 | 827 | layer_surface_t wrapper = { |
|
| 803 | - | .mon = &monitor, |
|
| 804 | - | .layer_surface = &layer, |
|
| 828 | + | .mon = &monitor, |
|
| 829 | + | .layer_surface = &layer, |
|
| 805 | 830 | }; |
|
| 806 | 831 | ||
| 807 | 832 | assert(layer_surface_output_monitor(&wrapper) == &monitor); |
|
| 808 | 833 | } |
|
| 809 | 834 |
| 1025 | 1050 | { "workspaces", test_workspace_queries }, |
|
| 1026 | 1051 | { "paths-and-borders", test_paths_and_border_policy }, |
|
| 1027 | 1052 | { "rules", test_rule_application }, |
|
| 1028 | 1053 | { "focus", test_focus_queries }, |
|
| 1029 | 1054 | { "workspace-scale", test_workspace_scale }, |
|
| 1055 | + | { "output-scale-change", test_output_scale_change }, |
|
| 1030 | 1056 | { "window-state", test_window_state_storage }, |
|
| 1031 | 1057 | { "child-reaping", test_child_reaping }, |
|
| 1032 | 1058 | { "spawn-tracking", test_spawn_tracking }, |
|
| 1033 | 1059 | { "layer-unmap-monitor", test_layer_unmap_monitor }, |
|
| 1034 | 1060 | { "command-failure-notification", test_command_failure_notification }, |