forked from aniani/vim
patch 8.1.0301: GTK: input method popup displayed on wrong screen.
Problem: GTK: Input method popup displayed on wrong screen. Solution: Add the screen position offset. (Ken Takata, closes #3268)
This commit is contained in:
parent
d8f0cef2bd
commit
3f6a16f022
@ -944,6 +944,8 @@ drawBalloon(BalloonEval *beval)
|
|||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
int screen_w;
|
int screen_w;
|
||||||
int screen_h;
|
int screen_h;
|
||||||
|
int screen_x;
|
||||||
|
int screen_y;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int x_offset = EVAL_OFFSET_X;
|
int x_offset = EVAL_OFFSET_X;
|
||||||
@ -956,8 +958,8 @@ drawBalloon(BalloonEval *beval)
|
|||||||
screen = gtk_widget_get_screen(beval->target);
|
screen = gtk_widget_get_screen(beval->target);
|
||||||
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
|
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
|
||||||
# endif
|
# endif
|
||||||
gui_gtk_get_screen_size_of_win(beval->balloonShell,
|
gui_gtk_get_screen_geom_of_win(beval->balloonShell,
|
||||||
&screen_w, &screen_h);
|
&screen_x, &screen_y, &screen_w, &screen_h);
|
||||||
# if !GTK_CHECK_VERSION(3,0,0)
|
# if !GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_ensure_style(beval->balloonShell);
|
gtk_widget_ensure_style(beval->balloonShell);
|
||||||
gtk_widget_ensure_style(beval->balloonLabel);
|
gtk_widget_ensure_style(beval->balloonLabel);
|
||||||
@ -998,14 +1000,16 @@ drawBalloon(BalloonEval *beval)
|
|||||||
y += beval->y;
|
y += beval->y;
|
||||||
|
|
||||||
/* Get out of the way of the mouse pointer */
|
/* 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;
|
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;
|
y_offset = -requisition.height - EVAL_OFFSET_Y;
|
||||||
|
|
||||||
/* Sanitize values */
|
/* Sanitize values */
|
||||||
x = CLAMP(x + x_offset, 0, MAX(0, screen_w - requisition.width));
|
x = CLAMP(x + x_offset, 0,
|
||||||
y = CLAMP(y + y_offset, 0, MAX(0, screen_h - requisition.height));
|
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 */
|
/* Show the balloon */
|
||||||
# if GTK_CHECK_VERSION(3,0,0)
|
# if GTK_CHECK_VERSION(3,0,0)
|
||||||
|
@ -5008,27 +5008,35 @@ gui_mch_set_shellsize(int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
#if GTK_CHECK_VERSION(3,22,0)
|
||||||
GdkDisplay *dpy = gtk_widget_get_display(wid);
|
GdkDisplay *dpy = gtk_widget_get_display(wid);
|
||||||
GdkWindow *win = gtk_widget_get_window(wid);
|
|
||||||
GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
|
GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
|
||||||
GdkRectangle geometry;
|
|
||||||
|
|
||||||
gdk_monitor_get_geometry(monitor, &geometry);
|
gdk_monitor_get_geometry(monitor, &geometry);
|
||||||
*width = geometry.width;
|
|
||||||
*height = geometry.height;
|
|
||||||
#else
|
#else
|
||||||
GdkScreen* screen;
|
GdkScreen* screen;
|
||||||
|
int monitor;
|
||||||
|
|
||||||
if (wid != NULL && gtk_widget_has_screen(wid))
|
if (wid != NULL && gtk_widget_has_screen(wid))
|
||||||
screen = gtk_widget_get_screen(wid);
|
screen = gtk_widget_get_screen(wid);
|
||||||
else
|
else
|
||||||
screen = gdk_screen_get_default();
|
screen = gdk_screen_get_default();
|
||||||
*width = gdk_screen_get_width(screen);
|
monitor = gdk_screen_get_monitor_at_window(screen, win);
|
||||||
*height = gdk_screen_get_height(screen);
|
gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
|
||||||
#endif
|
#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
|
void
|
||||||
gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
|
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
|
/* Subtract 'guiheadroom' from the height to allow some room for the
|
||||||
* window manager (task list and window title bar). */
|
* window manager (task list and window title bar). */
|
||||||
|
16
src/mbyte.c
16
src/mbyte.c
@ -4951,24 +4951,26 @@ im_add_to_input(char_u *str, int len)
|
|||||||
static void
|
static void
|
||||||
im_preedit_window_set_position(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)
|
if (preedit_window == NULL)
|
||||||
return;
|
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)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
|
gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
|
||||||
#else
|
#else
|
||||||
gdk_window_get_origin(gui.drawarea->window, &x, &y);
|
gdk_window_get_origin(gui.drawarea->window, &x, &y);
|
||||||
#endif
|
#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);
|
x = x + FILL_X(gui.col);
|
||||||
y = y + FILL_Y(gui.row);
|
y = y + FILL_Y(gui.row);
|
||||||
if (x + w > sw)
|
if (x + width > screen_x + screen_width)
|
||||||
x = sw - w;
|
x = screen_x + screen_width - width;
|
||||||
if (y + h > sh)
|
if (y + height > screen_y + screen_height)
|
||||||
y = sh - h;
|
y = screen_y + screen_height - height;
|
||||||
gtk_window_move(GTK_WINDOW(preedit_window), x, y);
|
gtk_window_move(GTK_WINDOW(preedit_window), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ int gui_mch_maximized(void);
|
|||||||
void gui_mch_unmaximize(void);
|
void gui_mch_unmaximize(void);
|
||||||
void gui_mch_newfont(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_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_get_screen_dimensions(int *screen_w, int *screen_h);
|
||||||
void gui_mch_settitle(char_u *title, char_u *icon);
|
void gui_mch_settitle(char_u *title, char_u *icon);
|
||||||
void gui_mch_enable_menu(int showit);
|
void gui_mch_enable_menu(int showit);
|
||||||
|
@ -794,6 +794,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
301,
|
||||||
/**/
|
/**/
|
||||||
300,
|
300,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user