1ef981d24Smrg/* 2ef981d24Smrg * 3ef981d24SmrgCopyright (c) 1992 X Consortium 4ef981d24Smrg 5ef981d24SmrgPermission is hereby granted, free of charge, to any person obtaining a copy 6ef981d24Smrgof this software and associated documentation files (the "Software"), to deal 7ef981d24Smrgin the Software without restriction, including without limitation the rights 8ef981d24Smrgto use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9ef981d24Smrgcopies of the Software, and to permit persons to whom the Software is 10ef981d24Smrgfurnished to do so, subject to the following conditions: 11ef981d24Smrg 12ef981d24SmrgThe above copyright notice and this permission notice shall be included in 13ef981d24Smrgall copies or substantial portions of the Software. 14ef981d24Smrg 15ef981d24SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16ef981d24SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17ef981d24SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18ef981d24SmrgX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19ef981d24SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20ef981d24SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21ef981d24Smrg 22ef981d24SmrgExcept as contained in this notice, the name of the X Consortium shall not be 23ef981d24Smrgused in advertising or otherwise to promote the sale, use or other dealings 24ef981d24Smrgin this Software without prior written authorization from the X Consortium. 25ef981d24Smrg * 26ef981d24Smrg * Author: Keith Packard, MIT X Consortium 27ef981d24Smrg */ 28ef981d24Smrg 29ef981d24Smrg#include <X11/Xlibint.h> 30ef981d24Smrg#include <X11/Xutil.h> 31ef981d24Smrg#include <X11/extensions/Xext.h> 32ef981d24Smrg#include <X11/extensions/extutil.h> 33ef981d24Smrg#include <X11/extensions/saverproto.h> 34ef981d24Smrg#include <X11/extensions/scrnsaver.h> 35ef981d24Smrg 36ef981d24Smrg 37ef981d24Smrgstatic XExtensionInfo _screen_saver_info_data; 38ef981d24Smrgstatic XExtensionInfo *screen_saver_info = &_screen_saver_info_data; 39347791aaSmrgstatic const char *screen_saver_extension_name = ScreenSaverName; 40ef981d24Smrg 41ef981d24Smrg#define ScreenSaverCheckExtension(dpy,i,val) \ 42ef981d24Smrg XextCheckExtension (dpy, i, screen_saver_extension_name, val) 43ef981d24Smrg#define ScreenSaverSimpleCheckExtension(dpy,i) \ 44ef981d24Smrg XextSimpleCheckExtension (dpy, i, screen_saver_extension_name) 45ef981d24Smrg 46ef981d24Smrgstatic int close_display( 47ef981d24Smrg Display * /* dpy */, 48ef981d24Smrg XExtCodes * /* codes */ 49ef981d24Smrg); 50ef981d24Smrg 51ef981d24Smrgstatic Bool wire_to_event( 52ef981d24Smrg Display * /* dpy */, 53ef981d24Smrg XEvent * /* re */, 54ef981d24Smrg xEvent * /* event */ 55ef981d24Smrg); 56ef981d24Smrg 57ef981d24Smrgstatic Status event_to_wire( 58ef981d24Smrg Display * /* dpy */, 59ef981d24Smrg XEvent * /* re */, 60ef981d24Smrg xEvent * /* event */ 61ef981d24Smrg); 62ef981d24Smrg 63ef981d24Smrgstatic /* const */ XExtensionHooks screen_saver_extension_hooks = { 64ef981d24Smrg NULL, /* create_gc */ 65ef981d24Smrg NULL, /* copy_gc */ 66ef981d24Smrg NULL, /* flush_gc */ 67ef981d24Smrg NULL, /* free_gc */ 68ef981d24Smrg NULL, /* create_font */ 69ef981d24Smrg NULL, /* free_font */ 70ef981d24Smrg close_display, /* close_display */ 71ef981d24Smrg wire_to_event, /* wire_to_event */ 72ef981d24Smrg event_to_wire, /* event_to_wire */ 73ef981d24Smrg NULL, /* error */ 74ef981d24Smrg NULL, /* error_string */ 75ef981d24Smrg}; 76ef981d24Smrg 77ef981d24Smrgstatic XEXT_GENERATE_FIND_DISPLAY (find_display, screen_saver_info, 78200d7199Smrg screen_saver_extension_name, 79ef981d24Smrg &screen_saver_extension_hooks, 80ef981d24Smrg ScreenSaverNumberEvents, NULL) 81ef981d24Smrg 82ef981d24Smrgstatic XEXT_GENERATE_CLOSE_DISPLAY (close_display, screen_saver_info) 83ef981d24Smrg 84ef981d24Smrg 85ef981d24Smrgstatic Bool wire_to_event ( 86ef981d24Smrg Display *dpy, 87ef981d24Smrg XEvent *re, 88ef981d24Smrg xEvent *event) 89ef981d24Smrg{ 90ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 91ef981d24Smrg XScreenSaverNotifyEvent *se; 92ef981d24Smrg xScreenSaverNotifyEvent *sevent; 93ef981d24Smrg 94ef981d24Smrg ScreenSaverCheckExtension (dpy, info, False); 95ef981d24Smrg 96ef981d24Smrg switch ((event->u.u.type & 0x7f) - info->codes->first_event) { 97ef981d24Smrg case ScreenSaverNotify: 987bf574ccSmrg se = (XScreenSaverNotifyEvent *) re; 99ef981d24Smrg sevent = (xScreenSaverNotifyEvent *) event; 1007bf574ccSmrg se->type = sevent->type & 0x7f; 1017bf574ccSmrg se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event); 1027bf574ccSmrg se->send_event = (sevent->type & 0x80) != 0; 1037bf574ccSmrg se->display = dpy; 1047bf574ccSmrg se->window = sevent->window; 105ee424013Smrg se->root = sevent->root; 1067bf574ccSmrg se->state = sevent->state; 107ef981d24Smrg se->kind = sevent->kind; 108ef981d24Smrg se->forced = True; 109ef981d24Smrg if (sevent->forced == xFalse) 110ef981d24Smrg se->forced = False; 111ef981d24Smrg se->time = sevent->timestamp; 1127bf574ccSmrg return True; 113ef981d24Smrg } 114ef981d24Smrg return False; 115ef981d24Smrg} 116ef981d24Smrg 117ef981d24Smrgstatic Status event_to_wire ( 118ef981d24Smrg Display *dpy, 119ef981d24Smrg XEvent *re, 120ef981d24Smrg xEvent *event) 121ef981d24Smrg{ 122ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 123ef981d24Smrg XScreenSaverNotifyEvent *se; 124ef981d24Smrg xScreenSaverNotifyEvent *sevent; 125ef981d24Smrg 126ef981d24Smrg ScreenSaverCheckExtension (dpy, info, 0); 127ef981d24Smrg 128ef981d24Smrg switch ((re->type & 0x7f) - info->codes->first_event) { 129ef981d24Smrg case ScreenSaverNotify: 1307bf574ccSmrg se = (XScreenSaverNotifyEvent *) re; 131ef981d24Smrg sevent = (xScreenSaverNotifyEvent *) event; 1327bf574ccSmrg sevent->type = (CARD8) (se->type | (se->send_event ? 0x80 : 0)); 1337bf574ccSmrg sevent->sequenceNumber = se->serial & 0xffff; 1347bf574ccSmrg sevent->root = (CARD32) se->root; 1357bf574ccSmrg sevent->window = (CARD32) se->window; 1367bf574ccSmrg sevent->state = (BYTE) se->state; 1377bf574ccSmrg sevent->kind = (BYTE) se->kind; 138ef981d24Smrg sevent->forced = xFalse; 139ef981d24Smrg if (se->forced == True) 140ef981d24Smrg sevent->forced = xTrue; 1417bf574ccSmrg sevent->timestamp = (CARD32) se->time; 1427bf574ccSmrg return 1; 143ef981d24Smrg } 144ef981d24Smrg return 0; 145ef981d24Smrg} 146ef981d24Smrg 147ef981d24Smrg/**************************************************************************** 1487bf574ccSmrg * * 1497bf574ccSmrg * ScreenSaver public interfaces * 1507bf574ccSmrg * * 151ef981d24Smrg ****************************************************************************/ 152ef981d24Smrg 153ef981d24SmrgBool XScreenSaverQueryExtension ( 154ef981d24Smrg Display *dpy, 15565eef222Smrg int *event_base_return, 15665eef222Smrg int *error_base_return) 157ef981d24Smrg{ 158ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 159ef981d24Smrg 160ef981d24Smrg if (XextHasExtension(info)) { 16165eef222Smrg *event_base_return = info->codes->first_event; 16265eef222Smrg *error_base_return = info->codes->first_error; 163ef981d24Smrg return True; 164ef981d24Smrg } else { 165ef981d24Smrg return False; 166ef981d24Smrg } 167ef981d24Smrg} 168ef981d24Smrg 169ef981d24Smrg 170ef981d24SmrgStatus XScreenSaverQueryVersion( 171ef981d24Smrg Display *dpy, 17265eef222Smrg int *major_version_return, 17365eef222Smrg int *minor_version_return) 174ef981d24Smrg{ 175ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 176ef981d24Smrg xScreenSaverQueryVersionReply rep; 177ef981d24Smrg register xScreenSaverQueryVersionReq *req; 178ef981d24Smrg 179ef981d24Smrg ScreenSaverCheckExtension (dpy, info, 0); 180ef981d24Smrg 181ef981d24Smrg LockDisplay (dpy); 182ef981d24Smrg GetReq (ScreenSaverQueryVersion, req); 1837bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 184ef981d24Smrg req->saverReqType = X_ScreenSaverQueryVersion; 185ef981d24Smrg req->clientMajor = ScreenSaverMajorVersion; 186ef981d24Smrg req->clientMinor = ScreenSaverMinorVersion; 187ef981d24Smrg if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 188ef981d24Smrg UnlockDisplay (dpy); 189ef981d24Smrg SyncHandle (); 190ef981d24Smrg return 0; 191ef981d24Smrg } 19265eef222Smrg *major_version_return = rep.majorVersion; 19365eef222Smrg *minor_version_return = rep.minorVersion; 194ef981d24Smrg UnlockDisplay (dpy); 195ef981d24Smrg SyncHandle (); 196ef981d24Smrg return 1; 197ef981d24Smrg} 198ef981d24Smrg 199ef981d24SmrgXScreenSaverInfo *XScreenSaverAllocInfo (void) 200ef981d24Smrg{ 201ef981d24Smrg return (XScreenSaverInfo *) Xmalloc (sizeof (XScreenSaverInfo)); 202ef981d24Smrg} 203ef981d24Smrg 204ef981d24SmrgStatus XScreenSaverQueryInfo ( 205ef981d24Smrg Display *dpy, 206ef981d24Smrg Drawable drawable, 207ef981d24Smrg XScreenSaverInfo *saver_info) 208ef981d24Smrg{ 209ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 210ef981d24Smrg xScreenSaverQueryInfoReply rep; 211ef981d24Smrg register xScreenSaverQueryInfoReq *req; 212ef981d24Smrg 213ef981d24Smrg ScreenSaverCheckExtension (dpy, info, 0); 214ef981d24Smrg 215ef981d24Smrg LockDisplay (dpy); 216ef981d24Smrg GetReq (ScreenSaverQueryInfo, req); 2177bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 218ef981d24Smrg req->saverReqType = X_ScreenSaverQueryInfo; 2197bf574ccSmrg req->drawable = (CARD32) drawable; 220ef981d24Smrg if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 221ef981d24Smrg UnlockDisplay (dpy); 222ef981d24Smrg SyncHandle (); 223ef981d24Smrg return 0; 224ef981d24Smrg } 225ef981d24Smrg UnlockDisplay (dpy); 226ef981d24Smrg SyncHandle (); 227ef981d24Smrg saver_info->window = rep.window; 228ef981d24Smrg saver_info->state = rep.state; 229ef981d24Smrg saver_info->kind = rep.kind; 230ef981d24Smrg saver_info->til_or_since = rep.tilOrSince; 231ef981d24Smrg saver_info->idle = rep.idle; 232ef981d24Smrg saver_info->eventMask = rep.eventMask; 233ef981d24Smrg return 1; 234ef981d24Smrg} 235ef981d24Smrg 236ef981d24Smrgvoid XScreenSaverSelectInput ( 237ef981d24Smrg register Display *dpy, 238ef981d24Smrg Drawable drawable, 239ef981d24Smrg unsigned long mask) 240ef981d24Smrg{ 241ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 2427bf574ccSmrg register xScreenSaverSelectInputReq *req; 243ef981d24Smrg 244ef981d24Smrg ScreenSaverSimpleCheckExtension (dpy, info); 245ef981d24Smrg 246ef981d24Smrg LockDisplay (dpy); 247ef981d24Smrg GetReq (ScreenSaverSelectInput, req); 2487bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 249ef981d24Smrg req->saverReqType = X_ScreenSaverSelectInput; 2507bf574ccSmrg req->drawable = (CARD32) drawable; 2517bf574ccSmrg req->eventMask = (CARD32) mask; 252ef981d24Smrg UnlockDisplay (dpy); 253ef981d24Smrg SyncHandle (); 254ef981d24Smrg} 255ef981d24Smrg 256ef981d24Smrgstatic void 257ef981d24SmrgXScreenSaverProcessWindowAttributes ( 258ef981d24Smrg register Display *dpy, 259ef981d24Smrg xChangeWindowAttributesReq *req, 260ef981d24Smrg register unsigned long valuemask, 261ef981d24Smrg register XSetWindowAttributes *attributes) 2627bf574ccSmrg{ 2637bf574ccSmrg unsigned long values[32] = { 0 }; 264ef981d24Smrg register unsigned long *value = values; 2657bf574ccSmrg unsigned long nvalues; 266ef981d24Smrg 267ef981d24Smrg if (valuemask & CWBackPixmap) 268ef981d24Smrg *value++ = attributes->background_pixmap; 269200d7199Smrg 270ef981d24Smrg if (valuemask & CWBackPixel) 2717bf574ccSmrg *value++ = attributes->background_pixel; 272ef981d24Smrg 273ef981d24Smrg if (valuemask & CWBorderPixmap) 2747bf574ccSmrg *value++ = attributes->border_pixmap; 275ef981d24Smrg 276ef981d24Smrg if (valuemask & CWBorderPixel) 2777bf574ccSmrg *value++ = attributes->border_pixel; 278ef981d24Smrg 279ef981d24Smrg if (valuemask & CWBitGravity) 2807bf574ccSmrg *value++ = (unsigned long) attributes->bit_gravity; 281ef981d24Smrg 282ef981d24Smrg if (valuemask & CWWinGravity) 2837bf574ccSmrg *value++ = (unsigned long) attributes->win_gravity; 284ef981d24Smrg 285ef981d24Smrg if (valuemask & CWBackingStore) 2867bf574ccSmrg *value++ = (unsigned long) attributes->backing_store; 287200d7199Smrg 288ef981d24Smrg if (valuemask & CWBackingPlanes) 289ef981d24Smrg *value++ = attributes->backing_planes; 290ef981d24Smrg 291ef981d24Smrg if (valuemask & CWBackingPixel) 2927bf574ccSmrg *value++ = attributes->backing_pixel; 293ef981d24Smrg 294ef981d24Smrg if (valuemask & CWOverrideRedirect) 2957bf574ccSmrg *value++ = (unsigned long) attributes->override_redirect; 296ef981d24Smrg 297ef981d24Smrg if (valuemask & CWSaveUnder) 2987bf574ccSmrg *value++ = (unsigned long) attributes->save_under; 299ef981d24Smrg 300ef981d24Smrg if (valuemask & CWEventMask) 3017bf574ccSmrg *value++ = (unsigned long) attributes->event_mask; 302ef981d24Smrg 303ef981d24Smrg if (valuemask & CWDontPropagate) 3047bf574ccSmrg *value++ = (unsigned long) attributes->do_not_propagate_mask; 305ef981d24Smrg 306ef981d24Smrg if (valuemask & CWColormap) 307ef981d24Smrg *value++ = attributes->colormap; 308ef981d24Smrg 309ef981d24Smrg if (valuemask & CWCursor) 310ef981d24Smrg *value++ = attributes->cursor; 311ef981d24Smrg 3127bf574ccSmrg nvalues = (unsigned long) (value - values); 3137bf574ccSmrg req->length += nvalues; 314ef981d24Smrg 315ef981d24Smrg nvalues <<= 2; /* watch out for macros... */ 316ef981d24Smrg Data32 (dpy, (long *) values, (long)nvalues); 317ef981d24Smrg 3187bf574ccSmrg} 319ef981d24Smrg 320ef981d24Smrgvoid XScreenSaverSetAttributes ( 321ef981d24Smrg Display *dpy, 322ef981d24Smrg Drawable drawable, 323ef981d24Smrg int x, 324ef981d24Smrg int y, 325ef981d24Smrg unsigned int width, 326ef981d24Smrg unsigned int height, 327ef981d24Smrg unsigned int border_width, 328ef981d24Smrg int depth, 329ef981d24Smrg unsigned int class, 330ef981d24Smrg Visual *visual, 331ef981d24Smrg unsigned long valuemask, 332ef981d24Smrg XSetWindowAttributes *attributes) 333ef981d24Smrg{ 334ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 335ef981d24Smrg register xScreenSaverSetAttributesReq *req; 336ef981d24Smrg 337ef981d24Smrg ScreenSaverSimpleCheckExtension (dpy, info); 338ef981d24Smrg 339ef981d24Smrg LockDisplay (dpy); 340ef981d24Smrg GetReq (ScreenSaverSetAttributes, req); 3417bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 342ef981d24Smrg req->saverReqType = X_ScreenSaverSetAttributes; 3437bf574ccSmrg req->drawable = (CARD32) drawable; 3447bf574ccSmrg req->x = (INT16) x; 3457bf574ccSmrg req->y = (INT16) y; 3467bf574ccSmrg req->width = (CARD16) width; 3477bf574ccSmrg req->height = (CARD16) height; 3487bf574ccSmrg req->borderWidth = (CARD16) border_width; 3497bf574ccSmrg req->c_class = (BYTE) class; 3507bf574ccSmrg req->depth = (CARD8) depth; 35165eef222Smrg if (visual == (Visual *)CopyFromParent) 352ef981d24Smrg req->visualID = CopyFromParent; 353ef981d24Smrg else 3547bf574ccSmrg req->visualID = (CARD32) visual->visualid; 355ef981d24Smrg /* abuse an Xlib internal interface - is this legal for us? */ 3567bf574ccSmrg if ((req->mask = (CARD32) valuemask) != 0) 3577bf574ccSmrg XScreenSaverProcessWindowAttributes (dpy, 358200d7199Smrg (xChangeWindowAttributesReq *)req, 359ef981d24Smrg valuemask, attributes); 360ef981d24Smrg UnlockDisplay (dpy); 361ef981d24Smrg SyncHandle (); 362ef981d24Smrg} 363ef981d24Smrg 364ef981d24Smrg 365ef981d24Smrgvoid XScreenSaverUnsetAttributes ( 366ef981d24Smrg register Display *dpy, 367ef981d24Smrg Drawable drawable) 368ef981d24Smrg{ 369ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 370ef981d24Smrg register xScreenSaverUnsetAttributesReq *req; 371ef981d24Smrg 372ef981d24Smrg ScreenSaverSimpleCheckExtension (dpy, info); 373ef981d24Smrg 374ef981d24Smrg LockDisplay (dpy); 375ef981d24Smrg GetReq (ScreenSaverUnsetAttributes, req); 3767bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 377ef981d24Smrg req->saverReqType = X_ScreenSaverUnsetAttributes; 3787bf574ccSmrg req->drawable = (CARD32) drawable; 379ef981d24Smrg UnlockDisplay (dpy); 380ef981d24Smrg SyncHandle (); 381ef981d24Smrg} 382ef981d24Smrg 383ef981d24Smrg 384ef981d24SmrgStatus XScreenSaverRegister ( 385ef981d24Smrg Display *dpy, 386ef981d24Smrg int screen, 387ef981d24Smrg XID xid, 388ef981d24Smrg Atom type) 389ef981d24Smrg{ 390ef981d24Smrg Atom prop; 391ef981d24Smrg unsigned long ul; 392ef981d24Smrg 393ef981d24Smrg prop = XInternAtom (dpy, ScreenSaverPropertyName, False); 394ef981d24Smrg if (!prop) 395ef981d24Smrg return 0; 396ef981d24Smrg 397ef981d24Smrg ul = (unsigned long) xid; 398200d7199Smrg XChangeProperty (dpy, RootWindow(dpy,screen), prop, type, 32, 399ef981d24Smrg PropModeReplace, (unsigned char *) &ul, 1); 400ef981d24Smrg return 1; 401ef981d24Smrg} 402ef981d24Smrg 403ef981d24Smrg 404ef981d24Smrg 405ef981d24SmrgStatus XScreenSaverUnregister ( 406ef981d24Smrg Display *dpy, 407ef981d24Smrg int screen) 408ef981d24Smrg{ 409ef981d24Smrg Atom prop; 410ef981d24Smrg 411ef981d24Smrg prop = XInternAtom (dpy, ScreenSaverPropertyName, False); 412ef981d24Smrg if (!prop) 413ef981d24Smrg return 0; 414ef981d24Smrg 415ef981d24Smrg XDeleteProperty (dpy, RootWindow(dpy,screen), prop); 416ef981d24Smrg return 1; 417ef981d24Smrg} 418ef981d24Smrg 419ef981d24Smrg 420ef981d24Smrg 421ef981d24SmrgStatus XScreenSaverGetRegistered ( 422ef981d24Smrg Display *dpy, 423ef981d24Smrg int screen, 424ef981d24Smrg XID *xid, 425ef981d24Smrg Atom *type) 426ef981d24Smrg{ 427ef981d24Smrg Atom actual_type = None; 428ef981d24Smrg int actual_format; 429ef981d24Smrg unsigned long nitems, bytesafter; 430ef981d24Smrg unsigned long *ulp = (unsigned long *) 0; 431ef981d24Smrg Atom prop; 432ef981d24Smrg int retval = 0; 433ef981d24Smrg 434ef981d24Smrg prop = XInternAtom (dpy, ScreenSaverPropertyName, False); 435ef981d24Smrg if (!prop) 436ef981d24Smrg return retval; 437ef981d24Smrg 438ef981d24Smrg if (XGetWindowProperty (dpy, RootWindow(dpy,screen), prop, 0L, 1L, False, 439ef981d24Smrg AnyPropertyType, &actual_type, &actual_format, 440ef981d24Smrg &nitems, &bytesafter, (unsigned char **) &ulp) 441ef981d24Smrg != Success) 442ef981d24Smrg return retval; 443ef981d24Smrg 444ef981d24Smrg if (ulp) { 445ef981d24Smrg if (actual_format == 32) { 446ef981d24Smrg *xid = (XID) ulp[0]; 447ef981d24Smrg *type = actual_type; 448ef981d24Smrg retval = 1; 449ef981d24Smrg } 450ef981d24Smrg XFree ((char *) ulp); 451ef981d24Smrg } 452ef981d24Smrg return retval; 453ef981d24Smrg} 454ef981d24Smrg 455ef981d24Smrgvoid 456ef981d24SmrgXScreenSaverSuspend (Display *dpy, Bool suspend) 457ef981d24Smrg{ 458ef981d24Smrg XExtDisplayInfo *info = find_display (dpy); 459ef981d24Smrg xScreenSaverSuspendReq *req; 460ef981d24Smrg 461ef981d24Smrg ScreenSaverSimpleCheckExtension (dpy, info); 462ef981d24Smrg 463ef981d24Smrg LockDisplay (dpy); 464ef981d24Smrg GetReq (ScreenSaverSuspend, req); 4657bf574ccSmrg req->reqType = (CARD8) info->codes->major_opcode; 466ef981d24Smrg req->saverReqType = X_ScreenSaverSuspend; 4677bf574ccSmrg req->suspend = (CARD32) suspend; 468ef981d24Smrg UnlockDisplay (dpy); 469ef981d24Smrg SyncHandle (); 470ef981d24Smrg} 471