summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/force_display_urgency_hint.c28
-rw-r--r--sway/config.c1
-rw-r--r--sway/desktop/xwayland.c6
-rw-r--r--sway/input/seat.c4
-rw-r--r--sway/meson.build1
8 files changed, 42 insertions, 1 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;
113sway_cmd cmd_focus_wrapping; 113sway_cmd cmd_focus_wrapping;
114sway_cmd cmd_font; 114sway_cmd cmd_font;
115sway_cmd cmd_for_window; 115sway_cmd cmd_for_window;
116sway_cmd cmd_force_display_urgency_hint;
116sway_cmd cmd_force_focus_wrapping; 117sway_cmd cmd_force_focus_wrapping;
117sway_cmd cmd_fullscreen; 118sway_cmd cmd_fullscreen;
118sway_cmd cmd_gaps; 119sway_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..a25ffff8
--- /dev/null
+++ b/sway/commands/force_display_urgency_hint.c
@@ -0,0 +1,28 @@
1#include "log.h"
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/tree/arrange.h"
5#include "sway/tree/container.h"
6#include "sway/tree/view.h"
7#include "sway/tree/layout.h"
8
9struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
10 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "force_display_urgency_hint",
12 EXPECTED_AT_LEAST, 1))) {
13 return error;
14 }
15
16 char *err;
17 int timeout = (int)strtol(argv[0], &err, 10);
18 if (*err) {
19 if (strcmp(err, "ms") != 0) {
20 return cmd_results_new(CMD_INVALID, "force_display_urgency_hint",
21 "Expected 'force_display_urgency_hint <timeout> ms'");
22 }
23 }
24
25 config->urgent_timeout = timeout > 0 ? timeout : 0;
26
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28}
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..816429d3 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -679,12 +679,14 @@ void seat_set_focus_warp(struct sway_seat *seat,
679 679
680 // If urgent, start a timer to unset it 680 // If urgent, start a timer to unset it
681 if (container && container->type == C_VIEW && 681 if (container && container->type == C_VIEW &&
682 last_workspace && last_workspace != new_workspace &&
682 view_is_urgent(container->sway_view) && 683 view_is_urgent(container->sway_view) &&
684 config->urgent_timeout > 0 &&
683 !container->sway_view->urgent_timer) { 685 !container->sway_view->urgent_timer) {
684 struct sway_view *view = container->sway_view; 686 struct sway_view *view = container->sway_view;
685 view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop, 687 view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop,
686 handle_urgent_timeout, view); 688 handle_urgent_timeout, view);
687 wl_event_source_timer_update(view->urgent_timer, 1000); 689 wl_event_source_timer_update(view->urgent_timer, config->urgent_timeout);
688 } 690 }
689 691
690 // If we've focused a floating container, bring it to the front. 692 // 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',