mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
Merge pull request #2317 from RyanDwyer/force-display-urgency-hint
Implement force_display_urgency_hint
This commit is contained in:
commit
51730a0597
@ -113,6 +113,7 @@ sway_cmd cmd_focus_follows_mouse;
|
|||||||
sway_cmd cmd_focus_wrapping;
|
sway_cmd cmd_focus_wrapping;
|
||||||
sway_cmd cmd_font;
|
sway_cmd cmd_font;
|
||||||
sway_cmd cmd_for_window;
|
sway_cmd cmd_for_window;
|
||||||
|
sway_cmd cmd_force_display_urgency_hint;
|
||||||
sway_cmd cmd_force_focus_wrapping;
|
sway_cmd cmd_force_focus_wrapping;
|
||||||
sway_cmd cmd_fullscreen;
|
sway_cmd cmd_fullscreen;
|
||||||
sway_cmd cmd_gaps;
|
sway_cmd cmd_gaps;
|
||||||
|
@ -324,6 +324,7 @@ struct sway_config {
|
|||||||
char *font;
|
char *font;
|
||||||
size_t font_height;
|
size_t font_height;
|
||||||
bool pango_markup;
|
bool pango_markup;
|
||||||
|
size_t urgent_timeout;
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
bool focus_follows_mouse;
|
bool focus_follows_mouse;
|
||||||
|
@ -108,6 +108,7 @@ static struct cmd_handler handlers[] = {
|
|||||||
{ "focus_wrapping", cmd_focus_wrapping },
|
{ "focus_wrapping", cmd_focus_wrapping },
|
||||||
{ "font", cmd_font },
|
{ "font", cmd_font },
|
||||||
{ "for_window", cmd_for_window },
|
{ "for_window", cmd_for_window },
|
||||||
|
{ "force_display_urgency_hint", cmd_force_display_urgency_hint },
|
||||||
{ "force_focus_wrapping", cmd_force_focus_wrapping },
|
{ "force_focus_wrapping", cmd_force_focus_wrapping },
|
||||||
{ "fullscreen", cmd_fullscreen },
|
{ "fullscreen", cmd_fullscreen },
|
||||||
{ "gaps", cmd_gaps },
|
{ "gaps", cmd_gaps },
|
||||||
|
23
sway/commands/force_display_urgency_hint.c
Normal file
23
sway/commands/force_display_urgency_hint.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "force_display_urgency_hint",
|
||||||
|
EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *err;
|
||||||
|
int timeout = (int)strtol(argv[0], &err, 10);
|
||||||
|
if (*err) {
|
||||||
|
if (strcmp(err, "ms") != 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "force_display_urgency_hint",
|
||||||
|
"Expected 'force_display_urgency_hint <timeout> ms'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config->urgent_timeout = timeout > 0 ? timeout : 0;
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
@ -186,6 +186,7 @@ static void config_defaults(struct sway_config *config) {
|
|||||||
config->default_orientation = L_NONE;
|
config->default_orientation = L_NONE;
|
||||||
if (!(config->font = strdup("monospace 10"))) goto cleanup;
|
if (!(config->font = strdup("monospace 10"))) goto cleanup;
|
||||||
config->font_height = 17; // height of monospace 10
|
config->font_height = 17; // height of monospace 10
|
||||||
|
config->urgent_timeout = 500;
|
||||||
|
|
||||||
// floating view
|
// floating view
|
||||||
config->floating_maximum_width = 0;
|
config->floating_maximum_width = 0;
|
||||||
|
@ -442,6 +442,12 @@ static void handle_set_hints(struct wl_listener *listener, void *data) {
|
|||||||
if (!xsurface->mapped) {
|
if (!xsurface->mapped) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!xsurface->hints_urgency && view->urgent_timer) {
|
||||||
|
// The view is is in the timeout period. We'll ignore the request to
|
||||||
|
// unset urgency so that the view remains urgent until the timer clears
|
||||||
|
// it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (view->allow_request_urgent) {
|
if (view->allow_request_urgent) {
|
||||||
view_set_urgent(view, (bool)xsurface->hints_urgency);
|
view_set_urgent(view, (bool)xsurface->hints_urgency);
|
||||||
}
|
}
|
||||||
|
@ -677,14 +677,20 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If urgent, start a timer to unset it
|
// If urgent, either unset the urgency or start a timer to unset it
|
||||||
if (container && container->type == C_VIEW &&
|
if (container && container->type == C_VIEW &&
|
||||||
view_is_urgent(container->sway_view) &&
|
view_is_urgent(container->sway_view) &&
|
||||||
!container->sway_view->urgent_timer) {
|
!container->sway_view->urgent_timer) {
|
||||||
struct sway_view *view = container->sway_view;
|
struct sway_view *view = container->sway_view;
|
||||||
|
if (last_workspace && last_workspace != new_workspace &&
|
||||||
|
config->urgent_timeout > 0) {
|
||||||
view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop,
|
view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop,
|
||||||
handle_urgent_timeout, view);
|
handle_urgent_timeout, view);
|
||||||
wl_event_source_timer_update(view->urgent_timer, 1000);
|
wl_event_source_timer_update(view->urgent_timer,
|
||||||
|
config->urgent_timeout);
|
||||||
|
} else {
|
||||||
|
view_set_urgent(view, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've focused a floating container, bring it to the front.
|
// If we've focused a floating container, bring it to the front.
|
||||||
|
@ -47,6 +47,7 @@ sway_sources = files(
|
|||||||
'commands/focus_wrapping.c',
|
'commands/focus_wrapping.c',
|
||||||
'commands/font.c',
|
'commands/font.c',
|
||||||
'commands/for_window.c',
|
'commands/for_window.c',
|
||||||
|
'commands/force_display_urgency_hint.c',
|
||||||
'commands/force_focus_wrapping.c',
|
'commands/force_focus_wrapping.c',
|
||||||
'commands/fullscreen.c',
|
'commands/fullscreen.c',
|
||||||
'commands/gaps.c',
|
'commands/gaps.c',
|
||||||
|
Loading…
Reference in New Issue
Block a user