Commit 525e5cff authored by Alexander Larsson's avatar Alexander Larsson

x11: Initial cut at supporting window scaling for X11

If you set GDK_SCALE=2 in the environment then all windows will be
scaled by 2. Its not an ideal solution as it doesn't handle
multi-monitors at different scales, and only affects gtk apps.
But it is a good starting points and will help a lot on HiDPI
laptops.
parent ed4fcee4
......@@ -135,10 +135,12 @@ gdk_x11_device_core_get_history (GdkDevice *device,
XTimeCoord *xcoords;
GdkTimeCoord **coords;
GdkWindow *impl_window;
GdkWindowImplX11 *impl;
int tmp_n_events;
int i, j;
impl_window = _gdk_window_get_impl_window (window);
impl = GDK_WINDOW_IMPL_X11 (impl_window->impl);
xcoords = XGetMotionEvents (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (impl_window),
start, stop, &tmp_n_events);
......@@ -149,11 +151,13 @@ gdk_x11_device_core_get_history (GdkDevice *device,
for (i = 0, j = 0; i < tmp_n_events; i++)
{
if (impl_coord_in_window (window, xcoords[i].x, xcoords[i].y))
if (impl_coord_in_window (window,
xcoords[i].x / impl->window_scale,
xcoords[i].y / impl->window_scale))
{
coords[j]->time = xcoords[i].time;
coords[j]->axes[0] = xcoords[i].x - window->abs_x;
coords[j]->axes[1] = xcoords[i].y - window->abs_y;
coords[j]->axes[0] = (double)xcoords[i].x / impl->window_scale - window->abs_x;
coords[j]->axes[1] = (double)xcoords[i].y / impl->window_scale - window->abs_y;
j++;
}
}
......@@ -194,6 +198,7 @@ gdk_x11_device_core_get_state (GdkDevice *device,
{
gint x_int, y_int;
/* TODO: This rounds the coords, should use double */
gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
if (axes)
......@@ -232,7 +237,9 @@ gdk_x11_device_core_warp (GdkDevice *device,
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_device_get_display (device));
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y);
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
x * GDK_X11_SCREEN (screen)->window_scale,
y * GDK_X11_SCREEN (screen)->window_scale);
}
static void
......@@ -246,6 +253,7 @@ gdk_x11_device_core_query_state (GdkDevice *device,
gint *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
GdkDisplay *display;
GdkScreen *default_screen;
Window xroot_window, xchild_window;
......@@ -291,16 +299,16 @@ gdk_x11_device_core_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
*root_x = xroot_x;
*root_x = xroot_x / impl->window_scale;
if (root_y)
*root_y = xroot_y;
*root_y = xroot_y / impl->window_scale;
if (win_x)
*win_x = xwin_x;
*win_x = xwin_x / impl->window_scale;
if (win_y)
*win_y = xwin_y;
*win_y = xwin_y / impl->window_scale;
if (mask)
*mask = xmask;
......@@ -413,6 +421,7 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
GdkModifierType *mask,
gboolean get_toplevel)
{
GdkWindowImplX11 *impl;
GdkDisplay *display;
GdkScreen *screen;
Display *xdisplay;
......@@ -464,6 +473,7 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
for (list = toplevels; list != NULL; list = g_list_next (list))
{
window = GDK_WINDOW (list->data);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
xwindow = GDK_WINDOW_XID (window);
gdk_x11_display_error_trap_push (display);
XQueryPointer (xdisplay, xwindow,
......@@ -479,7 +489,7 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
break;
}
gdk_window_get_geometry (window, NULL, NULL, &width, &height);
if (winx >= 0 && winy >= 0 && winx < width && winy < height)
if (winx >= 0 && winy >= 0 && winx < width * impl->window_scale && winy < height * impl->window_scale)
{
/* A childless toplevel, or below another window? */
XSetWindowAttributes attributes;
......@@ -532,12 +542,15 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
gdk_x11_display_ungrab (display);
window = gdk_x11_window_lookup_for_display (display, last);
impl = NULL;
if (window)
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
*win_x = (window) ? xwin_x : -1;
*win_x = (window) ? xwin_x / impl->window_scale : -1;
if (win_y)
*win_y = (window) ? xwin_y : -1;
*win_y = (window) ? xwin_y / impl->window_scale : -1;
if (mask)
*mask = xmask;
......
......@@ -303,7 +303,9 @@ gdk_x11_device_xi2_warp (GdkDevice *device,
XIWarpPointer (GDK_SCREEN_XDISPLAY (screen),
device_xi2->device_id,
None, dest,
0, 0, 0, 0, x, y);
0, 0, 0, 0,
x * GDK_X11_SCREEN(screen)->window_scale,
y * GDK_X11_SCREEN(screen)->window_scale);
}
static void
......@@ -317,6 +319,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
gint *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display;
GdkScreen *default_screen;
......@@ -381,16 +384,16 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
*root_x = (gint) xroot_x;
*root_x = (gint) (xroot_x / impl->window_scale);
if (root_y)
*root_y = (gint) xroot_y;
*root_y = (gint) (xroot_y / impl->window_scale);
if (win_x)
*win_x = (gint) xwin_x;
*win_x = (gint) (xwin_x / impl->window_scale);
if (win_y)
*win_y = (gint) xwin_y;
*win_y = (gint) (xwin_y / impl->window_scale);
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
......@@ -479,6 +482,7 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
GdkModifierType *mask,
gboolean get_toplevel)
{
GdkWindowImplX11 *impl;
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display;
GdkScreen *screen;
......@@ -624,12 +628,15 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
gdk_x11_display_ungrab (display);
window = gdk_x11_window_lookup_for_display (display, last);
impl = NULL;
if (window)
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
*win_x = (window) ? (gint) xwin_x : -1;
*win_x = (window) ? (gint) (xwin_x / impl->window_scale) : -1;
if (win_y)
*win_y = (window) ? (gint) xwin_y : -1;
*win_y = (window) ? (gint) (xwin_y / impl->window_scale) : -1;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
......
......@@ -332,9 +332,11 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
GdkEvent *event,
XEvent *xevent)
{
GdkWindowImplX11 *impl;
GdkX11DeviceManagerCore *device_manager;
GdkWindow *window;
gboolean return_val;
int scale;
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
device_manager = GDK_X11_DEVICE_MANAGER_CORE (translator);
......@@ -342,14 +344,18 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
window = get_event_window (translator, xevent);
scale = 1;
if (window)
{
if (GDK_WINDOW_DESTROYED (window) || !GDK_IS_WINDOW (window))
return FALSE;
g_object_ref (window);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
scale = impl->window_scale;
}
event->any.window = window;
event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
......@@ -458,10 +464,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->scroll.window = window;
event->scroll.time = xevent->xbutton.time;
event->scroll.x = (gdouble) xevent->xbutton.x;
event->scroll.y = (gdouble) xevent->xbutton.y;
event->scroll.x_root = (gdouble) xevent->xbutton.x_root;
event->scroll.y_root = (gdouble) xevent->xbutton.y_root;
event->scroll.x = (gdouble) xevent->xbutton.x / scale;
event->scroll.y = (gdouble) xevent->xbutton.y / scale;
event->scroll.x_root = (gdouble) xevent->xbutton.x_root / scale;
event->scroll.y_root = (gdouble) xevent->xbutton.y_root / scale;
event->scroll.state = (GdkModifierType) xevent->xbutton.state;
event->scroll.device = device_manager->core_pointer;
......@@ -480,10 +486,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->button.type = GDK_BUTTON_PRESS;
event->button.window = window;
event->button.time = xevent->xbutton.time;
event->button.x = (gdouble) xevent->xbutton.x;
event->button.y = (gdouble) xevent->xbutton.y;
event->button.x_root = (gdouble) xevent->xbutton.x_root;
event->button.y_root = (gdouble) xevent->xbutton.y_root;
event->button.x = (gdouble) xevent->xbutton.x / scale;
event->button.y = (gdouble) xevent->xbutton.y / scale;
event->button.x_root = (gdouble) xevent->xbutton.x_root / scale;
event->button.y_root = (gdouble) xevent->xbutton.y_root / scale;
event->button.axes = NULL;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
......@@ -523,10 +529,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->button.type = GDK_BUTTON_RELEASE;
event->button.window = window;
event->button.time = xevent->xbutton.time;
event->button.x = (gdouble) xevent->xbutton.x;
event->button.y = (gdouble) xevent->xbutton.y;
event->button.x_root = (gdouble) xevent->xbutton.x_root;
event->button.y_root = (gdouble) xevent->xbutton.y_root;
event->button.x = (gdouble) xevent->xbutton.x / scale;
event->button.y = (gdouble) xevent->xbutton.y / scale;
event->button.x_root = (gdouble) xevent->xbutton.x_root / scale;
event->button.y_root = (gdouble) xevent->xbutton.y_root / scale;
event->button.axes = NULL;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
......@@ -553,10 +559,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = window;
event->motion.time = xevent->xmotion.time;
event->motion.x = (gdouble) xevent->xmotion.x;
event->motion.y = (gdouble) xevent->xmotion.y;
event->motion.x_root = (gdouble) xevent->xmotion.x_root;
event->motion.y_root = (gdouble) xevent->xmotion.y_root;
event->motion.x = (gdouble) xevent->xmotion.x / scale;
event->motion.y = (gdouble) xevent->xmotion.y / scale;
event->motion.x_root = (gdouble) xevent->xmotion.x_root / scale;
event->motion.y_root = (gdouble) xevent->xmotion.y_root / scale;
event->motion.axes = NULL;
event->motion.state = (GdkModifierType) xevent->xmotion.state;
event->motion.is_hint = xevent->xmotion.is_hint;
......@@ -602,10 +608,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->crossing.subwindow = NULL;
event->crossing.time = xevent->xcrossing.time;
event->crossing.x = (gdouble) xevent->xcrossing.x;
event->crossing.y = (gdouble) xevent->xcrossing.y;
event->crossing.x_root = (gdouble) xevent->xcrossing.x_root;
event->crossing.y_root = (gdouble) xevent->xcrossing.y_root;
event->crossing.x = (gdouble) xevent->xcrossing.x / scale;
event->crossing.y = (gdouble) xevent->xcrossing.y / scale;
event->crossing.x_root = (gdouble) xevent->xcrossing.x_root / scale;
event->crossing.y_root = (gdouble) xevent->xcrossing.y_root / scale;
event->crossing.mode = translate_crossing_mode (xevent->xcrossing.mode);
event->crossing.detail = translate_notify_type (xevent->xcrossing.detail);
......@@ -646,10 +652,10 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
event->crossing.subwindow = NULL;
event->crossing.time = xevent->xcrossing.time;
event->crossing.x = (gdouble) xevent->xcrossing.x;
event->crossing.y = (gdouble) xevent->xcrossing.y;
event->crossing.x_root = (gdouble) xevent->xcrossing.x_root;
event->crossing.y_root = (gdouble) xevent->xcrossing.y_root;
event->crossing.x = (gdouble) xevent->xcrossing.x / scale;
event->crossing.y = (gdouble) xevent->xcrossing.y / scale;
event->crossing.x_root = (gdouble) xevent->xcrossing.x_root / scale;
event->crossing.y_root = (gdouble) xevent->xcrossing.y_root / scale;
event->crossing.mode = translate_crossing_mode (xevent->xcrossing.mode);
event->crossing.detail = translate_notify_type (xevent->xcrossing.detail);
......
......@@ -1115,6 +1115,8 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
XGenericEventCookie *cookie;
gboolean return_val = TRUE;
GdkWindow *window;
GdkWindowImplX11 *impl;
int scale;
XIEvent *ev;
device_manager = (GdkX11DeviceManagerXI2 *) translator;
......@@ -1136,6 +1138,13 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
if (window && GDK_WINDOW_DESTROYED (window))
return FALSE;
scale = 1;
if (window)
{
impl = GDK_WINDOW_IMPL_X11 (window->impl);
scale = impl->window_scale;
}
if (ev->evtype == XI_Motion ||
ev->evtype == XI_ButtonRelease)
{
......@@ -1232,10 +1241,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->scroll.window = window;
event->scroll.time = xev->time;
event->scroll.x = (gdouble) xev->event_x;
event->scroll.y = (gdouble) xev->event_y;
event->scroll.x_root = (gdouble) xev->root_x;
event->scroll.y_root = (gdouble) xev->root_y;
event->scroll.x = (gdouble) xev->event_x / scale;
event->scroll.y = (gdouble) xev->event_y / scale;
event->scroll.x_root = (gdouble) xev->root_x / scale;
event->scroll.y_root = (gdouble) xev->root_y / scale;
event->scroll.delta_x = 0;
event->scroll.delta_y = 0;
......@@ -1259,10 +1268,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->button.window = window;
event->button.time = xev->time;
event->button.x = (gdouble) xev->event_x;
event->button.y = (gdouble) xev->event_y;
event->button.x_root = (gdouble) xev->root_x;
event->button.y_root = (gdouble) xev->root_y;
event->button.x = (gdouble) xev->event_x / scale;
event->button.y = (gdouble) xev->event_y / scale;
event->button.x_root = (gdouble) xev->root_x / scale;
event->button.y_root = (gdouble) xev->root_y / scale;
event->button.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
......@@ -1350,10 +1359,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->scroll.window = window;
event->scroll.time = xev->time;
event->scroll.x = (gdouble) xev->event_x;
event->scroll.y = (gdouble) xev->event_y;
event->scroll.x_root = (gdouble) xev->root_x;
event->scroll.y_root = (gdouble) xev->root_y;
event->scroll.x = (gdouble) xev->event_x / scale;
event->scroll.y = (gdouble) xev->event_y / scale;
event->scroll.x_root = (gdouble) xev->root_x / scale;
event->scroll.y_root = (gdouble) xev->root_y / scale;
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
......@@ -1367,10 +1376,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = window;
event->motion.time = xev->time;
event->motion.x = (gdouble) xev->event_x;
event->motion.y = (gdouble) xev->event_y;
event->motion.x_root = (gdouble) xev->root_x;
event->motion.y_root = (gdouble) xev->root_y;
event->motion.x = (gdouble) xev->event_x / scale;
event->motion.y = (gdouble) xev->event_y / scale;
event->motion.x_root = (gdouble) xev->root_x / scale;
event->motion.y_root = (gdouble) xev->root_y / scale;
event->motion.device = device;
gdk_event_set_source_device (event, source_device);
......@@ -1423,10 +1432,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->touch.window = window;
event->touch.time = xev->time;
event->touch.x = (gdouble) xev->event_x;
event->touch.y = (gdouble) xev->event_y;
event->touch.x_root = (gdouble) xev->root_x;
event->touch.y_root = (gdouble) xev->root_y;
event->touch.x = (gdouble) xev->event_x / scale;
event->touch.y = (gdouble) xev->event_y / scale;
event->touch.x_root = (gdouble) xev->root_x / scale;
event->touch.y_root = (gdouble) xev->root_y / scale;
event->touch.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
......@@ -1492,10 +1501,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->touch.sequence = GUINT_TO_POINTER (xev->detail);
event->touch.type = GDK_TOUCH_UPDATE;
event->touch.time = xev->time;
event->touch.x = (gdouble) xev->event_x;
event->touch.y = (gdouble) xev->event_y;
event->touch.x_root = (gdouble) xev->root_x;
event->touch.y_root = (gdouble) xev->root_y;
event->touch.x = (gdouble) xev->event_x / scale;
event->touch.y = (gdouble) xev->event_y / scale;
event->touch.x_root = (gdouble) xev->root_x / scale;
event->touch.y_root = (gdouble) xev->root_y / scale;
event->touch.device = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (xev->deviceid));
......@@ -1540,10 +1549,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->crossing.type = (ev->evtype == XI_Enter) ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
event->crossing.x = (gdouble) xev->event_x;
event->crossing.y = (gdouble) xev->event_y;
event->crossing.x_root = (gdouble) xev->root_x;
event->crossing.y_root = (gdouble) xev->root_y;
event->crossing.x = (gdouble) xev->event_x / scale;
event->crossing.y = (gdouble) xev->event_y / scale;
event->crossing.x_root = (gdouble) xev->root_x / scale;
event->crossing.y_root = (gdouble) xev->root_y / scale;
event->crossing.time = xev->time;
event->crossing.focus = xev->focus;
......
......@@ -558,11 +558,16 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{
GdkRectangle expose_rect;
int x2, y2;
expose_rect.x = xevent->xexpose.x;
expose_rect.y = xevent->xexpose.y;
expose_rect.width = xevent->xexpose.width;
expose_rect.height = xevent->xexpose.height;
expose_rect.x = xevent->xexpose.x / window_impl->window_scale;
expose_rect.y = xevent->xexpose.y / window_impl->window_scale;
x2 = (xevent->xexpose.x + xevent->xexpose.width + window_impl->window_scale -1) / window_impl->window_scale;
expose_rect.width = x2 - expose_rect.x;
y2 = (xevent->xexpose.y + xevent->xexpose.height + window_impl->window_scale -1) / window_impl->window_scale;
expose_rect.height = y2 - expose_rect.y;
_gdk_x11_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
return_val = FALSE;
......@@ -573,6 +578,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
case GraphicsExpose:
{
GdkRectangle expose_rect;
int x2, y2;
GDK_NOTE (EVENTS,
g_message ("graphics expose:\tdrawable: %ld",
......@@ -584,10 +590,14 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
break;
}
expose_rect.x = xevent->xgraphicsexpose.x;
expose_rect.y = xevent->xgraphicsexpose.y;
expose_rect.width = xevent->xgraphicsexpose.width;
expose_rect.height = xevent->xgraphicsexpose.height;
expose_rect.x = xevent->xgraphicsexpose.x / window_impl->window_scale;
expose_rect.y = xevent->xgraphicsexpose.y / window_impl->window_scale;
x2 = (xevent->xgraphicsexpose.x + xevent->xgraphicsexpose.width + window_impl->window_scale -1) / window_impl->window_scale;
expose_rect.width = x2 - expose_rect.x;
y2 = (xevent->xgraphicsexpose.y + xevent->xgraphicsexpose.height + window_impl->window_scale -1) / window_impl->window_scale;
expose_rect.height = y2 - expose_rect.y;
_gdk_x11_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
return_val = FALSE;
......@@ -773,8 +783,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
: ""));
if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
{
window->width = xevent->xconfigure.width;
window->height = xevent->xconfigure.height;
window->width = xevent->xconfigure.width / window_impl->window_scale;
window->height = xevent->xconfigure.height / window_impl->window_scale;
_gdk_window_update_size (window);
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
......@@ -799,8 +809,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{
event->configure.type = GDK_CONFIGURE;
event->configure.window = window;
event->configure.width = xevent->xconfigure.width;
event->configure.height = xevent->xconfigure.height;
event->configure.width = xevent->xconfigure.width / window_impl->window_scale;
event->configure.height = xevent->xconfigure.height / window_impl->window_scale;
if (!xevent->xconfigure.send_event &&
!xevent->xconfigure.override_redirect &&
......@@ -818,22 +828,22 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
&tx, &ty,
&child_window))
{
event->configure.x = tx;
event->configure.y = ty;
event->configure.x = tx / window_impl->window_scale;
event->configure.y = ty / window_impl->window_scale;
}
gdk_x11_display_error_trap_pop_ignored (display);
}
else
{
event->configure.x = xevent->xconfigure.x;
event->configure.y = xevent->xconfigure.y;
event->configure.x = xevent->xconfigure.x / window_impl->window_scale;
event->configure.y = xevent->xconfigure.y / window_impl->window_scale;
}
if (!is_substructure)
{
window->x = event->configure.x;
window->y = event->configure.y;
window->width = xevent->xconfigure.width;
window->height = xevent->xconfigure.height;
window->width = xevent->xconfigure.width / window_impl->window_scale;
window->height = xevent->xconfigure.height / window_impl->window_scale;
_gdk_window_update_size (window);
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
......@@ -1015,11 +1025,15 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
XserverRegion repair;
GdkRectangle rect;
int x2, y2;
rect.x = window->x + damage_event->area.x / window_impl->window_scale;
rect.y = window->y + damage_event->area.y / window_impl->window_scale;
rect.x = window->x + damage_event->area.x;
rect.y = window->y + damage_event->area.y;
rect.width = damage_event->area.width;
rect.height = damage_event->area.height;
x2 = (rect.x * window_impl->window_scale + damage_event->area.width + window_impl->window_scale -1) / window_impl->window_scale;
y2 = (rect.y * window_impl->window_scale + damage_event->area.height + window_impl->window_scale -1) / window_impl->window_scale;
rect.width = x2 - rect.x;
rect.height = y2 - rect.y;
repair = XFixesCreateRegion (display_x11->xdisplay,
&damage_event->area, 1);
......
......@@ -510,15 +510,19 @@ gdk_window_cache_new (GdkScreen *screen)
{
GList *toplevel_windows, *list;
GdkWindow *window;
GdkWindowImplX11 *impl;
gint x, y, width, height;
toplevel_windows = gdk_screen_get_toplevel_windows (screen);
for (list = toplevel_windows; list; list = list->next)
{
window = GDK_WINDOW (list->data);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
gdk_window_get_geometry (window, &x, &y, &width, &height);
gdk_window_cache_add (result, GDK_WINDOW_XID (window),
x, y, width, height,
x * impl->window_scale, y * impl->window_scale,
width * impl->window_scale,
height * impl->window_scale,
gdk_window_is_visible (window));
}
g_list_free (toplevel_windows);
......@@ -556,7 +560,10 @@ gdk_window_cache_new (GdkScreen *screen)
if (gdk_screen_is_composited (screen))
{
cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
gdk_window_cache_add (result, cow, 0, 0, gdk_screen_get_width (screen), gdk_screen_get_height (screen), TRUE);
gdk_window_cache_add (result, cow, 0, 0,
gdk_screen_get_width (screen) * GDK_X11_SCREEN(screen)->window_scale,
gdk_screen_get_height (screen) * GDK_X11_SCREEN(screen)->window_scale,
TRUE);
XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
}
#endif
......@@ -651,12 +658,12 @@ is_pointer_within_shape (GdkDisplay *display,
child->shape = NULL;
if (gdk_display_supports_shapes (display))
child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
child->xid, ShapeBounding);