/* Hide the bar from sight. */ int hide_bar (rp_screen *s) { if (s->bar_is_raised) { if (defaults.bar_sticky) { /* Something just wanted the current message gone. */ s->bar_is_raised = BAR_IS_WINDOW_LIST; show_bar(s, defaults.window_fmt); } else { s->bar_is_raised = 0; XUnmapWindow (dpy, s->bar_window); /* Possibly restore colormap. */ if (current_window()) { XUninstallColormap (dpy, s->def_cmap); XInstallColormap (dpy, current_window()->colormap); } } return 1; } return 0; }
void select_client(Client *c) { XColor border_colour_active, border_colour_inactive; XColor border_colour_float_active, border_colour_float_inactive; XColor dummy; unsigned long bpixel; if (current) { XAllocNamedColor(dpy, DefaultColormap(dpy, current->xstuff->screen->screen), settings_get( "border.colour.inactive" ), &border_colour_inactive, &dummy); XAllocNamedColor(dpy, DefaultColormap(dpy, current->xstuff->screen->screen), settings_get( "border.colour.float.inactive" ), &border_colour_float_inactive, &dummy); if (is_sticky(current)) bpixel = border_colour_float_inactive.pixel; else bpixel = border_colour_inactive.pixel; XSetWindowBorder(dpy, current->xstuff->parent, bpixel); } if (c) { XAllocNamedColor(dpy, DefaultColormap(dpy, c->xstuff->screen->screen), settings_get( "border.colour.active" ), &border_colour_active, &dummy); XAllocNamedColor(dpy, DefaultColormap(dpy, c->xstuff->screen->screen), settings_get( "border.colour.float.active" ), &border_colour_float_active, &dummy); if (is_sticky(c)) bpixel = border_colour_float_active.pixel; else bpixel = border_colour_active.pixel; XSetWindowBorder(dpy, c->xstuff->parent, bpixel); XInstallColormap(dpy, c->xstuff->cmap); XSetInputFocus(dpy, c->xstuff->window, RevertToPointerRoot, CurrentTime); } current = c; }
static void install_cmap(WScreen *scr, Colormap cmap) { if(cmap==None) cmap=scr->default_cmap; XInstallColormap(wglobal.dpy, cmap); }
/* Show window listing in bar. */ int show_bar (rp_screen *s, char *fmt) { if (!s->bar_is_raised) { s->bar_is_raised = BAR_IS_WINDOW_LIST; if (defaults.bar_sticky) XMapWindow (dpy, s->bar_window); else XMapRaised (dpy, s->bar_window); update_window_names (s, fmt); /* Switch to the default colormap */ if (current_window()) XUninstallColormap (dpy, current_window()->colormap); XInstallColormap (dpy, s->def_cmap); reset_alarm(); return 1; } /* If the bar is raised we still need to display the window names. */ update_window_names (s, fmt); return 0; }
/* Raise the bar and put it in the right spot */ static void prepare_bar (rp_screen *s, int width, int height, int multiline) { width = width < s->width ? width : s->width; height = height < s->height ? height : s->height; XMoveResizeWindow (dpy, s->bar_window, bar_x (s, width), bar_y (s, height), width, height); /* Map the bar if needed */ if (!s->bar_is_raised) { s->bar_is_raised = BAR_IS_MESSAGE; if (defaults.bar_sticky && !multiline) XMapWindow (dpy, s->bar_window); else XMapRaised (dpy, s->bar_window); /* Switch to the default colormap */ if (current_window()) XUninstallColormap (dpy, current_window()->colormap); XInstallColormap (dpy, s->def_cmap); } if (multiline || !defaults.bar_sticky) XRaiseWindow (dpy, s->bar_window); XClearWindow (dpy, s->bar_window); XSync (dpy, False); }
void Frame::set_colormaps(Colormap cmap) { if (cmap == None) cmap = DefaultColormap(QX11Info::display(), DefaultScreen(QX11Info::display())); XInstallColormap(QX11Info::display(), cmap); }
/* the following two functions change the colormap for 8-bit displays. They should check and do nothing on true color displays */ void ChooseColorMap(int which) { Visual visual; XColor color; int i; if (dDepth!=8)return; /* only for 256 color display! */ if (primo==0) { visual = *DefaultVisual(display, SCREEN); colormap= XCreateColormap(display, window, &visual, AllocAll); } color.flags=DoRed | DoGreen | DoBlue; for (i=0; i< 256; i++) { color.pixel=i; color.red=0xffffL * ((long) (i+which) * 101 %256)/255L; color.green=0xffffL * ((long) (i+which) * 151 %256)/255L; color.blue=0xffffL * ((long) (i+which) * 171 %256)/255L; XStoreColor(display, colormap, &color); } if (primo==0) { XInstallColormap(display,colormap); XSetWindowColormap(display,window,colormap); primo=1; } }
void StopWinMenu(short selected, XEvent *event) { switch(selected){ case I_ICONIFY: IconifyWin(TheWin); break; case I_CLOSE: CloseWin(TheWin); break; case I_AUTORISE: if(TheWin->flags & RISEN) { MoveResizeWin(TheWin, TheWin->ra.x, TheWin->ra.y, TheWin->ra.w, TheWin->ra.h); TheWin->flags &= ~RISEN; } else { int maxw, maxh, bw, bh, wi, hi; maxw = TheWin->ra.maxw; maxh = TheWin->ra.maxh; bw = TheWin->ra.bw; bh = TheWin->ra.bh; wi = TheWin->ra.wi; hi = TheWin->ra.hi; TheWin->ra.x = TheWin->Attr.x; TheWin->ra.y = TheWin->Attr.y; TheWin->ra.w = TheWin->Attr.width; TheWin->ra.h = TheWin->Attr.height; MoveResizeWin(TheWin, 0, 0, (maxw > TheScreen.width) ? (bw + ((int)((TheScreen.width - bw - 1) / wi)) * wi) : maxw, (maxh > TheScreen.height) ? (bh + ((int)((TheScreen.height - bh - 1) / hi)) * hi) : maxh); TheWin->flags |= RISEN; } break; case I_BACK: LowerWin(TheWin); break; case I_KILL: break; case I_MENU: WinMenuMenu(TheWin, event->xbutton.x, event->xbutton.y); break; case I_REALLY: XKillClient(disp, TheWin->win); break; default: if(move_back) XWarpPointer(disp, None, None, 0, 0, 0, 0, hexX, hexY); } XUnmapWindow(disp, TheScreen.HexMenu.IconParent); if(TheWin) XInstallColormap(disp, TheWin->Attributes.colormap); ReinstallDefaultHandle(); UngrabPointer(); }
void Blackbox::setActiveScreen(BScreen *screen) { if (active_screen && active_screen == screen) // nothing to do return; assert(screen != 0); active_screen = screen; // install screen colormap XInstallColormap(XDisplay(), active_screen->screenInfo().colormap()); if (! focused_window || focused_window->screen() != active_screen) setFocusedWindow(0); }
void rmclient(Client *c) { Client *cc; if (c == clients) clients = c->next; else if((cc = clients)) for (; cc->next; cc = cc->next) if (cc->next == c) { cc->next = cc->next->next; break; } if(c->active) { if(!menuactive) setfocus(None); c->active=False; activeclient = NULL; XInstallColormap(dpy, scr->cmap); } else if(prefs.focus==FOC_CLICKTOTYPE) XUngrabButton(dpy, Button1, AnyModifier, c->parent); #ifdef USE_FONTSETS if(c->title) free(c->title); #else if(c->title.value) XFree(c->title.value); #endif if(c->parent != c->scr->root) { XDestroyWindow(dpy, c->parent); XDeleteContext(dpy, c->parent, client_context); } if(c->close) XDeleteContext(dpy, c->close, client_context); if(c->drag) XDeleteContext(dpy, c->drag, client_context); if(c->iconify) XDeleteContext(dpy, c->iconify, client_context); if(c->zoom) XDeleteContext(dpy, c->zoom, client_context); if(c->depth) XDeleteContext(dpy, c->depth, client_context); if(c->resize) XDeleteContext(dpy, c->resize, client_context); if(c->icon) rmicon(c->icon); if(c->window) XDeleteContext(dpy, c->window, client_context); free(c); }
MenuItem *StartMenu(Menu *menu, int x, int y, Bool q, void (*prc)(XEvent *event, MenuItem *selectedMenuItem)) { selectedMenuItem=NULL; quittable = q; keepIt = ((TheScreen.desktop.flags & UDETransientMenus) ? 0 : KeepNonTransMenu) | KeepMenuActive; SpecialProc = prc; if(x>(TheScreen.width-menu->width)) x=TheScreen.width-menu->width; if(y>(TheScreen.height-menu->height-1)) y=TheScreen.height-menu->height-1; Menu2ws(menu,TheScreen.desktop.ActiveWorkSpace); InstallMenuHandle(); GrabPointer(TheScreen.root,ButtonPressMask|ButtonReleaseMask|LeaveWindowMask|\ EnterWindowMask,TheScreen.Mice[C_DEFAULT]); menu->parent=NULL; XInstallColormap(disp,TheScreen.colormap); MapMenu(menu, x, y); while(keepIt){ XEvent event; XNextEvent(disp,&event); if(Handle[event.type]) (*Handle[event.type])(&event); } UngrabPointer(); ReinstallDefaultHandle(); DeleteMenuTree(menu); if(ActiveWin) XInstallColormap(disp,ActiveWin->Attributes.colormap); activemen=NULL; return(selectedMenuItem); }
void install_cmap_cb( Widget w, XtPointer client_data, XtPointer call_data) { Widget canvas = (Widget) client_data; XSetWindowAttributes set_win_att; set_win_att.colormap = globals.cmap; XChangeWindowAttributes(XtDisplay(canvas), XtWindow(canvas), CWColormap, &set_win_att); XInstallColormap(XtDisplay(canvas), globals.cmap); return; }
void qapp::install_colormap(Colormap cmap) { static Colormap lastmap = None; if(cmap == lastmap) return; lastmap = cmap; if(cmap == None) cmap = DefaultColormap(qt_xdisplay(), DefaultScreen(qt_xdisplay())); XInstallColormap(qt_xdisplay(), cmap); }
void XfsmInitializeColorMap() { Display *ADisplay; Screen *AScreen; ADisplay = XtDisplay( XfsmTopLevel ); AScreen = XtScreen( XfsmTopLevel ); XfsmColorMap = DefaultColormapOfScreen( AScreen ); if ( XFSM_SWITCH_COLOR_MAP ) { XfsmColorMap = XCopyColormapAndFree( ADisplay, XfsmColorMap ); XInstallColormap( ADisplay, XfsmColorMap ); XtVaSetValues( XfsmTopLevel, XmNcolormap, XfsmColorMap, NULL ); } }
void setColormap(Display * display, Window window, Colormap cmap, Bool inwindow) { XSetWindowColormap(display, window, cmap); /* Now, here we have a problem. When we are running full-screen, the window's override_redirect attribute is on. So, the window manager never gets the ColormapNotify event that gets generated on the above XSetWindowColormap() call, and does not So, a quick solution is to install it ourselves. The problem with this is that it violates the ICCCM convention that only window managers should install colormaps. Indeed, Fvwm _enforces_ this by immediately un-doing any XInstallColormap() performed by a client (which is why this does not work right under Fvwm). */ if (!inwindow) { XInstallColormap(display, cmap); } }
void select_client(Client *c) { if (current) XSetWindowBorder(dpy, current->parent, current->screen->bg.pixel); if (c) { unsigned long bpixel; #ifdef VWM if (is_sticky(c)) bpixel = c->screen->fc.pixel; else #endif bpixel = c->screen->fg.pixel; XSetWindowBorder(dpy, c->parent, bpixel); #ifdef COLOURMAP XInstallColormap(dpy, c->cmap); #endif XSetInputFocus(dpy, c->window, RevertToPointerRoot, CurrentTime); } current = c; }
/* Hide the bar from sight. */ int hide_bar (rp_screen *s) { if (s->bar_is_raised) { s->bar_is_raised = 0; XUnmapWindow (dpy, s->bar_window); /* Possibly restore colormap. */ if (current_window()) { XUninstallColormap (dpy, s->def_cmap); XInstallColormap (dpy, current_window()->colormap); } return 1; } return 0; }
/* _xdga2_gfxdrv_exit: * Shuts down gfx driver. */ static void _xdga2_gfxdrv_exit(BITMAP *bmp) { XLOCK(); if (_xwin.in_dga_mode) { _xwin_input_handler = 0; XDGACloseFramebuffer(_xwin.display, _xwin.screen); XDGASetMode(_xwin.display, _xwin.screen, 0); _xwin.in_dga_mode = 0; if (_dga_cmap) { XFreeColormap(_xwin.display, _dga_cmap); _dga_cmap = 0; } XInstallColormap(_xwin.display, _xwin.colormap); set_display_switch_mode(SWITCH_BACKGROUND); } XUNLOCK(); }
void StartWinMenu(UltimateContext *uc,int x,int y) { TheWin = uc; selectedHex = ICONWINS; hexX = x; hexY = y; if(x < TheScreen.HexMenu.x) x = TheScreen.HexMenu.x; if(x > (TheScreen.width + TheScreen.HexMenu.x - TheScreen.HexMenu.width)) { x = TheScreen.width + TheScreen.HexMenu.x - TheScreen.HexMenu.width; } if(y < TheScreen.HexMenu.y) y = TheScreen.HexMenu.y; if(y > (TheScreen.height + TheScreen.HexMenu.y - TheScreen.HexMenu.height)) { y = TheScreen.height + TheScreen.HexMenu.y - TheScreen.HexMenu.height; } SetHexShape(ICONWINS); XMoveWindow(disp, TheScreen.HexMenu.IconParent, x - TheScreen.HexMenu.x, y - TheScreen.HexMenu.y); XInstallColormap(disp, TheScreen.colormap); XMapRaised(disp, TheScreen.HexMenu.IconParent); GrabPointer(TheScreen.HexMenu.IconParent, ButtonPressMask|ButtonReleaseMask|EnterWindowMask, TheScreen.Mice[C_BORDER]); move_back=False; if((x != hexX) | (y != hexY)){ XWarpPointer(disp, None, TheScreen.root, 0, 0, 0, 0, x, y); move_back = True; hexX -= x; hexY -= y; } InstallWinMenuHandle(); }
unsigned char * x_set_palette(void) { XColor color; int a,r,g,b; int tbl0[4]={0,21845,43690,65535}; int tbl1[8]={0,9362,18724,28086,37449,46811,56173,65535}; x_colormap=XCreateColormap(x_display,x_root_window,x_default_visual,AllocAll); XInstallColormap(x_display,x_colormap); switch(x_depth) { case 4: for (a=0;a<16;a++) { color.red=(a&8)?65535:0; color.green=tbl0[(a>>1)&3]; color.blue=(a&1)?65535:0; color.pixel=a; color.flags=DoRed|DoGreen|DoBlue; XStoreColor(x_display,x_colormap,&color); } break; case 8: for (a=0;a<256;a++) { color.red=tbl1[(a>>5)&7]; color.green=tbl1[(a>>2)&7]; color.blue=tbl0[a&3]; color.pixel=a; color.flags=DoRed|DoGreen|DoBlue; XStoreColor(x_display,x_colormap,&color); } break; case 15: for (a=0;a<32768;a++){ color.red=((a>>10)&31)*(65535/31); color.green=((a>>5)&31)*(65535/31); color.blue=(a&31)*(65535/31); color.pixel=a; color.flags=DoRed|DoGreen|DoBlue; XStoreColor(x_display,x_colormap,&color); } break; case 16: for (a=0;a<65536;a++){ color.red=((a>>11)&31)*(65535/31); color.green=((a>>5)&63)*(65535/63); color.blue=(a&31)*(65535/31); color.pixel=a; color.flags=DoRed|DoGreen|DoBlue; XStoreColor(x_display,x_colormap,&color); } break; case 24: for (r=0;r<256;r++) for (g=0;g<256;g++) for (b=0;b<256;b++) { color.red=r<<8; color.green=g<<8; color.blue=b<<8; color.pixel=(r<<16)+(g<<8)+(b); color.flags=DoRed|DoGreen|DoBlue; XStoreColor(x_display,x_colormap,&color); } break; } X_FLUSH(); return NULL; }
char * get_more_input (char *prompt, char *preinput, int history_id, completion_fn compl_fn) { /* Emacs 21 uses a 513 byte string to store the keysym name. */ char keysym_buf[513]; rp_screen *s = current_screen (); KeySym ch; unsigned int modifier; rp_input_line *line; char *final_input; edit_status status; Window focus; int revert, done = 0; history_reset(); /* Create our line structure */ line = input_line_new (prompt, preinput, history_id, compl_fn); /* We don't want to draw overtop of the program bar. */ hide_bar (s); /* Switch to the default colormap. */ if (current_window()) XUninstallColormap (dpy, current_window()->colormap); XInstallColormap (dpy, s->def_cmap); XMapWindow (dpy, s->input_window); XRaiseWindow (dpy, s->input_window); XClearWindow (dpy, s->input_window); /* Switch focus to our input window to read the next key events. */ XGetInputFocus (dpy, &focus, &revert); set_window_focus (s->input_window); XSync (dpy, False); update_input_window (s, line); while (!done) { read_key (&ch, &modifier, keysym_buf, sizeof (keysym_buf)); modifier = x11_mask_to_rp_mask (modifier); PRINT_DEBUG (("ch = %ld, modifier = %d, keysym_buf = %s", ch, modifier, keysym_buf)); status = execute_edit_action (line, ch, modifier, keysym_buf); switch (status) { case EDIT_COMPLETE: case EDIT_DELETE: case EDIT_INSERT: case EDIT_MOVE: /* If the text changed (and we didn't just complete something) then set the virgin bit. */ if (status != EDIT_COMPLETE) line->compl->virgin = 1; /* In all cases, we need to redisplay the input string. */ update_input_window (s, line); break; case EDIT_NO_OP: ring_bell (); break; case EDIT_ABORT: final_input = NULL; done = 1; break; case EDIT_DONE: final_input = xstrdup (line->buffer); done = 1; break; default: PRINT_ERROR (("Unhandled status %d; this is a *BUG*\n", status)); exit (EXIT_FAILURE); } } /* Clean up our line structure */ input_line_free (line); /* Revert focus. */ set_window_focus (focus); XUnmapWindow (dpy, s->input_window); /* Possibly restore colormap. */ if (current_window()) { XUninstallColormap (dpy, s->def_cmap); XInstallColormap (dpy, current_window()->colormap); } return final_input; }
void Client::setColormaps(Colormap cmap) { if (cmap== None) colorMap = DefaultColormap(display(), DefaultScreen(display())); XInstallColormap(display(), colorMap); }
static void destroy_passwd_window (saver_info *si) { saver_preferences *p = &si->prefs; passwd_dialog_data *pw = si->pw_data; saver_screen_info *ssi = pw->prompt_screen; Colormap cmap = DefaultColormapOfScreen (ssi->screen); Pixel black = BlackPixelOfScreen (ssi->screen); Pixel white = WhitePixelOfScreen (ssi->screen); XEvent event; cleanup_passwd_window (si); if (si->cached_passwd) { char *wipe = si->cached_passwd; while (*wipe) *wipe++ = '\0'; free(si->cached_passwd); si->cached_passwd = NULL; } move_mouse_grab (si, RootWindowOfScreen (ssi->screen), ssi->cursor, ssi->number); if (pw->passwd_cursor) XFreeCursor (si->dpy, pw->passwd_cursor); if (p->verbose_p) fprintf (stderr, "%s: %d: moving mouse back to %d,%d.\n", blurb(), ssi->number, pw->previous_mouse_x, pw->previous_mouse_y); XWarpPointer (si->dpy, None, RootWindowOfScreen (ssi->screen), 0, 0, 0, 0, pw->previous_mouse_x, pw->previous_mouse_y); while (XCheckMaskEvent (si->dpy, PointerMotionMask, &event)) if (p->verbose_p) fprintf (stderr, "%s: discarding MotionNotify event.\n", blurb()); if (si->passwd_dialog) { if (si->prefs.verbose_p) fprintf (stderr, "%s: %d: destroying password dialog.\n", blurb(), pw->prompt_screen->number); XDestroyWindow (si->dpy, si->passwd_dialog); si->passwd_dialog = 0; } if (pw->save_under) { restore_background(si); XFreePixmap (si->dpy, pw->save_under); pw->save_under = 0; } if (pw->passwd_string) free (pw->passwd_string); if (pw->passwd_font) XFreeFont (si->dpy, pw->passwd_font); if (pw->uname_font) XFreeFont (si->dpy, pw->uname_font); if (pw->foreground != black && pw->foreground != white) XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L); if (pw->background != black && pw->background != white) XFreeColors (si->dpy, cmap, &pw->background, 1, 0L); if (pw->passwd_foreground != black && pw->passwd_foreground != white) XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L); if (pw->passwd_background != black && pw->passwd_background != white) XFreeColors (si->dpy, cmap, &pw->passwd_background, 1, 0L); if (pw->logo_pixmap) XFreePixmap (si->dpy, pw->logo_pixmap); if (pw-> logo_clipmask) XFreePixmap (si->dpy, pw->logo_clipmask); if (pw->logo_pixels) { if (pw->logo_npixels) XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L); free (pw->logo_pixels); pw->logo_pixels = 0; pw->logo_npixels = 0; } if (pw->save_under) XFreePixmap (si->dpy, pw->save_under); if (cmap) XInstallColormap (si->dpy, cmap); memset (pw, 0, sizeof(*pw)); free (pw); si->pw_data = 0; }
/** * info_msg and prompt may be NULL. */ static int make_passwd_window (saver_info *si, const char *info_msg, const char *prompt, Bool echo) { passwd_dialog_data *pw; Screen *screen; Colormap cmap; saver_screen_info *ssi = &si->screens [mouse_screen (si)]; cleanup_passwd_window (si); if (! ssi) return -1; /* [email protected] - fix for mirroring with external monitor */ get_current_screen_size(si, ssi); if (!si->pw_data) if (new_passwd_window (si) < 0) return -1; if (!(pw = si->pw_data)) return -1; pw->ratio = 1.0; pw->prompt_screen = ssi; /* [email protected] * Figure out where on the desktop to place the window so that it will * actually be visible and centered with respect to screen */ pw->x = MAX((ssi->width - pw->width) / 2, 0); pw->y = MAX((ssi->height - pw->height) / 2, 0); /* [email protected] - Get the rest of the resources from the config file */ pw->uname_field_x = pw->x + get_integer_resource(si->dpy, "chromeos.username.x", "Integer"); pw->uname_field_y = pw->y + get_integer_resource(si->dpy, "chromeos.username.y", "Integer"); pw->passwd_field_x = pw->x + get_integer_resource(si->dpy, "chromeos.password.x", "Integer"); pw->passwd_field_y = pw->y + get_integer_resource(si->dpy, "chromeos.password.y", "Integer"); if (si->prefs.verbose_p) fprintf (stderr, "%s: %d: creating password dialog (\"%s\")\n", blurb(), pw->prompt_screen->number, info_msg ? info_msg : ""); screen = pw->prompt_screen->screen; cmap = DefaultColormapOfScreen (screen); pw->echo_input = echo; pw->draw_password_prompt = (NULL != prompt); /* Only create the window the first time around */ if (!si->passwd_dialog) { XSetWindowAttributes attrs; unsigned long attrmask = CWOverrideRedirect | CWEventMask; attrs.override_redirect = True; attrs.event_mask = (ExposureMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask); si->passwd_dialog = XCreateWindow (si->dpy, RootWindowOfScreen(screen), ssi->x, ssi->y, ssi->width, ssi->height, 0, DefaultDepthOfScreen (screen), InputOutput, DefaultVisualOfScreen(screen), attrmask, &attrs); XSetWindowBackground (si->dpy, si->passwd_dialog, pw->background); /* We use the default visual, not ssi->visual, so that the logo pixmap's visual matches that of the si->passwd_dialog window. */ pw->logo_pixmap = xscreensaver_logo (ssi->screen, DefaultVisualOfScreen(screen), si->passwd_dialog, cmap, pw->background, &pw->logo_pixels, &pw->logo_npixels, &pw->logo_clipmask, True); } else /* On successive prompts, just resize the window */ { XWindowChanges wc; unsigned int mask = CWX | CWY | CWWidth | CWHeight; wc.x = ssi->x; wc.y = ssi->y; wc.width = ssi->width; wc.height = ssi->height; XConfigureWindow (si->dpy, si->passwd_dialog, mask, &wc); } restore_background(si); XMapRaised (si->dpy, si->passwd_dialog); XSync (si->dpy, False); move_mouse_grab (si, si->passwd_dialog, pw->passwd_cursor, pw->prompt_screen->number); undo_vp_motion (si); si->pw_data = pw; if (cmap) XInstallColormap (si->dpy, cmap); draw_passwd_window (si); return 0; }
void init_toneclock(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int i, size_hour, istart; toneclockstruct *tclock; /* initialize */ if (toneclocks == NULL) { if ((toneclocks = (toneclockstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (toneclockstruct))) == NULL) return; } tclock = &toneclocks[MI_SCREEN(mi)]; tclock->mi = mi; if (tclock->gc == None) { if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { XColor color; #ifndef STANDALONE tclock->fg = MI_FG_PIXEL(mi); tclock->bg = MI_BG_PIXEL(mi); #endif tclock->blackpixel = MI_BLACK_PIXEL(mi); tclock->whitepixel = MI_WHITE_PIXEL(mi); if ((tclock->cmap = XCreateColormap(display, window, MI_VISUAL(mi), AllocNone)) == None) { free_toneclock(display, tclock); return; } XSetWindowColormap(display, window, tclock->cmap); (void) XParseColor(display, tclock->cmap, "black", &color); (void) XAllocColor(display, tclock->cmap, &color); MI_BLACK_PIXEL(mi) = color.pixel; (void) XParseColor(display, tclock->cmap, "white", &color); (void) XAllocColor(display, tclock->cmap, &color); MI_WHITE_PIXEL(mi) = color.pixel; #ifndef STANDALONE (void) XParseColor(display, tclock->cmap, background, &color); (void) XAllocColor(display, tclock->cmap, &color); MI_BG_PIXEL(mi) = color.pixel; (void) XParseColor(display, tclock->cmap, foreground, &color); (void) XAllocColor(display, tclock->cmap, &color); MI_FG_PIXEL(mi) = color.pixel; #endif tclock->colors = (XColor *) NULL; tclock->ncolors = 0; } if ((tclock->gc = XCreateGC(display, MI_WINDOW(mi), (unsigned long) 0, (XGCValues *) NULL)) == None) { free_toneclock(display, tclock); return; } } /* Clear Display */ MI_CLEARWINDOW(mi); tclock->painted = False; XSetFunction(display, tclock->gc, GXxor); /*Set up toneclock data */ if (MI_IS_FULLRANDOM(mi)) { if (NRAND(10)) tclock->original = False; else tclock->original = True; } else { tclock->original = original; } tclock->direction = (LRAND() & 1) ? 1 : -1; tclock->win_width = MI_WIDTH(mi); tclock->win_height = MI_HEIGHT(mi); if (tclock->hour != NULL) free_hour(tclock); if ( tclock->original ) { tclock->num_hour = 12; } else { tclock->num_hour = MI_COUNT(mi); } tclock->x0 = tclock->win_width / 2; tclock->y0 = tclock->win_height / 2; if (tclock->num_hour == 0) { tclock->num_hour = DEF_NUM_hour; } else if (tclock->num_hour < 0) { tclock->num_hour = NRAND(-tclock->num_hour) + 1; } if ( tclock->num_hour < 12 ) istart = NRAND( 12 - tclock->num_hour ); else istart = 0; if ((tclock->hour = (toneclockhour *) calloc(tclock->num_hour, sizeof (toneclockhour))) == NULL) { free_toneclock(display, tclock); return; } if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { /* Set up colour map */ if (tclock->colors != NULL) { if (tclock->ncolors && !tclock->no_colors) free_colors(display, tclock->cmap, tclock->colors, tclock->ncolors); free(tclock->colors); tclock->colors = (XColor *) NULL; } tclock->ncolors = MI_NCOLORS(mi); if (tclock->ncolors < 2) tclock->ncolors = 2; if (tclock->ncolors <= 2) tclock->mono_p = True; else tclock->mono_p = False; if (tclock->mono_p) tclock->colors = (XColor *) NULL; else if ((tclock->colors = (XColor *) malloc(sizeof (*tclock->colors) * (tclock->ncolors + 1))) == NULL) { free_toneclock(display, tclock); return; } tclock->cycle_p = has_writable_cells(mi); if (tclock->cycle_p) { if (MI_IS_FULLRANDOM(mi)) { if (!NRAND(8)) tclock->cycle_p = False; else tclock->cycle_p = True; } else { tclock->cycle_p = cycle_p; } } if (!tclock->mono_p) { if (!(LRAND() % 10)) make_random_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tclock->cmap, tclock->colors, &tclock->ncolors, True, True, &tclock->cycle_p); else if (!(LRAND() % 2)) make_uniform_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tclock->cmap, tclock->colors, &tclock->ncolors, True, &tclock->cycle_p); else make_smooth_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tclock->cmap, tclock->colors, &tclock->ncolors, True, &tclock->cycle_p); } XInstallColormap(display, tclock->cmap); if (tclock->ncolors < 2) { tclock->ncolors = 2; tclock->no_colors = True; } else tclock->no_colors = False; if (tclock->ncolors <= 2) tclock->mono_p = True; if (tclock->mono_p) tclock->cycle_p = False; } #ifndef NO_DBUF if (tclock->dbuf != None) XFreePixmap(display, tclock->dbuf); tclock->dbuf = XCreatePixmap(display, window, tclock->win_width, tclock->win_height, MI_DEPTH(mi)); /* Allocation checked */ if (tclock->dbuf != None) { XGCValues gcv; gcv.foreground = 0; gcv.background = 0; gcv.graphics_exposures = False; gcv.function = GXcopy; if (tclock->dbuf_gc != None) XFreeGC(display, tclock->dbuf_gc); if ((tclock->dbuf_gc = XCreateGC(display, (Drawable) tclock->dbuf, GCForeground | GCBackground | GCGraphicsExposures | GCFunction, &gcv)) == None) { XFreePixmap(display, tclock->dbuf); tclock->dbuf = None; } else { XFillRectangle(display, (Drawable) tclock->dbuf, tclock->dbuf_gc, 0, 0, tclock->win_width, tclock->win_height); /*XSetBackground(display, MI_GC(mi), MI_BLACK_PIXEL(mi)); XSetFunction(display, MI_GC(mi), GXcopy);*/ } } #endif tclock->angle = NRAND(360) * PI_RAD; tclock->velocity = (NRAND(7) - 3) * PI_RAD; size_hour = MIN( tclock->win_width , tclock->win_height) / 3; tclock->pulsating = False; tclock->moving = False; tclock->anglex = 0.0; tclock->angley = 0.0; tclock->fill = 0; tclock->radius = size_hour; tclock->max_radius =0.0; if ( ( !tclock->original && NRAND( 15 ) == 3 ) || tclock->num_hour > 12 ) tclock->randomhour = True; else tclock->randomhour = False; if ( !tclock->original && tclock->win_width > 20 ) { if ( abs( MI_SIZE(mi) ) > size_hour ) { if ( MI_SIZE( mi ) < 0 ) { size_hour = -size_hour; } } else { size_hour = MI_SIZE(mi); } if ( size_hour < 0 ) { tclock->radius = MIN(NRAND( size_hour - 10) + 10, tclock->radius ); } else { tclock->radius = MIN( size_hour , tclock->radius ); } if ( MI_IS_FULLRANDOM( mi ) ) { if ( NRAND(2) ) tclock->pulsating = True; else tclock->pulsating = False; tclock->fill = NRAND( 101 ); } else { tclock->pulsating = pulsating; tclock->fill = fill; } } tclock->phase = 0.0; if ( tclock->pulsating ) tclock->ph_vel = (NRAND(7) - 3) * PI_RAD; for (i = 0; i < tclock->num_hour; i++) { toneclockhour *hour0; hour0 = &tclock->hour[i]; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { if (tclock->ncolors > 2) hour0->colour = NRAND(tclock->ncolors - 2) + 2; else hour0->colour = 1; /* Just in case */ XSetForeground(display, tclock->gc, tclock->colors[hour0->colour].pixel); } else { if (MI_NPIXELS(mi) > 2) hour0->colour = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else hour0->colour = 1; /*Xor'red so WHITE may not be appropriate */ XSetForeground(display, tclock->gc, hour0->colour); } hour0->angle = NRAND(360) * PI_RAD; hour0->velocity = (NRAND(7) - 3) * PI_RAD; hour0->radius = tclock->radius / 5.0; tclock->max_radius = MAX( tclock->max_radius , hour0->radius ); hour0->num_point = 12; hour0->num_point1 = 16; if ( tclock->randomhour ) { int j; hour0->point_numbers = tclock->hexadecimal_clock + i * hour0->num_point1; if ( NRAND( 14 ) == 4 ) { for (j = 0; j < ( hour0->num_point1 / 4 ) - 1 ; j++) { hour0->point_numbers[ j * 4 ] = NRAND( 12 ) + 1; hour0->point_numbers[ j * 4 + 1 ] = NRAND( 12 ) + 1; hour0->point_numbers[ j * 4 + 2 ] = NRAND( 12 ) + 1; hour0->point_numbers[ j * 4 + 3 ] = NRAND( 12 ) + 1; } hour0->point_numbers[ hour0->num_point1 / 4 ] = 1; hour0->point_numbers[ 1 + hour0->num_point1 / 4 ] = 1; hour0->point_numbers[ 2 + hour0->num_point1 / 4 ] = 1; hour0->point_numbers[ 3 + hour0->num_point1 / 4 ] = 1; } else { for (j = 0; j < hour0->num_point1 / 4 ; j++) { hour0->point_numbers[ j * 4 ] = NRAND( 12 ) + 1; hour0->point_numbers[ j * 4 + 1 ] = hour0->point_numbers[ j * 4 ]; hour0->point_numbers[ j * 4 + 2 ] = NRAND( 12 ) + 1; hour0->point_numbers[ j * 4 + 3 ] = NRAND( 12 ) + 1; } } } else hour0->point_numbers = original_clock[i+istart]; if ( NRAND( 100 ) >= tclock->fill ) hour0->draw = True; else hour0->draw = False; #ifdef NO_DBUF { int x0 , y0; x0 = (int) (tclock->radius * sin( -tclock->angle - PI_RAD * i * 360.0 / tclock->num_hour ) * 0.5 * ( 1 + cos( tclock->phase ) ) + tclock->x0 + tclock->a_x * sin( tclock->anglex ) ); y0 = (int) (tclock->radius * cos( -tclock->angle - PI_RAD * i * 360.0 / tclock->num_hour ) * 0.5 * ( 1 + cos( tclock->phase ) ) + tclock->y0 + tclock->a_y * sin( tclock->angley ) ); toneclock_drawhour(mi , hour0 , x0 , y0 ); } #endif } tclock->a_x = 0; tclock->a_y = 0; if ( !tclock->original && tclock->win_width > 20 ) { if ( tclock->radius < MIN( tclock->win_width , tclock->win_height) / 4 ) { if ( MI_IS_FULLRANDOM( mi ) ) { if ( NRAND(2) ) tclock->moving = True; } else { tclock->moving = move_clock; } if ( tclock->moving ) { tclock->a_x = (int) floor( ( tclock->win_width / 2 ) - 1.05 * ( tclock->radius + tclock->max_radius ) ); tclock->a_y = (int) floor( ( tclock->win_height / 2 ) - 1.05 * ( tclock->radius + tclock->max_radius ) ); tclock->vx = (NRAND(15) - 7) * PI_RAD; tclock->vy = (NRAND(15) - 7) * PI_RAD; } } } XFlush(display); XSetFunction(display, tclock->gc, GXcopy); }
dsxc_lutput (void) /* C-- */ { float tcol[LVX*3]; int k, istat, ka, kdiv; char flags; unsigned short int j; /* Cbegin */ DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; PDSOPEN = F77_NAMED_COMMON(ds_panelb).pdsopen; NUMDDCOL = F77_NAMED_COMMON(lutacom).numddcol; (void) dsxc_lutload ( tcol ); /* Load LUT into working LUT */ flags = DoRed | DoGreen | DoBlue; if ( DSOPEN || PDSOPEN ) { if ( OWNCOL ) { kdiv = LVX/NUMDDCOL; for ( k = 15; k<15+LVX; k++ ) { ka = 15 + ((k-15)/kdiv); COLOUR[ka].pixel = PC_ID[ka]; COLOUR[ka].flags = flags; j = tcol[3*(k-15)+0]*65535.0; COLOUR[ka].red = j; j = tcol[3*(k-15)+1]*65535.0; COLOUR[ka].green = j; j = tcol[3*(k-15)+2]*65535.0; COLOUR[ka].blue = j; } XStoreColors ( VD_ID, CM_ID, COLOUR, 15+NUMDDCOL ); XInstallColormap ( VD_ID, CM_ID ); XFlush ( VD_ID ); } else { for ( k = 15; k < 15+LVX; k++ ) { COLOUR[k].flags = flags; j = tcol[3*(k-15)+0]*65535.0; COLOUR[k].red = j; j = tcol[3*(k-15)+1]*65535.0; COLOUR[k].green = j; j = tcol[3*(k-15)+2]*65535.0; COLOUR[k].blue = j; istat = XAllocColor ( VD_ID, CM_ID, &COLOUR[k] ); if ( istat==0 ) { (void) c_printo ( "ERROR: Colour pixel not allocated" ); PC_ID[k] = 0 ; } else PC_ID[k] = COLOUR[k].pixel; } XFlush ( VD_ID ); } } }
void init_mandelbrot(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); mandelstruct *mp; if (mandels == NULL) { if ((mandels = (mandelstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (mandelstruct))) == NULL) return; } mp = &mandels[MI_SCREEN(mi)]; mp->mi = mi; mp->screen_width = MI_WIDTH(mi); mp->screen_height = MI_HEIGHT(mi); mp->backwards = (Bool) (LRAND() & 1); if (mp->backwards) mp->column = mp->screen_width - 1; else mp->column = 0; mp->power = NRAND(3) + MINPOWER; mp->counter = 0; MI_CLEARWINDOW(mi); if (MI_IS_FULLRANDOM(mi)) { mp->binary = (Bool) (LRAND() & 1); mp->dem = (Bool) (LRAND() & 1); mp->interior = NRAND(interior_size); #if 0 /* too slow */ mp->pow = (NRAND(5) == 0); mp->sin = (NRAND(5) == 0); #endif } else { mp->binary = binary_p; mp->dem = dem_p; if (index_p) { mp->interior = INDEX; } else if(alpha_p) { mp->interior = ALPHA; } else if(lyap_p) { mp->interior = LYAPUNOV; } else { mp->interior = NONE; } mp->pow = pow_p; mp->sin = sin_p; } mp->reptop = 300; /* these could be tuned a little closer, but the selection ** process throws out the chaf anyway, it just takes slightly ** longer */ mp->extreme_ul.real = -3.0; mp->extreme_ul.imag = -3.0; mp->extreme_lr.real = 3.0; mp->extreme_lr.imag = 3.0; if (!mp->gc) { if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { XColor color; #ifndef STANDALONE mp->fg = MI_FG_PIXEL(mi); mp->bg = MI_BG_PIXEL(mi); #endif mp->blackpixel = MI_BLACK_PIXEL(mi); mp->whitepixel = MI_WHITE_PIXEL(mi); if ((mp->cmap = XCreateColormap(display, window, MI_VISUAL(mi), AllocNone)) == None) { free_mandelbrot(display, mp); return; } XSetWindowColormap(display, window, mp->cmap); (void) XParseColor(display, mp->cmap, "black", &color); (void) XAllocColor(display, mp->cmap, &color); MI_BLACK_PIXEL(mi) = color.pixel; (void) XParseColor(display, mp->cmap, "white", &color); (void) XAllocColor(display, mp->cmap, &color); MI_WHITE_PIXEL(mi) = color.pixel; #ifndef STANDALONE (void) XParseColor(display, mp->cmap, background, &color); (void) XAllocColor(display, mp->cmap, &color); MI_BG_PIXEL(mi) = color.pixel; (void) XParseColor(display, mp->cmap, foreground, &color); (void) XAllocColor(display, mp->cmap, &color); MI_FG_PIXEL(mi) = color.pixel; #endif mp->colors = (XColor *) NULL; mp->ncolors = 0; } if ((mp->gc = XCreateGC(display, MI_WINDOW(mi), (unsigned long) 0, (XGCValues *) NULL)) == None) { free_mandelbrot(display, mp); return; } } MI_CLEARWINDOW(mi); /* Set up colour map */ mp->direction = (LRAND() & 1) ? 1 : -1; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { if (mp->colors != NULL) { if (mp->ncolors && !mp->no_colors) free_colors(display, mp->cmap, mp->colors, mp->ncolors); free(mp->colors); mp->colors = (XColor *) NULL; } mp->ncolors = MI_NCOLORS(mi); if (mp->ncolors < 2) mp->ncolors = 2; if (mp->ncolors <= 2) mp->mono_p = True; else mp->mono_p = False; if (mp->mono_p) mp->colors = (XColor *) NULL; else if ((mp->colors = (XColor *) malloc(sizeof (*mp->colors) * (mp->ncolors + 1))) == NULL) { free_mandelbrot(display, mp); return; } mp->cycle_p = has_writable_cells(mi); if (mp->cycle_p) { if (MI_IS_FULLRANDOM(mi)) { if (!NRAND(8)) mp->cycle_p = False; else mp->cycle_p = True; } else { mp->cycle_p = cycle_p; } } if (!mp->mono_p) { if (!(LRAND() % 10)) make_random_colormap( #if STANDALONE display, MI_WINDOW(mi), #else mi, #endif mp->cmap, mp->colors, &mp->ncolors, True, True, &mp->cycle_p); else if (!(LRAND() % 2)) make_uniform_colormap( #if STANDALONE display, MI_WINDOW(mi), #else mi, #endif mp->cmap, mp->colors, &mp->ncolors, True, &mp->cycle_p); else make_smooth_colormap( #if STANDALONE display, MI_WINDOW(mi), #else mi, #endif mp->cmap, mp->colors, &mp->ncolors, True, &mp->cycle_p); } XInstallColormap(display, mp->cmap); if (mp->ncolors < 2) { mp->ncolors = 2; mp->no_colors = True; } else mp->no_colors = False; if (mp->ncolors <= 2) mp->mono_p = True; if (mp->mono_p) mp->cycle_p = False; } if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { if (mp->mono_p) { mp->cur_color = MI_BLACK_PIXEL(mi); } } Select(&mp->extreme_ul,&mp->extreme_lr, mp->screen_width,mp->screen_height, (int) mp->power,mp->reptop, mp->pow, mp->sin, &mp->ul,&mp->lr); }
void x_handle_video_event(XEvent * e) { Region region; XRectangle rect; switch (e->type) { case Expose: // keep on selecting expose events. //region = XCreateRegion(); exposed = true; rect.x = (short) e->xexpose.x; rect.y = (short) e->xexpose.y; rect.width = (unsigned short) e->xexpose.width; rect.height = (unsigned short) e->xexpose.height; module_logger(&X_Video, _L | L_2, _("dirtying rectangle (%d,%d+%d,%d)\n"), rect.x, rect.y, rect.width, rect.height); vdp_redraw_screen(rect.x / vwxm, rect.y / vwym, rect.width / vwxm, rect.height / vwym); //XUnionRectWithRegion(&rect, region, region); if (e->xexpose.count == 0) { //XSetRegion(x11_dpy, vgc, region); // vdpcompleteredraw(); x_draw_sides(); // VIDEO(update, ()); vdp_update(); rect.x = 0; rect.y = 0; rect.width = vwxsz; rect.height = vwysz; //XUnionRectWithRegion(&rect, region, region); //XSetRegion(x11_dpy, vgc, region); //XDestroyRegion(region); } break; case ColormapNotify: break; case ConfigureNotify: // window size might have changed. vwxoff = e->xconfigure.x; vwyoff = e->xconfigure.y; vwxsz = e->xconfigure.width; vwysz = e->xconfigure.height; module_logger(&X_Video, _L|0, _("Resize: vwxsz = %d, vwysz = %d\n"), vwxsz, vwysz); vwxm = vwxsz / 256; vwym = vwysz / 192; // XSetClipRectangles(x11_dpy, vgc, 0, 0, &e->xconfigure, 1, Unsorted); XSetClipMask(x11_dpy, vgc, None); #if USING_XIMAGE x_alloc_image(); #endif vdpcompleteredraw(); break; case EnterNotify: case FocusIn: XInstallColormap(x11_dpy, x11_cmap); break; case LeaveNotify: case FocusOut: XInstallColormap(x11_dpy, DefaultColormap(x11_dpy, x11_screen)); break; case MapNotify: vwin_iconified = false; break; case UnmapNotify: vwin_iconified = true; break; } }
void init_tik_tak(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int i, max_objects, size_object; tik_takstruct *tiktak; /* initialize */ if (tik_taks == NULL) { if ((tik_taks = (tik_takstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (tik_takstruct))) == NULL) return; } tiktak = &tik_taks[MI_SCREEN(mi)]; tiktak->mi = mi; if (tiktak->gc == None) { if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { XColor color; #ifndef STANDALONE tiktak->fg = MI_FG_PIXEL(mi); tiktak->bg = MI_BG_PIXEL(mi); #endif tiktak->blackpixel = MI_BLACK_PIXEL(mi); tiktak->whitepixel = MI_WHITE_PIXEL(mi); if ((tiktak->cmap = XCreateColormap(display, window, MI_VISUAL(mi), AllocNone)) == None) { free_tik_tak(display, tiktak); return; } XSetWindowColormap(display, window, tiktak->cmap); (void) XParseColor(display, tiktak->cmap, "black", &color); (void) XAllocColor(display, tiktak->cmap, &color); MI_BLACK_PIXEL(mi) = color.pixel; (void) XParseColor(display, tiktak->cmap, "white", &color); (void) XAllocColor(display, tiktak->cmap, &color); MI_WHITE_PIXEL(mi) = color.pixel; #ifndef STANDALONE (void) XParseColor(display, tiktak->cmap, background, &color); (void) XAllocColor(display, tiktak->cmap, &color); MI_BG_PIXEL(mi) = color.pixel; (void) XParseColor(display, tiktak->cmap, foreground, &color); (void) XAllocColor(display, tiktak->cmap, &color); MI_FG_PIXEL(mi) = color.pixel; #endif tiktak->colors = (XColor *) NULL; tiktak->ncolors = 0; } if ((tiktak->gc = XCreateGC(display, MI_WINDOW(mi), (unsigned long) 0, (XGCValues *) NULL)) == None) { free_tik_tak(display, tiktak); return; } } /* Clear Display */ MI_CLEARWINDOW(mi); tiktak->painted = False; XSetFunction(display, tiktak->gc, GXxor); /*Set up tik_tak data */ tiktak->direction = (LRAND() & 1) ? 1 : -1; tiktak->win_width = MI_WIDTH(mi); tiktak->win_height = MI_HEIGHT(mi); tiktak->num_object = MI_COUNT(mi); tiktak->x0 = tiktak->win_width / 2; tiktak->y0 = tiktak->win_height / 2; max_objects = MI_COUNT(mi); if (tiktak->num_object == 0) { tiktak->num_object = DEF_NUM_OBJECT; max_objects = DEF_NUM_OBJECT; } else if (tiktak->num_object < 0) { max_objects = -tiktak->num_object; tiktak->num_object = NRAND(-tiktak->num_object) + 1; } if (tiktak->object == NULL) if ((tiktak->object = (tik_takobject *) calloc(max_objects, sizeof (tik_takobject))) == NULL) { free_tik_tak(display, tiktak); return; } size_object = MIN( tiktak->win_width , tiktak->win_height) / 3; if ( abs( MI_SIZE(mi) ) > size_object) { if ( MI_SIZE( mi ) < 0 ) { size_object = -size_object; } } else { size_object = MI_SIZE(mi); } if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { /* Set up colour map */ if (tiktak->colors != NULL) { if (tiktak->ncolors && !tiktak->no_colors) free_colors(display, tiktak->cmap, tiktak->colors, tiktak->ncolors); free(tiktak->colors); tiktak->colors = (XColor *) NULL; } tiktak->ncolors = MI_NCOLORS(mi); if (tiktak->ncolors < 2) tiktak->ncolors = 2; if (tiktak->ncolors <= 2) tiktak->mono_p = True; else tiktak->mono_p = False; if (tiktak->mono_p) tiktak->colors = (XColor *) NULL; else if ((tiktak->colors = (XColor *) malloc(sizeof (*tiktak->colors) * (tiktak->ncolors + 1))) == NULL) { free_tik_tak(display, tiktak); return; } tiktak->cycle_p = has_writable_cells(mi); if (tiktak->cycle_p) { if (MI_IS_FULLRANDOM(mi)) { if (!NRAND(8)) tiktak->cycle_p = False; else tiktak->cycle_p = True; } else { tiktak->cycle_p = cycle_p; } } if (!tiktak->mono_p) { if (!(LRAND() % 10)) make_random_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tiktak->cmap, tiktak->colors, &tiktak->ncolors, True, True, &tiktak->cycle_p); else if (!(LRAND() % 2)) make_uniform_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tiktak->cmap, tiktak->colors, &tiktak->ncolors, True, &tiktak->cycle_p); else make_smooth_colormap( #ifdef STANDALONE MI_DISPLAY(mi), MI_WINDOW(mi), #else mi, #endif tiktak->cmap, tiktak->colors, &tiktak->ncolors, True, &tiktak->cycle_p); } XInstallColormap(display, tiktak->cmap); if (tiktak->ncolors < 2) { tiktak->ncolors = 2; tiktak->no_colors = True; } else tiktak->no_colors = False; if (tiktak->ncolors <= 2) tiktak->mono_p = True; if (tiktak->mono_p) tiktak->cycle_p = False; } for (i = 0; i < tiktak->num_object; i++) { tik_takobject *object0; object0 = &tiktak->object[i]; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { if (tiktak->ncolors > 2) object0->colour = NRAND(tiktak->ncolors - 2) + 2; else object0->colour = 1; /* Just in case */ XSetForeground(display, tiktak->gc, tiktak->colors[object0->colour].pixel); } else { if (MI_NPIXELS(mi) > 2) object0->colour = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else object0->colour = 1; /*Xor'red so WHITE may not be appropriate */ XSetForeground(display, tiktak->gc, object0->colour); } object0->angle = NRAND(90) * PI_RAD; object0->angle1 = NRAND(90) * PI_RAD; object0->velocity_a = (NRAND(7) - 3) * PI_RAD; object0->velocity_a1 = (NRAND(7) - 3) * PI_RAD; if (size_object == 0) object0->size_ob = 9; else if (size_object > 0) object0->size_ob = size_object; else object0->size_ob = NRAND(-size_object) + 1; object0->size_ob++; object0->num_point = NRAND(6)+3; if (LRAND() & 1) object0->size_mult = 1.0; else { object0->num_point *= 2; object0->size_mult = 1.0 - ( 1.0 / (float) ((LRAND() & 1) + 2 ) ); } if (object0->xy != NULL) free(object0->xy); if ((object0->xy = (XPoint *) malloc(sizeof( XPoint ) * (2 * object0->num_point + 2))) == NULL) { free_tik_tak(display, tiktak); return; } if ((LRAND() & 1) || object0->size_ob < 10 ) { object0->inner = False; if ( object0->xy1 != NULL ) free( object0->xy1 ); object0->xy1 = (XPoint *) NULL; } else { object0->inner = True; object0->size_ob1 = object0->size_ob - NRAND( object0->size_ob / 5 ) - 1; object0->num_point1 = NRAND(6)+3; if (LRAND() & 1) object0->size_mult1 = 1.0; else { object0->num_point1 *= 2; object0->size_mult1 = 1.0 - ( 1.0 / (float) ((LRAND() & 1) + 2 ) ); } if (object0->xy1 != NULL) free(object0->xy1); if ((object0->xy1 = (XPoint *) malloc(sizeof( XPoint ) * (2 * object0->num_point1 + 2))) == NULL) { free_tik_tak(display, tiktak); return; } object0->size_mult1 = 1.0; } tik_tak_setupobject( mi , object0); tik_tak_reset_object( object0); tik_tak_drawobject(mi, object0 ); } XFlush(display); XSetFunction(display, tiktak->gc, GXcopy); }
main() { Window w2; Display *dpy = XOpenDisplay(NIL); assert(dpy); Screen *scr = DefaultScreenOfDisplay(dpy); // CreateWindow Window w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroyWindow(dpy, w); // CreateWindow with arguments XSetWindowAttributes swa; swa.background_pixel = WhitePixelOfScreen(scr); swa.bit_gravity = NorthWestGravity; swa.border_pixel = BlackPixelOfScreen(scr); swa.colormap = DefaultColormapOfScreen(scr); swa.cursor = None; swa.win_gravity = NorthGravity; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixel | CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWWinGravity, &swa); // CreateWindow with other arguments XDestroyWindow(dpy, w); Pixmap pixmap = XCreatePixmap(dpy, RootWindowOfScreen(scr), 45, 25, DefaultDepthOfScreen(scr)); assert(pixmap); swa.background_pixmap = pixmap; swa.border_pixmap = pixmap; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixmap | CWBorderPixmap, &swa); // ChangeWindowAttributes swa.backing_planes = 0x1; swa.backing_pixel = WhitePixelOfScreen(scr); swa.save_under = True; swa.event_mask = KeyPressMask | KeyReleaseMask; swa.do_not_propagate_mask = ButtonPressMask | Button4MotionMask; swa.override_redirect = False; XChangeWindowAttributes(dpy, w, CWBackingPlanes | CWBackingPixel | CWSaveUnder | CWEventMask | CWDontPropagate | CWOverrideRedirect, &swa); // GetWindowAttributes XWindowAttributes wa; Status success = XGetWindowAttributes(dpy, w, &wa); // DestroyWindow (done) // DestroySubwindows w2 = XCreateWindow(dpy, w, 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroySubwindows(dpy, w); // ChangeSaveSet // Display *dpy2 = XOpenDisplay(NIL); // assert(dpy2); // XAddToSaveSet(dpy2, w); // XCloseDisplay(dpy2); // ReparentWindow w2 = XCreateWindow(dpy, RootWindowOfScreen(scr), 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XReparentWindow(dpy, w2, w, 10, 5); // MapWindow XMapWindow(dpy, w); // MapSubwindows XMapSubwindows(dpy, w); // UnmapWindow XUnmapWindow(dpy, w); // UnmapSubwindows XMapWindow(dpy, w); XUnmapSubwindows(dpy, w2); XMapSubwindows(dpy, w); // ConfigureWindow Window w3 = XCreateWindow(dpy, w, 10, 50, 100, 10, 2, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XMapWindow(dpy, w3); XWindowChanges wc; wc.x = -5; wc.y = -10; wc.width = 50; wc.height = 40; wc.border_width = 7; wc.sibling = w2; wc.stack_mode = Opposite; XConfigureWindow(dpy, w3, CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWSibling | CWStackMode, &wc); // CirculateWindow XCirculateSubwindows(dpy, w, RaiseLowest); // GetGeometry Window root; int x, y; unsigned width, height, border_width, depth; XGetGeometry(dpy, w, &root, &x, &y, &width, &height, &border_width, &depth); // QueryTree Window parent; Window *children; unsigned nchildren; success = XQueryTree(dpy, w, &root, &parent, &children, &nchildren); XFree(children); // InternAtom Atom a = XInternAtom(dpy, "WM_PROTOCOLS", True); // GetAtomName char *string = XGetAtomName(dpy, XA_PRIMARY); XFree(string); // ChangeProperty XStoreName(dpy, w, "test window"); // DeleteProperty XDeleteProperty(dpy, w, XA_WM_NAME); // GetProperty // TODO // ListProperties int num_prop; Atom *list = XListProperties(dpy, w, &num_prop); XFree(list); // SetSelectionOwner XSetSelectionOwner(dpy, XA_PRIMARY, w, 12000); XSetSelectionOwner(dpy, XA_SECONDARY, w, CurrentTime); // GetSelectionOwner Window wx = XGetSelectionOwner(dpy, XA_PRIMARY); // ConvertSelection XConvertSelection(dpy, XA_SECONDARY, XA_CURSOR, XA_POINT, w, CurrentTime); // SendEvent // GrabPointer std::cerr << "Grabbing" << std::endl; int res = XGrabPointer(dpy, w, False, Button5MotionMask | PointerMotionHintMask, GrabModeSync, GrabModeAsync, w, None, CurrentTime); XSync(dpy, False); // sleep(5); // UngrabPointer std::cerr << "Ungrabbing" << std::endl; XUngrabPointer(dpy, CurrentTime); // GrabButton XGrabButton(dpy, 3, ShiftMask | ControlMask, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, 2, AnyModifier, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); // UngrabButton XUngrabButton(dpy, 2, LockMask, w); // ChangeActivePointerGrab XChangeActivePointerGrab(dpy, ButtonPressMask, None, CurrentTime); // GrabKeyboard XGrabKeyboard(dpy, w, True, GrabModeSync, GrabModeSync, 12000); // UngrabKeyboard XUngrabKeyboard(dpy, 13000); // GrabKey XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Tab), ShiftMask | Mod3Mask, w, True, GrabModeSync, GrabModeSync); // UngrabKey XUngrabKey(dpy, AnyKey, AnyModifier, w); // AllowEvents XAllowEvents(dpy, AsyncPointer, 14000); // GrabServer XGrabServer(dpy); // UngrabServer XUngrabServer(dpy); // QueryPointer Window child; int root_x, root_y, win_x, win_y; unsigned mask; Bool bres = XQueryPointer(dpy, w, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); // GetMotionEvents int nevents; XGetMotionEvents(dpy, w, 15000, 16000, &nevents); // TranslateCoordinates int dest_x, dest_y; XTranslateCoordinates(dpy, w, w2, 10, 20, &dest_x, &dest_y, &child); // WarpPointer XWarpPointer(dpy, w, w2, 0, 0, 100, 100, 20, 30); // SetInputFocus XSetInputFocus(dpy,w, RevertToPointerRoot, 17000); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, 17000); // GetInputFocus Window focus; int revert_to; XGetInputFocus(dpy, &focus, &revert_to); // QueryKeymap char keys_return[32]; XQueryKeymap(dpy, keys_return); // OpenFont Font fid = XLoadFont(dpy, "cursor"); // CloseFont XUnloadFont(dpy, fid); // QueryFont XFontStruct *fs = XLoadQueryFont(dpy, "cursor"); assert(fs); // QueryTextExtents int direction, font_ascent, font_descent; XCharStruct overall; XQueryTextExtents(dpy, fs -> fid, "toto", 4, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, "odd__length", 11, &direction, &font_ascent, &font_descent, &overall); XChar2b c2bs; c2bs.byte1 = '$'; c2bs.byte2 = 'B'; XQueryTextExtents16(dpy, fs -> fid, &c2bs, 1, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, longString, strlen(longString), &direction, &font_ascent, &font_descent, &overall); // ListFonts int actual_count; char **fontList = XListFonts(dpy, "*", 100, &actual_count); XFree((char *)fontList); // ListFontsWithInfo int count; XFontStruct *info; char **names = XListFontsWithInfo(dpy, "*", 100, &count, &info); XFreeFontInfo(names, info, count); // SetFontPath // GetFontPath int npaths; char **charList = XGetFontPath(dpy, &npaths); char **charList2 = new char *[npaths + 1]; memcpy(charList2, charList, npaths * sizeof(char *)); charList2[npaths] = charList2[0]; XSetFontPath(dpy, charList2, npaths + 1); XSetFontPath(dpy, charList, npaths); // Reset to some reasonnable value XFreeFontPath(charList); delete [] charList2; // CreatePixmap Pixmap pix2 = XCreatePixmap(dpy, w, 100, 200, DefaultDepthOfScreen(scr)); // FreePixmap XFreePixmap(dpy, pix2); // CreateGC Pixmap bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr), "\000\000\001\000\000\001\000\000\001\377\377\377", 3, 4); XGCValues gcv; gcv.function = GXand; gcv.plane_mask = 0x1; gcv.foreground = WhitePixelOfScreen(scr); gcv.background = BlackPixelOfScreen(scr); gcv.line_width = 2; gcv.line_style = LineDoubleDash; gcv.cap_style = CapProjecting; gcv.join_style = JoinRound; gcv.fill_style = FillStippled; gcv.fill_rule = EvenOddRule; gcv.arc_mode = ArcPieSlice; gcv.tile = pixmap; gcv.stipple = bitmap; gcv.ts_x_origin = 3; gcv.ts_y_origin = 4; gcv.font = fs -> fid; gcv.subwindow_mode = ClipByChildren; gcv.graphics_exposures = True; gcv.clip_x_origin = 5; gcv.clip_y_origin = 6; gcv.clip_mask = bitmap; gcv.dash_offset = 1; gcv.dashes = 0xc2; GC gc = XCreateGC(dpy, w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList | GCArcMode, &gcv); // ChangeGC gcv.function = GXandReverse; // Only a few of these should appear, since the values are cached on the client side by the Xlib. XChangeGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, &gcv); // CopyGC GC gc2 = XCreateGC(dpy, w, 0, NIL); XCopyGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, gc2); // SetDashes XSetDashes(dpy, gc, 3, "\001\377\001", 3); // SetClipRectangles XRectangle rectangles[] = { { 10, 20, 30, 40 }, { 100, 200, 5, 3 }, { -5, 1, 12, 24 } }; XSetClipRectangles(dpy, gc, 12, 9, rectangles, SIZEOF(rectangles), Unsorted); // FreeGC // done already // ClearArea XClearArea(dpy, w, 30, 10, 10, 100, False); // CopyArea XCopyArea(dpy, w, pixmap, gc, 0, 0, 100, 100, 10, 10); // CopyPlane // This won't work if the Screen doesn't have at least 3 planes XCopyPlane(dpy, pixmap, w, gc, 20, 10, 40, 30, 0, 0, 0x4); // PolyPoint XDrawPoint(dpy, w, gc, 1, 2); XPoint points[] = { { 3, 4 }, { 5, 6 } }; XDrawPoints(dpy, w, gc, points, SIZEOF(points), CoordModeOrigin); // PolyLine XDrawLines(dpy, w, gc, points, SIZEOF(points), CoordModePrevious); // PolySegment XSegment segments[] = { { 7, 8, 9, 10 }, { 11, 12, 13, 14 }, { 15, 16, 17, 18 } }; XDrawSegments(dpy, w, gc, segments, SIZEOF(segments)); // PolyRectangle XDrawRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyArc XArc arcs[] = { { 10, 20, 30, 40, 50, 60 }, { -70, 80, 90, 100, 110, 120 }, { 10, 20, 30, 40, 50, -30 } }; XDrawArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // FillPoly XFillPolygon(dpy, w, gc, points, SIZEOF(points), Convex, CoordModePrevious); // PolyFillRectangle XFillRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyFillArc XFillArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // PutImage // GetImage XImage *image = XGetImage(dpy, w, 10, 20, 40, 30, AllPlanes, ZPixmap); XPutImage(dpy, w, gc, image, 0, 0, 50, 60, 40, 30); XSync(dpy, False); // Make the next request starts at the beginning of a packet // PolyText8 XTextItem textItems[3]; textItems[0].chars = "toto"; textItems[0].nchars = strlen(textItems[0].chars); textItems[0].delta = -3; textItems[0].font = fs->fid; textItems[1].chars = "titi"; textItems[1].nchars = strlen(textItems[1].chars); textItems[1].delta = 3; textItems[1].font = None; textItems[2].chars = "tutu"; textItems[2].nchars = strlen(textItems[2].chars); textItems[2].delta = 0; textItems[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems, 3); XTextItem textItems2[3]; textItems2[0].chars = "totox"; textItems2[0].nchars = strlen(textItems2[0].chars); textItems2[0].delta = -3; textItems2[0].font = fs->fid; textItems2[1].chars = "titi"; textItems2[1].nchars = strlen(textItems2[1].chars); textItems2[1].delta = 3; textItems2[1].font = None; textItems2[2].chars = "tutu"; textItems2[2].nchars = strlen(textItems2[2].chars); textItems2[2].delta = 0; textItems2[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems2, 3); // PolyText16 XChar2b c2b2[] = { 0, 't', 0, 'x' }; XTextItem16 items16[] = { { &c2bs, 1, -5, None }, { NULL, 0, 0, None }, { c2b2, 2, 0, fs -> fid } }; XDrawText16(dpy, w, gc, 10, 0, items16, SIZEOF(items16)); // ImageText8 XDrawImageString(dpy, w, gc, 10, 10, "toto", 4); // ImageText16 XDrawImageString16(dpy, w, gc, 10, 10, &c2bs, 1); XDrawImageString16(dpy, w, gc, 10, 20, c2b2, 2); // CreateColormap // Don't forget to tell the kids how it was when we had only 8 bits per pixel. Colormap colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // FreeColormap XFreeColormap(dpy, colormap); colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // CopyColormapAndFree Colormap colormap2 = XCopyColormapAndFree(dpy, colormap); // InstallColormap XInstallColormap(dpy, colormap2); // UninstallColormap XUninstallColormap(dpy, colormap2); // ListInstalledColormaps int num; Colormap *colormapList = XListInstalledColormaps(dpy, w, &num); // AllocColor XColor screen; screen.red = 0; screen.green = 32767; screen.blue = 65535; screen.flags = DoRed | DoGreen | DoBlue; success = XAllocColor(dpy, colormap, &screen); // AllocNamedColor XColor screen2, exact; success = XAllocNamedColor(dpy, colormap, "Wheat", &screen2, &exact); // AllocColorCells unsigned long plane_masks, pixels; success = XAllocColorCells(dpy, colormap, False, &plane_masks, 1, &pixels, 1); // AllocColorPlanes unsigned long rmask, gmask, bmask; success = XAllocColorPlanes(dpy, colormap, False, &pixels, 1, 0, 0, 0, &rmask, &gmask, &bmask); // FreeColors unsigned long pixels2[2] = { screen.pixel, screen2.pixel }; XFreeColors(dpy, colormap, pixels2, 2, 0); // StoreColors success = XAllocColorCells(dpy, colormap, False, NIL, 0, pixels2, 2); // On many contemporary (that is, year 2000) video cards, you can't allocate read / write cells // I want my requests to be sent, however. if (!success) { XSetErrorHandler(errorHandler); } XColor colors[2]; colors[0] = screen; colors[0].pixel = pixels2[0]; colors[1] = screen2; colors[1].pixel = pixels2[1]; XStoreColors(dpy, colormap, colors, 2); // StoreNamedColor XStoreNamedColor(dpy, colormap, "Wheat", colors[0].pixel, DoBlue); XSync(dpy, False); XSetErrorHandler(NIL); // Restore the default handler // QueryColors screen2.pixel = WhitePixelOfScreen(scr); XQueryColor(dpy, colormap, &screen2); // LookupColor success = XLookupColor(dpy, colormap, "DarkCyan", &exact, &screen); // CreateCursor Cursor cursor = XCreatePixmapCursor(dpy, pixmap, None, &exact, colors, 10, 10); // CreateGlyphCursor Cursor cursor2 = XCreateGlyphCursor(dpy, fs -> fid, fs -> fid, 'X', 0, &exact, colors); // FreeCursor XFreeCursor(dpy, cursor2); // RecolorCursor XRecolorCursor(dpy, cursor, colors, &exact); // QueryBestSize success = XQueryBestSize(dpy, CursorShape, RootWindowOfScreen(scr), 100, 20, &width, &height); // QueryExtension int major_opcode, first_event, first_error; XQueryExtension(dpy, "toto", &major_opcode, &first_event, &first_error); // ListExtensions int nextensions; char **extensionList = XListExtensions(dpy, &nextensions); for(char **p = extensionList; nextensions; nextensions--, p++) std::cout << *p << std::endl; XFree(extensionList); // ChangeKeyboardMapping // GetKeyboardMapping int min_keycodes, max_keycodes; XDisplayKeycodes(dpy, &min_keycodes, &max_keycodes); int keysyms_per_keycode; KeySym *keysyms = XGetKeyboardMapping(dpy, min_keycodes, max_keycodes - min_keycodes + 1, &keysyms_per_keycode); XChangeKeyboardMapping(dpy, min_keycodes, keysyms_per_keycode, keysyms, max_keycodes - min_keycodes + 1); // ChangeKeyboardControl // GetKeyboardControl XKeyboardState keyboardState; XGetKeyboardControl(dpy, &keyboardState); XKeyboardControl keyboardValues; keyboardValues.key_click_percent = keyboardState.key_click_percent; keyboardValues.bell_percent = keyboardState.bell_percent; keyboardValues.bell_pitch = keyboardState.bell_pitch; keyboardValues.bell_duration = keyboardState.bell_duration; keyboardValues.led = 1; keyboardValues.led_mode = LedModeOn; keyboardValues.key = min_keycodes; keyboardValues.auto_repeat_mode = AutoRepeatModeDefault; XChangeKeyboardControl(dpy, KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration | KBLed | KBLedMode | KBKey | KBAutoRepeatMode, &keyboardValues); // Bell XBell(dpy, 90); // ChangePointerControl // GetPointerControl int accel_numerator, accel_denominator, threshold; XGetPointerControl(dpy, &accel_numerator, &accel_denominator, &threshold); XChangePointerControl(dpy, True, True, accel_numerator, accel_denominator, threshold); // SetScreenSaver // GetScreenSaver int timeout, interval, prefer_blanking, allow_exposures; XGetScreenSaver(dpy, &timeout, &interval, &prefer_blanking, &allow_exposures); XSetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exposures); // ChangeHosts // ListHosts int nhosts; Bool state; XHostAddress *hostList = XListHosts(dpy, &nhosts, &state); XHostAddress host; host.family = FamilyInternet; host.length = 4; host.address = "\001\002\003\004"; XAddHost(dpy, &host); // SetAccessControl XSetAccessControl(dpy, EnableAccess); // SetCloseDownMode XSetCloseDownMode(dpy, RetainTemporary); // KillClient XKillClient(dpy, AllTemporary); // RotateProperties Atom properties[] = { XInternAtom(dpy, "CUT_BUFFER0", False), XInternAtom(dpy, "CUT_BUFFER1", False), XInternAtom(dpy, "CUT_BUFFER2", False) }; XRotateWindowProperties(dpy, RootWindowOfScreen(scr), properties, SIZEOF(properties), -1); // ForceScreenSaver XForceScreenSaver(dpy, ScreenSaverReset); // SetPointerMapping // GetPointerMapping unsigned char map[64]; int map_length = XGetPointerMapping(dpy, map, 64); XSetPointerMapping(dpy, map, map_length); // SetModifierMapping // GetModifierMapping XModifierKeymap *modmap = XGetModifierMapping(dpy); XSetModifierMapping(dpy, modmap); // NoOperation XNoOp(dpy); for(;;) { XEvent e; XNextEvent(dpy, &e); std::cout << "Got an event of type " << e.type << std::endl; } }