mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
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.
This commit is contained in:
parent
1d40640188
commit
0076c528b7
5 changed files with 30 additions and 41 deletions
|
|
@ -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 */
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
22
src/ipc.c
22
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 <resize drawContents="no" /> is used */
|
||||
ipc_event_window_geometry(view, &new_geo);
|
||||
|
||||
resize_indicator_update(view);
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/view.c
25
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue