Skip to content

Commit a4d3838

Browse files
committed
ext-toplevel: support additional states
(sticky, always on top)
1 parent c7b2ca6 commit a4d3838

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/implementations/cairo-dock-ext-toplevel.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static GldiObjectManager myExtToplevelObjectMgr;
4747
struct _GldiExtWindowActor {
4848
GldiWaylandWindowActor wactor;
4949
state_handle *chandle; // extension object handle (the ext_handle is stored in wactor)
50+
uint32_t extra_state; // last received state -- used only to keep track of is_above
5051
};
5152
typedef struct _GldiExtWindowActor GldiExtWindowActor;
5253

@@ -138,6 +139,29 @@ static void _set_fullscreen (GldiWindowActor *actor, gboolean bFullScreen)
138139
else ext_foreign_toplevel_state_handle_v1_unset_fullscreen (wactor->chandle);
139140
}
140141

142+
static void _set_above (GldiWindowActor *actor, gboolean bAbove)
143+
{
144+
if (!actor) return;
145+
GldiExtWindowActor *wactor = (GldiExtWindowActor *)actor;
146+
if (bAbove) ext_foreign_toplevel_state_handle_v1_set_always_on_top (wactor->chandle);
147+
else ext_foreign_toplevel_state_handle_v1_unset_always_on_top (wactor->chandle);
148+
}
149+
150+
static void _is_above_or_below (GldiWindowActor *actor, gboolean *bIsAbove, gboolean *bIsBelow)
151+
{
152+
GldiExtWindowActor *wactor = (GldiExtWindowActor *)actor;
153+
*bIsAbove = !!(wactor->extra_state & EXT_FOREIGN_TOPLEVEL_STATE_HANDLE_V1_STATE_ALWAYS_ON_TOP);
154+
*bIsBelow = FALSE; // not supported
155+
}
156+
157+
static void _set_sticky (GldiWindowActor *actor, gboolean bSticky)
158+
{
159+
GldiExtWindowActor *wactor = (GldiExtWindowActor *)actor;
160+
if (bSticky) ext_foreign_toplevel_state_handle_v1_set_sticky (wactor->chandle);
161+
else ext_foreign_toplevel_state_handle_v1_unset_sticky (wactor->chandle);
162+
}
163+
164+
141165
static void _capabilities_cb (G_GNUC_UNUSED void *data, G_GNUC_UNUSED struct ext_foreign_toplevel_state_manager_v1 *manager,
142166
G_GNUC_UNUSED uint32_t notifications, uint32_t actions)
143167
{
@@ -224,14 +248,18 @@ static void _gldi_toplevel_state_cb (void *data, G_GNUC_UNUSED state_handle *han
224248
gboolean maximized_pending = !!(states & EXT_FOREIGN_TOPLEVEL_STATE_HANDLE_V1_STATE_MAXIMIZED);
225249
gboolean minimized_pending = !!(states & EXT_FOREIGN_TOPLEVEL_STATE_HANDLE_V1_STATE_MINIMIZED);
226250
gboolean fullscreen_pending = !!(states & EXT_FOREIGN_TOPLEVEL_STATE_HANDLE_V1_STATE_FULLSCREEN);
227-
//!! TODO: sticky !!
251+
gboolean sticky_pending = !!(states & EXT_FOREIGN_TOPLEVEL_STATE_HANDLE_V1_STATE_STICKY);
228252

229253
cd_debug ("wactor: %p (%s), activated: %d", wactor, wactor->actor.cName ? wactor->actor.cName : "(no name)", activated_pending);
230254

231255
_update_active (wactor, activated_pending);
232256
gldi_wayland_wm_maximized_changed (wactor, maximized_pending, FALSE);
233257
gldi_wayland_wm_minimized_changed (wactor, minimized_pending, FALSE);
234258
gldi_wayland_wm_fullscreen_changed (wactor, fullscreen_pending, FALSE);
259+
gldi_wayland_wm_sticky_changed (wactor, sticky_pending, FALSE);
260+
261+
GldiExtWindowActor *tl_actor = (GldiExtWindowActor*)data;
262+
tl_actor->extra_state = states;
235263
}
236264

237265
static void _gldi_toplevel_done_cb (void *data, G_GNUC_UNUSED ext_handle *handle)
@@ -361,16 +389,15 @@ gboolean gldi_ext_toplevel_try_init (struct wl_registry *registry)
361389
// wmb.lower = _lower;
362390
wmb.maximize = _maximize;
363391
wmb.set_fullscreen = _set_fullscreen;
364-
// wmb.set_above = _set_above;
392+
wmb.set_above = _set_above;
365393
wmb.set_thumbnail_area = _set_thumbnail_area;
366394
// wmb.set_window_border = _set_window_border;
367395
// wmb.get_icon_surface = _get_icon_surface;
368396
// wmb.get_thumbnail_surface = _get_thumbnail_surface;
369397
// wmb.get_texture = _get_texture;
370398
wmb.get_transient_for = _get_transient_for;
371-
// wmb.is_above_or_below = _is_above_or_below;
372-
// wmb.is_sticky = _is_sticky;
373-
// wmb.set_sticky = _set_sticky;
399+
wmb.is_above_or_below = _is_above_or_below;
400+
wmb.set_sticky = _set_sticky;
374401
wmb.can_minimize_maximize_close = _can_minimize_maximize_close;
375402
// wmb.get_id = _get_id;
376403
wmb.pick_window = gldi_wayland_wm_pick_window;

0 commit comments

Comments
 (0)