[libwnck/wip/muktupavels/wnck-handle: 6/11] 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: 6/11] screen: move screen handling to WnckHandle
- Date: Tue, 22 Feb 2022 19:36:33 +0000 (UTC)
commit c73eda752e1f4caca9d90bc7d8b91a56af4d6be5
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/screen.c | 7 +++---
libwnck/selector.c | 26 ++++++++++++++++++++-
libwnck/selector.h | 8 +++++--
libwnck/tasklist.c | 50 ++++++++++++++++++++++++++++------------
libwnck/tasklist.h | 2 ++
libwnck/window.c | 5 +++-
libwnck/wnck-handle-private.h | 8 -------
libwnck/wnck-handle.c | 53 ++++++++++++++++++++++++++++++++++++-------
libwnck/wnck-handle.h | 19 ++++++++++++----
11 files changed, 162 insertions(+), 44 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/screen.c b/libwnck/screen.c
index 0d66903f..dbe94a60 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -575,7 +575,7 @@ _wnck_screen_construct (WnckScreen *screen,
WnckScreen*
wnck_screen_get (int index)
{
- return _wnck_handle_get_screen (_wnck_get_handle (), index);
+ return wnck_handle_get_screen (_wnck_get_handle (), index);
}
/**
@@ -590,7 +590,7 @@ wnck_screen_get (int index)
WnckScreen*
wnck_screen_get_default (void)
{
- return _wnck_handle_get_default_screen (_wnck_get_handle ());
+ return wnck_handle_get_default_screen (_wnck_get_handle ());
}
/**
@@ -610,8 +610,7 @@ wnck_screen_get_default (void)
WnckScreen*
wnck_screen_get_for_root (gulong root_window_id)
{
- return _wnck_handle_get_screen_for_root (_wnck_get_handle (),
- root_window_id);
+ return wnck_handle_get_screen_for_root (_wnck_get_handle (), root_window_id);
}
WnckHandle *
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/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 348cbda5..f17b3154 100644
--- a/libwnck/wnck-handle-private.h
+++ b/libwnck/wnck-handle-private.h
@@ -26,14 +26,6 @@ G_BEGIN_DECLS
WnckClientType _wnck_handle_get_client_type (WnckHandle *self);
-WnckScreen *_wnck_handle_get_default_screen (WnckHandle *self);
-
-WnckScreen *_wnck_handle_get_screen (WnckHandle *self,
- int index);
-
-WnckScreen *_wnck_handle_get_screen_for_root (WnckHandle *self,
- gulong root_window_id);
-
WnckScreen *_wnck_handle_get_existing_screen (WnckHandle *self,
int number);
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 0eb34244..57e1216b 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -29,6 +29,8 @@
#include "config.h"
#include "wnck-handle-private.h"
+#include <gdk/gdkx.h>
+
#include "private.h"
#include "screen.h"
#include "window.h"
@@ -84,7 +86,7 @@ filter_func (GdkXEvent *gdkxevent,
{
WnckScreen *screen;
- screen = _wnck_handle_get_screen_for_root (self, xevent->xany.window);
+ screen = wnck_handle_get_screen_for_root (self, xevent->xany.window);
if (screen != NULL)
{
@@ -331,8 +333,18 @@ _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)
+wnck_handle_get_default_screen (WnckHandle *self)
{
Display *display;
@@ -342,12 +354,23 @@ _wnck_handle_get_default_screen (WnckHandle *self)
if (display == NULL)
return NULL;
- return _wnck_handle_get_screen (self, DefaultScreen (display));
+ 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)
+wnck_handle_get_screen (WnckHandle *self,
+ int index)
{
Display *display;
@@ -372,9 +395,24 @@ _wnck_handle_get_screen (WnckHandle *self,
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)
+wnck_handle_get_screen_for_root (WnckHandle *self,
+ gulong root_window_id)
{
Display *display;
int i;
@@ -469,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]