[libwnck/wip/muktupavels/wnck-handle: 10/15] screen: move screen handling to WnckHandle
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/wnck-handle: 10/15] screen: move screen handling to WnckHandle
- Date: Thu, 17 Feb 2022 14:51:31 +0000 (UTC)
commit 54c45c011f542c899a5627905e47712037c6bb99
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Aug 19 21:41:48 2019 +0300
screen: move screen handling to WnckHandle
And update libwnck to use new functions.
libwnck/pager.c | 26 ++++++-
libwnck/pager.h | 2 +
libwnck/private.h | 10 ++-
libwnck/screen.c | 112 ++++-----------------------
libwnck/selector.c | 26 ++++++-
libwnck/selector.h | 8 +-
libwnck/tasklist.c | 50 ++++++++----
libwnck/tasklist.h | 2 +
libwnck/util.c | 3 +-
libwnck/window.c | 5 +-
libwnck/wnck-handle-private.h | 3 +
libwnck/wnck-handle.c | 171 ++++++++++++++++++++++++++++++++++++++----
libwnck/wnck-handle.h | 19 +++--
13 files changed, 297 insertions(+), 140 deletions(-)
---
diff --git a/libwnck/pager.c b/libwnck/pager.c
index c769d62c..dad53070 100644
--- a/libwnck/pager.c
+++ b/libwnck/pager.c
@@ -61,6 +61,8 @@
struct _WnckPagerPrivate
{
+ WnckHandle *handle;
+
WnckScreen *screen;
int n_rows; /* really columns for vertical orientation */
@@ -296,7 +298,8 @@ _wnck_pager_set_screen (WnckPager *pager)
return;
gdkscreen = gtk_widget_get_screen (GTK_WIDGET (pager));
- pager->priv->screen = wnck_screen_get (gdk_x11_screen_get_screen_number (gdkscreen));
+ pager->priv->screen = wnck_handle_get_screen (pager->priv->handle,
+ gdk_x11_screen_get_screen_number (gdkscreen));
if (!wnck_pager_set_layout_hint (pager))
{
@@ -2194,6 +2197,27 @@ wnck_pager_new (void)
WnckPager *pager;
pager = g_object_new (WNCK_TYPE_PAGER, NULL);
+ pager->priv->handle = _wnck_get_handle ();
+
+ return GTK_WIDGET (pager);
+}
+
+/**
+ * wnck_pager_new_with_handle:
+ * @handle: a #WnckHandle
+ *
+ * Creates a new #WnckPager. The #WnckPager will show the #WnckWorkspace of the
+ * #WnckScreen it is on.
+ *
+ * Returns: a newly created #WnckPager.
+ */
+GtkWidget *
+wnck_pager_new_with_handle (WnckHandle *handle)
+{
+ WnckPager *pager;
+
+ pager = g_object_new (WNCK_TYPE_PAGER, NULL);
+ pager->priv->handle = handle;
return GTK_WIDGET (pager);
}
diff --git a/libwnck/pager.h b/libwnck/pager.h
index c67f2fa3..db830ed2 100644
--- a/libwnck/pager.h
+++ b/libwnck/pager.h
@@ -104,6 +104,8 @@ GType wnck_pager_get_type (void) G_GNUC_CONST;
GtkWidget* wnck_pager_new (void);
+GtkWidget* wnck_pager_new_with_handle (WnckHandle *handle);
+
gboolean wnck_pager_set_orientation (WnckPager *pager,
GtkOrientation orientation);
gboolean wnck_pager_set_n_rows (WnckPager *pager,
diff --git a/libwnck/private.h b/libwnck/private.h
index 22a155c7..468f7060 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -104,8 +104,6 @@ void _wnck_screen_change_workspace_name (WnckScreen *screen,
int number,
const char *name);
-void _wnck_screen_shutdown_all (void);
-
gboolean _wnck_workspace_set_geometry (WnckWorkspace *space, int w, int h);
gboolean _wnck_workspace_set_viewport (WnckWorkspace *space, int x, int y);
@@ -114,6 +112,12 @@ Display *_wnck_get_default_display (void);
#define WNCK_SCREEN_XSCREEN(screen) (_wnck_screen_get_xscreen (screen))
+void _wnck_screen_construct (WnckScreen *screen,
+ WnckHandle *handle,
+ Display *display,
+ int number);
+
+Window _wnck_screen_get_xroot (WnckScreen *screen);
Screen *_wnck_screen_get_xscreen (WnckScreen *screen);
GdkScreen *_wnck_screen_get_gdk_screen (WnckScreen *screen);
@@ -121,8 +125,6 @@ GdkScreen *_wnck_screen_get_gdk_screen (WnckScreen *screen);
SnDisplay* _wnck_screen_get_sn_display (WnckScreen *screen);
#endif
-WnckScreen* _wnck_screen_get_existing (int number);
-
WnckHandle *_wnck_screen_get_handle (WnckScreen *screen);
void _wnck_pager_activate_workspace (WnckWorkspace *wspace,
diff --git a/libwnck/screen.c b/libwnck/screen.c
index 305440d8..dbe94a60 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -65,8 +65,6 @@
#define _NET_WM_BOTTOMRIGHT 2
#define _NET_WM_BOTTOMLEFT 3
-static WnckScreen** screens = NULL;
-
struct _WnckScreenPrivate
{
WnckHandle *handle;
@@ -500,8 +498,6 @@ wnck_screen_finalize (GObject *object)
g_free (screen->priv->wm_name);
screen->priv->wm_name = NULL;
- screens[screen->priv->number] = NULL;
-
#ifdef HAVE_STARTUP_NOTIFICATION
sn_display_unref (screen->priv->sn_display);
screen->priv->sn_display = NULL;
@@ -526,12 +522,13 @@ sn_error_trap_pop (SnDisplay *display,
}
#endif /* HAVE_STARTUP_NOTIFICATION */
-static void
-wnck_screen_construct (Display *display,
- WnckScreen *screen,
- int number)
+void
+_wnck_screen_construct (WnckScreen *screen,
+ WnckHandle *handle,
+ Display *display,
+ int number)
{
- screen->priv->handle = _wnck_get_handle ();
+ screen->priv->handle = handle;
/* Create the initial state of the screen. */
screen->priv->xroot = RootWindow (display, number);
@@ -578,44 +575,7 @@ wnck_screen_construct (Display *display,
WnckScreen*
wnck_screen_get (int index)
{
- Display *display;
-
- display = _wnck_get_default_display ();
-
- g_return_val_if_fail (display != NULL, NULL);
-
- if (index >= ScreenCount (display))
- return NULL;
-
- if (screens == NULL)
- {
- screens = g_new0 (WnckScreen*, ScreenCount (display));
- }
-
- if (screens[index] == NULL)
- {
- screens[index] = g_object_new (WNCK_TYPE_SCREEN, NULL);
-
- wnck_screen_construct (display, screens[index], index);
- }
-
- return screens[index];
-}
-
-WnckScreen*
-_wnck_screen_get_existing (int number)
-{
- Display *display;
-
- display = _wnck_get_default_display ();
-
- g_return_val_if_fail (display != NULL, NULL);
- g_return_val_if_fail (number < ScreenCount (display), NULL);
-
- if (screens != NULL)
- return screens[number];
- else
- return NULL;
+ return wnck_handle_get_screen (_wnck_get_handle (), index);
}
/**
@@ -630,15 +590,7 @@ _wnck_screen_get_existing (int number)
WnckScreen*
wnck_screen_get_default (void)
{
- int default_screen;
- Display *default_display = _wnck_get_default_display ();
-
- if (default_display == NULL)
- return NULL;
-
- default_screen = DefaultScreen (default_display);
-
- return wnck_screen_get (default_screen);
+ return wnck_handle_get_default_screen (_wnck_get_handle ());
}
/**
@@ -658,24 +610,7 @@ wnck_screen_get_default (void)
WnckScreen*
wnck_screen_get_for_root (gulong root_window_id)
{
- int i;
- Display *display;
-
- if (screens == NULL)
- return NULL;
-
- i = 0;
- display = _wnck_get_default_display ();
-
- while (i < ScreenCount (display))
- {
- if (screens[i] != NULL && screens[i]->priv->xroot == root_window_id)
- return screens[i];
-
- ++i;
- }
-
- return NULL;
+ return wnck_handle_get_screen_for_root (_wnck_get_handle (), root_window_id);
}
WnckHandle *
@@ -2510,6 +2445,12 @@ wnck_screen_get_height (WnckScreen *screen)
return HeightOfScreen (screen->priv->xscreen);
}
+Window
+_wnck_screen_get_xroot (WnckScreen *screen)
+{
+ return screen->priv->xroot;
+}
+
Screen *
_wnck_screen_get_xscreen (WnckScreen *screen)
{
@@ -2740,26 +2681,3 @@ _wnck_screen_change_workspace_name (WnckScreen *screen,
g_free (names);
}
-
-void
-_wnck_screen_shutdown_all (void)
-{
- int i;
- Display *display;
-
- if (screens == NULL)
- return;
-
- display = _wnck_get_default_display ();
-
- for (i = 0; i < ScreenCount (display); ++i)
- {
- if (screens[i] != NULL) {
- g_object_unref (screens[i]);
- screens[i] = NULL;
- }
- }
-
- g_free (screens);
- screens = NULL;
-}
diff --git a/libwnck/selector.c b/libwnck/selector.c
index b975b27f..ea686d14 100644
--- a/libwnck/selector.c
+++ b/libwnck/selector.c
@@ -52,6 +52,8 @@
*/
struct _WnckSelectorPrivate {
+ WnckHandle *handle;
+
GtkWidget *image;
WnckWindow *icon_window;
@@ -118,7 +120,8 @@ wnck_selector_get_screen (WnckSelector *selector)
screen = gtk_widget_get_screen (GTK_WIDGET (selector));
- return wnck_screen_get (gdk_x11_screen_get_screen_number (screen));
+ return wnck_handle_get_screen (selector->priv->handle,
+ gdk_x11_screen_get_screen_number (screen));
}
static GdkPixbuf *
@@ -1273,6 +1276,27 @@ wnck_selector_new (void)
WnckSelector *selector;
selector = g_object_new (WNCK_TYPE_SELECTOR, NULL);
+ selector->priv->handle = _wnck_get_handle ();
+
+ return GTK_WIDGET (selector);
+}
+
+/**
+ * wnck_selector_new_with_handle:
+ * @handle: a #WnckHandle
+ *
+ * Creates a new #WnckSelector. The #WnckSelector will list #WnckWindow of the
+ * #WnckScreen it is on.
+ *
+ * Returns: a newly created #WnckSelector.
+ */
+GtkWidget *
+wnck_selector_new_with_handle (WnckHandle *handle)
+{
+ WnckSelector *selector;
+
+ selector = g_object_new (WNCK_TYPE_SELECTOR, NULL);
+ selector->priv->handle = handle;
return GTK_WIDGET (selector);
}
diff --git a/libwnck/selector.h b/libwnck/selector.h
index 4783162b..bb6fceb9 100644
--- a/libwnck/selector.h
+++ b/libwnck/selector.h
@@ -27,6 +27,7 @@
#define WNCK_SELECTOR_H
#include <gtk/gtk.h>
+#include <libwnck/wnck-handle.h>
G_BEGIN_DECLS
#define WNCK_TYPE_SELECTOR (wnck_selector_get_type ())
@@ -62,8 +63,11 @@ struct _WnckSelectorClass
void (* pad4) (void);
};
-GtkWidget *wnck_selector_new (void);
-GType wnck_selector_get_type (void) G_GNUC_CONST;
+GtkWidget *wnck_selector_new (void);
+
+GtkWidget *wnck_selector_new_with_handle (WnckHandle *handle);
+
+GType wnck_selector_get_type (void) G_GNUC_CONST;
G_END_DECLS
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c
index 4166d768..d2985973 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/tasklist.c
@@ -189,6 +189,8 @@ typedef struct _skipped_window
struct _WnckTasklistPrivate
{
+ WnckHandle *handle;
+
WnckScreen *screen;
WnckTask *active_task; /* NULL if active window not in tasklist */
@@ -1816,12 +1818,9 @@ get_preferred_size (WnckTasklist *self,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- WnckHandle *handle;
int min_button_width;
- handle = wnck_screen_get_handle (self->priv->screen);
-
- get_minimum_button_size (handle, &min_button_width, NULL);
+ get_minimum_button_size (self->priv->handle, &min_button_width, NULL);
if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -2160,7 +2159,8 @@ wnck_tasklist_realize (GtkWidget *widget)
tasklist = WNCK_TASKLIST (widget);
gdkscreen = gtk_widget_get_screen (widget);
- tasklist->priv->screen = wnck_screen_get (gdk_x11_screen_get_screen_number (gdkscreen));
+ tasklist->priv->screen = wnck_handle_get_screen (tasklist->priv->handle,
+ gdk_x11_screen_get_screen_number (gdkscreen));
g_assert (tasklist->priv->screen != NULL);
#ifdef HAVE_STARTUP_NOTIFICATION
@@ -2555,10 +2555,31 @@ wnck_tasklist_new (void)
WnckTasklist *tasklist;
tasklist = g_object_new (WNCK_TYPE_TASKLIST, NULL);
+ tasklist->priv->handle = _wnck_get_handle ();
return GTK_WIDGET (tasklist);
}
+/**
+ * wnck_tasklist_new_with_handle:
+ * @handle: a #WnckHandle
+ *
+ * Creates a new #WnckTasklist. The #WnckTasklist will list #WnckWindow of the
+ * #WnckScreen it is on.
+ *
+ * Returns: a newly created #WnckTasklist.
+ */
+GtkWidget *
+wnck_tasklist_new_with_handle (WnckHandle *handle)
+{
+ WnckTasklist *self;
+
+ self = g_object_new (WNCK_TYPE_TASKLIST, NULL);
+ self->priv->handle = handle;
+
+ return GTK_WIDGET (self);
+}
+
static void
wnck_tasklist_free_tasks (WnckTasklist *tasklist)
{
@@ -3683,17 +3704,15 @@ wnck_task_scale_icon (WnckHandle *handle,
static GdkPixbuf *
wnck_task_get_icon (WnckTask *task)
{
- WnckHandle *handle;
WnckWindowState state;
GdkPixbuf *pixbuf;
- handle = wnck_screen_get_handle (task->tasklist->priv->screen);
pixbuf = NULL;
switch (task->type)
{
case WNCK_TASK_CLASS_GROUP:
- pixbuf = wnck_task_scale_icon (handle,
+ pixbuf = wnck_task_scale_icon (task->tasklist->priv->handle,
wnck_class_group_get_mini_icon (task->class_group),
FALSE);
break;
@@ -3701,7 +3720,7 @@ wnck_task_get_icon (WnckTask *task)
case WNCK_TASK_WINDOW:
state = wnck_window_get_state (task->window);
- pixbuf = wnck_task_scale_icon (handle,
+ pixbuf = wnck_task_scale_icon (task->tasklist->priv->handle,
wnck_window_get_mini_icon (task->window),
state & WNCK_WINDOW_STATE_MINIMIZED);
break;
@@ -3718,7 +3737,7 @@ wnck_task_get_icon (WnckTask *task)
gsize mini_icon_size;
GdkPixbuf *loaded;
- mini_icon_size = _wnck_handle_get_default_mini_icon_size (handle);
+ mini_icon_size = _wnck_handle_get_default_mini_icon_size (task->tasklist->priv->handle);
loaded = (* task->tasklist->priv->icon_loader) (icon,
mini_icon_size,
@@ -3727,7 +3746,7 @@ wnck_task_get_icon (WnckTask *task)
if (loaded != NULL)
{
- pixbuf = wnck_task_scale_icon (handle, loaded, FALSE);
+ pixbuf = wnck_task_scale_icon (task->tasklist->priv->handle, loaded, FALSE);
g_object_unref (G_OBJECT (loaded));
}
}
@@ -3737,7 +3756,7 @@ wnck_task_get_icon (WnckTask *task)
{
gsize mini_icon_size;
- mini_icon_size = _wnck_handle_get_default_mini_icon_size (handle);
+ mini_icon_size = _wnck_handle_get_default_mini_icon_size (task->tasklist->priv->handle);
_wnck_get_fallback_icons (NULL, 0, &pixbuf, mini_icon_size);
}
@@ -3933,6 +3952,7 @@ static gboolean
wnck_task_motion_timeout (gpointer data)
{
WnckWorkspace *ws;
+ WnckScreen *screen;
WnckTask *task = WNCK_TASK (data);
task->button_activate = 0;
@@ -3942,7 +3962,9 @@ wnck_task_motion_timeout (gpointer data)
* There should only be *one* activate call.
*/
ws = wnck_window_get_workspace (task->window);
- if (ws && ws != wnck_screen_get_active_workspace (wnck_screen_get_default ()))
+ screen = wnck_handle_get_default_screen (task->tasklist->priv->handle);
+
+ if (ws && ws != wnck_screen_get_active_workspace (screen))
{
wnck_workspace_activate (ws, task->dnd_timestamp);
}
@@ -4281,7 +4303,7 @@ wnck_task_create_widgets (WnckTask *task, GtkReliefStyle relief)
task->button = wnck_button_new ();
wnck_button_set_handle (WNCK_BUTTON (task->button),
- wnck_screen_get_handle (task->tasklist->priv->screen));
+ task->tasklist->priv->handle);
gtk_button_set_relief (GTK_BUTTON (task->button), relief);
diff --git a/libwnck/tasklist.h b/libwnck/tasklist.h
index 0659f9d6..b308802b 100644
--- a/libwnck/tasklist.h
+++ b/libwnck/tasklist.h
@@ -89,6 +89,8 @@ GType wnck_tasklist_get_type (void) G_GNUC_CONST;
GtkWidget *wnck_tasklist_new (void);
+GtkWidget *wnck_tasklist_new_with_handle (WnckHandle *handle);
+
G_DEPRECATED
const int *wnck_tasklist_get_size_hint_list (WnckTasklist *tasklist,
int *n_elements);
diff --git a/libwnck/util.c b/libwnck/util.c
index d649d82b..701878b4 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -198,7 +198,8 @@ wnck_set_default_mini_icon_size (gsize size)
wnck_handle_set_default_mini_icon_size (_wnck_get_handle (), size);
default_screen = DefaultScreen (_wnck_get_default_display ());
- screen = _wnck_screen_get_existing (default_screen);
+ screen = _wnck_handle_get_existing_screen (_wnck_get_handle (),
+ default_screen);
if (WNCK_IS_SCREEN (screen))
{
diff --git a/libwnck/window.c b/libwnck/window.c
index 73234ab9..ebd7cf1a 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -3092,9 +3092,12 @@ update_transient_for (WnckWindow *window)
&parent) &&
parent != window->priv->xwindow)
{
+ WnckHandle *handle;
+
window->priv->transient_for = parent;
- if (wnck_screen_get_for_root (window->priv->transient_for) != NULL)
+ handle = wnck_screen_get_handle (window->priv->screen);
+ if (wnck_handle_get_screen_for_root (handle, window->priv->transient_for) != NULL)
window->priv->transient_for_root = TRUE;
else
window->priv->transient_for_root = FALSE;
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
index b08cd79a..f17b3154 100644
--- a/libwnck/wnck-handle-private.h
+++ b/libwnck/wnck-handle-private.h
@@ -26,6 +26,9 @@ G_BEGIN_DECLS
WnckClientType _wnck_handle_get_client_type (WnckHandle *self);
+WnckScreen *_wnck_handle_get_existing_screen (WnckHandle *self,
+ int number);
+
gsize _wnck_handle_get_default_icon_size (WnckHandle *self);
gsize _wnck_handle_get_default_mini_icon_size (WnckHandle *self);
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 9d4d39c2..57e1216b 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2003 Kim Woelders
+ * Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2005-2007 Vincent Untz
* Copyright (C) 2021 Alberts Muktupāvels
*
@@ -27,6 +29,8 @@
#include "config.h"
#include "wnck-handle-private.h"
+#include <gdk/gdkx.h>
+
#include "private.h"
#include "screen.h"
#include "window.h"
@@ -35,16 +39,18 @@
struct _WnckHandle
{
- GObject parent;
+ GObject parent;
+
+ WnckScreen **screens;
- WnckClientType client_type;
+ WnckClientType client_type;
- gsize default_icon_size;
- gsize default_mini_icon_size;
+ gsize default_icon_size;
+ gsize default_mini_icon_size;
- GHashTable *class_group_hash;
- GHashTable *app_hash;
- GHashTable *window_hash;
+ GHashTable *class_group_hash;
+ GHashTable *app_hash;
+ GHashTable *window_hash;
};
enum
@@ -65,19 +71,23 @@ filter_func (GdkXEvent *gdkxevent,
GdkEvent *event,
gpointer data)
{
+ WnckHandle *self;
XEvent *xevent = gdkxevent;
#ifdef HAVE_STARTUP_NOTIFICATION
int i;
Display *display;
#endif /* HAVE_STARTUP_NOTIFICATION */
+ self = WNCK_HANDLE (data);
+
switch (xevent->type)
{
case PropertyNotify:
{
WnckScreen *screen;
- screen = wnck_screen_get_for_root (xevent->xany.window);
+ screen = wnck_handle_get_screen_for_root (self, xevent->xany.window);
+
if (screen != NULL)
{
_wnck_screen_process_property_notify (screen, xevent);
@@ -126,11 +136,12 @@ filter_func (GdkXEvent *gdkxevent,
while (i < ScreenCount (display))
{
- WnckScreen *s;
+ WnckScreen *screen;
- s = _wnck_screen_get_existing (i);
- if (s != NULL)
- sn_display_process_event (_wnck_screen_get_sn_display (s),
+ screen = _wnck_handle_get_existing_screen (self, i);
+
+ if (screen != NULL)
+ sn_display_process_event (_wnck_screen_get_sn_display (screen),
xevent);
++i;
@@ -181,7 +192,16 @@ wnck_handle_finalize (GObject *object)
self->app_hash = NULL;
}
- _wnck_screen_shutdown_all ();
+ if (self->screens != NULL)
+ {
+ Display *display;
+ int i;
+
+ for (i = 0; i < ScreenCount (display); ++i)
+ g_clear_object (&self->screens[i]);
+
+ g_clear_pointer (&self->screens, g_free);
+ }
if (self->window_hash != NULL)
{
@@ -313,6 +333,130 @@ _wnck_handle_get_client_type (WnckHandle *self)
return self->client_type;
}
+/**
+ * wnck_handle_get_default_screen:
+ * @self: a #WnckHandle
+ *
+ * Gets the default #WnckScreen on the default display.
+ *
+ * Returns: (transfer none) (nullable): the default #WnckScreen. The
+ * returned #WnckScreen is owned by #WnckHandle and must not be referenced
+ * or unreferenced. This can return %NULL if not on X11.
+ */
+WnckScreen *
+wnck_handle_get_default_screen (WnckHandle *self)
+{
+ Display *display;
+
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+
+ display = _wnck_get_default_display ();
+ if (display == NULL)
+ return NULL;
+
+ return wnck_handle_get_screen (self, DefaultScreen (display));
+}
+
+/**
+ * wnck_handle_get_screen:
+ * @self: a #WnckHandle
+ * @index: screen number, starting from 0.
+ *
+ * Gets the #WnckScreen for a given screen on the default display.
+ *
+ * Returns: (transfer none): the #WnckScreen for screen @index, or %NULL
+ * if no such screen exists. The returned #WnckScreen is owned by #WnckHandle
+ * and must not be referenced or unreferenced.
+ */
+WnckScreen *
+wnck_handle_get_screen (WnckHandle *self,
+ int index)
+{
+ Display *display;
+
+ display = _wnck_get_default_display ();
+
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+ g_return_val_if_fail (display != NULL, NULL);
+
+ if (index >= ScreenCount (display))
+ return NULL;
+
+ if (self->screens == NULL)
+ self->screens = g_new0 (WnckScreen*, ScreenCount (display));
+
+ if (self->screens[index] == NULL)
+ {
+ self->screens[index] = g_object_new (WNCK_TYPE_SCREEN, NULL);
+
+ _wnck_screen_construct (self->screens[index], self, display, index);
+ }
+
+ return self->screens[index];
+}
+
+/**
+ * wnck_handle_get_screen_for_root:
+ * @self: a #WnckHandle
+ * @root_window_id: an X window ID.
+ *
+ * Gets the #WnckScreen for the root window at @root_window_id, or
+ * %NULL if no #WnckScreen exists for this root window.
+ *
+ * This function does not work if wnck_handle_get_screen() was not called
+ * for the sought #WnckScreen before, and returns %NULL.
+ *
+ * Returns: (transfer none): the #WnckScreen for the root window at
+ * @root_window_id, or %NULL. The returned #WnckScreen is owned by
+ * #WnckHandle and must not be referenced or unreferenced.
+ */
+WnckScreen *
+wnck_handle_get_screen_for_root (WnckHandle *self,
+ gulong root_window_id)
+{
+ Display *display;
+ int i;
+
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+
+ if (self->screens == NULL)
+ return NULL;
+
+ display = _wnck_get_default_display ();
+ i = 0;
+
+ while (i < ScreenCount (display))
+ {
+ WnckScreen *screen;
+
+ screen = self->screens[i];
+ if (screen != NULL && _wnck_screen_get_xroot (screen) == root_window_id)
+ return screen;
+
+ ++i;
+ }
+
+ return NULL;
+}
+
+WnckScreen *
+_wnck_handle_get_existing_screen (WnckHandle *self,
+ int number)
+{
+ Display *display;
+
+ display = _wnck_get_default_display ();
+
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+ g_return_val_if_fail (display != NULL, NULL);
+ g_return_val_if_fail (number < ScreenCount (display), NULL);
+
+ if (self->screens != NULL)
+ return self->screens[number];
+
+ return NULL;
+}
+
/**
* wnck_handle_set_default_icon_size:
* @self: a #WnckHandle
@@ -363,7 +507,6 @@ _wnck_handle_get_default_mini_icon_size (WnckHandle *self)
return self->default_mini_icon_size;
}
-
void
_wnck_handle_insert_class_group (WnckHandle *self,
const char *id,
diff --git a/libwnck/wnck-handle.h b/libwnck/wnck-handle.h
index 1f7aae15..a7b5c861 100644
--- a/libwnck/wnck-handle.h
+++ b/libwnck/wnck-handle.h
@@ -23,6 +23,7 @@
#define WNCK_HANDLE_H
#include <glib-object.h>
+#include <libwnck/screen.h>
#include <libwnck/util.h>
G_BEGIN_DECLS
@@ -30,13 +31,21 @@ G_BEGIN_DECLS
#define WNCK_TYPE_HANDLE (wnck_handle_get_type ())
G_DECLARE_FINAL_TYPE (WnckHandle, wnck_handle, WNCK, HANDLE, GObject)
-WnckHandle *wnck_handle_new (WnckClientType client_type);
+WnckHandle *wnck_handle_new (WnckClientType client_type);
-void wnck_handle_set_default_icon_size (WnckHandle *self,
- gsize icon_size);
+WnckScreen *wnck_handle_get_default_screen (WnckHandle *self);
-void wnck_handle_set_default_mini_icon_size (WnckHandle *self,
- gsize icon_size);
+WnckScreen *wnck_handle_get_screen (WnckHandle *self,
+ int index);
+
+WnckScreen *wnck_handle_get_screen_for_root (WnckHandle *self,
+ gulong root_window_id);
+
+void wnck_handle_set_default_icon_size (WnckHandle *self,
+ gsize icon_size);
+
+void wnck_handle_set_default_mini_icon_size (WnckHandle *self,
+ gsize icon_size);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]