[libgnomekbd] Trying to be smart chosing the current monitor



commit fc9f4a8f558ab93e1cd734ba41bc3268b8b1be2b
Author: Sergey V. Udaltsov <svu gnome org>
Date:   Sat Jun 11 13:47:31 2011 +0100

    Trying to be smart chosing the current monitor
    
    https://bugzilla.gnome.org/show_bug.cgi?id=647646

 libgnomekbd/gkbd-keyboard-drawing.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c
index 434a122..5f5d120 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.c
+++ b/libgnomekbd/gkbd-keyboard-drawing.c
@@ -2146,8 +2146,21 @@ get_preferred_width (GtkWidget * widget,
 		     gint * minimum_width, gint * natural_width)
 {
 	GdkRectangle rect;
-	GdkScreen *scr = gdk_screen_get_default ();
-	gint w, monitor = gdk_screen_get_primary_monitor (scr);
+	gint w, monitor;
+	GdkDisplay *display = gtk_widget_get_display (widget);
+	GdkDeviceManager *gdm = gdk_display_get_device_manager (display);
+	GdkScreen *scr = NULL;
+	GList *devices =
+	    gdk_device_manager_list_devices (gdm, GDK_SOURCE_KEYBOARD);
+	if (g_list_length (devices) > 0) {
+		gint x, y;
+		GdkDevice *dev = GDK_DEVICE (devices->data);
+		gdk_device_get_position (dev, &scr, &x, &y);
+		monitor = gdk_screen_get_monitor_at_point (scr, x, y);
+	} else {
+		scr = gdk_screen_get_default ();
+		monitor = gdk_screen_get_primary_monitor (scr);
+	}
 	gdk_screen_get_monitor_geometry (scr, monitor, &rect);
 	w = rect.width;
 	*minimum_width = *natural_width = w - (w >> 2);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]