Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
QGtkScreen: Only divide by dpr when needed
Browse files Browse the repository at this point in the history
In 30b8b6a we divided the returned
resolution by the display scale. This is necessary under Wayland due to
a gtk+ bug, but doing this of course breaks x11.

A bug has been filed for this upstream
(https://bugzilla.gnome.org/show_bug.cgi?id=788497), but in the
meantime, only do the division on Wayland to avoid breaking X11.
  • Loading branch information
rburchell committed Oct 4, 2017
1 parent 30b8b6a commit d491c37
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/qgtkscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

#include <gtk/gtk.h>

#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif

Q_LOGGING_CATEGORY(lcScreen, "qt.qpa.gtk.screen");

QGtkScreen::QGtkScreen(GdkMonitor *monitor)
Expand All @@ -42,15 +46,29 @@ QGtkScreen::QGtkScreen(GdkMonitor *monitor)

QRect QGtkScreen::availableGeometry() const
{
qreal dpr = devicePixelRatio();
qreal dpr = 1.0;
GdkDisplay *dpy = gdk_display_get_default();
#ifdef GDK_WINDOWING_WAYLAND
// Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=788497
if (GDK_IS_WAYLAND_DISPLAY(dpy)) {
dpr = devicePixelRatio();
}
#endif
GdkRectangle geometry;
gdk_monitor_get_workarea(m_monitor, &geometry);
return QRect(geometry.x / dpr, geometry.y / dpr, geometry.width / dpr, geometry.height / dpr);
}

QRect QGtkScreen::geometry() const
{
qreal dpr = devicePixelRatio();
qreal dpr = 1.0;
GdkDisplay *dpy = gdk_display_get_default();
#ifdef GDK_WINDOWING_WAYLAND
// Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=788497
if (GDK_IS_WAYLAND_DISPLAY(dpy)) {
dpr = devicePixelRatio();
}
#endif
GdkRectangle geometry;
gdk_monitor_get_geometry(m_monitor, &geometry);
return QRect(geometry.x / dpr, geometry.y / dpr, geometry.width / dpr, geometry.height / dpr);
Expand Down

0 comments on commit d491c37

Please sign in to comment.