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.
This commit is contained in:
Isaac Freund 2021-01-02 20:09:23 +01:00 committed by Ilia Bozhinov
parent 8b90d5e17f
commit 5d24f6e098
1 changed files with 16 additions and 0 deletions

View File

@ -378,6 +378,10 @@ static void toplevel_send_state(struct wlr_foreign_toplevel_handle_v1 *toplevel)
void wlr_foreign_toplevel_handle_v1_set_maximized( void wlr_foreign_toplevel_handle_v1_set_maximized(
struct wlr_foreign_toplevel_handle_v1 *toplevel, bool maximized) { struct wlr_foreign_toplevel_handle_v1 *toplevel, bool maximized) {
if (maximized == !!(toplevel->state &
WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED)) {
return;
}
if (maximized) { if (maximized) {
toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED; toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED;
} else { } else {
@ -388,6 +392,10 @@ void wlr_foreign_toplevel_handle_v1_set_maximized(
void wlr_foreign_toplevel_handle_v1_set_minimized( void wlr_foreign_toplevel_handle_v1_set_minimized(
struct wlr_foreign_toplevel_handle_v1 *toplevel, bool minimized) { struct wlr_foreign_toplevel_handle_v1 *toplevel, bool minimized) {
if (minimized == !!(toplevel->state &
WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED)) {
return;
}
if (minimized) { if (minimized) {
toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED; toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED;
} else { } else {
@ -398,6 +406,10 @@ void wlr_foreign_toplevel_handle_v1_set_minimized(
void wlr_foreign_toplevel_handle_v1_set_activated( void wlr_foreign_toplevel_handle_v1_set_activated(
struct wlr_foreign_toplevel_handle_v1 *toplevel, bool activated) { struct wlr_foreign_toplevel_handle_v1 *toplevel, bool activated) {
if (activated == !!(toplevel->state &
WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED)) {
return;
}
if (activated) { if (activated) {
toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED; toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED;
} else { } else {
@ -408,6 +420,10 @@ void wlr_foreign_toplevel_handle_v1_set_activated(
void wlr_foreign_toplevel_handle_v1_set_fullscreen( void wlr_foreign_toplevel_handle_v1_set_fullscreen(
struct wlr_foreign_toplevel_handle_v1 * toplevel, bool fullscreen) { struct wlr_foreign_toplevel_handle_v1 * toplevel, bool fullscreen) {
if (fullscreen == !!(toplevel->state &
WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN)) {
return;
}
if (fullscreen) { if (fullscreen) {
toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN; toplevel->state |= WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN;
} else { } else {