This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository engage.
View the commit online.
commit fa1bc821931a3b572dd817a38cc26b85b3026c83
Author: Alastair Poole <[email protected]>
AuthorDate: Wed Dec 2 07:01:18 2026 +0000
engage: use the compositor's framed window previews
Engage built its own frame around a raw mirror for live previews and
around a private pixel copy for last previews. The two paths could
display different content from IBox, especially for Wayland clients.
Use the same framed mirror as IBox for both modes and hold an iconic
preview reference while the live tile exists. The updated compositor
keeps minimized Wayland clients drawing while a live reference exists
and takes a snapshot when creating a preview without one. X11 uses
the existing compositor mirror in both modes.
The module built successfully. Private Xvfb runs matched the baseline
window states for both settings. In a private Wayland compositor,
the live tile drove frame callbacks for a minimized client, and last
mode left the client suspended.
Co-Authored-By: OpenAI Codex (GPT-6) <[email protected]>
---
e_mod_main.c | 8 --
e_mod_main.h | 4 -
engage_dock.c | 116 ++++++---------------------
engage_windows.c | 236 -------------------------------------------------------
meson.build | 6 +-
5 files changed, 23 insertions(+), 347 deletions(-)
diff --git a/e_mod_main.c b/e_mod_main.c
index 8cf978b..3750a2c 100644
--- a/e_mod_main.c
+++ b/e_mod_main.c
@@ -315,8 +315,6 @@ client_changed(void *data EINA_UNUSED, int type, void *event)
if (!ec) return ECORE_CALLBACK_PASS_ON;
if (type == E_EVENT_CLIENT_REMOVE)
engage_window_removed(ec);
- else if (type == E_EVENT_CLIENT_UNICONIFY)
- engage_window_restored(ec);
else if (type == E_EVENT_CLIENT_ICONIFY)
engage_window_minimized(ec);
if (ec->iconic || type == E_EVENT_CLIENT_UNICONIFY ||
@@ -425,12 +423,6 @@ e_modapi_init(E_Module *module)
_Static_assert(EINA_C_ARRAY_LENGTH(events) == EINA_C_ARRAY_LENGTH(handlers),
"Each event needs a handler slot");
if (!engage_launchers_init()) return NULL;
- if (!engage_windows_init())
- {
- engage_launchers_shutdown();
- return NULL;
- }
-
if (!config_init())
{
engage_windows_shutdown();
diff --git a/e_mod_main.h b/e_mod_main.h
index f2c00d2..9c0dc33 100644
--- a/e_mod_main.h
+++ b/e_mod_main.h
@@ -101,7 +101,6 @@ Eina_Bool engage_launcher_has_window(Efreet_Desktop *app);
Eina_Bool engage_launchers_move(int from, int target);
-Eina_Bool engage_windows_init(void);
void engage_windows_shutdown(void);
@@ -113,13 +112,10 @@ const Eina_List *engage_windows_collect(void);
void engage_window_minimized(E_Client *client);
-void engage_window_capture(E_Client *client);
-void engage_window_restored(E_Client *client);
void engage_window_removed(E_Client *client);
-Evas_Object *engage_window_preview_add(E_Client *client, Evas *evas);
Eina_Bool engage_windows_move(E_Client *client, E_Client *anchor, Eina_Bool after);
diff --git a/engage_dock.c b/engage_dock.c
index cbf4744..25d8090 100644
--- a/engage_dock.c
+++ b/engage_dock.c
@@ -62,7 +62,6 @@ typedef struct
{
Engage_Dock *dock;
Evas_Object *visual;
- Evas_Object *preview_content;
Evas_Object *live_preview_frame;
Evas_Object *indicator;
Evas_Object *badge;
@@ -76,7 +75,6 @@ typedef struct
double launch_pulse;
double start, scale, target;
int units, slot, indicator_slot;
- int preview_frame_w, preview_frame_h;
Eina_Rect preview_geometry, indicator_geometry;
double position, cross_position;
Eina_Bool placed;
@@ -408,12 +406,11 @@ live_preview_frame_deleted(void *data, Evas *evas EINA_UNUSED,
}
static void
-live_preview_image_deleted(void *data, Evas *evas EINA_UNUSED,
+preview_deleted(void *data, Evas *evas EINA_UNUSED,
Evas_Object *obj, void *event EINA_UNUSED)
{
Dock_Tile *tile = data;
- if (tile->preview_content == obj) tile->preview_content = NULL;
if (tile->visual == obj) tile->visual = NULL;
}
@@ -429,7 +426,6 @@ tile_free(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
if (tile->hover_job) ecore_job_del(tile->hover_job);
if (tile->tooltip_timer) ecore_timer_del(tile->tooltip_timer);
if (tile->tooltip_anchor) evas_object_del(tile->tooltip_anchor);
- if (tile->preview_content) evas_object_del(tile->preview_content);
evas_object_del(tile->visual);
if (tile->live_preview_frame)
{
@@ -544,7 +540,6 @@ dock_layout(Evas_Object *box, Evas_Object_Box_Data *layout, void *data)
Engage_Dock *dock;
Evas *evas;
Evas_Object_Box_Option *option;
- Evas_Object *image;
Eina_List *l;
Dock_Tile *tile, *pressed;
Dock_Section group;
@@ -560,7 +555,7 @@ dock_layout(Evas_Object *box, Evas_Object_Box_Data *layout, void *data)
int axis, cross, tx, ty, tw, th, vx, vy, vw, vh;
int along_space, cross_space, along_gap;
int glow_size, glow_x, glow_y, glow_radius;
- int frame_w, frame_h, iw, ih, visual_x, visual_y;
+ int iw, ih, visual_x, visual_y;
dock = data;
total = 0;
@@ -683,14 +678,10 @@ dock_layout(Evas_Object *box, Evas_Object_Box_Data *layout, void *data)
}
else if (tile->preview_image)
{
- frame_w = tile->preview_frame_w;
- frame_h = tile->preview_frame_h;
- vw = MAX(0, tw * 9 / 10 - frame_w);
- vh = MAX(0, th * 9 / 10 - frame_h);
- image = tile->preview_content ? tile->preview_content : tile->visual;
- iw = ih = 0;
- if (image && (tile->preview_content || !frame_w))
- evas_object_image_size_get(image, &iw, &ih);
+ vw = tw * 9 / 10;
+ vh = th * 9 / 10;
+ iw = tile->client->w;
+ ih = tile->client->h;
if (iw > 0 && ih > 0)
{
if ((int64_t)vw * ih > (int64_t)vh * iw)
@@ -698,8 +689,6 @@ dock_layout(Evas_Object *box, Evas_Object_Box_Data *layout, void *data)
else
vh = (int)((int64_t)vw * ih / iw);
}
- vw += frame_w;
- vh += frame_h;
}
else if (!tile->temporary && tile->client)
@@ -1209,93 +1198,33 @@ running_indicator_add(Evas *evas)
}
static Evas_Object *
-live_preview_add(Dock_Tile *tile, E_Client *client, Evas *evas)
+preview_visual_add(Dock_Tile *tile, E_Client *client, Evas *evas)
{
Evas_Object *frame = client->frame;
- Evas_Object *image;
+ Evas_Object *preview;
+ Eina_Bool live;
if (!frame || !client->pixmap || evas_object_evas_get(frame) != evas)
return NULL;
- e_comp_object_iconic_preview_add(frame);
- image = e_comp_object_util_mirror_add(frame);
- if (!image ||
- (!e_pixmap_is_x(client->pixmap) &&
- !evas_object_image_native_surface_get(image) &&
- !e_pixmap_image_exists(client->pixmap)))
+ live = engage_config_dock_preview_animation_get();
+ if (live) e_comp_object_iconic_preview_add(frame);
+ preview = e_comp_object_util_frame_mirror_add(frame);
+ if (!preview)
{
- if (image) evas_object_del(image);
- e_comp_object_iconic_preview_del(frame);
+ if (live) e_comp_object_iconic_preview_del(frame);
return NULL;
}
- tile->live_preview_frame = frame;
- evas_object_event_callback_add(frame, EVAS_CALLBACK_DEL, live_preview_frame_deleted, tile);
- evas_object_event_callback_add(image, EVAS_CALLBACK_DEL, live_preview_image_deleted, tile);
- return image;
-}
-
-static Evas_Object *
-preview_visual_add(Dock_Tile *tile, E_Client *client, Evas *evas)
-{
- Evas_Object *image;
- const char *file;
- const char *group;
- Evas_Object *frame;
- int content_w;
- int content_h;
- double scale;
- const char *title;
-
- image = NULL;
- if (engage_config_dock_preview_animation_get())
- image = live_preview_add(tile, client, evas);
- if (!image) image = engage_window_preview_add(client, evas);
- if (!image) return NULL;
+ if (live)
+ {
+ tile->live_preview_frame = frame;
+ evas_object_event_callback_add(frame, EVAS_CALLBACK_DEL,
+ live_preview_frame_deleted, tile);
+ }
+ evas_object_event_callback_add(preview, EVAS_CALLBACK_DEL, preview_deleted, tile);
tile->preview_image = EINA_TRUE;
-
- file = NULL;
- group = NULL;
- frame = NULL;
- if (client->frame && e_comp_object_frame_exists(client->frame) && client->frame_object)
- {
- edje_object_file_get(client->frame_object, &file, &group);
- if (file && group) frame = edje_object_add(evas);
- }
- if (frame)
- {
- if (edje_object_file_set(frame, file, group))
- {
- scale = edje_object_scale_get(client->frame_object);
- edje_object_scale_set(frame, (scale > 0.0 ? scale : edje_scale_get()) * 0.55);
- edje_object_signal_emit(frame, "e,version,22", "e");
- edje_object_signal_emit(frame, "e,state,focused", "e");
- edje_object_signal_emit(frame, "e,state,visible", "e");
- evas_object_resize(frame, 100, 100);
- edje_object_message_signal_process(frame);
- edje_object_calc_force(frame);
- if (edje_object_part_geometry_get(frame, "e.swallow.client",
- NULL, NULL, &content_w, &content_h) &&
- edje_object_part_swallow(frame, "e.swallow.client", image))
- {
- tile->preview_frame_w = MAX(0, 100 - content_w);
- tile->preview_frame_h = MAX(0, 100 - content_h);
- }
- else E_FREE_FUNC(frame, evas_object_del);
- }
- else E_FREE_FUNC(frame, evas_object_del);
- }
-
- if (!frame) return image;
-
- title = e_client_util_name_get(client);
- if (title && title[0])
- edje_object_part_text_escaped_set(frame, "e.text.title", title);
-
- tile->preview_content = image;
- evas_object_pass_events_set(image, EINA_TRUE);
- evas_object_show(image);
- return frame;
+ return preview;
}
static Evas_Object *
@@ -1928,7 +1857,6 @@ dock_minimize(void *data, Evas_Object *frame, const char *signal)
}
if (!client->iconic || stopping) return EINA_FALSE;
previews = engage_config_dock_previews_get();
- if (previews) engage_window_capture(client);
/* Keep the frame available to the preview builder during the effect,
* even when the destination tile is offscreen. */
diff --git a/engage_windows.c b/engage_windows.c
index dc1ebf0..3fd32e2 100644
--- a/engage_windows.c
+++ b/engage_windows.c
@@ -1,20 +1,5 @@
#include "e_mod_main.h"
-#if defined(ENGAGE_HAVE_XCB) && !defined(HAVE_WAYLAND_ONLY)
-# include <X11/Xlib.h>
-# include <xcb/xcb.h>
-#endif
-
-enum { PREVIEW_MAX = 192 };
-
-typedef struct
-{
- int width, height;
- Eina_Bool alpha;
- uint32_t pixels[];
-} Snapshot;
-
-static Eina_Hash *snapshots;
static Eina_List *window_order;
Eina_Bool
@@ -24,188 +9,6 @@ engage_window_eligible(E_Client *ec)
!e_client_util_ignored_get(ec) && !ec->netwm.state.skip_taskbar;
}
-static Snapshot *
-snapshot_copy(const uint32_t *pixels, int width, int height, int bytes_per_row,
- Eina_Bool alpha)
-{
- int longest;
- int limit;
- int w;
- int h;
- int stride;
- Snapshot *shot;
- int y;
- int x;
-
- if (!pixels || width <= 0 || height <= 0 ||
- bytes_per_row / (int)sizeof(*pixels) < width) return NULL;
-
- longest = MAX(width, height);
- limit = MIN(longest, PREVIEW_MAX);
- w = MAX(1, (int)((int64_t)width * limit / longest));
- h = MAX(1, (int)((int64_t)height * limit / longest));
- stride = bytes_per_row / sizeof(*pixels);
- shot = malloc(sizeof(*shot) + (size_t)w * h * sizeof(*pixels));
- if (!shot) return NULL;
-
- shot->width = w;
- shot->height = h;
- shot->alpha = alpha;
- for (y = 0; y < h; y++)
- for (x = 0; x < w; x++)
- shot->pixels[y * w + x] =
- pixels[(size_t)((int64_t)y * height / h) * stride +
- (int64_t)x * width / w];
- return shot;
-}
-
-#if defined(ENGAGE_HAVE_XCB) && !defined(HAVE_WAYLAND_ONLY)
-static xcb_connection_t *snapshot_x_connection;
-
-static Snapshot *
-snapshot_x_capture(E_Client *client)
-{
- E_Pixmap *pixmap;
- xcb_drawable_t drawable;
- const Visual *visual;
- int width;
- int height;
- Display *display;
- const xcb_setup_t *setup;
- const uint16_t endian_probe = 1;
- unsigned int byte_order;
- xcb_format_iterator_t format;
- xcb_get_image_cookie_t request;
- xcb_generic_error_t *error;
- xcb_get_image_reply_t *reply;
- Snapshot *shot;
- int stride;
-
- pixmap = client->pixmap;
- drawable = e_pixmap_pixmap_get(pixmap);
- visual = e_pixmap_visual_get(pixmap);
-
- if (!drawable || !visual ||
- visual->red_mask != 0xff0000 || visual->green_mask != 0x00ff00 ||
- visual->blue_mask != 0x0000ff ||
- !e_pixmap_size_get(pixmap, &width, &height) ||
- width <= 0 || height <= 0 || width > UINT16_MAX || height > UINT16_MAX ||
- (int64_t)width * height > 16 * 1024 * 1024)
- return NULL;
-
- display = (Display *)ecore_x_display_get();
- if (!display) return NULL;
- if (snapshot_x_connection && xcb_connection_has_error(snapshot_x_connection))
- {
- xcb_disconnect(snapshot_x_connection);
- snapshot_x_connection = NULL;
- }
- if (!snapshot_x_connection)
- snapshot_x_connection = xcb_connect(DisplayString(display), NULL);
- if (!snapshot_x_connection || xcb_connection_has_error(snapshot_x_connection))
- return NULL;
-
- setup = xcb_get_setup(snapshot_x_connection);
- byte_order = *(const uint8_t *)&endian_probe ?
- XCB_IMAGE_ORDER_LSB_FIRST : XCB_IMAGE_ORDER_MSB_FIRST;
- if (setup->image_byte_order != byte_order) return NULL;
-
- format = xcb_setup_pixmap_formats_iterator(setup);
- while (format.rem && format.data->depth != client->depth)
- xcb_format_next(&format);
- if (!format.rem || format.data->bits_per_pixel != 32 ||
- !format.data->scanline_pad || format.data->scanline_pad > 32)
- return NULL;
-
- /* Keep X errors local to this request. The compositor's X connection and
- * shared-memory images are left alone if a pixmap has just been replaced. */
- request = xcb_get_image(snapshot_x_connection, XCB_IMAGE_FORMAT_Z_PIXMAP,
- drawable, 0, 0, width, height, UINT32_MAX);
- error = NULL;
- reply = xcb_get_image_reply(snapshot_x_connection, request, &error);
-
- shot = NULL;
- stride = width * (int)sizeof(uint32_t);
- if (!error && reply && reply->depth == client->depth &&
- xcb_get_image_data_length(reply) == stride * height)
- shot = snapshot_copy((const uint32_t *)xcb_get_image_data(reply),
- width, height, stride, client->argb);
- free(error);
- free(reply);
- return shot;
-}
-#endif
-
-static Snapshot *
-snapshot_capture(E_Client *ec)
-{
- E_Pixmap *pixmap;
- Evas_Object *mirror;
- int w;
- int h;
- Snapshot *shot;
- void *pixels;
-
- pixmap = ec->pixmap;
- if (!pixmap || !ec->frame) return NULL;
- if (e_pixmap_is_x(pixmap))
- {
-#if defined(ENGAGE_HAVE_XCB) && !defined(HAVE_WAYLAND_ONLY)
- if (e_comp->gl) return snapshot_x_capture(ec);
-#else
- if (e_comp->gl) return NULL;
-#endif
- }
- else if (!e_pixmap_is_pixels(pixmap))
- return NULL;
-
- if (!e_pixmap_image_is_argb(pixmap) || !e_pixmap_image_data_get(pixmap))
- return NULL;
-
- mirror = e_comp_object_util_mirror_add(ec->frame);
- if (!mirror) return NULL;
-
- /* Copy only existing CPU pixels, without asking Evas to refresh the mirror. */
- evas_object_image_pixels_dirty_set(mirror, EINA_FALSE);
- evas_object_image_pixels_get_callback_set(mirror, NULL, NULL);
-
- shot = NULL;
- evas_object_image_size_get(mirror, &w, &h);
- if (w > 0 && h > 0 && !evas_object_image_native_surface_get(mirror))
- {
- pixels = evas_object_image_data_get(mirror, EINA_FALSE);
- shot = snapshot_copy(pixels, w, h, evas_object_image_stride_get(mirror),
- evas_object_image_alpha_get(mirror));
- if (pixels) evas_object_image_data_set(mirror, pixels);
- }
- evas_object_del(mirror);
- return shot;
-}
-
-static Snapshot *
-snapshot_capture_once(E_Client *ec)
-{
- Snapshot *shot;
-
- shot = eina_hash_find(snapshots, &ec);
- if (shot) return shot;
-
- shot = snapshot_capture(ec);
- if (shot && !eina_hash_add(snapshots, &ec, shot))
- {
- free(shot);
- return NULL;
- }
- return shot;
-}
-
-Eina_Bool
-engage_windows_init(void)
-{
- snapshots = eina_hash_pointer_new(free);
- return snapshots != NULL;
-}
-
void
engage_windows_shutdown(void)
{
@@ -213,14 +16,6 @@ engage_windows_shutdown(void)
EINA_LIST_FREE(window_order, client)
e_object_unref(E_OBJECT(client));
- E_FREE_FUNC(snapshots, eina_hash_free);
-#if defined(ENGAGE_HAVE_XCB) && !defined(HAVE_WAYLAND_ONLY)
- if (snapshot_x_connection)
- {
- xcb_disconnect(snapshot_x_connection);
- snapshot_x_connection = NULL;
- }
-#endif
}
Eina_Bool
@@ -257,24 +52,11 @@ engage_window_minimized(E_Client *client)
}
-void
-engage_window_capture(E_Client *client)
-{
- snapshot_capture_once(client);
-}
-
-void
-engage_window_restored(E_Client *client)
-{
- eina_hash_del_by_key(snapshots, &client);
-}
-
void
engage_window_removed(E_Client *client)
{
Eina_List *node;
- engage_window_restored(client);
node = eina_list_data_find_list(window_order, client);
if (!node) return;
@@ -282,24 +64,6 @@ engage_window_removed(E_Client *client)
e_object_unref(E_OBJECT(client));
}
-Evas_Object *
-engage_window_preview_add(E_Client *client, Evas *evas)
-{
- Snapshot *shot;
- Evas_Object *image;
-
- shot = snapshot_capture_once(client);
- if (!shot) return NULL;
-
- image = evas_object_image_filled_add(evas);
- if (!image) return NULL;
-
- evas_object_image_size_set(image, shot->width, shot->height);
- evas_object_image_alpha_set(image, shot->alpha);
- evas_object_image_data_copy_set(image, shot->pixels);
- return image;
-}
-
Eina_Bool
engage_windows_move(E_Client *client, E_Client *anchor, Eina_Bool after)
{
diff --git a/meson.build b/meson.build
index 4edf712..791b68a 100644
--- a/meson.build
+++ b/meson.build
@@ -4,16 +4,12 @@ project('engage', 'c', version: '0.1.0',
enlightenment = dependency('enlightenment')
eldbus = dependency('eldbus')
math = meson.get_compiler('c').find_library('m', required: false)
-xcb = dependency('xcb', required: false)
module_c_args = ['-DENGAGE_VERSION="@0@"'.format(meson.project_version())]
# Release builds pack bitfields in public structs such as E_Client.
enlightenment_release = enlightenment.get_variable(pkgconfig: 'release')
if not enlightenment_release.startswith('dev-')
module_c_args += '-DE_RELEASE_BUILD=1'
endif
-if xcb.found()
- module_c_args += '-DENGAGE_HAVE_XCB'
-endif
module_dir = enlightenment.get_variable(pkgconfig: 'modules') / 'engage'
module_arch = enlightenment.get_variable(pkgconfig: 'module_arch')
@@ -31,7 +27,7 @@ module_sources = files(
shared_module('module', module_sources,
name_prefix: '',
gnu_symbol_visibility: 'hidden',
- dependencies: [enlightenment, eldbus, math, xcb],
+ dependencies: [enlightenment, eldbus, math],
c_args: module_c_args,
install: true,
install_dir: module_dir / module_arch)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.