diff options
author | William Wold <[email protected]> | 2019-06-20 21:52:13 +0000 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-06-21 18:47:54 +0200 |
commit | a05c438cca0e25b47d24ee3a2cf2db259d96cbf1 (patch) | |
tree | 829de562c5aaab84dafd696a98a4ce86897100ba | |
parent | ef54e9a53d5a24933a323afccd4689f2e9f2fe69 (diff) | |
download | mate-panel-a05c438cca0e25b47d24ee3a2cf2db259d96cbf1.tar.bz2 mate-panel-a05c438cca0e25b47d24ee3a2cf2db259d96cbf1.tar.xz |
Reinit panel-multimonitor when screen is changed
-rw-r--r-- | mate-panel/panel-multimonitor.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/mate-panel/panel-multimonitor.c b/mate-panel/panel-multimonitor.c index 67c1b53c..1a262746 100644 --- a/mate-panel/panel-multimonitor.c +++ b/mate-panel/panel-multimonitor.c @@ -370,6 +370,16 @@ panel_multimonitor_reinit_idle (gpointer data) } static void +panel_multimonitor_handle_screen_changed (GdkScreen *screen, + gpointer user_data) +{ + if (reinit_id) + return; + + reinit_id = g_idle_add (panel_multimonitor_reinit_idle, NULL); +} + +static void panel_multimonitor_handle_monitor_changed (GdkDisplay *display, GdkMonitor *monitor, gpointer user_data) @@ -426,12 +436,14 @@ void panel_multimonitor_init (void) { GdkDisplay *display; + GdkScreen *screen; int i; if (initialized) return; display = gdk_display_get_default (); + screen = gdk_display_get_default_screen (display); have_randr = FALSE; @@ -442,12 +454,23 @@ panel_multimonitor_init (void) #endif // HAVE_RANDR #endif // HAVE_X11 - /* monitors-changed. Since we'll likely get two signals in some cases, - * we do the real callback in the idle loop. */ + /* + * The screen signals probably shouldn't be needed, but sometimes on X11 they are + * the only ones that get fired + */ + + g_signal_handlers_disconnect_by_func (screen, panel_multimonitor_handle_screen_changed, NULL); + g_signal_connect (screen, "size-changed", + G_CALLBACK (panel_multimonitor_handle_screen_changed), NULL); + g_signal_connect (screen, "monitors-changed", + G_CALLBACK (panel_multimonitor_handle_screen_changed), NULL); + + g_signal_handlers_disconnect_by_func (display, panel_multimonitor_handle_monitor_changed, NULL); g_signal_connect (display, "monitor-added", G_CALLBACK (panel_multimonitor_handle_monitor_changed), NULL); g_signal_connect (display, "monitor-removed", G_CALLBACK (panel_multimonitor_handle_monitor_changed), NULL); + for (i = 0; i < gdk_display_get_n_monitors (display); i++) { GdkMonitor *monitor; @@ -466,15 +489,11 @@ panel_multimonitor_init (void) void panel_multimonitor_reinit (void) { - GdkDisplay *display; GList *toplevels, *l; if (geometries) g_free (geometries); - display = gdk_display_get_default (); - g_signal_handlers_disconnect_by_func (display, panel_multimonitor_handle_monitor_changed, NULL); - initialized = FALSE; panel_multimonitor_init (); |