Skip to content

Commit

Permalink
xcb: use QXcbConnection::selectionOwner() convenience API
Browse files Browse the repository at this point in the history
Change-Id: I4fbae152829206b15bf0430d3fb2c9e2b6026566
Reviewed-by: Liang Qi <[email protected]>
  • Loading branch information
gatispaeglis authored and liangqi committed Oct 22, 2021
1 parent 7f0e227 commit fdbf7cd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/plugins/platforms/xcb/qxcbclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 1 addition & 9 deletions src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/xcb/qxcbsystemtraytracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class QXcbSystemTrayTracker : public QObject, public QXcbWindowEventListener
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();

Expand Down
7 changes: 3 additions & 4 deletions src/plugins/platforms/xcb/qxcbxsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit fdbf7cd

Please sign in to comment.