| 1 |
/* |
| 2 |
|
| 3 |
Copyright 1986, 1998 The Open Group |
| 4 |
|
| 5 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 6 |
documentation for any purpose is hereby granted without fee, provided that |
| 7 |
the above copyright notice appear in all copies and that both that |
| 8 |
copyright notice and this permission notice appear in supporting |
| 9 |
documentation. |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included |
| 12 |
in all copies or substantial portions of the Software. |
| 13 |
|
| 14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 17 |
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
|
| 22 |
Except as contained in this notice, the name of The Open Group shall |
| 23 |
not be used in advertising or otherwise to promote the sale, use or |
| 24 |
other dealings in this Software without prior written authorization |
| 25 |
from The Open Group. |
| 26 |
|
| 27 |
*/ |
| 28 |
|
| 29 |
#ifdef HAVE_CONFIG_H |
| 30 |
#include <config.h> |
| 31 |
#endif |
| 32 |
#include "Xlibint.h" |
| 33 |
|
| 34 |
#define AllMaskBits (CWX|CWY|CWWidth|CWHeight|\ |
| 35 |
CWBorderWidth|CWSibling|CWStackMode) |
| 36 |
|
| 37 |
Status XReconfigureWMWindow ( |
| 38 |
register Display *dpy, |
| 39 |
Window w, |
| 40 |
int screen, |
| 41 |
unsigned int mask, |
| 42 |
XWindowChanges *changes) |
| 43 |
{ |
| 44 |
Window root = RootWindow (dpy, screen); |
| 45 |
_XAsyncHandler async; |
| 46 |
_XAsyncErrorState async_state; |
| 47 |
|
| 48 |
/* |
| 49 |
* Only need to go through the trouble if we are actually changing the |
| 50 |
* stacking mode. |
| 51 |
*/ |
| 52 |
if (!(mask & CWStackMode)) { |
| 53 |
XConfigureWindow (dpy, w, mask, changes); |
| 54 |
return True; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
/* |
| 59 |
* We need to inline XConfigureWindow and XSync so that everything is done |
| 60 |
* while the display is locked. |
| 61 |
*/ |
| 62 |
|
| 63 |
LockDisplay(dpy); |
| 64 |
|
| 65 |
/* |
| 66 |
* XConfigureWindow (dpy, w, mask, changes); |
| 67 |
*/ |
| 68 |
{ |
| 69 |
unsigned long values[7]; |
| 70 |
register unsigned long *value = values; |
| 71 |
long nvalues; |
| 72 |
register xConfigureWindowReq *req; |
| 73 |
|
| 74 |
GetReq(ConfigureWindow, req); |
| 75 |
|
| 76 |
async_state.min_sequence_number = dpy->request; |
| 77 |
async_state.max_sequence_number = dpy->request; |
| 78 |
async_state.error_code = BadMatch; |
| 79 |
async_state.major_opcode = X_ConfigureWindow; |
| 80 |
async_state.minor_opcode = 0; |
| 81 |
async_state.error_count = 0; |
| 82 |
async.next = dpy->async_handlers; |
| 83 |
async.handler = _XAsyncErrorHandler; |
| 84 |
async.data = (XPointer)&async_state; |
| 85 |
dpy->async_handlers = &async; |
| 86 |
|
| 87 |
req->window = w; |
| 88 |
mask &= AllMaskBits; |
| 89 |
req->mask = mask; |
| 90 |
|
| 91 |
if (mask & CWX) *value++ = changes->x; |
| 92 |
if (mask & CWY) *value++ = changes->y; |
| 93 |
if (mask & CWWidth) *value++ = changes->width; |
| 94 |
if (mask & CWHeight) *value++ = changes->height; |
| 95 |
if (mask & CWBorderWidth) *value++ = changes->border_width; |
| 96 |
if (mask & CWSibling) *value++ = changes->sibling; |
| 97 |
if (mask & CWStackMode) *value++ = changes->stack_mode; |
| 98 |
req->length += (nvalues = value - values); |
| 99 |
nvalues <<= 2; /* watch out for macros... */ |
| 100 |
Data32 (dpy, (long *) values, nvalues); |
| 101 |
} |
| 102 |
|
| 103 |
/* |
| 104 |
* XSync (dpy, 0) |
| 105 |
*/ |
| 106 |
{ |
| 107 |
xGetInputFocusReply rep; |
| 108 |
_X_UNUSED register xReq *req; |
| 109 |
|
| 110 |
GetEmptyReq(GetInputFocus, req); |
| 111 |
(void) _XReply (dpy, (xReply *)&rep, 0, xTrue); |
| 112 |
} |
| 113 |
|
| 114 |
DeqAsyncHandler(dpy, &async); |
| 115 |
UnlockDisplay(dpy); |
| 116 |
SyncHandle(); |
| 117 |
|
| 118 |
|
| 119 |
/* |
| 120 |
* If the request succeeded, then everything is okay; otherwise, send event |
| 121 |
*/ |
| 122 |
if (!async_state.error_count) |
| 123 |
return True; |
| 124 |
else { |
| 125 |
XConfigureRequestEvent ev = { |
| 126 |
.type = ConfigureRequest, |
| 127 |
.window = w, |
| 128 |
.parent = root, |
| 129 |
.value_mask = (mask & AllMaskBits), |
| 130 |
.x = changes->x, |
| 131 |
.y = changes->y, |
| 132 |
.width = changes->width, |
| 133 |
.height = changes->height, |
| 134 |
.border_width = changes->border_width, |
| 135 |
.above = changes->sibling, |
| 136 |
.detail = changes->stack_mode, |
| 137 |
}; |
| 138 |
return (XSendEvent (dpy, root, False, |
| 139 |
SubstructureRedirectMask|SubstructureNotifyMask, |
| 140 |
(XEvent *)&ev)); |
| 141 |
} |
| 142 |
} |