diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-07-20 21:46:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 21:46:56 -0400 |
commit | 51730a059778e1d91e2f4b412f39e77a66f48155 (patch) | |
tree | 1d043b7551e251f1b662e952e9f62be72877a7cc | |
parent | Merge pull request #2318 from RedSoxFan/fix-output-wildcard (diff) | |
parent | Fix urgent timer logic and remove unnecessary header includes (diff) | |
download | sway-51730a059778e1d91e2f4b412f39e77a66f48155.tar.gz sway-51730a059778e1d91e2f4b412f39e77a66f48155.tar.zst sway-51730a059778e1d91e2f4b412f39e77a66f48155.zip |
Merge pull request #2317 from RyanDwyer/force-display-urgency-hint
Implement force_display_urgency_hint
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/force_display_urgency_hint.c | 23 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 6 | ||||
-rw-r--r-- | sway/input/seat.c | 14 | ||||
-rw-r--r-- | sway/meson.build | 1 |
8 files changed, 44 insertions, 4 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 1e93e2a3..e71a7228 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -113,6 +113,7 @@ sway_cmd cmd_focus_follows_mouse; | |||
113 | sway_cmd cmd_focus_wrapping; | 113 | sway_cmd cmd_focus_wrapping; |
114 | sway_cmd cmd_font; | 114 | sway_cmd cmd_font; |
115 | sway_cmd cmd_for_window; | 115 | sway_cmd cmd_for_window; |
116 | sway_cmd cmd_force_display_urgency_hint; | ||
116 | sway_cmd cmd_force_focus_wrapping; | 117 | sway_cmd cmd_force_focus_wrapping; |
117 | sway_cmd cmd_fullscreen; | 118 | sway_cmd cmd_fullscreen; |
118 | sway_cmd cmd_gaps; | 119 | sway_cmd cmd_gaps; |
diff --git a/include/sway/config.h b/include/sway/config.h index 6f6710e9..87768399 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -324,6 +324,7 @@ struct sway_config { | |||
324 | char *font; | 324 | char *font; |
325 | size_t font_height; | 325 | size_t font_height; |
326 | bool pango_markup; | 326 | bool pango_markup; |
327 | size_t urgent_timeout; | ||
327 | 328 | ||
328 | // Flags | 329 | // Flags |
329 | bool focus_follows_mouse; | 330 | bool focus_follows_mouse; |
diff --git a/sway/commands.c b/sway/commands.c index 73c968ea..f1f03574 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -108,6 +108,7 @@ static struct cmd_handler handlers[] = { | |||
108 | { "focus_wrapping", cmd_focus_wrapping }, | 108 | { "focus_wrapping", cmd_focus_wrapping }, |
109 | { "font", cmd_font }, | 109 | { "font", cmd_font }, |
110 | { "for_window", cmd_for_window }, | 110 | { "for_window", cmd_for_window }, |
111 | { "force_display_urgency_hint", cmd_force_display_urgency_hint }, | ||
111 | { "force_focus_wrapping", cmd_force_focus_wrapping }, | 112 | { "force_focus_wrapping", cmd_force_focus_wrapping }, |
112 | { "fullscreen", cmd_fullscreen }, | 113 | { "fullscreen", cmd_fullscreen }, |
113 | { "gaps", cmd_gaps }, | 114 | { "gaps", cmd_gaps }, |
diff --git a/sway/commands/force_display_urgency_hint.c b/sway/commands/force_display_urgency_hint.c new file mode 100644 index 00000000..5e5e2d55 --- /dev/null +++ b/sway/commands/force_display_urgency_hint.c | |||
@@ -0,0 +1,23 @@ | |||
1 | #include "sway/commands.h" | ||
2 | #include "sway/config.h" | ||
3 | |||
4 | struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) { | ||
5 | struct cmd_results *error = NULL; | ||
6 | if ((error = checkarg(argc, "force_display_urgency_hint", | ||
7 | EXPECTED_AT_LEAST, 1))) { | ||
8 | return error; | ||
9 | } | ||
10 | |||
11 | char *err; | ||
12 | int timeout = (int)strtol(argv[0], &err, 10); | ||
13 | if (*err) { | ||
14 | if (strcmp(err, "ms") != 0) { | ||
15 | return cmd_results_new(CMD_INVALID, "force_display_urgency_hint", | ||
16 | "Expected 'force_display_urgency_hint <timeout> ms'"); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | config->urgent_timeout = timeout > 0 ? timeout : 0; | ||
21 | |||
22 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
23 | } | ||
diff --git a/sway/config.c b/sway/config.c index 00500812..4b892852 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -186,6 +186,7 @@ static void config_defaults(struct sway_config *config) { | |||
186 | config->default_orientation = L_NONE; | 186 | config->default_orientation = L_NONE; |
187 | if (!(config->font = strdup("monospace 10"))) goto cleanup; | 187 | if (!(config->font = strdup("monospace 10"))) goto cleanup; |
188 | config->font_height = 17; // height of monospace 10 | 188 | config->font_height = 17; // height of monospace 10 |
189 | config->urgent_timeout = 500; | ||
189 | 190 | ||
190 | // floating view | 191 | // floating view |
191 | config->floating_maximum_width = 0; | 192 | config->floating_maximum_width = 0; |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 72dc7ca2..bce0a37b 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -442,6 +442,12 @@ static void handle_set_hints(struct wl_listener *listener, void *data) { | |||
442 | if (!xsurface->mapped) { | 442 | if (!xsurface->mapped) { |
443 | return; | 443 | return; |
444 | } | 444 | } |
445 | if (!xsurface->hints_urgency && view->urgent_timer) { | ||
446 | // The view is is in the timeout period. We'll ignore the request to | ||
447 | // unset urgency so that the view remains urgent until the timer clears | ||
448 | // it. | ||
449 | return; | ||
450 | } | ||
445 | if (view->allow_request_urgent) { | 451 | if (view->allow_request_urgent) { |
446 | view_set_urgent(view, (bool)xsurface->hints_urgency); | 452 | view_set_urgent(view, (bool)xsurface->hints_urgency); |
447 | } | 453 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index eadf3b26..e77d88a8 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -677,14 +677,20 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | // If urgent, start a timer to unset it | 680 | // If urgent, either unset the urgency or start a timer to unset it |
681 | if (container && container->type == C_VIEW && | 681 | if (container && container->type == C_VIEW && |
682 | view_is_urgent(container->sway_view) && | 682 | view_is_urgent(container->sway_view) && |
683 | !container->sway_view->urgent_timer) { | 683 | !container->sway_view->urgent_timer) { |
684 | struct sway_view *view = container->sway_view; | 684 | struct sway_view *view = container->sway_view; |
685 | view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop, | 685 | if (last_workspace && last_workspace != new_workspace && |
686 | handle_urgent_timeout, view); | 686 | config->urgent_timeout > 0) { |
687 | wl_event_source_timer_update(view->urgent_timer, 1000); | 687 | view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop, |
688 | handle_urgent_timeout, view); | ||
689 | wl_event_source_timer_update(view->urgent_timer, | ||
690 | config->urgent_timeout); | ||
691 | } else { | ||
692 | view_set_urgent(view, false); | ||
693 | } | ||
688 | } | 694 | } |
689 | 695 | ||
690 | // If we've focused a floating container, bring it to the front. | 696 | // If we've focused a floating container, bring it to the front. |
diff --git a/sway/meson.build b/sway/meson.build index c58d3470..09bc40b8 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -47,6 +47,7 @@ sway_sources = files( | |||
47 | 'commands/focus_wrapping.c', | 47 | 'commands/focus_wrapping.c', |
48 | 'commands/font.c', | 48 | 'commands/font.c', |
49 | 'commands/for_window.c', | 49 | 'commands/for_window.c', |
50 | 'commands/force_display_urgency_hint.c', | ||
50 | 'commands/force_focus_wrapping.c', | 51 | 'commands/force_focus_wrapping.c', |
51 | 'commands/fullscreen.c', | 52 | 'commands/fullscreen.c', |
52 | 'commands/gaps.c', | 53 | 'commands/gaps.c', |