summaryrefslogtreecommitdiff
path: root/libwnck/wnck-handle.c
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2022-02-18 20:33:39 +0200
committerMarco Trevisan <mail@3v1n0.net>2022-02-22 15:49:57 +0000
commitace10756cb42ba8b80524426749f83d58360f5e2 (patch)
tree99973db58d6e1377b8cef9cb2fba4ad118c66ff2 /libwnck/wnck-handle.c
parent7da54dc6b0036b303dea2f1a0e940b00884e42bf (diff)
downloadlibwnck-ace10756cb42ba8b80524426749f83d58360f5e2.tar.gz
screen: move screens to WnckHandle
Diffstat (limited to 'libwnck/wnck-handle.c')
-rw-r--r--libwnck/wnck-handle.c132
1 files changed, 119 insertions, 13 deletions
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index f1ddf1c..157aabe 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
*
@@ -31,16 +33,18 @@ G_DECLARE_FINAL_TYPE (WnckHandle, wnck_handle, WNCK, HANDLE, GObject)
struct _WnckHandle
{
- GObject parent;
+ GObject parent;
- WnckClientType client_type;
+ WnckScreen **screens;
- gsize default_icon_size;
- gsize default_mini_icon_size;
+ WnckClientType client_type;
- GHashTable *class_group_hash;
- GHashTable *app_hash;
- GHashTable *window_hash;
+ gsize default_icon_size;
+ gsize default_mini_icon_size;
+
+ GHashTable *class_group_hash;
+ GHashTable *app_hash;
+ GHashTable *window_hash;
};
enum
@@ -61,19 +65,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);
@@ -122,11 +130,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;
@@ -177,7 +186,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)
{
@@ -301,6 +319,94 @@ _wnck_handle_get_client_type (WnckHandle *self)
return self->client_type;
}
+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));
+}
+
+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];
+}
+
+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;
+}
+
void
_wnck_handle_set_default_icon_size (WnckHandle *self,
gsize icon_size)