From 16df417cc6b63e149750ac15df61bbe4f90f82ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 30 Aug 2013 14:30:14 +0200 Subject: [PATCH] XCB variant for displayWidth/Height and update after RandR event DisplayWidth and height provide proper values though internally things are wrong as QDesktopWidget seems to not emit the signal. --- events.cpp | 17 +++++++++++++---- libkwineffects/kwinglobals.h | 8 -------- xcbutils.cpp | 1 + 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/events.cpp b/events.cpp index 92122ede40..613dc50615 100644 --- a/events.cpp +++ b/events.cpp @@ -424,10 +424,19 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) } default: if (eventType == Xcb::Extensions::self()->randrNotifyEvent() && Xcb::Extensions::self()->isRandrAvailable()) { -#warning Need an XCB replacement for XRRUpdateConfiguration -#if KWIN_QT5_PORTING - XRRUpdateConfiguration(e); -#endif + auto *event = reinterpret_cast(e); + xcb_screen_t *screen = defaultScreen(); + if (event->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) { + screen->width_in_pixels = event->height; + screen->height_in_pixels = event->width; + screen->width_in_millimeters = event->mheight; + screen->height_in_millimeters = event->mwidth; + } else { + screen->width_in_pixels = event->width; + screen->height_in_pixels = event->height; + screen->width_in_millimeters = event->mwidth; + screen->height_in_millimeters = event->mheight; + } if (compositing()) { // desktopResized() should take care of when the size or // shape of the desktop has changed, but we also want to diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index 53a0502052..9e214498dc 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -172,23 +172,15 @@ KWIN_EXPORT xcb_screen_t *defaultScreen() inline KWIN_EXPORT int displayWidth() { -#if 0 xcb_screen_t *screen = defaultScreen(); return screen ? screen->width_in_pixels : 0; -#else - return XDisplayWidth(display(), DefaultScreen(display())); -#endif } inline KWIN_EXPORT int displayHeight() { -#if 0 xcb_screen_t *screen = defaultScreen(); return screen ? screen->height_in_pixels : 0; -#else - return XDisplayHeight(display(), DefaultScreen(display())); -#endif } /** @internal */ diff --git a/xcbutils.cpp b/xcbutils.cpp index 54a09e33c7..155169f4e9 100644 --- a/xcbutils.cpp +++ b/xcbutils.cpp @@ -129,6 +129,7 @@ void Extensions::init() } if (m_randr.present) { randrVersion = xcb_randr_query_version_unchecked(c, RANDR_MAX_MAJOR, RANDR_MAX_MINOR); + xcb_randr_select_input(connection(), rootWindow(), XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE); } if (m_damage.present) { damageVersion = xcb_damage_query_version_unchecked(c, DAMAGE_MAX_MAJOR, DAMAGE_MIN_MAJOR);