diff options
author | Isaac Freund <ifreund@ifreund.xyz> | 2021-01-02 20:09:23 +0100 |
---|---|---|
committer | Ilia Bozhinov <ammen99@gmail.com> | 2021-01-05 12:22:20 +0100 |
commit | 5d24f6e09861e32837afb5f36c41f21edf0fc900 (patch) | |
tree | 36386332726ccfeaba711295aa3aa8f4bab3511f | |
parent | 8b90d5e17f4a09caf27e0cdd34bb155f4272d0e7 (diff) |
toplevel-management: avoid redundant state events
Check if there would be a state change on setting maximized, minimized,
activated, or fullscreen before sending a state event.
-rw-r--r-- | types/wlr_foreign_toplevel_management_v1.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/types/wlr_foreign_toplevel_management_v1.c b/types/wlr_foreign_toplevel_management_v1.c index 56052096..49805ef9 100644 --- a/types/wlr_foreign_toplevel_management_v1.c +++ b/types/wlr_foreign_toplevel_management_v1.c @@ -378,6 +378,10 @@ static void toplevel_send_state(struct wlr_foreign_toplevel_handle_v1 *toplevel) void wlr_foreign_toplevel_handle_v1_set_maximized( struct wlr_foreign_toplevel_handle_v1 *toplevel, bool maximized) { + if (maximized == !!(toplevel->state & + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED)) { + return; + } if (maximized) { toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED; } else { @@ -388,6 +392,10 @@ void wlr_foreign_toplevel_handle_v1_set_maximized( void wlr_foreign_toplevel_handle_v1_set_minimized( struct wlr_foreign_toplevel_handle_v1 *toplevel, bool minimized) { + if (minimized == !!(toplevel->state & + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED)) { + return; + } if (minimized) { toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED; } else { @@ -398,6 +406,10 @@ void wlr_foreign_toplevel_handle_v1_set_minimized( void wlr_foreign_toplevel_handle_v1_set_activated( struct wlr_foreign_toplevel_handle_v1 *toplevel, bool activated) { + if (activated == !!(toplevel->state & + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED)) { + return; + } if (activated) { toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED; } else { @@ -408,6 +420,10 @@ void wlr_foreign_toplevel_handle_v1_set_activated( void wlr_foreign_toplevel_handle_v1_set_fullscreen( struct wlr_foreign_toplevel_handle_v1 * toplevel, bool fullscreen) { + if (fullscreen == !!(toplevel->state & + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN)) { + return; + } if (fullscreen) { toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN; } else { |