2
* Copyright (C) 2011 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
* Sam Spilsbury <sam.spilsbury@canonical.com>
22
#include "inputremover.h"
25
compiz::WindowInputRemover::WindowInputRemover (Display *dpy,
32
mInputRectOrdering (0),
33
mBoundingRects (NULL),
35
mBoundingRectOrdering (0),
40
compiz::WindowInputRemover::~WindowInputRemover ()
47
compiz::WindowInputRemover::save ()
50
int count = 0, ordering;
53
unsigned int width, height, border, depth;
55
/* FIXME: There should be a generic GetGeometry request we can
56
* use here in order to avoid a round-trip */
57
if (!XGetGeometry (mDpy, mShapeWindow, &root, &x, &y, &width, &height,
63
rects = XShapeGetRectangles (mDpy, mShapeWindow, ShapeInput,
66
/* check if the returned shape exactly matches the window shape -
67
* if that is true, the window currently has no set input shape */
69
(rects[0].x == -((int) border)) &&
70
(rects[0].y == -((int) border)) &&
71
(rects[0].width == (width + border)) &&
72
(rects[0].height == (height + border)))
82
mInputRectOrdering = ordering;
84
rects = XShapeGetRectangles (mDpy, mShapeWindow, ShapeBounding,
88
XFree (mBoundingRects);
90
mBoundingRects = rects;
91
mNBoundingRects = count;
92
mBoundingRectOrdering = ordering;
94
mShapeMask = XShapeInputSelected (mDpy, mShapeWindow);
100
compiz::WindowInputRemover::remove ()
105
XShapeSelectInput (mDpy, mShapeWindow, NoEventMask);
107
XShapeCombineRectangles (mDpy, mShapeWindow, ShapeInput, 0, 0,
108
NULL, 0, ShapeSet, 0);
109
XShapeCombineRectangles (mDpy, mShapeWindow, ShapeBounding, 0, 0,
110
NULL, 0, ShapeSet, 0);
112
XShapeSelectInput (mDpy, mShapeWindow, ShapeNotify);
119
compiz::WindowInputRemover::restore ()
125
XShapeCombineRectangles (mDpy, mShapeWindow, ShapeInput, 0, 0,
126
mInputRects, mNInputRects,
127
ShapeSet, mInputRectOrdering);
131
XShapeCombineMask (mDpy, mShapeWindow, ShapeInput,
132
0, 0, None, ShapeSet);
140
XShapeCombineRectangles (mDpy, mShapeWindow, ShapeBounding, 0, 0,
141
mBoundingRects, mNBoundingRects,
142
ShapeSet, mBoundingRectOrdering);
146
XShapeCombineMask (mDpy, mShapeWindow, ShapeBounding,
147
0, 0, None, ShapeSet);
151
XFree (mBoundingRects);
154
XShapeSelectInput (mDpy, mShapeWindow, mShapeMask);
160
mBoundingRects = NULL;