Fix null dereference in Workspace::workspaceEvent()
If Xcb::CurrentInput fails for some reason, the "->" operator will return null.
This commit is contained in:
parent
636cbbe024
commit
276baa7dd5
1 changed files with 14 additions and 12 deletions
|
@ -283,18 +283,20 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
|
|||
&& (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) {
|
||||
Xcb::CurrentInput currentInput;
|
||||
kwinApp()->updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp)
|
||||
// it seems we can "loose" focus reversions when the closing window hold a grab
|
||||
// => catch the typical pattern (though we don't want the focus on the root anyway) #348935
|
||||
const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR;
|
||||
if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) {
|
||||
// kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
|
||||
Window *window = mostRecentlyActivatedWindow();
|
||||
if (window != nullptr) {
|
||||
requestFocus(window, true);
|
||||
} else if (activateNextWindow(nullptr)) {
|
||||
; // ok, activated
|
||||
} else {
|
||||
focusToNull();
|
||||
if (!currentInput.isNull()) {
|
||||
// it seems we can "loose" focus reversions when the closing window hold a grab
|
||||
// => catch the typical pattern (though we don't want the focus on the root anyway) #348935
|
||||
const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR;
|
||||
if (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot) {
|
||||
// kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
|
||||
Window *window = mostRecentlyActivatedWindow();
|
||||
if (window != nullptr) {
|
||||
requestFocus(window, true);
|
||||
} else if (activateNextWindow(nullptr)) {
|
||||
; // ok, activated
|
||||
} else {
|
||||
focusToNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue