[libwnck/wip/muktupavels/wnck-handle-3: 1/4] screen: store WnckHandle in struct




commit dfacd0e6cfba955f6e655f40baa27cdfd61b0e12
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Dec 26 15:32:44 2021 +0200

    screen: store WnckHandle in struct
    
    Before 5ab809143a7d commit event filter was added in wnck_screen_get
    when constructing first screen. Store WnckHandle in WnckScreen struct
    to ensure that event filter is always added otherwise we might end up
    without event filter if on startup nothing calls _wnck_get_handle.
    
    This change introduces new requirement - wnck_set_client_type must be
    used before using WnckScreen APIs.

 libwnck/private.h |  2 ++
 libwnck/screen.c  | 12 ++++++++++++
 2 files changed, 14 insertions(+)
---
diff --git a/libwnck/private.h b/libwnck/private.h
index f1a4af2..d37c328 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -133,6 +133,8 @@ SnDisplay* _wnck_screen_get_sn_display (WnckScreen *screen);
 
 WnckScreen* _wnck_screen_get_existing (int number);
 
+WnckHandle    *_wnck_screen_get_handle          (WnckScreen    *screen);
+
 void           _wnck_pager_activate_workspace   (WnckWorkspace *wspace,
                                                  guint32        timestamp);
 int            _wnck_pager_get_n_workspaces     (WnckPager     *pager);
diff --git a/libwnck/screen.c b/libwnck/screen.c
index d6db387..473c3fc 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -69,6 +69,8 @@ static WnckScreen** screens = NULL;
 
 struct _WnckScreenPrivate
 {
+  WnckHandle *handle;
+
   int number;
   Window xroot;
   Screen *xscreen;
@@ -529,6 +531,8 @@ wnck_screen_construct (Display    *display,
                        WnckScreen *screen,
                        int         number)
 {
+  screen->priv->handle = _wnck_get_handle ();
+
   /* Create the initial state of the screen. */
   screen->priv->xroot = RootWindow (display, number);
   screen->priv->xscreen = ScreenOfDisplay (display, number);
@@ -674,6 +678,14 @@ wnck_screen_get_for_root (gulong root_window_id)
   return NULL;
 }
 
+WnckHandle *
+_wnck_screen_get_handle (WnckScreen *screen)
+{
+  g_return_val_if_fail (WNCK_IS_SCREEN (screen), NULL);
+
+  return screen->priv->handle;
+}
+
 /**
  * wnck_screen_get_number:
  * @screen: a #WnckScreen.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]