summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-19 22:58:45 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-19 22:58:45 +0200
commit3f6a16f022c437eccaeb683640b25a972cb1b376 (patch)
treee004b48fa09a91045fd50df8b9c1d62551160180
parentd8f0cef2bdbdc15d7906f991725e09e67c97cf7e (diff)
downloadvim-git-8.1.0301.tar.gz
patch 8.1.0301: GTK: input method popup displayed on wrong screen.v8.1.0301
Problem: GTK: Input method popup displayed on wrong screen. Solution: Add the screen position offset. (Ken Takata, closes #3268)
-rw-r--r--src/gui_beval.c16
-rw-r--r--src/gui_gtk_x11.c26
-rw-r--r--src/mbyte.c16
-rw-r--r--src/proto/gui_gtk_x11.pro2
-rw-r--r--src/version.c2
5 files changed, 40 insertions, 22 deletions
diff --git a/src/gui_beval.c b/src/gui_beval.c
index 49694cfdd..03216008e 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -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)
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 7541d7907..196c9dc7b 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -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). */
diff --git a/src/mbyte.c b/src/mbyte.c
index 96b39b411..ee1d572ee 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -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);
}
diff --git a/src/proto/gui_gtk_x11.pro b/src/proto/gui_gtk_x11.pro
index aea8d0b68..111cac7c9 100644
--- a/src/proto/gui_gtk_x11.pro
+++ b/src/proto/gui_gtk_x11.pro
@@ -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);
diff --git a/src/version.c b/src/version.c
index e7ea55f9d..4cb2f3419 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 301,
+/**/
300,
/**/
299,