diff --git a/autotests/mock_workspace.h b/autotests/mock_workspace.h --- a/autotests/mock_workspace.h +++ b/autotests/mock_workspace.h @@ -51,6 +51,10 @@ void registerEventFilter(X11EventFilter *filter); void unregisterEventFilter(X11EventFilter *filter); + bool compositing() const { + return false; + } + static Workspace *self(); Q_SIGNALS: diff --git a/events.cpp b/events.cpp --- a/events.cpp +++ b/events.cpp @@ -81,8 +81,6 @@ namespace KWin { -extern int currentRefreshRate(); - // **************************************** // Workspace // **************************************** @@ -428,29 +426,7 @@ case XCB_FOCUS_OUT: return true; // always eat these, they would tell Qt that KWin is the active app default: - if (eventType == Xcb::Extensions::self()->randrNotifyEvent() && Xcb::Extensions::self()->isRandrAvailable()) { - 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 - // catch refresh rate changes - if (m_compositor->xrrRefreshRate() != currentRefreshRate()) - m_compositor->setCompositeResetTimer(0); - } - - } else if (eventType == Xcb::Extensions::self()->syncAlarmNotifyEvent() && Xcb::Extensions::self()->isSyncAvailable()) { + if (eventType == Xcb::Extensions::self()->syncAlarmNotifyEvent() && Xcb::Extensions::self()->isSyncAvailable()) { for (Client *c : clients) c->syncEvent(reinterpret_cast< xcb_sync_alarm_notify_event_t* >(e)); for (Client *c : desktops) diff --git a/options.h b/options.h --- a/options.h +++ b/options.h @@ -783,6 +783,8 @@ bool loadCompositingConfig(bool force); void reparseConfiguration(); + static int currentRefreshRate(); + //---------------------- Q_SIGNALS: // for properties diff --git a/options.cpp b/options.cpp --- a/options.cpp +++ b/options.cpp @@ -42,6 +42,11 @@ #ifndef KCMRULES int currentRefreshRate() +{ + return Options::currentRefreshRate(); +} + +int Options::currentRefreshRate() { int rate = -1; QString syncScreenName(QLatin1String("primary screen")); diff --git a/plugins/platforms/x11/standalone/screens_xrandr.cpp b/plugins/platforms/x11/standalone/screens_xrandr.cpp --- a/plugins/platforms/x11/standalone/screens_xrandr.cpp +++ b/plugins/platforms/x11/standalone/screens_xrandr.cpp @@ -18,6 +18,9 @@ along with this program. If not, see . *********************************************************************/ #include "screens_xrandr.h" +#include "composite.h" +#include "options.h" +#include "workspace.h" #include "xcbutils.h" @@ -185,6 +188,29 @@ Q_ASSERT((event->response_type & ~0x80) == Xcb::Extensions::self()->randrNotifyEvent()); // let's try to gather a few XRandR events, unlikely that there is just one startChangedTimer(); + + // update default screen + auto *xrrEvent = reinterpret_cast(event); + xcb_screen_t *screen = defaultScreen(); + if (xrrEvent->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) { + screen->width_in_pixels = xrrEvent->height; + screen->height_in_pixels = xrrEvent->width; + screen->width_in_millimeters = xrrEvent->mheight; + screen->height_in_millimeters = xrrEvent->mwidth; + } else { + screen->width_in_pixels = xrrEvent->width; + screen->height_in_pixels = xrrEvent->height; + screen->width_in_millimeters = xrrEvent->mwidth; + screen->height_in_millimeters = xrrEvent->mheight; + } + if (workspace()->compositing()) { + // desktopResized() should take care of when the size or + // shape of the desktop has changed, but we also want to + // catch refresh rate changes + if (Compositor::self()->xrrRefreshRate() != Options::currentRefreshRate()) + Compositor::self()->setCompositeResetTimer(0); + } + return false; }