[Xfce4-commits] [apps/xfce4-terminal] 01/01: Watch for screen size changes

noreply at xfce.org noreply at xfce.org
Wed Jan 4 15:29:47 CET 2017


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit 33a72843141f2e478d8305c11e8c1d5a2c01c774
Author: Igor <f2404 at yandex.ru>
Date:   Wed Jan 4 17:27:57 2017 +0300

    Watch for screen size changes
    
    To update drop-down window size or position accordingly.
    Size change signal is emitted when monitor resolution is changed or another
    monitor is connected.
---
 terminal/terminal-window-dropdown.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index 44b59dd..4e08c48 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -84,6 +84,8 @@ static void     terminal_window_dropdown_toggle_real             (TerminalWindow
                                                                   guint32                 timestamp,
                                                                   gboolean                force_show);
 static void     terminal_window_dropdown_update_geometry         (TerminalWindowDropdown *dropdown);
+static void     terminal_dropdown_window_screen_size_changed     (GdkScreen              *screen,
+                                                                  TerminalWindowDropdown *dropdown);
 
 
 struct _TerminalWindowDropdownClass
@@ -399,6 +401,11 @@ terminal_window_dropdown_finalize (GObject *object)
   if (dropdown->status_icon != NULL)
     g_object_unref (G_OBJECT (dropdown->status_icon));
 
+  if (dropdown->screen != NULL)
+    g_signal_handlers_disconnect_by_func (G_OBJECT (dropdown->screen),
+                                          G_CALLBACK (terminal_dropdown_window_screen_size_changed),
+                                          dropdown);
+
   (*G_OBJECT_CLASS (terminal_window_dropdown_parent_class)->finalize) (object);
 }
 
@@ -728,7 +735,18 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
   if (move_to_active
       || dropdown->screen == NULL
       || dropdown->monitor_num == -1)
-    dropdown->screen = xfce_gdk_screen_get_active (&dropdown->monitor_num);
+    {
+      if (dropdown->screen != NULL)
+        g_signal_handlers_disconnect_by_func (G_OBJECT (dropdown->screen),
+                                              G_CALLBACK (terminal_dropdown_window_screen_size_changed),
+                                              dropdown);
+
+      dropdown->screen = xfce_gdk_screen_get_active (&dropdown->monitor_num);
+
+      /* watch for screen size changes to update terminal geometry accordingly*/
+      g_signal_connect (G_OBJECT (dropdown->screen), "size-changed",
+                        G_CALLBACK (terminal_dropdown_window_screen_size_changed), dropdown);
+    }
 
   /* get the active monitor size */
 #if GTK_CHECK_VERSION (3, 22, 0)
@@ -900,6 +918,16 @@ terminal_window_dropdown_get_timestamp (GtkWidget   *widget,
 
 
 
+static void
+terminal_dropdown_window_screen_size_changed (GdkScreen              *screen,
+                                              TerminalWindowDropdown *dropdown)
+{
+  /* resize/move terminal window due to a screen size change */
+  terminal_window_dropdown_show (dropdown, 0);
+}
+
+
+
 GtkWidget *
 terminal_window_dropdown_new (const gchar        *role,
                               const gchar        *icon,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list