Use an XCB replacement for XSelectInput
Wrapped in xcbutils. In addition the check whether another WM is running in main.cpp is improved by doing a checked request and directly checking for the error. If there is an error, KWin puts out an error message and quits.icc-effect-5.14.5
parent
bec5bcd50e
commit
d973194c36
10
client.cpp
10
client.cpp
|
@ -288,7 +288,7 @@ void Client::releaseWindow(bool on_shutdown)
|
|||
xcb_delete_property(c, m_client, atoms->kde_net_wm_frame_strut);
|
||||
xcb_reparent_window(c, m_client, rootWindow(), x(), y());
|
||||
xcb_change_save_set(c, XCB_SET_MODE_DELETE, m_client);
|
||||
XSelectInput(display(), m_client, NoEventMask);
|
||||
Xcb::selectInput(m_client, XCB_EVENT_MASK_NO_EVENT);
|
||||
if (on_shutdown)
|
||||
// Map the window, so it can be found after another WM is started
|
||||
xcb_map_window(connection(), m_client);
|
||||
|
@ -959,10 +959,10 @@ void Client::setShade(ShadeMode mode)
|
|||
shade_geometry_change = true;
|
||||
QSize s(sizeForClientSize(QSize(clientSize())));
|
||||
s.setHeight(border_top + border_bottom);
|
||||
XSelectInput(display(), m_wrapper, ClientWinMask); // Avoid getting UnmapNotify
|
||||
m_wrapper.selectInput(ClientWinMask); // Avoid getting UnmapNotify
|
||||
m_wrapper.unmap();
|
||||
xcb_unmap_window(connection(), m_client);
|
||||
XSelectInput(display(), m_wrapper, ClientWinMask | SubstructureNotifyMask);
|
||||
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
||||
exportMappingState(IconicState);
|
||||
plainResize(s);
|
||||
shade_geometry_change = false;
|
||||
|
@ -1207,12 +1207,12 @@ void Client::unmap()
|
|||
// which won't be missed, so this shouldn't be a problem. The chance the real UnmapNotify
|
||||
// will be missed is also very minimal, so I don't think it's needed to grab the server
|
||||
// here.
|
||||
XSelectInput(display(), m_wrapper, ClientWinMask); // Avoid getting UnmapNotify
|
||||
m_wrapper.selectInput(ClientWinMask); // Avoid getting UnmapNotify
|
||||
XUnmapWindow(display(), frameId());
|
||||
m_wrapper.unmap();
|
||||
xcb_unmap_window(connection(), m_client);
|
||||
m_decoInputExtent.unmap();
|
||||
XSelectInput(display(), m_wrapper, ClientWinMask | SubstructureNotifyMask);
|
||||
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
||||
if (decoration != NULL)
|
||||
decoration->widget()->hide(); // Not really necessary, but let it know the state
|
||||
exportMappingState(IconicState);
|
||||
|
|
14
main.cpp
14
main.cpp
|
@ -240,8 +240,16 @@ Application::Application()
|
|||
options = new Options;
|
||||
|
||||
// Check whether another windowmanager is running
|
||||
XSelectInput(display(), rootWindow(), SubstructureRedirectMask);
|
||||
Xcb::sync(); // Trigger error now
|
||||
const uint32_t maskValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};
|
||||
ScopedCPointer<xcb_generic_error_t> redirectCheck(xcb_request_check(connection(),
|
||||
xcb_change_window_attributes_checked(connection(),
|
||||
rootWindow(),
|
||||
XCB_CW_EVENT_MASK,
|
||||
maskValues)));
|
||||
if (!redirectCheck.isNull()) {
|
||||
fputs(i18n("kwin: another window manager is running (try using --replace)\n").toLocal8Bit().constData(), stderr);
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
atoms = new Atoms;
|
||||
|
||||
|
@ -286,7 +294,7 @@ void Application::lostSelection()
|
|||
sendPostedEvents();
|
||||
delete Workspace::self();
|
||||
// Remove windowmanager privileges
|
||||
XSelectInput(display(), rootWindow(), PropertyChangeMask);
|
||||
Xcb::selectInput(rootWindow(), XCB_EVENT_MASK_PROPERTY_CHANGE);
|
||||
quit();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ bool Unmanaged::track(Window w)
|
|||
return false;
|
||||
}
|
||||
setWindowHandles(w, w); // the window is also the frame
|
||||
XSelectInput(display(), w, attr.your_event_mask | StructureNotifyMask | PropertyChangeMask);
|
||||
Xcb::selectInput(w, attr.your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE);
|
||||
geom = QRect(attr.x, attr.y, attr.width, attr.height);
|
||||
checkScreen();
|
||||
vis = attr.visual;
|
||||
|
@ -98,7 +98,7 @@ void Unmanaged::release(bool on_shutdown)
|
|||
if (!QWidget::find(window())) { // don't affect our own windows
|
||||
if (Xcb::Extensions::self()->isShapeAvailable())
|
||||
XShapeSelectInput(display(), window(), NoEventMask);
|
||||
XSelectInput(display(), window(), NoEventMask);
|
||||
Xcb::selectInput(window(), XCB_EVENT_MASK_NO_EVENT);
|
||||
}
|
||||
if (!on_shutdown) {
|
||||
workspace()->removeUnmanaged(this);
|
||||
|
|
|
@ -209,15 +209,15 @@ Workspace::Workspace(bool restore)
|
|||
KStartupInfo::DisableKWinModule | KStartupInfo::AnnounceSilenceChanges, this);
|
||||
|
||||
// Select windowmanager privileges
|
||||
XSelectInput(display(), rootWindow(),
|
||||
KeyPressMask |
|
||||
PropertyChangeMask |
|
||||
ColormapChangeMask |
|
||||
SubstructureRedirectMask |
|
||||
SubstructureNotifyMask |
|
||||
FocusChangeMask | // For NotifyDetailNone
|
||||
ExposureMask
|
||||
);
|
||||
Xcb::selectInput(rootWindow(),
|
||||
XCB_EVENT_MASK_KEY_PRESS |
|
||||
XCB_EVENT_MASK_PROPERTY_CHANGE |
|
||||
XCB_EVENT_MASK_COLOR_MAP_CHANGE |
|
||||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
|
||||
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
|
||||
XCB_EVENT_MASK_FOCUS_CHANGE | // For NotifyDetailNone
|
||||
XCB_EVENT_MASK_EXPOSURE
|
||||
);
|
||||
|
||||
#ifdef KWIN_BUILD_SCREENEDGES
|
||||
ScreenEdges::create(this);
|
||||
|
|
13
xcbutils.h
13
xcbutils.h
|
@ -44,6 +44,7 @@ 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());
|
||||
static void moveWindow(xcb_window_t window, const QPoint &pos);
|
||||
static void moveWindow(xcb_window_t window, uint32_t x, uint32_t y);
|
||||
static void selectInput(xcb_window_t window, uint32_t events);
|
||||
|
||||
template <typename Reply,
|
||||
typename Cookie,
|
||||
|
@ -428,6 +429,7 @@ public:
|
|||
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());
|
||||
void selectInput(uint32_t events);
|
||||
operator xcb_window_t() const;
|
||||
private:
|
||||
Window(const Window &other);
|
||||
|
@ -617,6 +619,12 @@ void Window::focus(uint8_t revertTo, xcb_timestamp_t time)
|
|||
setInputFocus(m_window, revertTo, time);
|
||||
}
|
||||
|
||||
inline
|
||||
void Window::selectInput(uint32_t events)
|
||||
{
|
||||
Xcb::selectInput(m_window, events);
|
||||
}
|
||||
|
||||
// helper functions
|
||||
static inline void moveResizeWindow(WindowId window, const QRect &geometry)
|
||||
{
|
||||
|
@ -744,6 +752,11 @@ static inline void sync()
|
|||
}
|
||||
}
|
||||
|
||||
void selectInput(xcb_window_t window, uint32_t events)
|
||||
{
|
||||
xcb_change_window_attributes(connection(), window, XCB_CW_EVENT_MASK, &events);
|
||||
}
|
||||
|
||||
} // namespace X11
|
||||
|
||||
} // namespace KWin
|
||||
|
|
Loading…
Reference in New Issue