diff options
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 2 | ||||
-rw-r--r-- | sway/commands/mode.c | 19 | ||||
-rw-r--r-- | sway/desktop/output.c | 26 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 4 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 4 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 12 | ||||
-rw-r--r-- | sway/input/input-manager.c | 6 | ||||
-rw-r--r-- | sway/ipc-server.c | 4 | ||||
-rw-r--r-- | sway/sway-input.5.scd | 4 | ||||
-rw-r--r-- | sway/sway.5.scd | 4 | ||||
-rw-r--r-- | swaybar/render.c | 5 |
14 files changed, 60 insertions, 37 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index e75b0664..ac668c24 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -50,6 +50,7 @@ struct sway_mode { | |||
50 | char *name; | 50 | char *name; |
51 | list_t *keysym_bindings; | 51 | list_t *keysym_bindings; |
52 | list_t *keycode_bindings; | 52 | list_t *keycode_bindings; |
53 | bool pango; | ||
53 | }; | 54 | }; |
54 | 55 | ||
55 | struct input_config_mapped_from_region { | 56 | struct input_config_mapped_from_region { |
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index 026b5554..6469f097 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h | |||
@@ -15,6 +15,6 @@ void ipc_event_workspace(struct sway_container *old, | |||
15 | struct sway_container *new, const char *change); | 15 | struct sway_container *new, const char *change); |
16 | void ipc_event_window(struct sway_container *window, const char *change); | 16 | void ipc_event_window(struct sway_container *window, const char *change); |
17 | void ipc_event_barconfig_update(struct bar_config *bar); | 17 | void ipc_event_barconfig_update(struct bar_config *bar); |
18 | void ipc_event_mode(const char *mode); | 18 | void ipc_event_mode(const char *mode, bool pango); |
19 | 19 | ||
20 | #endif | 20 | #endif |
diff --git a/sway/commands/mode.c b/sway/commands/mode.c index 00331ccc..d2c14468 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c | |||
@@ -26,7 +26,17 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
26 | "mode", "Can only be used in config file."); | 26 | "mode", "Can only be used in config file."); |
27 | } | 27 | } |
28 | 28 | ||
29 | const char *mode_name = argv[0]; | 29 | bool pango = strcmp(*argv, "--pango_markup") == 0; |
30 | if (pango) { | ||
31 | argc--; argv++; | ||
32 | if (argc == 0) { | ||
33 | return cmd_results_new(CMD_FAILURE, "mode", | ||
34 | "Mode name is missing"); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | char *mode_name = *argv; | ||
39 | strip_quotes(mode_name); | ||
30 | struct sway_mode *mode = NULL; | 40 | struct sway_mode *mode = NULL; |
31 | // Find mode | 41 | // Find mode |
32 | for (int i = 0; i < config->modes->length; ++i) { | 42 | for (int i = 0; i < config->modes->length; ++i) { |
@@ -46,6 +56,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
46 | mode->name = strdup(mode_name); | 56 | mode->name = strdup(mode_name); |
47 | mode->keysym_bindings = create_list(); | 57 | mode->keysym_bindings = create_list(); |
48 | mode->keycode_bindings = create_list(); | 58 | mode->keycode_bindings = create_list(); |
59 | mode->pango = pango; | ||
49 | list_add(config->modes, mode); | 60 | list_add(config->modes, mode); |
50 | } | 61 | } |
51 | if (!mode) { | 62 | if (!mode) { |
@@ -54,13 +65,15 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
54 | return error; | 65 | return error; |
55 | } | 66 | } |
56 | if ((config->reading && argc > 1) || (!config->reading && argc == 1)) { | 67 | if ((config->reading && argc > 1) || (!config->reading && argc == 1)) { |
57 | wlr_log(L_DEBUG, "Switching to mode `%s'",mode->name); | 68 | wlr_log(L_DEBUG, "Switching to mode `%s' (pango=%d)", |
69 | mode->name, mode->pango); | ||
58 | } | 70 | } |
59 | // Set current mode | 71 | // Set current mode |
60 | config->current_mode = mode; | 72 | config->current_mode = mode; |
61 | if (argc == 1) { | 73 | if (argc == 1) { |
62 | // trigger IPC mode event | 74 | // trigger IPC mode event |
63 | ipc_event_mode(config->current_mode->name); | 75 | ipc_event_mode(config->current_mode->name, |
76 | config->current_mode->pango); | ||
64 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 77 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
65 | } | 78 | } |
66 | 79 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1e7494b3..1211cc07 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -81,8 +81,8 @@ static bool get_surface_box(struct root_geometry *geo, | |||
81 | return false; | 81 | return false; |
82 | } | 82 | } |
83 | 83 | ||
84 | int sw = surface->current->width; | 84 | int sw = surface->current.width; |
85 | int sh = surface->current->height; | 85 | int sh = surface->current.height; |
86 | 86 | ||
87 | double _sx = sx, _sy = sy; | 87 | double _sx = sx, _sy = sy; |
88 | rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height, | 88 | rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height, |
@@ -115,8 +115,8 @@ static void surface_for_each_surface(struct wlr_surface *surface, | |||
115 | wlr_surface_iterator_func_t iterator, void *user_data) { | 115 | wlr_surface_iterator_func_t iterator, void *user_data) { |
116 | geo->x = ox; | 116 | geo->x = ox; |
117 | geo->y = oy; | 117 | geo->y = oy; |
118 | geo->width = surface->current->width; | 118 | geo->width = surface->current.width; |
119 | geo->height = surface->current->height; | 119 | geo->height = surface->current.height; |
120 | geo->rotation = 0; | 120 | geo->rotation = 0; |
121 | 121 | ||
122 | wlr_surface_for_each_surface(surface, iterator, user_data); | 122 | wlr_surface_for_each_surface(surface, iterator, user_data); |
@@ -258,7 +258,7 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy, | |||
258 | 258 | ||
259 | float matrix[9]; | 259 | float matrix[9]; |
260 | enum wl_output_transform transform = | 260 | enum wl_output_transform transform = |
261 | wlr_output_transform_invert(surface->current->transform); | 261 | wlr_output_transform_invert(surface->current.transform); |
262 | wlr_matrix_project_box(matrix, &box, transform, rotation, | 262 | wlr_matrix_project_box(matrix, &box, transform, rotation, |
263 | wlr_output->transform_matrix); | 263 | wlr_output->transform_matrix); |
264 | 264 | ||
@@ -1163,16 +1163,22 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, | |||
1163 | int center_x = box.x + box.width/2; | 1163 | int center_x = box.x + box.width/2; |
1164 | int center_y = box.y + box.height/2; | 1164 | int center_y = box.y + box.height/2; |
1165 | 1165 | ||
1166 | if (pixman_region32_not_empty(&surface->current->surface_damage)) { | 1166 | if (pixman_region32_not_empty(&surface->buffer_damage)) { |
1167 | enum wl_output_transform transform = | ||
1168 | wlr_output_transform_invert(surface->current.transform); | ||
1169 | |||
1167 | pixman_region32_t damage; | 1170 | pixman_region32_t damage; |
1168 | pixman_region32_init(&damage); | 1171 | pixman_region32_init(&damage); |
1169 | pixman_region32_copy(&damage, &surface->current->surface_damage); | 1172 | pixman_region32_copy(&damage, &surface->buffer_damage); |
1170 | wlr_region_scale(&damage, &damage, output->wlr_output->scale); | 1173 | wlr_region_transform(&damage, &damage, transform, |
1171 | if (ceil(output->wlr_output->scale) > surface->current->scale) { | 1174 | surface->current.buffer_width, surface->current.buffer_height); |
1175 | wlr_region_scale(&damage, &damage, | ||
1176 | output->wlr_output->scale / (float)surface->current.scale); | ||
1177 | if (ceil(output->wlr_output->scale) > surface->current.scale) { | ||
1172 | // When scaling up a surface, it'll become blurry so we need to | 1178 | // When scaling up a surface, it'll become blurry so we need to |
1173 | // expand the damage region | 1179 | // expand the damage region |
1174 | wlr_region_expand(&damage, &damage, | 1180 | wlr_region_expand(&damage, &damage, |
1175 | ceil(output->wlr_output->scale) - surface->current->scale); | 1181 | ceil(output->wlr_output->scale) - surface->current.scale); |
1176 | } | 1182 | } |
1177 | pixman_region32_translate(&damage, box.x, box.y); | 1183 | pixman_region32_translate(&damage, box.x, box.y); |
1178 | wlr_region_rotated_bounds(&damage, &damage, rotation, | 1184 | wlr_region_rotated_bounds(&damage, &damage, rotation, |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index b4d796cb..179af617 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -73,8 +73,8 @@ static void save_view_buffer(struct sway_view *view, | |||
73 | } | 73 | } |
74 | if (view->surface && wlr_surface_has_buffer(view->surface)) { | 74 | if (view->surface && wlr_surface_has_buffer(view->surface)) { |
75 | instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer); | 75 | instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer); |
76 | instruction->saved_buffer_width = view->surface->current->width; | 76 | instruction->saved_buffer_width = view->surface->current.width; |
77 | instruction->saved_buffer_height = view->surface->current->height; | 77 | instruction->saved_buffer_height = view->surface->current.height; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 2b634749..ac35a8d1 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -251,8 +251,8 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
251 | view->natural_width = view->wlr_xdg_surface->geometry.width; | 251 | view->natural_width = view->wlr_xdg_surface->geometry.width; |
252 | view->natural_height = view->wlr_xdg_surface->geometry.height; | 252 | view->natural_height = view->wlr_xdg_surface->geometry.height; |
253 | if (!view->natural_width && !view->natural_height) { | 253 | if (!view->natural_width && !view->natural_height) { |
254 | view->natural_width = view->wlr_xdg_surface->surface->current->width; | 254 | view->natural_width = view->wlr_xdg_surface->surface->current.width; |
255 | view->natural_height = view->wlr_xdg_surface->surface->current->height; | 255 | view->natural_height = view->wlr_xdg_surface->surface->current.height; |
256 | } | 256 | } |
257 | 257 | ||
258 | view_map(view, view->wlr_xdg_surface->surface); | 258 | view_map(view, view->wlr_xdg_surface->surface); |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 2f0730e4..56bbb244 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -246,8 +246,8 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
246 | view->natural_width = view->wlr_xdg_surface_v6->geometry.width; | 246 | view->natural_width = view->wlr_xdg_surface_v6->geometry.width; |
247 | view->natural_height = view->wlr_xdg_surface_v6->geometry.height; | 247 | view->natural_height = view->wlr_xdg_surface_v6->geometry.height; |
248 | if (!view->natural_width && !view->natural_height) { | 248 | if (!view->natural_width && !view->natural_height) { |
249 | view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; | 249 | view->natural_width = view->wlr_xdg_surface_v6->surface->current.width; |
250 | view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; | 250 | view->natural_height = view->wlr_xdg_surface_v6->surface->current.height; |
251 | } | 251 | } |
252 | 252 | ||
253 | view_map(view, view->wlr_xdg_surface_v6->surface); | 253 | view_map(view, view->wlr_xdg_surface_v6->surface); |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 71803262..0669a485 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -278,7 +278,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
278 | wl_container_of(listener, xwayland_view, commit); | 278 | wl_container_of(listener, xwayland_view, commit); |
279 | struct sway_view *view = &xwayland_view->view; | 279 | struct sway_view *view = &xwayland_view->view; |
280 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 280 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
281 | struct wlr_surface_state *surface_state = xsurface->surface->current; | 281 | struct wlr_surface_state *surface_state = &xsurface->surface->current; |
282 | 282 | ||
283 | if (view->swayc->instructions->length) { | 283 | if (view->swayc->instructions->length) { |
284 | transaction_notify_view_ready_by_size(view, | 284 | transaction_notify_view_ready_by_size(view, |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 944e35aa..a2f11557 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -255,14 +255,12 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
255 | wlr_layer_surface_from_wlr_surface(surface); | 255 | wlr_layer_surface_from_wlr_surface(surface); |
256 | if (layer->current.keyboard_interactive) { | 256 | if (layer->current.keyboard_interactive) { |
257 | seat_set_focus_layer(cursor->seat, layer); | 257 | seat_set_focus_layer(cursor->seat, layer); |
258 | return; | ||
259 | } | 258 | } |
260 | } | 259 | } else if (surface && cont && cont->type != C_VIEW) { |
261 | // Avoid moving keyboard focus from a surface that accepts it to one | 260 | // Avoid moving keyboard focus from a surface that accepts it to one |
262 | // that does not unless the change would move us to a new workspace. | 261 | // that does not unless the change would move us to a new workspace. |
263 | // | 262 | // |
264 | // This prevents, for example, losing focus when clicking on swaybar. | 263 | // This prevents, for example, losing focus when clicking on swaybar. |
265 | if (surface && cont && cont->type != C_VIEW) { | ||
266 | struct sway_container *new_ws = cont; | 264 | struct sway_container *new_ws = cont; |
267 | if (new_ws && new_ws->type != C_WORKSPACE) { | 265 | if (new_ws && new_ws->type != C_WORKSPACE) { |
268 | new_ws = container_parent(new_ws, C_WORKSPACE); | 266 | new_ws = container_parent(new_ws, C_WORKSPACE); |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 29b47a7b..98f7d7cf 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -224,6 +224,9 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
224 | input_manager_libinput_config_pointer(input_device); | 224 | input_manager_libinput_config_pointer(input_device); |
225 | } | 225 | } |
226 | 226 | ||
227 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); | ||
228 | input_device->device_destroy.notify = handle_device_destroy; | ||
229 | |||
227 | struct sway_seat *seat = NULL; | 230 | struct sway_seat *seat = NULL; |
228 | if (!input_has_seat_configuration(input)) { | 231 | if (!input_has_seat_configuration(input)) { |
229 | wlr_log(L_DEBUG, "no seat configuration, using default seat"); | 232 | wlr_log(L_DEBUG, "no seat configuration, using default seat"); |
@@ -260,9 +263,6 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
260 | "device '%s' is not configured on any seats", | 263 | "device '%s' is not configured on any seats", |
261 | input_device->identifier); | 264 | input_device->identifier); |
262 | } | 265 | } |
263 | |||
264 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); | ||
265 | input_device->device_destroy.notify = handle_device_destroy; | ||
266 | } | 266 | } |
267 | 267 | ||
268 | static void handle_inhibit_activate(struct wl_listener *listener, void *data) { | 268 | static void handle_inhibit_activate(struct wl_listener *listener, void *data) { |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 96889b39..abdaa237 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -336,13 +336,15 @@ void ipc_event_barconfig_update(struct bar_config *bar) { | |||
336 | json_object_put(json); | 336 | json_object_put(json); |
337 | } | 337 | } |
338 | 338 | ||
339 | void ipc_event_mode(const char *mode) { | 339 | void ipc_event_mode(const char *mode, bool pango) { |
340 | if (!ipc_has_event_listeners(IPC_EVENT_MODE)) { | 340 | if (!ipc_has_event_listeners(IPC_EVENT_MODE)) { |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | wlr_log(L_DEBUG, "Sending mode::%s event", mode); | 343 | wlr_log(L_DEBUG, "Sending mode::%s event", mode); |
344 | json_object *obj = json_object_new_object(); | 344 | json_object *obj = json_object_new_object(); |
345 | json_object_object_add(obj, "change", json_object_new_string(mode)); | 345 | json_object_object_add(obj, "change", json_object_new_string(mode)); |
346 | json_object_object_add(obj, "pango_markup", | ||
347 | json_object_new_boolean(pango)); | ||
346 | 348 | ||
347 | const char *json_string = json_object_to_json_string(obj); | 349 | const char *json_string = json_object_to_json_string(obj); |
348 | ipc_send_event(json_string, IPC_EVENT_MODE); | 350 | ipc_send_event(json_string, IPC_EVENT_MODE); |
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index c07460b1..cf7a6385 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd | |||
@@ -67,8 +67,8 @@ For more information on these xkb configuration options, see | |||
67 | Enables or disables disable-while-typing for the specified input device. | 67 | Enables or disables disable-while-typing for the specified input device. |
68 | 68 | ||
69 | *input* <identifier> events enabled|disabled|disabled\_on\_external\_mouse | 69 | *input* <identifier> events enabled|disabled|disabled\_on\_external\_mouse |
70 | Enables or disables send_events for specified input device. (Disabling | 70 | Enables or disables send\_events for specified input device. (Disabling |
71 | send_events disables the input device) | 71 | send\_events disables the input device) |
72 | 72 | ||
73 | *input* <identifier> left\_handed enabled|disabled | 73 | *input* <identifier> left\_handed enabled|disabled |
74 | Enables or disables left handed mode for specified input device. | 74 | Enables or disables left handed mode for specified input device. |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 5ce6bf06..7c553d3f 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -413,10 +413,12 @@ The default colors are: | |||
413 | *mode* <mode> | 413 | *mode* <mode> |
414 | Switches to the specified mode. The default mode _default_. | 414 | Switches to the specified mode. The default mode _default_. |
415 | 415 | ||
416 | *mode* <mode> *{* <commands...> *}* | 416 | *mode* [--pango\_markup] <mode> *{* <commands...> *}* |
417 | _commands..._ after *{* will be added to the specified mode. A newline is | 417 | _commands..._ after *{* will be added to the specified mode. A newline is |
418 | required between *{* and the first command, and *}* must be alone on a | 418 | required between *{* and the first command, and *}* must be alone on a |
419 | line. Only *bindsym* and *bindcode* commands are permitted in mode blocks. | 419 | line. Only *bindsym* and *bindcode* commands are permitted in mode blocks. |
420 | If _--pango\_markup_ is given, then _mode_ will be interpreted as pango | ||
421 | markup. | ||
420 | 422 | ||
421 | *mouse\_warping* output|none | 423 | *mouse\_warping* output|none |
422 | If _output_ is specified, the mouse will be moved to new outputs as you | 424 | If _output_ is specified, the mouse will be moved to new outputs as you |
diff --git a/swaybar/render.c b/swaybar/render.c index 327a6f5f..efd3fdeb 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -298,7 +298,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, | |||
298 | 298 | ||
299 | int text_width, text_height; | 299 | int text_width, text_height; |
300 | get_text_size(cairo, config->font, &text_width, &text_height, | 300 | get_text_size(cairo, config->font, &text_width, &text_height, |
301 | output->scale, config->pango_markup, "%s", mode); | 301 | output->scale, config->mode_pango_markup, |
302 | "%s", mode); | ||
302 | 303 | ||
303 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | 304 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; |
304 | int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; | 305 | int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; |
@@ -329,7 +330,7 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, | |||
329 | double text_y = height / 2.0 - text_height / 2.0; | 330 | double text_y = height / 2.0 - text_height / 2.0; |
330 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); | 331 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); |
331 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); | 332 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); |
332 | pango_printf(cairo, config->font, output->scale, config->pango_markup, | 333 | pango_printf(cairo, config->font, output->scale, config->mode_pango_markup, |
333 | "%s", mode); | 334 | "%s", mode); |
334 | return surface_height; | 335 | return surface_height; |
335 | } | 336 | } |