Port Workspace's null focus window to xcb
Adding wrappers to Xcb::Window for setInputFocus. REVIEW: 110246
This commit is contained in:
parent
23b395059f
commit
2320b71cb7
3 changed files with 23 additions and 8 deletions
|
@ -240,11 +240,9 @@ void Workspace::init()
|
|||
supportWindow = new QWidget(NULL, Qt::X11BypassWindowManagerHint);
|
||||
XLowerWindow(display(), supportWindow->winId()); // See usage in layers.cpp
|
||||
|
||||
XSetWindowAttributes attr;
|
||||
attr.override_redirect = 1;
|
||||
null_focus_window = XCreateWindow(display(), rootWindow(), -1, -1, 1, 1, 0, CopyFromParent,
|
||||
InputOnly, CopyFromParent, CWOverrideRedirect, &attr);
|
||||
XMapWindow(display(), null_focus_window);
|
||||
const uint32_t nullFocusValues[] = {true};
|
||||
m_nullFocus.reset(new Xcb::Window(QRect(-1, -1, 1, 1), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, nullFocusValues));
|
||||
m_nullFocus->map();
|
||||
|
||||
unsigned long protocols[5] = {
|
||||
NET::Supported |
|
||||
|
@ -511,7 +509,6 @@ Workspace::~Workspace()
|
|||
delete client_keys_dialog;
|
||||
foreach (SessionInfo * s, session)
|
||||
delete s;
|
||||
XDestroyWindow(display(), null_focus_window);
|
||||
|
||||
// TODO: ungrabXServer();
|
||||
|
||||
|
@ -1378,7 +1375,7 @@ bool Workspace::checkStartupNotification(xcb_window_t w, KStartupInfoId &id, KSt
|
|||
*/
|
||||
void Workspace::focusToNull()
|
||||
{
|
||||
XSetInputFocus(display(), null_focus_window, RevertToPointerRoot, xTime());
|
||||
m_nullFocus->focus();
|
||||
}
|
||||
|
||||
void Workspace::setShowingDesktop(bool showing)
|
||||
|
|
|
@ -46,6 +46,11 @@ class KStartupInfoData;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
namespace Xcb
|
||||
{
|
||||
class Window;
|
||||
}
|
||||
|
||||
class Client;
|
||||
class KillWindow;
|
||||
class RootInfo;
|
||||
|
@ -556,7 +561,7 @@ private:
|
|||
int set_active_client_recursion;
|
||||
int block_stacking_updates; // When > 0, stacking updates are temporarily disabled
|
||||
bool blocked_propagating_new_clients; // Propagate also new clients after enabling stacking updates?
|
||||
Window null_focus_window;
|
||||
QScopedPointer<Xcb::Window> m_nullFocus;
|
||||
bool forced_global_mouse_grab;
|
||||
friend class StackingUpdatesBlocker;
|
||||
|
||||
|
|
13
xcbutils.h
13
xcbutils.h
|
@ -38,6 +38,7 @@ typedef xcb_window_t WindowId;
|
|||
|
||||
// forward declaration of methods
|
||||
static void defineCursor(xcb_window_t window, xcb_cursor_t cursor);
|
||||
static void setInputFocus(xcb_window_t window, uint8_t revertTo = XCB_INPUT_FOCUS_POINTER_ROOT, xcb_timestamp_t time = xTime());
|
||||
|
||||
template <typename Reply,
|
||||
typename Cookie,
|
||||
|
@ -355,6 +356,7 @@ public:
|
|||
void clear();
|
||||
void setBackgroundPixmap(xcb_pixmap_t pixmap);
|
||||
void defineCursor(xcb_cursor_t cursor);
|
||||
void focus(uint8_t revertTo = XCB_INPUT_FOCUS_POINTER_ROOT, xcb_timestamp_t time = xTime());
|
||||
operator xcb_window_t() const;
|
||||
private:
|
||||
Window(const Window &other);
|
||||
|
@ -533,6 +535,12 @@ void Window::defineCursor(xcb_cursor_t cursor)
|
|||
Xcb::defineCursor(m_window, cursor);
|
||||
}
|
||||
|
||||
inline
|
||||
void Window::focus(uint8_t revertTo, xcb_timestamp_t time)
|
||||
{
|
||||
setInputFocus(m_window, revertTo, time);
|
||||
}
|
||||
|
||||
// helper functions
|
||||
static inline void moveResizeWindow(WindowId window, const QRect &geometry)
|
||||
{
|
||||
|
@ -625,6 +633,11 @@ static inline void defineCursor(xcb_window_t window, xcb_cursor_t cursor)
|
|||
xcb_change_window_attributes(connection(), window, XCB_CW_CURSOR, &cursor);
|
||||
}
|
||||
|
||||
static inline void setInputFocus(xcb_window_t window, uint8_t revertTo, xcb_timestamp_t time)
|
||||
{
|
||||
xcb_set_input_focus(connection(), revertTo, window, time);
|
||||
}
|
||||
|
||||
} // namespace X11
|
||||
|
||||
} // namespace KWin
|
||||
|
|
Loading…
Reference in a new issue