1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

Allow windows to specify their own depth.

Accept windows' depth, visual and colormap instead of always using those
of the root window.  Internal windows such as menus behave as before.

In conjunction with a compositing manager on a display supporting the
RENDER extension windows can now manage their own opacity.

I wrote the patch after reading the FAQ for urxvt, which says,
regarding transparency support:

"3. Use an ARGB visual:

  urxvt -depth 32 -fg grey90 -bg rgba:0000/0000/4444/cccc

This requires XFT support, and the support of your X-server. If that
doesn't work for you, blame Xorg and Keith Packard. ARGB visuals
aren't there yet, no matter what they claim. Rxvt-Unicode contains the
necessary bugfixes and workarounds for Xft and Xlib to make it work,
but that doesn't mean that your WM has the required kludges in place."

  In conjunction with a compositing manager (I tested compton) it does
work and urxvt draws a semi-transparent background with fully opaque
foreground text and scrollbars; much prettier than applying a blanket
transparency value over the whole window with the compositing manager.
Other application windows I tested were, as expected, drawn the same
as before.

  I verified that urxvt is drawn in the same way when using xfwm4
(with builtin compositing).  Since Window Maker doesn't (at time of
writing) have its own compositing manager I should clarify that one is
required to see any benefit from this patch.

  Whether or not this feature is useful for any application other than
urxvt I don't know, though I assume that an application which chose an
ARGB visual in the same way would be able to draw itself prettily.

  On a display without RENDER things work just as they do without the
patch.  I have, however, only been able to test on a fairly standard
TrueColor display supporting multiple colour depths with 24bpp being
the default.  Testing with more ... exotic ... display types would
probably be advisable.
This commit is contained in:
Iain Patterson
2012-08-20 15:18:21 +01:00
committed by Carlos R. Mafra
parent 5fe4160025
commit 39a5f3da0b
7 changed files with 26 additions and 15 deletions

View File

@@ -62,7 +62,8 @@ WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
int width, int height, int *clearance,
int *title_min, int *title_max, int flags,
WTexture ** title_texture, WTexture ** resize_texture,
WMColor ** color, WMFont ** font)
WMColor ** color, WMFont ** font,
int depth, Visual *visual, Colormap colormap)
{
WFrameWindow *fwin;
@@ -84,8 +85,12 @@ WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
fwin->last_languagemode = XkbGroup2Index;
#endif
fwin->depth = depth;
fwin->visual = visual;
fwin->colormap = colormap;
fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER)
? FRAME_BORDER_WIDTH : 0);
? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap);
if (wPreferences.use_saveunders) {
unsigned long vmask;
XSetWindowAttributes attribs;

View File

@@ -147,6 +147,9 @@ typedef struct WFrameWindow {
unsigned int incomplete_title:1;
} flags;
int depth;
Visual *visual;
Colormap colormap;
} WFrameWindow;
@@ -156,7 +159,8 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int *title_min, int *title_max, int flags,
union WTexture **title_texture,
union WTexture **resize_texture,
WMColor **color, WMFont **font);
WMColor **color, WMFont **font,
int depth, Visual *visual, Colormap colormap);
void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags);

View File

@@ -187,7 +187,7 @@ static WIcon *wIconCreateCore(WScreen *scr, int coord_x, int coord_y)
coord_y,
wPreferences.icon_size,
wPreferences.icon_size,
0);
0, scr->w_depth, scr->w_visual, scr->w_colormap);
if (wPreferences.use_saveunders) {
vmask = CWSaveUnder;

View File

@@ -164,7 +164,8 @@ WMenu *wMenuCreate(WScreen * screen, char *title, int main_menu)
&wPreferences.menu_title_max_height,
flags,
screen->menu_title_texture, NULL,
screen->menu_title_color, &screen->menu_title_font);
screen->menu_title_color, &screen->menu_title_font,
screen->w_depth, screen->w_visual, screen->w_colormap);
menu->frame->core->descriptor.parent = menu;
menu->frame->core->descriptor.parent_type = WCLASS_MENU;

View File

@@ -46,7 +46,7 @@ extern XContext wWinContext;
* The created window.
*----------------------------------------------------------------------
*/
WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int height, int bwidth)
WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int height, int bwidth, int depth, Visual *visual, Colormap colormap)
{
WCoreWindow *core;
int vmask;
@@ -67,10 +67,10 @@ WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
vmask |= CWColormap;
attribs.colormap = screen->w_colormap;
attribs.colormap = colormap;
core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
bwidth, screen->w_depth, CopyFromParent, screen->w_visual, vmask, &attribs);
bwidth, depth, CopyFromParent, visual, vmask, &attribs);
core->width = width;
core->height = height;
core->screen_ptr = screen;
@@ -115,10 +115,8 @@ WCoreWindow *wCoreCreate(WCoreWindow * parent, int x, int y, int width, int heig
attribs.background_pixel = parent->screen_ptr->black_pixel;
attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
/*
vmask |= CWColormap;
attribs.colormap = parent->screen_ptr->w_colormap;
*/
vmask |= CWColormap;
attribs.colormap = parent->screen_ptr->w_colormap;
core->window =
XCreateWindow(dpy, parent->window, x, y, width, height, 0,
parent->screen_ptr->w_depth, CopyFromParent,

View File

@@ -43,7 +43,8 @@ typedef struct _WCoreWindow {
WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width,
int height, int bwidth);
int height, int bwidth,
int depth, Visual *visual, Colormap colormap);
WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y,
int width, int height);

View File

@@ -1094,7 +1094,8 @@ WWindow *wManageWindow(WScreen *scr, Window window)
&wPreferences.window_title_max_height,
foo,
scr->window_title_texture,
scr->resizebar_texture, scr->window_title_color, &scr->title_font);
scr->resizebar_texture, scr->window_title_color, &scr->title_font,
wattribs.depth, wattribs.visual, wattribs.colormap);
wwin->frame->flags.is_client_window_frame = 1;
wwin->frame->flags.justification = wPreferences.title_justification;
@@ -1373,7 +1374,8 @@ WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
&wPreferences.window_title_max_height,
foo,
scr->window_title_texture,
scr->resizebar_texture, scr->window_title_color, &scr->title_font);
scr->resizebar_texture, scr->window_title_color, &scr->title_font,
scr->w_depth, scr->w_visual, scr->w_colormap);
XSaveContext(dpy, window, wWinContext, (XPointer) & wwin->client_descriptor);