Patch 8.1.0301
Problem:    GTK: Input method popup displayed on wrong screen.
Solution:   Add the screen position offset. (Ken Takata, closes #3268)
Files:      src/gui_beval.c, src/gui_gtk_x11.c, src/mbyte.c,
            src/proto/gui_gtk_x11.pro


*** ../vim-8.1.0300/src/gui_beval.c     2018-06-28 12:05:07.085006926 +0200
--- src/gui_beval.c     2018-08-19 22:45:48.731522222 +0200
***************
*** 944,949 ****
--- 944,951 ----
        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,963 ****
        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);
  # if !GTK_CHECK_VERSION(3,0,0)
        gtk_widget_ensure_style(beval->balloonShell);
        gtk_widget_ensure_style(beval->balloonLabel);
--- 958,965 ----
        screen = gtk_widget_get_screen(beval->target);
        gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
  # endif
!       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,1011 ****
        y += beval->y;
  
        /* Get out of the way of the mouse pointer */
!       if (x + x_offset + requisition.width > screen_w)
            y_offset += 15;
!       if (y + y_offset + requisition.height > 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));
  
        /* Show the balloon */
  # if GTK_CHECK_VERSION(3,0,0)
--- 1000,1015 ----
        y += beval->y;
  
        /* Get out of the way of the mouse pointer */
!       if (x + x_offset + requisition.width > screen_x + screen_w)
            y_offset += 15;
!       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_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)
*** ../vim-8.1.0300/src/gui_gtk_x11.c   2018-08-07 20:01:34.245746660 +0200
--- src/gui_gtk_x11.c   2018-08-19 22:54:38.120976094 +0200
***************
*** 5008,5034 ****
  }
  
      void
! gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height)
  {
  #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;
  
      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);
  #endif
  }
  
  /*
--- 5008,5042 ----
  }
  
      void
! 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);
      GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
  
      gdk_monitor_get_geometry(monitor, &geometry);
  #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();
!     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,5045 ****
      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);
  
      /* Subtract 'guiheadroom' from the height to allow some room for the
       * window manager (task list and window title bar). */
--- 5047,5055 ----
      void
  gui_mch_get_screen_dimensions(int *screen_w, int *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). */
*** ../vim-8.1.0300/src/mbyte.c 2018-08-01 19:05:59.282223206 +0200
--- src/mbyte.c 2018-08-19 22:57:01.724150866 +0200
***************
*** 4951,4974 ****
       static void
  im_preedit_window_set_position(void)
  {
!     int x, y, w, h, sw, sh;
  
      if (preedit_window == NULL)
        return;
  
!     gui_gtk_get_screen_size_of_win(preedit_window, &sw, &sh);
  #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);
      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;
      gtk_window_move(GTK_WINDOW(preedit_window), x, y);
  }
  
--- 4951,4976 ----
       static void
  im_preedit_window_set_position(void)
  {
!     int x, y, width, height;
!     int screen_x, screen_y, screen_width, screen_height;
  
      if (preedit_window == NULL)
        return;
  
!     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), &width, &height);
      x = x + FILL_X(gui.col);
      y = y + FILL_Y(gui.row);
!     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);
  }
  
*** ../vim-8.1.0300/src/proto/gui_gtk_x11.pro   2018-05-17 13:53:00.000000000 
+0200
--- src/proto/gui_gtk_x11.pro   2018-08-19 22:57:22.476028708 +0200
***************
*** 25,31 ****
  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_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);
--- 25,31 ----
  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_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);
*** ../vim-8.1.0300/src/version.c       2018-08-19 22:20:11.628993678 +0200
--- src/version.c       2018-08-19 22:48:57.714733757 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     301,
  /**/

-- 
SUPERIMPOSE "England AD 787".  After a few more seconds we hear hoofbeats in
the distance.  They come slowly closer.  Then out of the mist comes KING
ARTHUR followed by a SERVANT who is banging two half coconuts together.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui