From 0076c528b7df0fc04098d3ccc5bfcdb66abe0ea3 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Thu, 16 Apr 2026 00:27:57 +0200 Subject: [PATCH] Add ipc_event_window_geometry() helper This allows creating events based on different labwc internal geometries. Also use ipc internal geometry for clients and not just deduplication. --- include/ipc.h | 3 ++- src/input/cursor.c | 17 ----------------- src/ipc.c | 22 ++++++++++++++++++++-- src/resize-outlines.c | 4 ++++ src/view.c | 25 ++++--------------------- 5 files changed, 30 insertions(+), 41 deletions(-) diff --git a/include/ipc.h b/include/ipc.h index eb69f1db..7b563693 100644 --- a/include/ipc.h +++ b/include/ipc.h @@ -71,6 +71,7 @@ void ipc_event_workspace(const char *change, struct workspace *current, struct workspace *old); void ipc_event_output(const char *change); void ipc_event_window(const char *change, struct view *view); +void ipc_event_window_geometry(struct view *view, struct wlr_box *new_geo); void ipc_event_shutdown(void); -#endif /* LABWC_IPC_H */ \ No newline at end of file +#endif /* LABWC_IPC_H */ diff --git a/src/input/cursor.c b/src/input/cursor.c index a66cee02..e8ac7d96 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -28,7 +28,6 @@ #include "input/keyboard.h" #include "input/tablet.h" #include "input/touch.h" -#include "ipc.h" #include "labwc.h" #include "layers.h" #include "menu/menu.h" @@ -375,22 +374,6 @@ process_cursor_resize(uint32_t time) view_move_resize(view, new_view_geo); } else { resize_outlines_update(view, new_view_geo); - if (view->mapped) { - view->current = new_view_geo; - struct wlr_box *last = &view->ipc_last_geo; - if (new_view_geo.x != last->x - || new_view_geo.y != last->y) { - ipc_event_window("move", view); - } - if (new_view_geo.width != last->width - || new_view_geo.height != last->height) { - ipc_event_window("resize", view); - } - last->x = new_view_geo.x; - last->y = new_view_geo.y; - last->width = new_view_geo.width; - last->height = new_view_geo.height; - } } } diff --git a/src/ipc.c b/src/ipc.c index f3f07c65..ec062338 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -631,9 +631,9 @@ ipc_json_view_node(struct view *view) /* geometry */ json_object_object_add(obj, "position", - ipc_json_position(view->current)); + ipc_json_position(view->ipc_last_geo)); json_object_object_add(obj, "dimension", - ipc_json_dimension(view->current)); + ipc_json_dimension(view->ipc_last_geo)); return obj; } @@ -1707,6 +1707,24 @@ ipc_event_window(const char *change, struct view *view) ipc_broadcast_event(IPC_EVENT_WINDOW, IPC_SUB_WINDOW, event); } +void +ipc_event_window_geometry(struct view *view, struct wlr_box *new_geo) +{ + struct wlr_box *last = &view->ipc_last_geo; + + bool moved = new_geo->x != last->x || new_geo->y != last->y; + bool resized = new_geo->width != last->width || new_geo->height != last->height; + *last = *new_geo; + + if (moved) { + ipc_event_window("move", view); + } + + if (resized) { + ipc_event_window("resize", view); + } +} + void ipc_event_shutdown(void) { diff --git a/src/resize-outlines.c b/src/resize-outlines.c index 113f128d..56127d5e 100644 --- a/src/resize-outlines.c +++ b/src/resize-outlines.c @@ -5,6 +5,7 @@ #include "common/border.h" #include "common/lab-scene-rect.h" #include "config/rcxml.h" +#include "ipc.h" #include "resize-indicator.h" #include "ssd.h" #include "theme.h" @@ -50,6 +51,9 @@ resize_outlines_update(struct view *view, struct wlr_box new_geo) outlines->view_geo = new_geo; + /* Required in case is used */ + ipc_event_window_geometry(view, &new_geo); + resize_indicator_update(view); } diff --git a/src/view.c b/src/view.c index ca959185..1aa89072 100644 --- a/src/view.c +++ b/src/view.c @@ -573,19 +573,11 @@ view_moved(struct view *view) * Fallback IPC emission: catch geometry corrections made by * the client on commit (e.g. terminal snapping to char grid). * The primary emission point is in view_move_resize() which - * fires immediately using view->pending. The ipc_last_geo - * dedup ensures no duplicates when pending == current. + * fires immediately using view->pending. Events are + * deduplicated in ipc_event_window_geometry(). */ if (view->mapped) { - struct wlr_box *last = &view->ipc_last_geo; - struct wlr_box *cur = &view->current; - if (cur->x != last->x || cur->y != last->y) { - ipc_event_window("move", view); - } - if (cur->width != last->width || cur->height != last->height) { - ipc_event_window("resize", view); - } - *last = *cur; + ipc_event_window_geometry(view, &view->current); } } @@ -618,16 +610,7 @@ view_move_resize(struct view *view, struct wlr_box geo) * realtime tracking that matches interactive move behaviour. */ if (view->mapped) { - struct wlr_box *last = &view->ipc_last_geo; - struct wlr_box *pending = &view->pending; - if (pending->x != last->x || pending->y != last->y) { - ipc_event_window("move", view); - } - if (pending->width != last->width - || pending->height != last->height) { - ipc_event_window("resize", view); - } - *last = *pending; + ipc_event_window_geometry(view, &view->pending); } }