From bb48c355223d33fd2237b5e6c5c15b9aab3ce876 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Wed, 20 Mar 2013 04:02:17 +0100 Subject: [PATCH] Window attributes moved to wCoreCreateTopLevel The function wCoreCreateTopLevel() is used in two files (icon.c and framewin.c), but after create the window, some attributes are changed. This patch moves the change inside the wCoreCreateTopLevel(), avoiding to call XChangeWindowAttributes() after the window creation. Now the window is created in only one step, with all the final attributes. Some details: - The function wCoreCreateTopLevel() has now one argument more, the border pixel color. This attribute was used always as the screen frame_border_pixel, but in icon.c the attribute is changed to white_pixel. Now the function wCoreCreateTopLevel() receives the value frame_border_pixel in framewin.c and scr->white_pixel in icon.c, as argument. - The vmask and attribs variables and the call to XChangeWindowAttributes() are removed in framewin.c and icon.c. The values CWSaveUnder for vmask and attribs.save_under = True are used if wPreferences.use_saveunders is True. - CWBorderPixel is not needed in icon.c, because was previously set in wcore.c! --- src/framewin.c | 10 +--------- src/icon.c | 16 ++-------------- src/wcore.c | 9 +++++++-- src/wcore.h | 3 ++- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/framewin.c b/src/framewin.c index b7a6e971..67cda92e 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -113,15 +113,7 @@ WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y, allocFrameBorderPixel(fwin->colormap, FRAME_SELECTED_BORDER_COLOR, &fwin->selected_border_pixel); fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER) - ? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap); - if (wPreferences.use_saveunders) { - unsigned long vmask; - XSetWindowAttributes attribs; - - vmask = CWSaveUnder; - attribs.save_under = True; - XChangeWindowAttributes(dpy, fwin->core->window, vmask, &attribs); - } + ? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap, scr->frame_border_pixel); /* setup stacking information */ fwin->core->stacking = wmalloc(sizeof(WStacking)); diff --git a/src/icon.c b/src/icon.c index e88ec30d..62f618a5 100644 --- a/src/icon.c +++ b/src/icon.c @@ -168,8 +168,6 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y) { WIcon *icon; - unsigned long vmask = 0; - XSetWindowAttributes attribs; icon = wmalloc(sizeof(WIcon)); icon->core = wCoreCreateTopLevel(scr, @@ -177,18 +175,8 @@ static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y) coord_y, wPreferences.icon_size, wPreferences.icon_size, - 0, scr->w_depth, scr->w_visual, scr->w_colormap); - - if (wPreferences.use_saveunders) { - vmask = CWSaveUnder; - attribs.save_under = True; - } - - /* a white border for selecting it */ - vmask |= CWBorderPixel; - attribs.border_pixel = scr->white_pixel; - - XChangeWindowAttributes(dpy, icon->core->window, vmask, &attribs); + 0, scr->w_depth, scr->w_visual, scr->w_colormap, + scr->white_pixel); /* will be overriden if this is a application icon */ icon->core->descriptor.handle_mousedown = miniwindowMouseDown; diff --git a/src/wcore.c b/src/wcore.c index 1abe8425..a2aff96a 100644 --- a/src/wcore.c +++ b/src/wcore.c @@ -43,7 +43,7 @@ extern XContext wWinContext; * Returns: * The created window. *--------------------------------------------------------------------- */ -WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, int bwidth, int depth, Visual *visual, Colormap colormap) +WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, int bwidth, int depth, Visual *visual, Colormap colormap, WMPixel border_pixel) { WCoreWindow *core; int vmask; @@ -56,13 +56,18 @@ WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int h attribs.cursor = wCursor[WCUR_DEFAULT]; attribs.background_pixmap = None; attribs.background_pixel = screen->black_pixel; - attribs.border_pixel = screen->frame_border_pixel; + attribs.border_pixel = border_pixel; attribs.event_mask = SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask; attribs.colormap = colormap; + if (wPreferences.use_saveunders) { + vmask |= CWSaveUnder; + attribs.save_under = True; + } + core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height, bwidth, depth, CopyFromParent, visual, vmask, &attribs); core->width = width; diff --git a/src/wcore.h b/src/wcore.h index 4e626ccd..6065c5fe 100644 --- a/src/wcore.h +++ b/src/wcore.h @@ -43,7 +43,8 @@ typedef struct _WCoreWindow { WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, int bwidth, - int depth, Visual *visual, Colormap colormap); + int depth, Visual *visual, Colormap colormap, + WMPixel border_pixel); WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height); -- 2.11.4.GIT