Port Unmanaged::track to XCB
Uses Xcb::WindowAttributes and Xcb::WindowGeometry instead of XLib variant. In addition it uses the XServerGrabber to ensure that the xserver grab is removed in all code paths. A new macro is added to utils.h to make the grabbing of XServer in current context more obvious.
This commit is contained in:
parent
b039a07f4d
commit
b36b242f12
2 changed files with 17 additions and 11 deletions
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "workspace.h"
|
||||
#include "effects.h"
|
||||
#include "deleted.h"
|
||||
#include "utils.h"
|
||||
#include "xcbutils.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
@ -48,22 +49,24 @@ Unmanaged::~Unmanaged()
|
|||
|
||||
bool Unmanaged::track(Window w)
|
||||
{
|
||||
XWindowAttributes attr;
|
||||
grabXServer();
|
||||
if (!XGetWindowAttributes(display(), w, &attr) || attr.map_state != IsViewable) {
|
||||
ungrabXServer();
|
||||
GRAB_SERVER_DURING_CONTEXT
|
||||
Xcb::WindowAttributes attr(w);
|
||||
Xcb::WindowGeometry geo(w);
|
||||
if (attr.isNull() || attr->map_state != XCB_MAP_STATE_VIEWABLE) {
|
||||
return false;
|
||||
}
|
||||
if (attr.c_class == InputOnly) {
|
||||
ungrabXServer();
|
||||
if (attr->_class == XCB_WINDOW_CLASS_INPUT_ONLY) {
|
||||
return false;
|
||||
}
|
||||
if (geo.isNull()) {
|
||||
return false;
|
||||
}
|
||||
setWindowHandles(w); // the window is also the frame
|
||||
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);
|
||||
Xcb::selectInput(w, attr->your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE);
|
||||
geom = geo.rect();
|
||||
checkScreen();
|
||||
m_visual = attr.visual->visualid;
|
||||
bit_depth = attr.depth;
|
||||
m_visual = attr->visual;
|
||||
bit_depth = geo->depth;
|
||||
info = new NETWinInfo(connection(), w, rootWindow(),
|
||||
NET::WMWindowType | NET::WMPid,
|
||||
NET::WM2Opacity |
|
||||
|
@ -78,7 +81,6 @@ bool Unmanaged::track(Window w)
|
|||
getWmOpaqueRegion();
|
||||
getSkipCloseAnimation();
|
||||
setupCompositing();
|
||||
ungrabXServer();
|
||||
if (effects)
|
||||
static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking();
|
||||
return true;
|
||||
|
|
4
utils.h
4
utils.h
|
@ -133,6 +133,8 @@ void ungrabXKeyboard();
|
|||
* Small helper class which performs @link grabXServer in the ctor and
|
||||
* @link ungrabXServer in the dtor. Use this class to ensure that grab and
|
||||
* ungrab are matched.
|
||||
*
|
||||
* To simplify usage consider using the macro GRAB_SERVER_DURING_CONTEXT
|
||||
**/
|
||||
class XServerGrabber
|
||||
{
|
||||
|
@ -145,6 +147,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#define GRAB_SERVER_DURING_CONTEXT XServerGrabber xserverGrabber;
|
||||
|
||||
// the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
|
||||
#ifndef UrgencyHint
|
||||
#define UrgencyHint XUrgencyHint
|
||||
|
|
Loading…
Reference in a new issue