/****f* libAfterImage/tutorials/create_top_level_window() * NAME * create_top_level_window() * SYNOPSIS * Window create_top_level_window( ASVisual *asv, Window root, * int x, int y, * unsigned int width, * unsigned int height, * unsigned int border_width, * unsigned long attr_mask, * XSetWindowAttributes *attr, * char *app_class ); * INPUTS * asv - pointer to valid preinitialized ASVisual structure. * root - root window of the screen on which to create window. * x, y - desired position of the window * width, height - desired window size. * border_width - desired initial border width of the window (may not * have any effect due to Window Manager intervention. * attr_mask - mask of the attributes that has to be set on the * window * attr - values of the attributes to be set. * app_class - title of the application to be used as its window * Title and resources class. * RETURN VALUE * ID of the created window. * DESCRIPTION * create_top_level_window() is autyomating process of creating top * level application window. It creates window for specified ASVisual, * and then sets up basic ICCCM hints for that window, such as WM_NAME, * WM_ICON_NAME, WM_CLASS and WM_PROTOCOLS. * SOURCE */ Window create_top_level_window( ASVisual *asv, Window root, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, unsigned long attr_mask, XSetWindowAttributes *attr, const char *app_class, const char *app_name ) { Window w = None; #ifndef X_DISPLAY_MISSING char *tmp ; XTextProperty name; XClassHint class1; w = create_visual_window(asv, root, x, y, width, height, border_width, InputOutput, attr_mask, attr ); tmp = (app_name==NULL)?(char*)get_application_name():(char*)app_name; XStringListToTextProperty (&tmp, 1, &name); class1.res_name = tmp; /* for future use */ class1.res_class = (char*)app_class; XSetWMProtocols (asv->dpy, w, &_XA_WM_DELETE_WINDOW, 1); XSetWMProperties (asv->dpy, w, &name, &name, NULL, 0, NULL, NULL, &class1); /* final cleanup */ XFree ((char *) name.value); #endif /* X_DISPLAY_MISSING */ return w; }
AfterShowXWindow * aftershow_create_x_window (AfterShowContext *ctx, AfterShowXWindow *parent, int width, int height) { AfterShowXWindow *window = safecalloc( 1, sizeof(AfterShowXWindow)); AfterShowXScreen *scr = parent->screen; unsigned long attr_mask = CWEventMask ; XSetWindowAttributes attr; window->magic = MAGIC_AFTERSHOW_X_WINDOW; window->screen = scr; attr.event_mask = ExposureMask; window->w = create_visual_window(scr->asv, parent->w, 0, 0, width, height, 0, InputOutput, attr_mask, &attr); add_hash_item (scr->windows, AS_HASHABLE(window->w), window); window->width = width; window->height = height; window->back = create_visual_pixmap(scr->asv, window->w, width, height, 0); window->gc = create_visual_gc(scr->asv, window->w, 0, NULL); window->depth = scr->asv->true_depth; window->back_width = width; window->back_height = height; return window; }
void CreateManagementWindows() { XSetWindowAttributes attr; /* attributes for create windows */ /* the SizeWindow will be moved into place in LoadASConfig() */ attr.override_redirect = True; attr.bit_gravity = NorthWestGravity; Scr.SizeWindow = create_visual_window (Scr.asv, Scr.Root, -999, -999, 10, 10, 0, InputOutput, CWBitGravity | CWOverrideRedirect, &attr); LOCAL_DEBUG_OUT( "Scr.SizeWindow = %lX;", Scr.SizeWindow ); /* create a window which will accept the keyboard focus when no other windows have it */ attr.event_mask = KeyPressMask | FocusChangeMask | AS_ROOT_EVENT_MASK; attr.override_redirect = True; Scr.ServiceWin = create_visual_window (Scr.asv, Scr.Root, 0, 0, 1, 1, 0, InputOutput, CWEventMask | CWOverrideRedirect, &attr); set_service_window_prop (Scr.wmprops, Scr.ServiceWin); LOCAL_DEBUG_OUT( "Scr.ServiceWin = %lX;", Scr.ServiceWin ); XMapRaised (dpy, Scr.ServiceWin); XSetInputFocus (dpy, Scr.ServiceWin, RevertToParent, CurrentTime); /* show_progress( "Service window created with ID %lX", Scr.ServiceWin ); */ }
void createMainWindow() { XSetWindowAttributes attr; int width = DEFAULT_TILE_WIDTH; int height = DEFAULT_TILE_HEIGHT; attr.event_mask = StructureNotifyMask|ButtonPressMask|ButtonReleaseMask ; AppState.mainWindow = create_visual_window( Scr.asv, Scr.Root, 0, 0, width, height, 0, InputOutput, CWEventMask, &attr); set_client_names( AppState.mainWindow, MyName, MyName, CLASS_ASMOUNT, CLASS_ASMOUNT ); setHints (width, height); set_client_cmd (AppState.mainWindow); /* showing window to let user see that we are doing something */ XMapRaised (dpy, AppState.mainWindow); // { XEvent e; do { XNextEvent(dpy, &e); } while (e.type != MapNotify); } AppState.mainCanvas = create_ascanvas (AppState.mainWindow); }
Bool redecorateVolume(void *data, void *aux_data) { ASVolume *v = (ASVolume*)data; ASVolumeCanvasPlacement *placement = (ASVolumeCanvasPlacement*) aux_data; int width = placement->tileWidth; int height = placement->tileHeight; int x = 0, y = 0; if (placement->vertical) { y = placement->currPos; placement->currPos += height; } else { x = placement->currPos; placement->currPos += width; } if (v) { XSetWindowAttributes attr; // ARGB2PIXEL(Scr.asv,Config->border_color_argb,&(attr.border_pixel)); if( v->canvas == NULL ) { Window w; attr.event_mask = EnterWindowMask|PointerMotionMask|LeaveWindowMask|StructureNotifyMask|ButtonReleaseMask|ButtonPressMask ; w = create_visual_window(Scr.asv, AppState.mainWindow, x, y, width, height, 0, InputOutput, CWEventMask|CWBorderPixel, &attr ); v->canvas = create_ascanvas( w ); show_progress("creating volume canvas (%p) for \"%s\"", v->canvas, v->name); handle_canvas_config( v->canvas ); } else { XSetWindowBorder( dpy, v->canvas->w, attr.border_pixel ); moveresize_canvas (v->canvas, x, y, width, height); } updateVolumeContents (v); set_astbar_size (v->contents, width, height); /* redraw will happen on ConfigureNotify */ #if 0 render_astbar (v->contents, v->canvas ); update_canvas_display (v->canvas ); #endif } return True; }
void cover_desktop () { XSetWindowAttributes attributes; unsigned long valuemask; Window w; XGCValues gcvalue; if (get_flags (Scr.Feel.flags, DontCoverDesktop)) return; ++_as_desktop_cover_recursion; if (_as_desktop_cover != None) return; valuemask = (CWBackPixmap | CWBackingStore | CWOverrideRedirect); attributes.background_pixmap = None; attributes.backing_store = NotUseful; attributes.override_redirect = True; w = create_visual_window (Scr.asv, Scr.Root, 0, 0, Scr.MyDisplayWidth, Scr.MyDisplayHeight, 0, InputOutput, valuemask, &attributes); XMapRaised (dpy, w); XSync (dpy, False); if (_as_desktop_cover_gc == NULL) { unsigned long mask = GCFunction | GCForeground | GCBackground | GCGraphicsExposures; CARD32 r16, g16, b16; if (_as_desktop_cover_xfs == NULL) _as_desktop_cover_xfs = XLoadQueryFont (dpy, "fixed"); if (_as_desktop_cover_xfs) { gcvalue.font = _as_desktop_cover_xfs->fid; mask |= GCFont; } LOCAL_DEBUG_OUT ("desk_anime_tint = %lX", Scr.Look.desktop_animation_tint); r16 = ARGB32_RED16 (Scr.Look.desktop_animation_tint); g16 = ARGB32_GREEN16 (Scr.Look.desktop_animation_tint); b16 = ARGB32_BLUE16 (Scr.Look.desktop_animation_tint); if (ASCS_BLACK_O_WHITE_CRITERIA16 (r16, g16, b16)) { gcvalue.foreground = Scr.asv->black_pixel; gcvalue.background = Scr.asv->white_pixel; } else { gcvalue.foreground = Scr.asv->white_pixel; gcvalue.background = Scr.asv->black_pixel; } gcvalue.function = GXcopy; gcvalue.graphics_exposures = 0; _as_desktop_cover_gc = create_visual_gc (Scr.asv, Scr.Root, mask, &gcvalue); } if (_as_desktop_cover_gc) { unsigned long pixel; ARGB2PIXEL (Scr.asv, Scr.Look.desktop_animation_tint, &pixel); gcvalue.foreground = pixel; gcvalue.function = GXand; XChangeGC (dpy, _as_desktop_cover_gc, GCFunction | GCForeground, &gcvalue); XFillRectangle (dpy, w, _as_desktop_cover_gc, 0, 0, Scr.MyDisplayWidth, Scr.MyDisplayHeight); gcvalue.foreground = Scr.asv->white_pixel; gcvalue.function = GXcopy; XChangeGC (dpy, _as_desktop_cover_gc, GCFunction | GCForeground, &gcvalue); } _as_desktop_cover = w; }
Window make_ident_window( int width, int height) { Window w; XSizeHints shints; ExtendedWMHints extwm_hints ; int x, y ; XSetWindowAttributes attr; LOCAL_DEBUG_OUT("configured geometry is %dx%d%+d%+d", width, height, Config->geometry.x, Config->geometry.y ); memset( &extwm_hints, 0x00, sizeof(extwm_hints)); switch( Config->gravity ) { case NorthEastGravity : x = Scr.MyDisplayWidth - width + Config->geometry.x ; y = Config->geometry.y ; break; case SouthEastGravity : x = Scr.MyDisplayWidth - width + Config->geometry.x ; y = Scr.MyDisplayHeight - height + Config->geometry.y ; break; case SouthWestGravity : x = Config->geometry.x ; y = Scr.MyDisplayHeight - height + Config->geometry.y ; break; case NorthWestGravity : default : x = Config->geometry.x ; y = Config->geometry.y ; break; } attr.event_mask = StructureNotifyMask ; w = create_visual_window( Scr.asv, Scr.Root, x, y, width, height, 0, InputOutput, CWEventMask, &attr); set_client_names( w, MyName, MyName, AS_MODULE_CLASS, CLASS_IDENT ); Scr.RootClipArea.x = x; Scr.RootClipArea.y = y; Scr.RootClipArea.width = width; Scr.RootClipArea.height = height; shints.flags = USSize|PMaxSize|PWinGravity; if( get_flags( Config->set_flags, IDENT_SET_GEOMETRY ) ) shints.flags |= USPosition ; else shints.flags |= PPosition ; shints.max_width = width; shints.max_height = height; shints.win_gravity = Config->gravity ; extwm_hints.pid = getpid(); extwm_hints.flags = EXTWM_PID|EXTWM_TypeSet ; extwm_hints.type_flags = EXTWM_TypeASModule ; set_client_hints( w, NULL, &shints, AS_DoesWmDeleteWindow, &extwm_hints ); set_client_cmd (w); /* showing window to let user see that we are doing something */ XMapRaised (dpy, w); LOCAL_DEBUG_OUT( "mapping main window at %ux%u%+d%+d", width, height, x, y ); /* final cleanup */ XFlush (dpy); sleep (1); /* we have to give AS a chance to spot us */ /* we will need to wait for PropertyNotify event indicating transition into Withdrawn state, so selecting event mask: */ XSelectInput (dpy, w, PropertyChangeMask|StructureNotifyMask); return w ; }