Port Client::updateCursor to XCB and new Cursor class
The Client::cursor property is changed from QCursor to Qt::CursorShape and renamed to m_cursor (as all usages are adjusted). This property is mostly used to define the cursor on e.g. the extended deco border window. To make this easier a XDefineCursor replacement is added to xcbutils.h both as a static method and as a member function to Xcb::Window.icc-effect-5.14.5
parent
f12cf0efba
commit
be4c76ede1
24
client.cpp
24
client.cpp
|
@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "bridge.h"
|
||||
#include "client_machine.h"
|
||||
#include "composite.h"
|
||||
#include "cursor.h"
|
||||
#include "group.h"
|
||||
#include "focuschain.h"
|
||||
#include "workspace.h"
|
||||
|
@ -109,6 +110,7 @@ Client::Client(Workspace* ws)
|
|||
, shade_below(NULL)
|
||||
, skip_switcher(false)
|
||||
, blocks_compositing(false)
|
||||
, m_cursor(Qt::ArrowCursor)
|
||||
, autoRaiseTimer(NULL)
|
||||
, shadeHoverTimer(NULL)
|
||||
, delayedMoveResizeTimer(NULL)
|
||||
|
@ -2233,7 +2235,7 @@ void Client::updateCursor()
|
|||
Position m = mode;
|
||||
if (!isResizable() || isShade())
|
||||
m = PositionCenter;
|
||||
QCursor c;
|
||||
Qt::CursorShape c = Qt::ArrowCursor;
|
||||
switch(m) {
|
||||
case PositionTopLeft:
|
||||
case PositionBottomRight:
|
||||
|
@ -2258,18 +2260,20 @@ void Client::updateCursor()
|
|||
c = Qt::ArrowCursor;
|
||||
break;
|
||||
}
|
||||
if (c.handle() == cursor.handle())
|
||||
if (c == m_cursor)
|
||||
return;
|
||||
cursor = c;
|
||||
m_cursor = c;
|
||||
if (decoration != NULL)
|
||||
decoration->widget()->setCursor(cursor);
|
||||
XDefineCursor(display(), frameId(), cursor.handle());
|
||||
decoration->widget()->setCursor(m_cursor);
|
||||
xcb_cursor_t nativeCursor = Cursor::x11Cursor(m_cursor);
|
||||
Xcb::defineCursor(frameId(), nativeCursor);
|
||||
if (m_decoInputExtent.isValid())
|
||||
XDefineCursor(display(), inputId(), cursor.handle());
|
||||
if (moveResizeMode) // XDefineCursor doesn't change cursor if there's pointer grab active
|
||||
XChangeActivePointerGrab(display(),
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask,
|
||||
cursor.handle(), xTime());
|
||||
m_decoInputExtent.defineCursor(nativeCursor);
|
||||
if (moveResizeMode) {
|
||||
// changing window attributes doesn't change cursor if there's pointer grab active
|
||||
xcb_change_active_pointer_grab(connection(), nativeCursor, xTime(),
|
||||
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::updateCompositeBlocking(bool readProperty)
|
||||
|
|
2
client.h
2
client.h
|
@ -923,7 +923,7 @@ private:
|
|||
QPixmap miniicon_pix;
|
||||
QPixmap bigicon_pix;
|
||||
QPixmap hugeicon_pix;
|
||||
QCursor cursor;
|
||||
Qt::CursorShape m_cursor;
|
||||
// DON'T reorder - Saved to config files !!!
|
||||
enum FullScreenMode {
|
||||
FullScreenNone,
|
||||
|
|
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "client.h"
|
||||
#include "composite.h"
|
||||
#include "cursor.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#include <kapplication.h>
|
||||
|
@ -2531,7 +2532,7 @@ bool Client::startMoveResize()
|
|||
XMapRaised(display(), move_resize_grab_window);
|
||||
if (XGrabPointer(display(), move_resize_grab_window, False,
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask,
|
||||
GrabModeAsync, GrabModeAsync, move_resize_grab_window, cursor.handle(), xTime()) == Success)
|
||||
GrabModeAsync, GrabModeAsync, move_resize_grab_window, Cursor::x11Cursor(m_cursor), xTime()) == Success)
|
||||
has_grab = true;
|
||||
if (grabXKeyboard(frameId()))
|
||||
has_grab = move_resize_has_keyboard_grab = true;
|
||||
|
|
15
xcbutils.h
15
xcbutils.h
|
@ -34,6 +34,9 @@ namespace Xcb {
|
|||
|
||||
typedef xcb_window_t WindowId;
|
||||
|
||||
// forward declaration of methods
|
||||
static void defineCursor(xcb_window_t window, xcb_cursor_t cursor);
|
||||
|
||||
template <typename Reply,
|
||||
typename Cookie,
|
||||
Reply *(*replyFunc)(xcb_connection_t*, Cookie, xcb_generic_error_t**),
|
||||
|
@ -344,6 +347,7 @@ public:
|
|||
**/
|
||||
void clear();
|
||||
void setBackgroundPixmap(xcb_pixmap_t pixmap);
|
||||
void defineCursor(xcb_cursor_t cursor);
|
||||
operator xcb_window_t() const;
|
||||
private:
|
||||
Window(const Window &other);
|
||||
|
@ -516,6 +520,12 @@ void Window::setBackgroundPixmap(xcb_pixmap_t pixmap)
|
|||
xcb_change_window_attributes(connection(), m_window, XCB_CW_BACK_PIXMAP, values);
|
||||
}
|
||||
|
||||
inline
|
||||
void Window::defineCursor(xcb_cursor_t cursor)
|
||||
{
|
||||
Xcb::defineCursor(m_window, cursor);
|
||||
}
|
||||
|
||||
// helper functions
|
||||
static inline void moveResizeWindow(WindowId window, const QRect &geometry)
|
||||
{
|
||||
|
@ -603,6 +613,11 @@ static inline QVector<xcb_rectangle_t> regionToRects(const QRegion ®ion)
|
|||
return rects;
|
||||
}
|
||||
|
||||
static inline void defineCursor(xcb_window_t window, xcb_cursor_t cursor)
|
||||
{
|
||||
xcb_change_window_attributes(connection(), window, XCB_CW_CURSOR, &cursor);
|
||||
}
|
||||
|
||||
} // namespace X11
|
||||
|
||||
} // namespace KWin
|
||||
|
|
Loading…
Reference in New Issue