[gnome-applets/wip/segeiger/windowpicker: 1/17] windowpicker: cleanup window initialization
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/segeiger/windowpicker: 1/17] windowpicker: cleanup window initialization
- Date: Sun, 13 Oct 2019 12:54:40 +0000 (UTC)
commit c290d0cb6ec063e66016e556ab2dbca84b39980b
Author: Sebastian Geiger <sbastig gmx net>
Date: Sun Oct 13 14:01:39 2019 +0200
windowpicker: cleanup window initialization
This cleans up the initialization for WnckWindows in the
TaskList. There are several cases when we need to initialize
the windows:
a) When the panel starts and initializes the WindowPicker applets.
b) When the panel is running but a new WindowPicker applet is
added to a panel.
c) When the screen geometry or monitor configuration changes because
it might cause windows to move to a different monitor.
We are using an idle function to ensure that GTK has finished
initializing the TaskList widget before we initialize the windows
on the list. This is necessary so we can reliably determine whether
a WnckWindow is on the same monitor as the TaskList to which we want
to add the window.
This change also moves the applet setup functions from wp_applet_init
to wp_applet_load to ensure that the TaskList widget has been correctly
initialized when our init_window idle function runs.
windowpicker/src/task-list.c | 29 +++++++++++++----------------
windowpicker/src/wp-applet.c | 10 +++++-----
2 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 80522ab06..c7a316ec2 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -29,7 +29,7 @@ struct _TaskList {
GtkBox parent;
WnckScreen *screen;
WpApplet *windowPickerApplet;
- guint size_update_event_source;
+ guint init_windows_event_source;
};
G_DEFINE_TYPE (TaskList, task_list, GTK_TYPE_BOX)
@@ -262,9 +262,12 @@ add_window (TaskList *list, WnckWindow *window)
}
static void
-add_windows (TaskList *list,
- GList *windows)
+add_windows (TaskList *list)
{
+ GList *windows;
+
+ windows = wnck_screen_get_windows (list->screen);
+
while (windows != NULL)
{
add_window (list, windows->data);
@@ -282,20 +285,17 @@ on_window_opened (WnckScreen *screen,
}
static gboolean
-on_monitors_changed (gpointer user_data)
+init_windows (gpointer user_data)
{
TaskList *list;
- GList *windows;
list = TASK_LIST (user_data);
clear_windows (list);
- windows = wnck_screen_get_windows (list->screen);
-
- add_windows (list, windows);
+ add_windows (list);
- list->size_update_event_source = 0;
+ list->init_windows_event_source = 0;
return G_SOURCE_REMOVE;
}
@@ -324,11 +324,11 @@ window_filter_function (GdkXEvent *gdk_xevent,
if (propertyEvent->atom != WORKAREA_ATOM)
return GDK_FILTER_CONTINUE;
- if (list->size_update_event_source != 0)
+ if (list->init_windows_event_source != 0)
return GDK_FILTER_CONTINUE;
- list->size_update_event_source = g_idle_add (on_monitors_changed,
- user_data);
+ list->init_windows_event_source = g_idle_add (init_windows,
+ user_data);
break;
}
@@ -378,7 +378,6 @@ static void task_list_init (TaskList *list) {
GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
GtkOrientation orientation;
- GList *windows;
orientation = get_applet_orientation (windowPickerApplet);
@@ -401,9 +400,7 @@ GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
window_filter_function,
taskList);
- windows = wnck_screen_get_windows (taskList->screen);
-
- add_windows (taskList, windows);
+ taskList->init_windows_event_source = g_idle_add (init_windows, taskList);
return (GtkWidget *) taskList;
}
diff --git a/windowpicker/src/wp-applet.c b/windowpicker/src/wp-applet.c
index 20ea11a23..0d1bec705 100644
--- a/windowpicker/src/wp-applet.c
+++ b/windowpicker/src/wp-applet.c
@@ -223,6 +223,11 @@ wp_applet_load (PanelApplet *panel_applet)
g_settings_bind (applet->settings, KEY_ICONS_GREYSCALE,
applet, KEY_ICONS_GREYSCALE, G_SETTINGS_BIND_GET);
+ wp_applet_setup_list (applet);
+ wp_applet_setup_title (applet);
+
+ wp_applet_setup_menu (panel_applet);
+
gtk_widget_show_all (GTK_WIDGET (applet));
}
@@ -434,11 +439,6 @@ wp_applet_init (WpApplet *applet)
applet->container = gtk_box_new (orientation, CONTAINER_SPACING);
gtk_container_add (GTK_CONTAINER (applet), applet->container);
-
- wp_applet_setup_list (applet);
- wp_applet_setup_title (applet);
-
- wp_applet_setup_menu (panel_applet);
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]