Port XQueryPointer usage to XCB

Introduces new XCB::Pointer wrapper and is used in
Client::leaveNotifyEvent and in Cursor and KillWindow to simplify
the usage.

CCBUG: 333836
This commit is contained in:
Martin Gräßlin 2014-04-25 11:18:49 +02:00
parent 5e1e58d197
commit 3204342809
4 changed files with 12 additions and 12 deletions

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "input.h"
#include "main.h"
#include "utils.h"
#include "xcbutils.h"
// KDE
#include <KConfig>
#include <KConfigGroup>
@ -228,9 +229,8 @@ void X11Cursor::doGetPos()
return;
}
m_timeStamp = QX11Info::appTime();
ScopedCPointer<xcb_query_pointer_reply_t> pointer(xcb_query_pointer_reply(connection(),
xcb_query_pointer_unchecked(connection(), rootWindow()), NULL));
if (!pointer) {
Xcb::Pointer pointer(rootWindow());
if (pointer.isNull()) {
return;
}
m_buttonMask = pointer->mask;

View file

@ -934,13 +934,11 @@ void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
// if this window is another client, but not if it's a popup ... maybe after KDE3.1 :(
// (repeat after me 'AARGHL!')
if (!lostMouse && e->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
// TODO: port to XCB
int d1, d2, d3, d4;
unsigned int d5;
Window w, child;
if (XQueryPointer(display(), frameId(), &w, &child, &d1, &d2, &d3, &d4, &d5) == False
|| child == XCB_WINDOW_NONE)
lostMouse = true; // really lost the mouse
Xcb::Pointer pointer(frameId());
if (!pointer || !pointer->same_screen || pointer->child == XCB_WINDOW_NONE) {
// really lost the mouse
lostMouse = true;
}
}
if (lostMouse) {
cancelAutoRaise();

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "cursor.h"
#include "workspace.h"
#include "xcbutils.h"
// Qt
#include <QCursor>
// XLib
@ -181,8 +182,7 @@ void KillWindow::handleKeyPress(xcb_keycode_t keycode, uint16_t state)
void KillWindow::performKill()
{
xcb_connection_t *c = connection();
ScopedCPointer<xcb_query_pointer_reply_t> pointer(xcb_query_pointer_reply(c, xcb_query_pointer_unchecked(c, rootWindow()), NULL));
Xcb::Pointer pointer(rootWindow());
if (!pointer.isNull() && pointer->child != XCB_WINDOW_NONE) {
killWindowId(pointer->child);
}

View file

@ -581,6 +581,8 @@ public:
}
};
XCB_WRAPPER(Pointer, xcb_query_pointer, xcb_window_t)
struct CurrentInputData : public WrapperData< xcb_get_input_focus_reply_t, xcb_get_input_focus_cookie_t >
{
static constexpr request_func requestFunc = &xcb_get_input_focus_unchecked;