From cd827e657103759b253836b8d6fd899adfc79cbd Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Wed, 13 Nov 2013 21:50:38 +0100 Subject: Tizen: Added screen orientation handling in xcb plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X Window events sent by Window Manager are used. Change-Id: I06970059a003326ddda94cf07d8822f14af5cadc Reviewed-by: Jarosław Staniek Reviewed-by: Tomasz Olszak --- src/plugins/platforms/xcb/qxcbconnection.cpp | 52 +++++++++++++++++++++++++++- src/plugins/platforms/xcb/qxcbconnection.h | 12 ++++++- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 7b2a37239a..63f8d42d1d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -32,6 +32,7 @@ ****************************************************************************/ #include +#include #include #include "qxcbconnection.h" @@ -1324,6 +1325,45 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t * drag()->handleFinished(event); } #endif + +#ifdef Q_OS_LINUX_TIZEN + if (event->type == atom(QXcbAtom::_X_ILLUME_DEACTIVATE_WINDOW)) { + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationHidden); + return; + } else if (event->type == atom(QXcbAtom::_E_WINDOW_ROTATION_CHANGE_PREPARE)) { + xcb_client_message_event_t reply = *event; + reply.response_type = XCB_CLIENT_MESSAGE; + reply.type = atom(QXcbAtom::_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE); + xcb_send_event(xcb_connection(), 0, reply.window, XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY| XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); + xcb_flush(xcb_connection()); + return; + } else if (event->type == atom(QXcbAtom::_E_WINDOW_ROTATION_CHANGE_REQUEST)) { + xcb_client_message_event_t reply = *event; + reply.response_type = XCB_CLIENT_MESSAGE; + reply.type = atom(QXcbAtom::_E_WINDOW_ROTATION_CHANGE_DONE); + + xcb_randr_screen_change_notify_event_t e; + e.config_timestamp = (xcb_timestamp_t)QDateTime::currentMSecsSinceEpoch(); + switch (reply.data.data32[1]) { + case 0: e.rotation = XCB_RANDR_ROTATION_ROTATE_90; break; + case 90: e.rotation = XCB_RANDR_ROTATION_ROTATE_180; break; + case 180: e.rotation = XCB_RANDR_ROTATION_ROTATE_270; break; + case 270: e.rotation = XCB_RANDR_ROTATION_ROTATE_0; break; + } + + QXcbScreen *scrn = m_screens.at(primaryScreen()); + e.width = scrn->geometry().width(); + e.height = scrn->geometry().height(); + e.mwidth = scrn->logicalDpi().first/Q_MM_PER_INCH/e.width; + e.mheight = scrn->logicalDpi().second/Q_MM_PER_INCH/e.height; + scrn->handleScreenChange(&e); + xcb_send_event(xcb_connection(), 0, reply.window, XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY| XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); + xcb_flush(xcb_connection()); + return; + } +#endif // Q_OS_LINUX_TIZEN + + if (m_systemTrayTracker && event->type == atom(QXcbAtom::MANAGER)) m_systemTrayTracker->notifyManagerClientMessageEvent(event); @@ -1538,7 +1578,17 @@ static const char * xcb_atomnames = { "Rel Vert Scroll\0" #ifdef Q_OS_LINUX_TIZEN "_X_ILLUME_DEACTIVATE_WINDOW\0" -#endif + "_E_WINDOW_ROTATION_AVAILABLE_LIST\0" + "_E_ILLUME_ROTATE_WINDOW_ANGLE\0" + "_E_WINDOW_ROTATION_PREFERRED_ROTATION\0" + "_E_ILLUME_ROTATE_ROOT_ANGLE\0" + "_E_WINDOW_ROTATION_SUPPORTED\0" + "_E_WINDOW_ROTATION_CHANGE_PREPARE\0" + "_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE\0" + "_E_WINDOW_ROTATION_CHANGE_REQUEST\0" + "_E_WINDOW_ROTATION_CHANGE_DONE\0" + "_E_WINDOW_ROTATION_APP_SUPPORTED\0" +#endif //Q_OS_LINUX_TIZEN "_XSETTINGS_SETTINGS\0" "_COMPIZ_DECOR_PENDING\0" "_COMPIZ_DECOR_REQUEST\0" diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 713955c04f..8b631e9b83 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -275,7 +275,17 @@ namespace QXcbAtom { #ifdef Q_OS_LINUX_TIZEN _X_ILLUME_DEACTIVATE_WINDOW, -#endif + _E_WINDOW_ROTATION_AVAILABLE_LIST, + _E_ILLUME_ROTATE_WINDOW_ANGLE, + _E_WINDOW_ROTATION_PREFERRED_ROTATION, + _E_ILLUME_ROTATE_ROOT_ANGLE, + _E_WINDOW_ROTATION_SUPPORTED, + _E_WINDOW_ROTATION_CHANGE_PREPARE, + _E_WINDOW_ROTATION_CHANGE_PREPARE_DONE, + _E_WINDOW_ROTATION_CHANGE_REQUEST, + _E_WINDOW_ROTATION_CHANGE_DONE, + _E_WINDOW_ROTATION_APP_SUPPORTED, +#endif //Q_OS_LINUX_TIZEN _XSETTINGS_SETTINGS, _COMPIZ_DECOR_PENDING, diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ab864c7fb7..7d10d0257b 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -520,6 +520,12 @@ void QXcbWindow::create() atom(QXcbAtom::_XEMBED_INFO), 32, 2, (void *)data)); +#ifdef Q_OS_LINUX_TIZEN + int set = 1; + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::_E_WINDOW_ROTATION_SUPPORTED), XCB_ATOM_CARDINAL, 32, + 1, &set)); +#endif //Q_OS_LINUX_TIZEN #if defined(XCB_USE_XINPUT2) connection()->xi2Select(m_window); -- cgit v1.2.3