[gnome-applets/wip-geiger-monitor] window-picker: add weak reference for monitor
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip-geiger-monitor] window-picker: add weak reference for monitor
- Date: Sat, 28 Mar 2020 16:20:07 +0000 (UTC)
commit 154ac3b354f781e07479f8af7a9cbeb4dd053f29
Author: Sebastian Geiger <sbastig gmx net>
Date: Sat Mar 28 17:18:56 2020 +0100
window-picker: add weak reference for monitor
gnome-applets/window-picker/task-item.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/gnome-applets/window-picker/task-item.c b/gnome-applets/window-picker/task-item.c
index b52b72aee..e55276935 100644
--- a/gnome-applets/window-picker/task-item.c
+++ b/gnome-applets/window-picker/task-item.c
@@ -580,6 +580,20 @@ get_window_monitor (WnckWindow *window)
return window_monitor;
}
+static void
+set_monitor (TaskItem *item, GdkMonitor *monitor)
+{
+ if (item->monitor)
+ g_object_remove_weak_pointer (G_OBJECT (item->monitor),
+ (gpointer *) &item->monitor);
+
+ item->monitor = monitor;
+
+ if (item->monitor)
+ g_object_add_weak_pointer (G_OBJECT (item->monitor),
+ (gpointer *) &item->monitor);
+}
+
static void
on_window_geometry_changed (WnckWindow *window,
TaskItem *item)
@@ -590,9 +604,10 @@ on_window_geometry_changed (WnckWindow *window,
window_monitor = get_window_monitor (window);
old_monitor = item->monitor;
+
if (old_monitor != window_monitor)
{
- item->monitor = window_monitor;
+ set_monitor (item, window_monitor);
g_signal_emit (item, task_item_signals[TASK_ITEM_MONITOR_CHANGED], 0);
}
@@ -1027,7 +1042,8 @@ GtkWidget *task_item_new (WpApplet* windowPickerApplet, WnckWindow *window) {
screen = wnck_window_get_screen (window);
taskItem->screen = screen;
taskItem->windowPickerApplet = windowPickerApplet;
- taskItem->monitor = get_window_monitor (window);
+
+ set_monitor (taskItem, get_window_monitor (window));
g_signal_connect_object (windowPickerApplet,
"placement-changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]