]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0301: GTK: input method popup displayed on wrong screen. v8.1.0301
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Aug 2018 20:58:45 +0000 (22:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Aug 2018 20:58:45 +0000 (22:58 +0200)
Problem:    GTK: Input method popup displayed on wrong screen.
Solution:   Add the screen position offset. (Ken Takata, closes #3268)

src/gui_beval.c
src/gui_gtk_x11.c
src/mbyte.c
src/proto/gui_gtk_x11.pro
src/version.c

index 49694cfdda5a49175dfe78d6a23cb595e53bed47..03216008e6a1e5be16a643b4363f0b1bab790be9 100644 (file)
@@ -944,6 +944,8 @@ drawBalloon(BalloonEval *beval)
        GtkRequisition  requisition;
        int             screen_w;
        int             screen_h;
+       int             screen_x;
+       int             screen_y;
        int             x;
        int             y;
        int             x_offset = EVAL_OFFSET_X;
@@ -956,8 +958,8 @@ drawBalloon(BalloonEval *beval)
        screen = gtk_widget_get_screen(beval->target);
        gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
 # endif
-       gui_gtk_get_screen_size_of_win(beval->balloonShell,
-                                                        &screen_w, &screen_h);
+       gui_gtk_get_screen_geom_of_win(beval->balloonShell,
+                                   &screen_x, &screen_y, &screen_w, &screen_h);
 # if !GTK_CHECK_VERSION(3,0,0)
        gtk_widget_ensure_style(beval->balloonShell);
        gtk_widget_ensure_style(beval->balloonLabel);
@@ -998,14 +1000,16 @@ drawBalloon(BalloonEval *beval)
        y += beval->y;
 
        /* Get out of the way of the mouse pointer */
-       if (x + x_offset + requisition.width > screen_w)
+       if (x + x_offset + requisition.width > screen_x + screen_w)
            y_offset += 15;
-       if (y + y_offset + requisition.height > screen_h)
+       if (y + y_offset + requisition.height > screen_y + screen_h)
            y_offset = -requisition.height - EVAL_OFFSET_Y;
 
        /* Sanitize values */
-       x = CLAMP(x + x_offset, 0, MAX(0, screen_w - requisition.width));
-       y = CLAMP(y + y_offset, 0, MAX(0, screen_h - requisition.height));
+       x = CLAMP(x + x_offset, 0,
+                           MAX(0, screen_x + screen_w - requisition.width));
+       y = CLAMP(y + y_offset, 0,
+                           MAX(0, screen_y + screen_h - requisition.height));
 
        /* Show the balloon */
 # if GTK_CHECK_VERSION(3,0,0)
index 7541d79072fe73dabe9d29e1f2a38d8bd2b4b3ca..196c9dc7be3e22f97b10ceed06c735f981f99bf6 100644 (file)
@@ -5008,27 +5008,35 @@ gui_mch_set_shellsize(int width, int height,
 }
 
     void
-gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height)
+gui_gtk_get_screen_geom_of_win(
+       GtkWidget *wid,
+       int *screen_x,
+       int *screen_y,
+       int *width,
+       int *height)
 {
+    GdkRectangle geometry;
+    GdkWindow *win = gtk_widget_get_window(wid);
 #if GTK_CHECK_VERSION(3,22,0)
     GdkDisplay *dpy = gtk_widget_get_display(wid);
-    GdkWindow *win = gtk_widget_get_window(wid);
     GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
-    GdkRectangle geometry;
 
     gdk_monitor_get_geometry(monitor, &geometry);
-    *width = geometry.width;
-    *height = geometry.height;
 #else
     GdkScreen* screen;
+    int monitor;
 
     if (wid != NULL && gtk_widget_has_screen(wid))
        screen = gtk_widget_get_screen(wid);
     else
        screen = gdk_screen_get_default();
-    *width = gdk_screen_get_width(screen);
-    *height = gdk_screen_get_height(screen);
+    monitor = gdk_screen_get_monitor_at_window(screen, win);
+    gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
 #endif
+    *screen_x = geometry.x;
+    *screen_y = geometry.y;
+    *width = geometry.width;
+    *height = geometry.height;
 }
 
 /*
@@ -5039,7 +5047,9 @@ gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height)
     void
 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
 {
-    gui_gtk_get_screen_size_of_win(gui.mainwin, screen_w, screen_h);
+    int            x, y;
+
+    gui_gtk_get_screen_geom_of_win(gui.mainwin, &x, &y, screen_w, screen_h);
 
     /* Subtract 'guiheadroom' from the height to allow some room for the
      * window manager (task list and window title bar). */
index 96b39b4114c983cfd63a6f6a63d1e4225c183440..ee1d572ee0263256466695b337c23f3e8b73b6eb 100644 (file)
@@ -4951,24 +4951,26 @@ im_add_to_input(char_u *str, int len)
      static void
 im_preedit_window_set_position(void)
 {
-    int x, y, w, h, sw, sh;
+    int x, y, width, height;
+    int screen_x, screen_y, screen_width, screen_height;
 
     if (preedit_window == NULL)
        return;
 
-    gui_gtk_get_screen_size_of_win(preedit_window, &sw, &sh);
+    gui_gtk_get_screen_geom_of_win(gui.drawarea,
+                         &screen_x, &screen_y, &screen_width, &screen_height);
 #if GTK_CHECK_VERSION(3,0,0)
     gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
 #else
     gdk_window_get_origin(gui.drawarea->window, &x, &y);
 #endif
-    gtk_window_get_size(GTK_WINDOW(preedit_window), &w, &h);
+    gtk_window_get_size(GTK_WINDOW(preedit_window), &width, &height);
     x = x + FILL_X(gui.col);
     y = y + FILL_Y(gui.row);
-    if (x + w > sw)
-       x = sw - w;
-    if (y + h > sh)
-       y = sh - h;
+    if (x + width > screen_x + screen_width)
+       x = screen_x + screen_width - width;
+    if (y + height > screen_y + screen_height)
+       y = screen_y + screen_height - height;
     gtk_window_move(GTK_WINDOW(preedit_window), x, y);
 }
 
index aea8d0b68e0801e07b77e315760c8d52995819b1..111cac7c996dfb2e2024a06fe027defbb6dfdd7c 100644 (file)
@@ -25,7 +25,7 @@ int gui_mch_maximized(void);
 void gui_mch_unmaximize(void);
 void gui_mch_newfont(void);
 void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
-void gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height);
+void gui_gtk_get_screen_geom_of_win(GtkWidget *wid, int *screen_x, int *screen_y, int *width, int *height);
 void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
 void gui_mch_settitle(char_u *title, char_u *icon);
 void gui_mch_enable_menu(int showit);
index e7ea55f9d5525ca6ca65e677d253357afe1ec504..4cb2f341954d8ab3a9066e99724e8ebebda0e87a 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    301,
 /**/
     300,
 /**/