/***************************** * * Exececute the dialog box procedure * Returns when a button is pushed. * return value is the ID of the button * ****************************/ void ShowDlg(t_dlg *dlg) { int i; t_dlgitem *dlgitem; XMapWindow(dlg->x11->disp, dlg->win.self); XMapSubwindows(dlg->x11->disp, dlg->win.self); for (i = 0; (i < dlg->nitem); i++) { LightBorder(dlg->x11->disp, dlg->dlgitem[i]->win.self, dlg->bg); } XSetForeground(dlg->x11->disp, dlg->x11->gc, dlg->x11->fg); for (i = 0; (i < dlg->nitem); i++) { dlgitem = dlg->dlgitem[i]; if ((dlgitem->type == edlgBN) && (dlgitem->u.button.bDefault)) { PushMouse(dlg->x11->disp, dlgitem->win.self, dlgitem->win.width/2, dlgitem->win.height/2); dlg->bPop = true; break; } } dlg->bGrab = false; }
bool ewmh_manage_window_type_desktop(Window win) { Atom *atom, rf; int f; unsigned long n, il, i; unsigned char *data = NULL; bool is_desktop = false; if(XGetWindowProperty(W->dpy, win, W->net_atom[net_wm_window_type], 0L, 0x7FFFFFFF, False, XA_ATOM, &rf, &f, &n, &il, &data) == Success && n) { atom = (Atom*)data; for(i = 0; i < n; ++i) { /* If it is a _NET_WM_WINDOW_TYPE_DESKTOP window */ if(atom[i] == W->net_atom[net_wm_window_type_desktop]) { /* map it, but don't manage it */ XMapWindow(W->dpy, win); XMapSubwindows(W->dpy, win); is_desktop = true; break; } } XFree(data); } return is_desktop; }
int InitMoveWindows(XParms xp, Parms p, int reps) { int i = 0; rows = (p->objects + MAXCOLS - 1) / MAXCOLS; x_offset = 0; y_offset = 0; delta1 = 1; children = (Window *) malloc (p->objects*sizeof (Window)); positions = (XPoint *) malloc(p->objects*sizeof(XPoint)); xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects); ymax = rows * (CHILDSIZE+CHILDSPACE); for (i = 0; i != p->objects; i++) { positions[i].x = (CHILDSIZE+CHILDSPACE) * (i/rows) + CHILDSPACE/2; positions[i].y = (CHILDSIZE+CHILDSPACE) * (i%rows) + CHILDSPACE/2; children[i] = XCreateSimpleWindow(xp->d, xp->w, positions[i].x, positions[i].y, CHILDSIZE, CHILDSIZE, 0, xp->foreground, xp->foreground); } if (p->special) XMapSubwindows (xp->d, xp->w); return reps; }
void setup_gl(void) { if (direct && !glXIsDirect(dpy, context)) warn("Server doesn't support direct rendering! Falling back to indirect.\n"); direct = glXIsDirect(dpy, context); check_gl(__LINE__); if (direct) info("Using direct rendering\n"); else info("Using indirect rendering\n"); glEnable(GL_TEXTURE_RECTANGLE_ARB); check_gl(__LINE__); //glDrawBuffer(GL_BACK); check_gl(__LINE__); *(void**) (&glXQueryDrawableProc) = glXGetProcAddress((GLubyte*)"glXQueryDrawable"); *(void**) (&glXBindTexImageProc) = glXGetProcAddress((GLubyte*)"glXBindTexImageEXT"); *(void**) (&glXReleaseTexImageProc) = glXGetProcAddress((GLubyte*)"glXReleaseTexImageEXT"); if (glXQueryDrawableProc == NULL) die(1, "No glXQueryDrawableProc\n"); if (glXBindTexImageProc == NULL) die(1, "No glXBindTexImageProc\n"); if (glXQueryDrawableProc == NULL) die(1, "No glXReleaseTexImageProc\n"); XMapSubwindows(dpy, overlay); info("Defined viewport as %d, %d (ratio = %g)\n", width, height, ratio); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glOrtho(0, width, height, 0, -2, 2); glMatrixMode(GL_MODELVIEW); //glOrtho(-1.0f, +1.0f, -1.0f*ratio, +1.0f*ratio, 1e-2f, 1e+4f); //for_windows(root, &print); //for_windows(root, &add); }
int main(int argc, char *argv[]) { t_x11 *x11; t_sc *sc; char *fn; x11 = GetX11(&argc, argv); if (argc > 1) { fn = argv[1]; } else { fn = "/usr/lib/X11/rgb.txt"; } if (!gmx_fexist(fn)) { fprintf(stderr, "Usage: %s rgb.txt\n", argv[0]); fprintf(stderr, "rgb.txt is usually somewhere in your X windows directories.\n"); exit(1); } sc = init_sc(x11, x11->root, fn); XMapWindow(x11->disp, sc->wd.self); XMapSubwindows(x11->disp, sc->wd.self); x11->MainLoop(x11); x11->CleanUp(x11); return 0; }
void show_menu(t_x11 *x11,t_menu *m,int x,int y,bool bGrab) { XMoveWindow(x11->disp,m->wd.self,x,y); m->bGrabbed=bGrab; XMapWindow(x11->disp,m->wd.self); XMapSubwindows(x11->disp,m->wd.self); }
void redecorateVolumes() { ASVolumeCanvasPlacement placement; int width, height; placement.vertical = get_flags(Config->flags, ASMOUNT_Vertical); placement.tileWidth = DEFAULT_TILE_WIDTH; placement.tileHeight = DEFAULT_TILE_HEIGHT; placement.currPos = 0; iterate_asbidirlist (AppState.volumes, redecorateVolume, &placement, NULL, False); XMapSubwindows (dpy, AppState.mainCanvas->w); width = placement.tileWidth; height = placement.tileHeight; if (placement.vertical) height = placement.currPos; else width = placement.currPos; setHints (width, height); /* setHints must happen first */ show_progress ( "resizing main canvas to %dx%d", width, height); resize_canvas (AppState.mainCanvas, width, height); ASSync (False); }
void autohide_show(void *p) { Panel *panel = (Panel *)p; stop_autohide_timeout(panel); panel->is_hidden = 0; XMapSubwindows(server.display, panel->main_win); // systray windows set_panel_window_geometry(panel); refresh_systray = TRUE; // ugly hack, because we actually only need to call XSetBackgroundPixmap panel_refresh = TRUE; }
void MapMenu(Menu *menu,int x, int y) { activemen=menu; menu->x=x; menu->y=y; XMapSubwindows(disp,menu->win); XMoveWindow(disp,menu->win,x,y); XMapRaised(disp,menu->win); }
void toolbar_client_show(Client *c) { Wm *w = c->wm; long win_state; c->mapped = True; if (w->stack_top_app && (w->stack_top_app->flags & CLIENT_FULLSCREEN_FLAG)) main_client_manage_toolbars_for_fullscreen(c, True); win_state = client_get_state(c); if (win_state == WithdrawnState) /* initial show() state */ { client_set_state(c,NormalState); wm_update_layout(c->wm, c, - c->height); } else if (win_state == IconicState) /* minimised, set maximised */ { client_set_state(c,NormalState); /* Make sure desktop flag is unset */ c->flags &= ~CLIENT_IS_MINIMIZED; wm_update_layout(c->wm, c, -(c->height - toolbar_win_offset(c))); if (c->flags & CLIENT_TITLE_HIDDEN_FLAG) { c->x = wm_get_offsets_size(c->wm, WEST, NULL, False); } else { c->x = theme_frame_defined_width_get(w->mbtheme, FRAME_UTILITY_MAX ) + wm_get_offsets_size(c->wm, WEST, NULL, False); c->y = c->y - ( c->height - toolbar_win_offset(c)); } /* destroy buttons so they get recreated ok */ client_buttons_delete_all(c); toolbar_client_move_resize(c); toolbar_client_redraw(c, False); } stack_move_client_above_type(c, MBCLIENT_TYPE_APP|MBCLIENT_TYPE_DESKTOP); XMapSubwindows(w->dpy, c->frame); XMapWindow(w->dpy, c->frame); comp_engine_client_show(w, c); }
/* * W_MapSubviews- * maps all children of the current view that where already realized. */ void W_MapSubviews(W_View * view) { XMapSubwindows(view->screen->display, view->window); XFlush(view->screen->display); view = view->childrenList; while (view) { view->flags.mapped = 1; view->flags.mapWhenRealized = 0; view = view->nextSister; } }
void setFuncSubWin(){ int i; for(i=0;i<MAX_FUNC;i++){ XUnmapWindow(dis,func_sub_win[i]); } XMapWindow(dis,func_sub_win[state]); if(state==SQUARE||state==CIRCLE){ XMapSubwindows( dis, func_sub_win[state]); } }
void dialog_client_show(Client *c) { Wm *w = c->wm; Client *highest_client = NULL; MBList *transient_list = NULL, *list_item = NULL; dbg("%s() called for %s\n", __func__, c->name); if (!c->mapped) { if (c->flags & CLIENT_IS_MINIMIZED) { Client *p = NULL; client_set_state(c, NormalState); c->flags &= ~CLIENT_IS_MINIMIZED; /* Make sure any transients are un minimized too */ stack_enumerate(w, p) if (p->trans == c) { p->show(p); XMapSubwindows(w->dpy, p->frame); XMapWindow(w->dpy, p->frame); } if (c->flags & CLIENT_IS_MODAL_FLAG) c->wm->n_modals_present++; } if (c->win_modal_blocker) { XMapWindow(w->dpy, c->win_modal_blocker); dbg("%s() blocker win mapped for '%s'\n", __func__, c->name); } /* Set flag below to delay actual mapping of window * till *after* we've synced the stack. This hacky * solution avoids problem of dialogs mapping for * clients below and causing flicker. * * Note could still cause issues with transients and remmapping * them if minimised.. */ c->flags |= CLIENT_DELAY_MAPPING; }
int main(int argc, char *argv[]) { const char *desc[] = { "[TT]g_xrama[tt] shows a Ramachandran movie, that is, it shows", "the Phi/Psi angles as a function of time in an X-Window.[PAR]" "Static Phi/Psi plots for printing can be made with [TT]g_rama[tt].[PAR]", "Some of the more common X command line options can be used:[BR]", "[TT]-bg[tt], [TT]-fg[tt] change colors, [TT]-font fontname[tt], changes the font." }; output_env_t oenv; t_x11 *x11; t_topology *ramatop; t_app *app; t_filenm fnm[] = { { efTRX, "-f", NULL, ffREAD }, { efTPX, NULL, NULL, ffREAD } }; #define NFILE asize(fnm) CopyRight(stderr, argv[0]); parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm, 0, NULL, asize(desc), desc, 0, NULL, &oenv); if ((x11 = GetX11(&argc, argv)) == NULL) { fprintf(stderr, "Can't open display, set your DISPLAY environment variable\n"); exit(1); } XSetForeground(x11->disp, x11->gc, x11->fg); app = init_app(x11, argc, argv); ramatop = init_rama(oenv, ftp2fn(efTRX, NFILE, fnm), ftp2fn(efTPX, NFILE, fnm), app->xr, 3); mk_gly(app); XMapWindow(x11->disp, app->wd.self); XMapSubwindows(x11->disp, app->wd.self); x11->MainLoop(x11); x11->CleanUp(x11); thanx(stderr); return 0; }
int main(int argc, char *argv[]) { t_x11 *x11; t_sc *sc; char *fn; x11=GetX11(&argc,argv); if (argc > 1) fn=argv[1]; else fn="/usr/lib/X11/rgb.txt"; sc=init_sc(x11,x11->root,fn); XMapWindow(x11->disp,sc->wd.self); XMapSubwindows(x11->disp,sc->wd.self); x11->MainLoop(x11); x11->CleanUp(x11); }
int InitCircWindows(XParms xp, Parms p, int reps) { int i; int pos; int color; children = (Window *) malloc (p->objects * sizeof (Window)); for (i = 0; i != p->objects; i++) { pos = i % STACK; color = (i & 1 ? xp->foreground : xp->background); children[i] = XCreateSimpleWindow (xp->d, xp->w, pos*CHILDSIZE/4 + (i/STACK)*2*CHILDSIZE, pos*CHILDSIZE/4, CHILDSIZE, CHILDSIZE, 0, color, color); } if (p->special) XMapSubwindows (xp->d, xp->w); return reps; }
int main(int argc, char *argv[]) { const char *desc[] = { "[TT]highway[tt] is the GROMCAS highway simulator. It is an X-windows", "gadget that shows a (periodic) Autobahn with a user defined", "number of cars. Fog can be turned on or off to increase the", "number of crashes. Nice for a background CPU-eater. A sample", "input file is in [TT]$GMXDATA/top/highway.dat[tt]" }; output_env_t oenv; t_x11 *x11; t_xhighway *xhw; t_filenm fnm[] = { { efDAT, "-f", "highway", ffREAD } }; #define NFILE asize(fnm) CopyRight(stderr, argv[0]); parse_common_args(&argc, argv, 0, NFILE, fnm, 0, NULL, asize(desc), desc, 0, NULL, &oenv); if ((x11 = GetX11(&argc, argv)) == NULL) { fprintf(stderr, "Can't connect to X Server.\n" "Check your DISPLAY environment variable\n"); exit(1); } xhw = GetXHW(x11, opt2fn("-f", NFILE, fnm)); XMapWindow(x11->disp, xhw->main.self); XMapSubwindows(x11->disp, xhw->main.self); x11->MainLoop(x11); x11->CleanUp(x11); thanx(stderr); return 0; }
void autohide_show(void* p) { Panel* panel = p; stop_autohide_timeout(panel); panel->is_hidden = 0; if (panel_strut_policy == STRUT_FOLLOW_SIZE) update_strut(p); XMapSubwindows(server.dsp, panel->main_win); // systray windows if (panel_horizontal) { if (panel_position & TOP) XResizeWindow(server.dsp, panel->main_win, panel->area.width, panel->area.height); else XMoveResizeWindow(server.dsp, panel->main_win, panel->posx, panel->posy, panel->area.width, panel->area.height); } else { if (panel_position & LEFT) XResizeWindow(server.dsp, panel->main_win, panel->area.width, panel->area.height); else XMoveResizeWindow(server.dsp, panel->main_win, panel->posx, panel->posy, panel->area.width, panel->area.height); } refresh_systray = 1; // ugly hack, because we actually only need to call XSetBackgroundPixmap panel_refresh = 1; }
void show_but(t_x11 *x11, t_butbox *bbox) { XMapWindow(x11->disp, bbox->wd.self); XMapSubwindows(x11->disp, bbox->wd.self); }
int main( int argc , char *argv[] ){ Display *display; Window window; Window pen_window[5]; Window color_window[5]; GC gc; char title[] = "Paint"; char icon_title[] = "Paint"; unsigned long background; unsigned long foreground; int button_size=40; char *colors[]={ "rgb:00/00/00", "rgb:ff/00/00", "rgb:00/ff/00", "rgb:00/00/ff", "rgb:ff/ff/00", }; int current_pen=2; unsigned long current_color=0; int x0,y0,x1,y1; int i; display = XOpenDisplay(NULL); background = WhitePixel(display,0); foreground = BlackPixel(display,0); window = XCreateSimpleWindow(display, DefaultRootWindow(display), 0,0,500,400, 0,0,background); XSetStandardProperties(display,window,title,icon_title, None,argv,argc,NULL); /* GC を生成し、各種設定を行う */ gc = XCreateGC(display,window,0,0); XSetBackground(display,gc,background); XSetForeground(display,gc,current_color); XSetLineAttributes(display,gc,current_pen, LineSolid,CapRound,JoinMiter); /* メインウィンドウのイベントマスクを設定 */ XSelectInput(display,window, ExposureMask | ButtonPressMask | ButtonMotionMask); /* ペンサイズ・色選択ウィンドウを作成 */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ pen_window[i] = XCreateSimpleWindow(display,window, 10,(button_size+10)*i+30, button_size,button_size, 1,mycolor(display,"rgb:aa/aa/aa"), mycolor(display,"rgb:ee/ee/ee")); color_window[i] = XCreateSimpleWindow(display,window, 500-10-button_size,(button_size+10)*i+30, button_size,button_size, 1,mycolor(display,"rgb:aa/aa/aa"), mycolor(display,colors[i])); XSelectInput(display,pen_window[i], ButtonPressMask | EnterWindowMask | LeaveWindowMask ); XSelectInput(display,color_window[i], ButtonPressMask | EnterWindowMask | LeaveWindowMask ); } /* 全てのウィンドウをマップ */ XMapWindow(display,window); XMapSubwindows(display,window); while (1){ XEvent event; XNextEvent(display,&event); switch ( event.type ){ case Expose: /* 再描画 */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ int pen_size = i*3+2; /* ペンサイズウィンドウを再描画 */ XSetForeground(display,gc,foreground); XFillArc(display,pen_window[i],gc, button_size/2-pen_size/2,button_size/2-pen_size/2, pen_size,pen_size,0,360*64); } break; case EnterNotify: /* ウィンドウにポインタが入った */ XSetWindowBorder(display,event.xany.window, mycolor(display,"black")); break; case LeaveNotify: /* ウィンドウからポインタが出た */ XSetWindowBorder(display,event.xany.window, mycolor(display,"rgb:aa/aa/aa")); break; case MotionNotify: /* ボタンを押しながらマウスが動いた */ x1 = event.xbutton.x; y1 = event.xbutton.y; XDrawLine(display,window,gc,x0,y0,x1,y1); x0 = x1; y0 = y1; break; case ButtonPress: /* ボタンが押された */ /* キャンバス上で押された? */ if ( event.xany.window == window ){ x0 = event.xbutton.x; y0 = event.xbutton.y; XDrawLine(display,window,gc,x0,y0,x0,y0); break; } /* ペンサイズ/色選択ウィンドウ上で押された? */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ /* ペンサイズを変更 */ if ( event.xany.window == pen_window[i] ){ current_pen = i*3+2; XSetLineAttributes(display,gc,current_pen, LineSolid,CapRound,JoinMiter); break; } /* 色を変更 */ if ( event.xany.window == color_window[i] ){ current_color = mycolor(display,colors[i]); XSetForeground(display,gc,current_color); break; } } break; } } }
int main(int argc,char **argv) { Display *dpy; Window w,quit,input,buttons[16],draw,clear; Window sinW,cosW,tanW; Window graph_list; Window root; int screen,xPoint,yPoint,l = 0,count = 0,yoko = 0,tate = 0,equCount = 0,equFlag = 0,value,equLength; float coef[10]; int coefCount = 0; int mustOpe = 0,forceDraw = 0; int colorCount = 0; int coefX,coefY; // For Graph List int graph_number = 0,graph_draw = 0,graph_equ_length = 0; char graph_equ[100]; char formula[255],string[255]; char buttonString[16] = {'1','2','3','+','4','5','6','-','7','8','9','*','0','x','=','/'}; char equ[255]; char text[100]; char color_name[9][15] = {"red","green","blue","yellow","magenta","cyan","SeaGreen","PowderBlue","black"}; unsigned long black, white; GC gc; KeySym key; XColor c0[9],c1[9]; XEvent e; Colormap cmap; dpy = XOpenDisplay(""); root = DefaultRootWindow (dpy); screen = DefaultScreen (dpy); white = WhitePixel (dpy, screen); black = BlackPixel (dpy, screen); cmap = DefaultColormap(dpy,0); for(count = 0;count < 9;count++) XAllocNamedColor(dpy,cmap,&color_name[count][0],&c1[count],&c0[count]); /*------------- Window Setting -------------------*/ w = XCreateSimpleWindow(dpy, root, 100, 100, WIDTH, HIGHT, BORDER, black, white); quit = XCreateSimpleWindow(dpy,w,10,3,30,12,BORDER,black,white); input = XCreateSimpleWindow(dpy,w,510,10,260,480,BORDER,black,white); draw = XCreateSimpleWindow(dpy,w,520,30,40,20,BORDER,black,white); clear = XCreateSimpleWindow(dpy,w,580,30,40,20,BORDER,black,white); sinW = XCreateSimpleWindow(dpy,w,630,30,20,10,BORDER,black,white); cosW = XCreateSimpleWindow(dpy,w,660,30,20,10,BORDER,black,white); tanW = XCreateSimpleWindow(dpy,w,690,30,20,10,BORDER,black,white); graph_list = XCreateSimpleWindow(dpy,w,800,10,170,480,BORDER,black,white); for(count = 0;count < 16;count++){ buttons[count] = XCreateSimpleWindow(dpy,w,550+tate*50,200+yoko*80,30,30,BORDER,black,white); tate++; if((count+1) % 4 == 0){ yoko++; tate = 0; } } gc = XCreateGC(dpy, w, 0, NULL); /* ------- Select Input --------------*/ XSelectInput(dpy,w,ButtonPressMask | ButtonReleaseMask | KeyPressMask); XSelectInput(dpy,quit,ButtonPressMask); XSelectInput(dpy,input,ButtonPressMask); XSelectInput(dpy,draw,ButtonPressMask); XSelectInput(dpy,clear,ButtonPressMask); XSelectInput(dpy,sinW,ButtonPressMask); XSelectInput(dpy,cosW,ButtonPressMask); XSelectInput(dpy,tanW,ButtonPressMask); for(count = 0;count < 16;count++){ XSelectInput(dpy,buttons[count],ButtonPressMask); } for(count = 0;count < 10;count++) coef[count] = 0; count = 0; XMapWindow(dpy, w); XMapSubwindows(dpy,w); while(1){ //Event XNextEvent(dpy,&e); switch (e.type){ case KeyPress: printf("keycode=%d \n",e.xkey.keycode); if(e.xkey.keycode == 24) return 0; case ButtonPress : while(count < 16){ if(e.xany.window == buttons[count]){ if(mustOpe == 1 && (count+1) % 4 != 0){ forceDraw = 1; printf("Force!\n"); break; }else{ mustOpe = 0; } XDrawString(dpy,input,gc,35+l,80,&buttonString[count],1); l += 10; equ[equCount] = buttonString[count]; equCount++; if((count+1) % 4 == 0){ equFlag = 1; } if(count == 13){ coef[coefCount] = cast(equ,strlen(equ)); equFlag = 2; forceDraw = 1; }else if(count == 14){ forceDraw = 1; } } count++; } if(e.xany.window == sinW || e.xany.window == cosW || e.xany.window == tanW){ if(e.xany.window == sinW){ XSetForeground(dpy,gc,c1[colorCount].pixel); colorCount++; graph_draw = 1; for(count = 0;count < 480;count++){ XDrawPoint(dpy,w,gc,(count+10),-50*sin((count-240)/50.0) + 250); } printf("Sin\n"); sprintf(graph_equ,"%d : Y = sin(x)",graph_number + 1); }else if(e.xany.window == cosW){ XSetForeground(dpy,gc,c1[colorCount].pixel); colorCount++; graph_draw = 1; for(count = 0;count < 480;count++){ XDrawPoint(dpy,w,gc,(count+10),-100*cos((count-240)/100.0) + 250); } sprintf(graph_equ,"%d : Y = cos(x)",graph_number + 1); }else if(e.xany.window == tanW){ XSetForeground(dpy,gc,c1[colorCount].pixel); colorCount++; graph_draw = 1; for(count = 0;count < 480;count++){ XDrawPoint(dpy,w,gc,(count+10),-100*tan((count-240)/100.0) + 250); } sprintf(graph_equ,"%d : Y = tan(x)",graph_number + 1); } XDrawString(dpy,graph_list,gc,10,(graph_number+1)*10,graph_equ,strlen(graph_equ)); graph_number++; } XSetForeground(dpy,gc,c1[8].pixel); if(e.xany.window == quit){ printf("Exit!\n"); return 0; } if(e.xany.window == clear){ printf("Clear!\n"); XClearWindow(dpy,w); XClearWindow(dpy,input); XClearWindow(dpy,graph_list); graph_number = 0; l = 0; equCount = 0; equLength = strlen(equ); memset(equ,'\0',equLength); } if(e.xany.window == draw || forceDraw == 1){ XSetForeground(dpy,gc,c1[colorCount].pixel); colorCount++; graph_draw = 1; printf("Draw!\n"); switch(equFlag){ case 0: value = atoi(equ); XClearWindow(dpy,input); sprintf(text,"%d",value); XDrawLine(dpy,w,gc,10,250-value,490,250-value); sprintf(graph_equ,"%d : Y = %d",graph_number + 1,value); break; case 1: value = cast(equ,strlen(equ)); XClearWindow(dpy,input); sprintf(text,"%d",value); XDrawLine(dpy,w,gc,10,250-value,490,250-value); sprintf(graph_equ,"%d : Y = %d",graph_number + 1,value); break; case 2: XClearWindow(dpy,input); sprintf(text,"%fx",coef[coefCount]); for(count = 0;count < 480;count++){ coefX = count + 10; coefY = -((count-240) * coef[coefCount]) + 250; XDrawPoint(dpy,w,gc,coefX,coefY); coefX = coefY = 0; } forceDraw = mustOpe = 0; sprintf(graph_equ,"%d : Y = %fx",graph_number + 1,coef[coefCount]); for(count = 0;count < 10;count++) coef[count] = 0; break; default: break; } equFlag = l = equCount = mustOpe = 0; equLength = strlen(equ); memset(equ,'\0',equLength); if(graph_draw){ XDrawString(dpy,graph_list,gc,10,(graph_number+1)*10,graph_equ,strlen(graph_equ)); graph_number++; } XSetForeground(dpy,gc,c1[8].pixel); XDrawString(dpy,input,gc,160,140,text,strlen(text)); } XSetForeground(dpy,gc,c1[8].pixel); /*----------- Basic Drawing -------------*/ XDrawString(dpy,quit,gc,4,10,"Exit",4); XDrawString(dpy,draw,gc,4,10,"Draw!",5); XDrawString(dpy,clear,gc,4,10,"Clear!",6); XDrawString(dpy,sinW,gc,2,8,"sin",3); XDrawString(dpy,cosW,gc,2,8,"cos",3); XDrawString(dpy,tanW,gc,2,8,"tan",3); XDrawString(dpy,w,gc,491,250,"X",1); XDrawString(dpy,w,gc,250,8,"Y",1); XDrawString(dpy,input,gc,15,80,"Y =",3); XDrawString(dpy,input,gc,70,140,"Last Answer:",12); XDrawLine(dpy,w,gc,10,250,490,250); XDrawLine(dpy,w,gc,250,10,250,490); tate = yoko = 0; graph_draw = 0; graph_equ_length = strlen(graph_equ); memset(graph_equ,"\0",graph_equ_length); if(colorCount == 8) colorCount = 0; for(count = 0;count < 16;count++){ XDrawString(dpy,buttons[count],gc,13,20,&buttonString[count],1); tate++; if((count+1) % 4 == 0){ yoko++; tate = 0; } } count = forceDraw = 0; /*-----------------------------------------*/ break; } } }
void show_logo(t_x11 *x11, t_logo *logo) { XMapWindow(x11->disp, logo->wd.self); XMapSubwindows(x11->disp, logo->wd.self); }
// initialisation d'une fenetre mail, avec du message void init_mail_win_graphique(int num_msg){ tab_mails[num_msg].mail_fen = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, WIDTH_MAIL_WIN, HEIGHT_MAIL_WIN, BORDER, BlackPixel(dpy,DefaultScreen(dpy)), color_fond_de_fen.pixel); tab_mails[num_msg].mail_contenu_fen= XCreateSimpleWindow(dpy, tab_mails[num_msg].mail_fen, MARGIN, MARGIN, WIDTH_MAIL_CONTENU, HEIGHT_MAIL_CONTENU, BORDER/2, BlackPixel(dpy,DefaultScreen(dpy)), WhitePixel(dpy,DefaultScreen(dpy))); // faire la requete char * contenu_mail= (char*) malloc(sizeof(char) * 4096); retr_handler(num_msg, contenu_mail); if(strcmp(contenu_mail, "") == 0){ XDrawString(dpy, main_fen, DefaultGC(dpy,DefaultScreen(dpy)), 10, 20, "Mail multipart non conforme", strlen("Mail multipart non conforme") ); besoin_msg_erreur=true; return; } int font_direction, font_ascent, font_descent; XCharStruct text_structure; char string_etal[]= "lj"; // pour avoir la taille max d'une ligne XTextExtents(font, string_etal, strlen(string_etal), &font_direction, &font_ascent, &font_descent, &text_structure); int width_max= WIDTH_MAIL_CONTENU; int width_tmp=0; int nb_ligne=0; tab_mails[num_msg].height_ligne=font_descent + font_ascent; // traiter le text tab_mails[num_msg].contenu_mail_traiter= (char*) malloc(sizeof(char) * 4096); tab_mails[num_msg].contenu_mail_traiter[0]='\0'; char* line; int cmpt_total=0; for(line= strtok(contenu_mail, "\n") ; line != NULL; line= strtok(NULL, "\n")){ // on lit le texte ligne par ligne nb_ligne++; width_tmp=0; char* debutmot=line; int cmpt=0; int debut=0; while(debutmot[cmpt] != '\n' && debutmot[cmpt] != '\0' ){ if(debutmot[cmpt] == '\r' ){ debutmot[cmpt] = ' '; } else{ if(debutmot[cmpt] == ' ' ){ XTextExtents(font, debutmot+debut, cmpt-debut+1, &font_direction, &font_ascent, &font_descent, &text_structure); if(width_tmp + text_structure.width> width_max){ strcat(tab_mails[num_msg].contenu_mail_traiter, "\n"); width_tmp=0; nb_ligne++; } else{ width_tmp+= text_structure.width; } strncat(tab_mails[num_msg].contenu_mail_traiter, debutmot+debut, cmpt-debut+1); debut+=(cmpt-debut+1); } } cmpt++; } if(cmpt-debut > 1){ XTextExtents(font, debutmot+debut, cmpt-debut+1, &font_direction, &font_ascent, &font_descent, &text_structure); if(width_tmp + text_structure.width> width_max){ strcat(tab_mails[num_msg].contenu_mail_traiter, "\n"); width_tmp=0; nb_ligne++; } else{ width_tmp+= text_structure.width; } strncat(tab_mails[num_msg].contenu_mail_traiter, debutmot+debut, cmpt-debut); debut+=(cmpt-debut+1); cmpt++; } strcat(tab_mails[num_msg].contenu_mail_traiter, "\n"); cmpt_total+= cmpt; } free(contenu_mail); tab_mails[num_msg].height_contenu_inter= nb_ligne * (tab_mails[num_msg].height_ligne + BORDER) + MARGIN; // faire une fenetre adapté tab_mails[num_msg].mail_contenu_inter= XCreateSimpleWindow(dpy, tab_mails[num_msg].mail_contenu_fen, 0, 0, WIDTH_MAIL_CONTENU, tab_mails[num_msg].height_contenu_inter, 0, BlackPixel(dpy,DefaultScreen(dpy)), WhitePixel(dpy,DefaultScreen(dpy))); tab_mails[num_msg].quit_button= XCreateSimpleWindow(dpy, tab_mails[num_msg].mail_fen, MARGIN, HEIGHT_MAIL_WIN -MARGIN - HEIGHT_BUTTON, WIDTH_BUTTON, HEIGHT_BUTTON, BORDER, BlackPixel(dpy,DefaultScreen(dpy)), color_fond.pixel); tab_mails[num_msg].slide_fond= XCreateSimpleWindow(dpy, tab_mails[num_msg].mail_fen, WIDTH_MAIL_WIN - MARGIN - WIDTH_FOND_SLIDE, MARGIN, WIDTH_FOND_SLIDE, HEIGHT_MAIL_CONTENU, BORDER/2, BlackPixel(dpy,DefaultScreen(dpy)), WhitePixel(dpy,DefaultScreen(dpy))); tab_mails[num_msg].slider= XCreateSimpleWindow(dpy, tab_mails[num_msg].slide_fond, 0, 0, WIDTH_SLIDER, HEIGHT_SLIDER, 0, BlackPixel(dpy,DefaultScreen(dpy)), color_focus.pixel); tab_mails[num_msg].posslider=0; tab_mails[num_msg].gc_glob=XCreateGC(dpy, tab_mails[num_msg].mail_fen, 0, NULL); XSetForeground(dpy, tab_mails[num_msg].gc_glob, BlackPixel(dpy,DefaultScreen(dpy))); XSetBackground(dpy, tab_mails[num_msg].gc_glob, color_fond.pixel); XSelectInput(dpy, tab_mails[num_msg].quit_button, ButtonPressMask | ExposureMask); XSelectInput(dpy, tab_mails[num_msg].mail_contenu_inter, ExposureMask); XSelectInput(dpy, tab_mails[num_msg].slider, PointerMotionMask | ButtonReleaseMask | ButtonPressMask | ExposureMask); XDefineCursor(dpy, tab_mails[num_msg].quit_button, cursor); XMapWindow(dpy, tab_mails[num_msg].mail_fen); XMapSubwindows(dpy, tab_mails[num_msg].mail_fen); XMapWindow(dpy, tab_mails[num_msg].mail_contenu_fen); XMapSubwindows(dpy, tab_mails[num_msg].mail_contenu_fen); XMapWindow(dpy, tab_mails[num_msg].slide_fond); XMapSubwindows(dpy, tab_mails[num_msg].slide_fond); XFlush(dpy); tab_mails[num_msg].init_window=true; }
int XMenuActivate( register Display *display, /* Display to put menu on. */ register XMenu *menu, /* Menu to activate. */ int *p_num, /* Pane number selected. */ int *s_num, /* Selection number selected. */ int x_pos, /* X coordinate of menu position. */ int y_pos, /* Y coordinate of menu position. */ unsigned int event_mask, /* Mouse button event mask. */ char **data, /* Pointer to return data value. */ void (*help_callback) (char const *, int, int)) /* Help callback. */ { int status; /* X routine call status. */ int orig_x; /* Upper left menu origin X coord. */ int orig_y; /* Upper left menu origin Y coord. */ int ret_val; /* Return value. */ register XMPane *p_ptr; /* Current XMPane. */ register XMPane *event_xmp; /* Event XMPane pointer. */ register XMPane *cur_p; /* Current pane. */ register XMSelect *cur_s; /* Current selection. */ XMWindow *event_xmw; /* Event XMWindow pointer. */ XEvent event; /* X input event. */ XEvent peek_event; /* X input peek ahead event. */ Bool selection = False; /* Selection has been made. */ Bool forward = True; /* Moving forward in the pane list. */ Window root, child; int root_x, root_y, win_x, win_y; unsigned int mask; KeySym keysym; /* * Define and allocate a foreign event queue to hold events * that don't belong to XMenu. These events are later restored * to the X event queue. */ typedef struct _xmeventque { XEvent event; struct _xmeventque *next; } XMEventQue; XMEventQue *feq = NULL; /* Foreign event queue. */ XMEventQue *feq_tmp; /* Foreign event queue temporary. */ /* * If there are no panes in the menu then return failure * because the menu is not initialized. */ if (menu->p_count == 0) { _XMErrorCode = XME_NOT_INIT; return(XM_FAILURE); } /* * Find the desired current pane. */ cur_p = _XMGetPanePtr(menu, *p_num); if (cur_p == NULL) { return(XM_FAILURE); } cur_p->activated = cur_p->active; /* * Find the desired current selection. * If the current selection index is out of range a null current selection * will be assumed and the cursor will be placed in the current pane * header. */ cur_s = _XMGetSelectionPtr(cur_p, *s_num); /* * Compute origin of menu so that cursor is in * Correct pane and selection. */ _XMTransToOrigin(display, menu, cur_p, cur_s, x_pos, y_pos, &orig_x, &orig_y); menu->x_pos = orig_x; /* Store X and Y coords of menu. */ menu->y_pos = orig_y; if (XMenuRecompute(display, menu) == XM_FAILURE) { return(XM_FAILURE); } /* * Flush the window creation queue. * This batches all window creates since lazy evaluation * is more efficient than individual evaluation. * This routine also does an XFlush(). */ if (_XMWinQueFlush(display, menu, cur_p, cur_s) == _FAILURE) { return(XM_FAILURE); } /* * Make sure windows are in correct order (in case we were passed * an already created menu in incorrect order.) */ for(p_ptr = menu->p_list->next; p_ptr != cur_p; p_ptr = p_ptr->next) XRaiseWindow(display, p_ptr->window); for(p_ptr = menu->p_list->prev; p_ptr != cur_p->prev; p_ptr = p_ptr->prev) XRaiseWindow(display, p_ptr->window); /* * Make sure all selection windows are mapped. */ for ( p_ptr = menu->p_list->next; p_ptr != menu->p_list; p_ptr = p_ptr->next ){ XMapSubwindows(display, p_ptr->window); } /* * Synchronize the X buffers and the event queue. * From here on, all events in the queue that don't belong to * XMenu are sent back to the application via an application * provided event handler or discarded if the application has * not provided an event handler. */ XSync(display, 0); /* * Grab the mouse for menu input. */ status = XGrabPointer( display, menu->parent, True, event_mask, GrabModeAsync, GrabModeAsync, None, menu->mouse_cursor, CurrentTime ); if (status == Success && x_menu_grab_keyboard) { status = XGrabKeyboard (display, menu->parent, False, GrabModeAsync, GrabModeAsync, CurrentTime); if (status != Success) XUngrabPointer(display, CurrentTime); } if (status == _X_FAILURE) { _XMErrorCode = XME_GRAB_MOUSE; return(XM_FAILURE); } /* * Map the menu panes. */ XMapWindow(display, cur_p->window); for (p_ptr = menu->p_list->next; p_ptr != cur_p; p_ptr = p_ptr->next) XMapWindow(display, p_ptr->window); for (p_ptr = cur_p->next; p_ptr != menu->p_list; p_ptr = p_ptr->next) XMapWindow(display, p_ptr->window); XRaiseWindow(display, cur_p->window); /* Make sure current */ /* pane is on top. */ cur_s = NULL; /* Clear current selection. */ /* * Begin event processing loop. */ while (1) { if (wait_func) (*wait_func) (wait_data); XNextEvent(display, &event); /* Get next event. */ switch (event.type) { /* Dispatch on the event type. */ case Expose: event_xmp = (XMPane *)XLookUpAssoc(display, menu->assoc_tab, event.xexpose.window); if (event_xmp == NULL) { /* * If AEQ mode is enabled then queue the event. */ if (menu->aeq) { feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue)); if (feq_tmp == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } feq_tmp->event = event; feq_tmp->next = feq; feq = feq_tmp; } else if (_XMEventHandler) (*_XMEventHandler)(&event); break; } if (event_xmp->activated) { XSetWindowBackground(display, event_xmp->window, menu->bkgnd_color); } else { XSetWindowBackgroundPixmap(display, event_xmp->window, menu->inact_pixmap); } _XMRefreshPane(display, menu, event_xmp); break; case EnterNotify: /* * First wait a small period of time, and see * if another EnterNotify event follows hard on the * heels of this one. i.e., the user is simply * "passing through". If so, ignore this one. */ event_xmw = (XMWindow *)XLookUpAssoc(display, menu->assoc_tab, event.xcrossing.window); if (event_xmw == NULL) break; if (event_xmw->type == SELECTION) { /* * We have entered a selection. */ /* if (XPending(display) == 0) usleep(150000); */ if (XPending(display) != 0) { XPeekEvent(display, &peek_event); if(peek_event.type == LeaveNotify) { break; } } cur_s = (XMSelect *)event_xmw; help_callback (cur_s->help_string, cur_p->serial, cur_s->serial); /* * If the pane we are in is active and the * selection entered is active then activate * the selection. */ if (cur_p->active && cur_s->active > 0) { cur_s->activated = 1; _XMRefreshSelection(display, menu, cur_s); } } else { /* * We have entered a pane. */ /* if (XPending(display) == 0) usleep(150000); */ if (XPending(display) != 0) { XPeekEvent(display, &peek_event); if (peek_event.type == EnterNotify) break; } XQueryPointer(display, menu->parent, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); event_xmp = (XMPane *)XLookUpAssoc(display, menu->assoc_tab, child); if (event_xmp == NULL) break; if (event_xmp == cur_p) break; if (event_xmp->serial > cur_p->serial) forward = True; else forward = False; p_ptr = cur_p; while (p_ptr != event_xmp) { if (forward) p_ptr = p_ptr->next; else p_ptr = p_ptr->prev; XRaiseWindow(display, p_ptr->window); } if (cur_p->activated) { cur_p->activated = False; XSetWindowBackgroundPixmap(display, cur_p->window, menu->inact_pixmap); _XMRefreshPane(display, menu, cur_p); } if (event_xmp->active) event_xmp->activated = True; #if 1 /* * i suspect the we don't get an EXPOSE event when backing * store is enabled; the menu windows content is probably * not drawn in when it should be in that case. * in that case, this is probably an ugly fix! * i hope someone more familiar with this code would * take it from here. -- [email protected]. */ XSetWindowBackground(display, event_xmp->window, menu->bkgnd_color); _XMRefreshPane(display, menu, event_xmp); #endif cur_p = event_xmp; } break; case LeaveNotify: event_xmw = (XMWindow *)XLookUpAssoc( display, menu->assoc_tab, event.xcrossing.window ); if (event_xmw == NULL) break; if(cur_s == NULL) break; /* * If the current selection was activated then * deactivate it. */ if (cur_s->activated) { cur_s->activated = False; _XMRefreshSelection(display, menu, cur_s); } cur_s = NULL; break; case ButtonPress: case ButtonRelease: *p_num = cur_p->serial; /* * Check to see if there is a current selection. */ if (cur_s != NULL) { /* * Set the selection number to the current selection. */ *s_num = cur_s->serial; /* * If the current selection was activated then * we have a valid selection otherwise we have * an inactive selection. */ if (cur_s->activated) { *data = cur_s->data; ret_val = XM_SUCCESS; } else { ret_val = XM_IA_SELECT; } } else { /* * No selection was current. */ ret_val = XM_NO_SELECT; } selection = True; break; case KeyPress: case KeyRelease: keysym = XLookupKeysym (&event.xkey, 0); /* Pop down on C-g and Escape. */ if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0) || keysym == XK_Escape) /* Any escape, ignore modifiers. */ { ret_val = XM_NO_SELECT; selection = True; } break; default: /* * If AEQ mode is enabled then queue the event. */ if (menu->aeq) { feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue)); if (feq_tmp == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } feq_tmp->event = event; feq_tmp->next = feq; feq = feq_tmp; } else if (_XMEventHandler) (*_XMEventHandler)(&event); } /* * If a selection has been made, break out of the event loop. */ if (selection == True) break; } /* * Unmap the menu. */ for ( p_ptr = menu->p_list->next; p_ptr != menu->p_list; p_ptr = p_ptr->next) { XUnmapWindow(display, p_ptr->window); } /* * Ungrab the mouse. */ XUngrabPointer(display, CurrentTime); XUngrabKeyboard(display, CurrentTime); /* * Restore bits under where the menu was if we managed * to save them and free the pixmap. */ /* * If there is a current selection deactivate it. */ if (cur_s != NULL) cur_s->activated = 0; /* * Deactivate the current pane. */ cur_p->activated = 0; XSetWindowBackgroundPixmap(display, cur_p->window, menu->inact_pixmap); /* * Synchronize the X buffers and the X event queue. */ XSync(display, 0); /* * Dispatch any events remaining on the queue. */ while (QLength(display)) { /* * Fetch the next event. */ XNextEvent(display, &event); /* * Discard any events left on the queue that belong to XMenu. * All others are held and then returned to the event queue. */ switch (event.type) { case Expose: case EnterNotify: case LeaveNotify: case ButtonPress: case ButtonRelease: /* * Does this event belong to one of XMenu's windows? * If so, discard it and process the next event. * If not fall through and treat it as a foreign event. */ event_xmp = (XMPane *)XLookUpAssoc( display, menu->assoc_tab, event.xbutton.window ); if (event_xmp != NULL) continue; default: /* * This is a foreign event. * Queue it for later return to the X event queue. */ feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue)); if (feq_tmp == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } feq_tmp->event = event; feq_tmp->next = feq; feq = feq_tmp; } } /* * Return any foreign events that were queued to the X event queue. */ while (feq != NULL) { feq_tmp = feq; XPutBackEvent(display, &feq_tmp->event); feq = feq_tmp->next; free((char *)feq_tmp); } wait_func = 0; /* * Return successfully. */ _XMErrorCode = XME_NO_ERROR; return(ret_val); }
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; } }
/* To call from C, use the routine below - without the extra underscore */ void draw_wave(double * results) { /* Note extra underscore in draw_wave routine - needed for Fortran */ float scale, point, coloratio = 65535.0 / 255.0; int i,j,k,y, zeroaxis, done, myscreen, points[WIDTH]; MYWINDOW base, quit; Font font,font2; GC itemgc,textgc,pointgc,linegc; XColor red,yellow,blue,green,black,white; XEvent myevent; Colormap cmap; KeySym mykey; Display *mydisp; /* Set rgb values for colors */ red.red= (int) (255 * coloratio); red.green= (int) (0 * coloratio); red.blue = (int) (0 * coloratio); yellow.red= (int) (255 * coloratio); yellow.green= (int) (255 * coloratio); yellow.blue= (int) (0 * coloratio); blue.red= (int) (0 * coloratio); blue.green= (int) (0 * coloratio); blue.blue= (int) (255 * coloratio); green.red= (int) (0 * coloratio); green.green= (int) (255 * coloratio); green.blue= (int) (0 * coloratio); black.red= (int) (0 * coloratio); black.green= (int) (0 * coloratio); black.blue= (int) (0 * coloratio); white.red= (int) (255 * coloratio); white.green= (int) (255 * coloratio); white.blue= (int) (255 * coloratio); mydisp = XOpenDisplay(""); if (!mydisp) { fprintf (stderr, "Hey! Either you don't have X or something's not right.\n"); fprintf (stderr, "Guess I won't be showing the graph. No big deal.\n"); exit(1); } myscreen = DefaultScreen(mydisp); cmap = DefaultColormap (mydisp, myscreen); XAllocColor (mydisp, cmap, &red); XAllocColor (mydisp, cmap, &yellow); XAllocColor (mydisp, cmap, &blue); XAllocColor (mydisp, cmap, &black); XAllocColor (mydisp, cmap, &green); XAllocColor (mydisp, cmap, &white); /* Set up for creating the windows */ /* XCreateSimpleWindow uses defaults for many attributes, */ /* thereby simplifying the programmer's work in many cases. */ /* base window position and size */ base.hints.x = 50; base.hints.y = 50; base.hints.width = WIDTH; base.hints.height = HEIGHT; base.hints.flags = PPosition | PSize; base.bordwidth = 5; /* window Creation */ /* base window */ base.window = XCreateSimpleWindow (mydisp, DefaultRootWindow (mydisp), base.hints.x, base.hints.y, base.hints.width, base.hints.height, base.bordwidth, black.pixel, black.pixel); XSetStandardProperties (mydisp, base.window, baseword, baseword, None, NULL, 0, &base.hints); /* quit window position and size (subwindow of base) */ quit.hints.x = 5; quit.hints.y = 450; quit.hints.width = 70; quit.hints.height = 30; quit.hints.flags = PPosition | PSize; quit.bordwidth = 5; quit.window = XCreateSimpleWindow (mydisp, base.window, quit.hints.x, quit.hints.y, quit.hints.width, quit.hints.height, quit.bordwidth, green.pixel, yellow.pixel); XSetStandardProperties (mydisp, quit.window, exitword, exitword, None, NULL, 0, &quit.hints); /* Load fonts */ /* font = XLoadFont (mydisp, "Rom28"); font2 = XLoadFont (mydisp, "Rom17.500"); */ font = XLoadFont (mydisp, "fixed"); font2 = XLoadFont (mydisp, "fixed"); /* GC creation and initialization */ textgc = XCreateGC (mydisp, base.window, 0,0); XSetFont (mydisp, textgc, font); XSetForeground (mydisp, textgc, white.pixel); linegc = XCreateGC (mydisp, base.window, 0,0); XSetForeground (mydisp, linegc, white.pixel); itemgc = XCreateGC (mydisp, quit.window, 0,0); XSetFont (mydisp, itemgc, font2); XSetForeground (mydisp, itemgc, black.pixel); pointgc = XCreateGC (mydisp, base.window, 0,0); XSetForeground (mydisp, pointgc, green.pixel); /* The program is event driven; the XSelectInput call sets which */ /* kinds of interrupts are desired for each window. */ /* These aren't all used. */ XSelectInput (mydisp, base.window, ButtonPressMask | KeyPressMask | ExposureMask); XSelectInput (mydisp, quit.window, ButtonPressMask | KeyPressMask | ExposureMask); /* window mapping -- this lets windows be displayed */ XMapRaised (mydisp, base.window); XMapSubwindows (mydisp, base.window); /* Scale each data point */ zeroaxis = HEIGHT/2; scale = (float)zeroaxis; for(j=0;j<WIDTH;j++) points[j] = zeroaxis - (int)(results[j] * scale); /* Main event loop -- exits when user clicks on "exit" */ done = 0; while (! done) { XNextEvent (mydisp, &myevent); /* Read next event */ switch (myevent.type) { case Expose: if (myevent.xexpose.count == 0) { if (myevent.xexpose.window == base.window) { XDrawString (mydisp, base.window, textgc, 775, 30, "Wave",4); XDrawLine (mydisp, base.window, linegc, 1,zeroaxis,WIDTH, zeroaxis); for (j=1; j<WIDTH; j++) XDrawPoint (mydisp, base.window, pointgc, j, points[j-1]); } else if (myevent.xexpose.window == quit.window) { XDrawString (mydisp, quit.window, itemgc, 12,20, exitword, strlen(exitword)); } } /* case Expose */ break; case ButtonPress: if (myevent.xbutton.window == quit.window) done = 1; break; case KeyPress: /* i = XLookupString (&myevent, text, 10, &mykey, 0); if (i == 1 && text[0] == 'q') done = 1; */ break; case MappingNotify: /* XRefreshKeyboardMapping (&myevent); */ break; } /* switch (myevent.type) */ } /* while (! done) */ XDestroyWindow (mydisp, base.window); XCloseDisplay (mydisp); }
Toolbar::Toolbar(BScreen *scrn) { _screen = scrn; blackbox = _screen->blackbox(); // get the clock updating every minute clock_timer = new bt::Timer(blackbox, this); clock_timer->recurring(True); const ToolbarOptions &options = _screen->resource().toolbarOptions(); const std::string &time_format = options.strftime_format; if (time_format.find("%S") != std::string::npos || time_format.find("%s") != std::string::npos || time_format.find("%r") != std::string::npos || time_format.find("%T") != std::string::npos) { clock_timer_resolution = 1; } else if (time_format.find("%M") != std::string::npos || time_format.find("%R") != std::string::npos) { clock_timer_resolution = 60; } else { clock_timer_resolution = 3600; } hide_timer = new bt::Timer(blackbox, this); hide_timer->setTimeout(blackbox->resource().autoRaiseDelay()); setLayer(options.always_on_top ? StackingList::LayerAbove : StackingList::LayerNormal); hidden = options.auto_hide; new_name_pos = 0; display = blackbox->XDisplay(); XSetWindowAttributes attrib; unsigned long create_mask = CWColormap | CWOverrideRedirect | CWEventMask; attrib.colormap = _screen->screenInfo().colormap(); attrib.override_redirect = True; attrib.event_mask = ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | ExposureMask; frame.window = XCreateWindow(display, _screen->screenInfo().rootWindow(), 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.window, this); attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask; frame.workspace_label = XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.workspace_label, this); frame.window_label = XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.window_label, this); frame.clock = XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.clock, this); frame.psbutton = XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.psbutton, this); frame.nsbutton = XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.nsbutton, this); frame.pwbutton = XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.pwbutton, this); frame.nwbutton = XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, _screen->screenInfo().depth(), InputOutput, _screen->screenInfo().visual(), create_mask, &attrib); blackbox->insertEventHandler(frame.nwbutton, this); frame.base = frame.slabel = frame.wlabel = frame.clk = frame.button = frame.pbutton = None; _screen->addStrut(&strut); reconfigure(); clock_timer->setTimeout(nextTimeout(clock_timer_resolution)); clock_timer->start(); XMapSubwindows(display, frame.window); XMapWindow(display, frame.window); }
void OGLwin_Open_Window(int x, int y, int width, int height, char *name, WINTYPE t, Window parent_win) { XSetWindowAttributes swa; XEvent event; unsigned long attr_mask; Window parent; Window root_win; if (!Dsp) { if (global_display != NULL) { Dsp = global_display; } else { Dsp = XOpenDisplay(0); } } if (getenv("OGLWIN_USE12")) { attributes[RGBA_SINGLE] = rgba12_att; attributes[RGBA_DOUBLE] = rgba12_datt; } Vi = glXChooseVisual(Dsp, DefaultScreen(Dsp), attributes[t]); Cmap = getColormap(Dsp, Vi, t); swa.border_pixel = 0; swa.colormap = Cmap; swa.event_mask = ExposureMask | StructureNotifyMask | VisibilityChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask; swa.override_redirect = OGLwin_override_redirect; attr_mask = CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; parent = parent_win; root_win = RootWindow(Dsp, Vi->screen); if (!parent) parent = root_win; if (parent_border) { parent = XCreateSimpleWindow(Dsp, parent, x, y, width, height, 0, 0, 0); XSelectInput(Dsp, parent, StructureNotifyMask); x = y = parent_border; width -= parent_border; height -= parent_border; } XWindow = XCreateWindow(Dsp, parent, x, y, width, height, 0, Vi->depth, InputOutput, Vi->visual, attr_mask, &swa); if (parent_win == root_win) { Window top_win = (parent_border ? parent : XWindow); /* * fix size/position/aspect of new swWindow */ { XSizeHints *size_hints; size_hints = XAllocSizeHints(); size_hints->flags = USSize | PSize | USPosition | PPosition; XSetWMNormalHints(Dsp, top_win, size_hints); XFree(size_hints); } XSetWMColormapWindows(Dsp, XWindow, &XWindow, 1); XStoreName(Dsp, top_win, name); XMapSubwindows(Dsp, top_win); XMapWindow(Dsp, top_win); XIfEvent(Dsp, &event, WaitForMapNotify, (char *) top_win); } else { XMapWindow(Dsp, XWindow); XIfEvent(Dsp, &event, WaitForMapNotify, (char *) XWindow); } Cxt = glXCreateContext(Dsp, Vi, 0, direct_context); //SetWin(); fontBase = -1; }
/* * Creates the playing windows. * Returns 0 on success, -1 on error. */ int Init_playing_windows(void) { unsigned w, h; Pixmap pix; GC cursorGC; if (!topWindow) { if (Init_top()) return -1; } Scale_dashes(); draw_width = top_width - (256 + 2); draw_height = top_height; drawWindow = XCreateSimpleWindow(dpy, topWindow, 258, 0, draw_width, draw_height, 0, 0, colors[BLACK].pixel); radarWindow = XCreateSimpleWindow(dpy, topWindow, 0, 0, 256, RadarHeight, 0, 0, colors[BLACK].pixel); radar_score_mapped = true; /* Create buttons */ #define BUTTON_WIDTH 84 ButtonHeight = buttonFont->ascent + buttonFont->descent + 2*BTN_BORDER; button_form = Widget_create_form(0, topWindow, 0, (int)RadarHeight, 256, ButtonHeight + 2, 0); Widget_create_activate(button_form, 0 + 0*BUTTON_WIDTH, 0, BUTTON_WIDTH, ButtonHeight, 1, "QUIT", Quit_callback, NULL); Widget_create_activate(button_form, 1 + 1*BUTTON_WIDTH, 0, BUTTON_WIDTH, ButtonHeight, 1, "ABOUT", About_callback, NULL); menu_button = Widget_create_menu(button_form, 2 + 2*BUTTON_WIDTH, 0, BUTTON_WIDTH, ButtonHeight, 1, "MENU"); Widget_add_pulldown_entry(menu_button, "KEYS", Keys_callback, NULL); Widget_add_pulldown_entry(menu_button, "CONFIG", Config_callback, NULL); Widget_add_pulldown_entry(menu_button, "COLORS", Colors_callback, NULL); Widget_add_pulldown_entry(menu_button, "SCORE", Score_callback, NULL); Widget_add_pulldown_entry(menu_button, "PLAYER", Player_callback, NULL); Widget_add_pulldown_entry(menu_button, "MOTD", Motd_callback, NULL); Widget_map_sub(button_form); /* Create score list window */ players_width = RadarWidth; players_height = top_height - (RadarHeight + ButtonHeight + 2); playersWindow = XCreateSimpleWindow(dpy, topWindow, 0, (int)RadarHeight + ButtonHeight + 2, players_width, players_height, 0, 0, colors[windowColor].pixel); /* * Selecting the events we can handle. */ XSelectInput(dpy, radarWindow, ExposureMask); XSelectInput(dpy, playersWindow, ExposureMask); XSelectInput(dpy, drawWindow, ButtonPressMask | ButtonReleaseMask); /* * Initialize misc. pixmaps if we're not color switching. * (This could be in dbuff_init_buffer completely IMHO, -- Metalite) */ switch (dbuf_state->type) { case PIXMAP_COPY: radarPixmap = XCreatePixmap(dpy, radarWindow, 256, RadarHeight, dispDepth); radarPixmap2 = XCreatePixmap(dpy, radarWindow, 256, RadarHeight, dispDepth); drawPixmap = XCreatePixmap(dpy, drawWindow, draw_width, draw_height, dispDepth); break; case MULTIBUFFER: radarPixmap = XCreatePixmap(dpy, radarWindow, 256, RadarHeight, dispDepth); radarPixmap2 = XCreatePixmap(dpy, radarWindow, 256, RadarHeight, dispDepth); dbuff_init_buffer(dbuf_state); break; case COLOR_SWITCH: radarPixmap2 = radarWindow; radarPixmap = radarWindow; drawPixmap = drawWindow; Paint_sliding_radar(); break; default: assert(0 && "Init_playing_windows: unknown dbuf state type."); break; } XAutoRepeatOff(dpy); /* We don't want any autofire, yet! */ if (kdpy) XAutoRepeatOff(kdpy); /* * Define a blank cursor for use with pointer control */ XQueryBestCursor(dpy, drawWindow, 1, 1, &w, &h); pix = XCreatePixmap(dpy, drawWindow, w, h, 1); cursorGC = XCreateGC(dpy, pix, 0, NULL); XSetForeground(dpy, cursorGC, 0); XFillRectangle(dpy, pix, cursorGC, 0, 0, w, h); XFreeGC(dpy, cursorGC); pointerControlCursor = XCreatePixmapCursor(dpy, pix, pix, &colors[BLACK], &colors[BLACK], 0, 0); XFreePixmap(dpy, pix); /* * Maps the windows, makes the visible. Voila! */ XMapSubwindows(dpy, topWindow); XMapWindow(dpy, topWindow); XSync(dpy, False); if (kdpy) { XMapWindow(kdpy, keyboardWindow); XSync(kdpy, False); } Init_spark_colors(); return 0; }
static Object P_Map_Subwindows (Object w) { Check_Type (w, T_Window); XMapSubwindows (WINDOW(w)->dpy, WINDOW(w)->win); return Void; }