xcb: use QXcbConnection::selectionOwner() convenience API

Change-Id: I4fbae152829206b15bf0430d3fb2c9e2b6026566
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Gatis Paeglis 2019-01-03 16:02:54 +01:00 committed by Liang Qi
parent 7f0e227d8a
commit fdbf7cdd09
4 changed files with 7 additions and 18 deletions

View File

@ -254,8 +254,7 @@ QXcbClipboard::~QXcbClipboard()
m_timestamp[QClipboard::Selection] != XCB_CURRENT_TIME) {
// First we check if there is a clipboard manager.
auto reply = Q_XCB_REPLY(xcb_get_selection_owner, xcb_connection(), atom(QXcbAtom::CLIPBOARD_MANAGER));
if (reply && reply->owner != XCB_NONE) {
if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) != XCB_NONE) {
// we delete the property so the manager saves all TARGETS.
xcb_delete_property(xcb_connection(), connection()->qtSelectionOwner(),
atom(QXcbAtom::_QT_SELECTION));
@ -784,8 +783,7 @@ xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t window, i
const QXcbEventNode *flushedTailNode = queue->flushedTail();
if (checkManager) {
auto reply = Q_XCB_REPLY(xcb_get_selection_owner, xcb_connection(), atom(QXcbAtom::CLIPBOARD_MANAGER));
if (!reply || reply->owner == XCB_NONE)
if (connection()->selectionOwner(atom(QXcbAtom::CLIPBOARD_MANAGER)) == XCB_NONE)
return nullptr;
}

View File

@ -83,14 +83,6 @@ QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection,
{
}
xcb_window_t QXcbSystemTrayTracker::locateTrayWindow(const QXcbConnection *connection, xcb_atom_t selection)
{
auto reply = Q_XCB_REPLY(xcb_get_selection_owner, connection->xcb_connection(), selection);
if (!reply)
return 0;
return reply->owner;
}
// Request a window to be docked on the tray.
void QXcbSystemTrayTracker::requestSystemTrayWindowDock(xcb_window_t window) const
{
@ -110,7 +102,7 @@ void QXcbSystemTrayTracker::requestSystemTrayWindowDock(xcb_window_t window) con
xcb_window_t QXcbSystemTrayTracker::trayWindow()
{
if (!m_trayWindow) {
m_trayWindow = QXcbSystemTrayTracker::locateTrayWindow(m_connection, m_selection);
m_trayWindow = m_connection->selectionOwner(m_selection);
if (m_trayWindow) { // Listen for DestroyNotify on tray.
m_connection->addWindowEventListener(m_trayWindow, this);
const quint32 mask = XCB_CW_EVENT_MASK;

View File

@ -70,7 +70,7 @@ private:
explicit QXcbSystemTrayTracker(QXcbConnection *connection,
xcb_atom_t trayAtom,
xcb_atom_t selection);
static xcb_window_t locateTrayWindow(const QXcbConnection *connection, xcb_atom_t selection);
void emitSystemTrayWindowChanged();
xcb_visualid_t netSystemTrayVisual();

View File

@ -235,12 +235,11 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen)
xcb_atom_t selection_owner_atom = atom_reply->atom;
auto selection_result = Q_XCB_REPLY(xcb_get_selection_owner,
screen->xcb_connection(), selection_owner_atom);
if (!selection_result)
xcb_window_t owner = screen->connection()->selectionOwner(selection_owner_atom);
if (owner == XCB_NONE)
return;
d_ptr->x_settings_window = selection_result->owner;
d_ptr->x_settings_window = owner;
if (!d_ptr->x_settings_window)
return;