diff options
author | Liang Qi <liang.qi@qt.io> | 2020-11-04 10:29:13 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-09-01 20:32:04 +0200 |
commit | 9a4c98e55659b32db984612e6247ac193812a502 (patch) | |
tree | 73ecd543dfe2dcf4a695a31b2508d8965023d17c /src/plugins/platforms/xcb/qxcbconnection.cpp | |
parent | f3743073a70086cfcf39a2daf2c605993ab25ce3 (diff) |
xcb: support xrandr(1.5) monitor setup
More information about monitor in xrandr 1.5, see
https://keithp.com/blogs/MST-monitors/
Since this change, screen is logical instead of physical.
If xrandr 1.5 and later is installed, Qt screen info will get
from xrandr monitor object instead of xrandr output if only have
1.2 to 1.4.
Users can manipulate monitor as they want, for example, a
combination for two physical screens, half of one screen and etc.
Didn't have chance to access MST monitors, but it should work
if xrandr monitor object was created automatically.
[ChangeLog][xcb] Qt screen info will get from xrandr monitor
object if 1.5 is installed.
Fixes: QTBUG-65457
Change-Id: Iad339cc0d4293b2403b4ef6bf6eb770feb3e685f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index e1c9bf80fc..86d1c6cd90 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -99,7 +99,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra if (hasXRandr()) xrandrSelectEvents(); - initializeScreens(); + initializeScreens(false); if (hasXInput2()) { xi2SetupDevices(); @@ -610,8 +610,14 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) ev->event_x, ev->event_y, ev->detail, static_cast<unsigned int>(m_buttonState)); HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); } - case XCB_CONFIGURE_NOTIFY: + case XCB_CONFIGURE_NOTIFY: { + if (isAtLeastXRandR15()) { + auto ev = reinterpret_cast<xcb_configure_notify_event_t *>(event); + if (ev->event == rootWindow()) + initializeScreens(true); + } HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); + } case XCB_MAP_NOTIFY: HANDLE_PLATFORM_WINDOW_EVENT(xcb_map_notify_event_t, event, handleMapNotifyEvent); case XCB_UNMAP_NOTIFY: @@ -729,11 +735,14 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) for (QXcbVirtualDesktop *virtualDesktop : qAsConst(m_virtualDesktops)) virtualDesktop->handleXFixesSelectionNotify(notify_event); } else if (isXRandrType(response_type, XCB_RANDR_NOTIFY)) { - updateScreens(reinterpret_cast<xcb_randr_notify_event_t *>(event)); + if (!isAtLeastXRandR15()) + updateScreens(reinterpret_cast<xcb_randr_notify_event_t *>(event)); } else if (isXRandrType(response_type, XCB_RANDR_SCREEN_CHANGE_NOTIFY)) { - auto change_event = reinterpret_cast<xcb_randr_screen_change_notify_event_t *>(event); - if (auto virtualDesktop = virtualDesktopForRootWindow(change_event->root)) - virtualDesktop->handleScreenChange(change_event); + if (!isAtLeastXRandR15()) { + auto change_event = reinterpret_cast<xcb_randr_screen_change_notify_event_t *>(event); + if (auto virtualDesktop = virtualDesktopForRootWindow(change_event->root)) + virtualDesktop->handleScreenChange(change_event); + } } else if (isXkbType(response_type)) { auto xkb_event = reinterpret_cast<_xkb_event *>(event); if (xkb_event->any.deviceID == m_keyboard->coreDeviceId()) { |