Eliminate a number of attribute fetches.

SVN revision: 22806
This commit is contained in:
Kim Woelders 2006-05-21 12:09:14 +00:00
parent 12adaa0f68
commit 61946c7db1
11 changed files with 98 additions and 74 deletions

View File

@ -58,7 +58,12 @@ ClientCreate(Window xwin)
Esnprintf(st, sizeof(st), "%8x", (int)xwin);
c->name = Estrdup(st);
c->win = ERegisterWindow(xwin);
c->win = ERegisterWindow(xwin, NULL);
if (!c->win)
{
Efree(c);
return NULL;
}
EventCallbackRegister(c->win, 0, ClientHandleEvents, c);
ESelectInput(c->win, StructureNotifyMask | SubstructureNotifyMask);

View File

@ -353,7 +353,7 @@ DeskEventsConfigure(Desk * dsk, int mode)
}
else
{
EGetWindowAttributes(win, &xwa);
EXGetWindowAttributes(win, &xwa);
dsk->event_mask = xwa.your_event_mask | EDESK_EVENT_MASK;
event_mask =
PropertyChangeMask | SubstructureRedirectMask |

View File

@ -86,13 +86,8 @@ typedef struct
EObj *next; /* Paint order */
EObj *prev; /* Paint order */
Pixmap pixmap;
struct
{
int depth; /* FIXME - Remove? */
Visual *visual; /* FIXME - Remove? */
int border_width;
} a;
int rcx, rcy, rcw, rch;
int bw;
int mode;
unsigned damaged:1;
unsigned fading:1;
@ -500,8 +495,8 @@ ECompMgrMoveResizeFix(EObj * eo, int x, int y, int w, int h)
}
/* Resizing - grab old contents */
pict =
EPictureCreateBuffer(Xwin(eo->win), wo, ho, cw->a.depth, cw->a.visual);
pict = EPictureCreateBuffer(EobjGetXwin(eo), wo, ho, WinGetDepth(eo->win),
WinGetVisual(eo->win));
XRenderComposite(disp, PictOpSrc, cw->picture, None, pict, 0, 0, 0, 0, 0, 0,
wo, ho);
@ -961,7 +956,7 @@ win_extents(EObj * eo)
unsigned int bw;
/* FIXME - Get this right */
bw = cw->a.border_width;
bw = cw->bw;
if (Mode_compmgr.use_pixmap)
{
cw->rcx = eo->x;
@ -1095,8 +1090,8 @@ win_shape(EObj * eo)
}
/* translate this */
x = eo->x + cw->a.border_width;
y = eo->y + cw->a.border_width;
x = eo->x + cw->bw;
y = eo->y + cw->bw;
ERegionTranslate(border, x, y);
D2printf("shape %#lx: %d %d\n", EobjGetXwin(eo), x, y);
@ -1211,7 +1206,7 @@ ECompMgrWinSetOpacity(EObj * eo, unsigned int opacity)
if (eo->noredir)
mode = WINDOW_UNREDIR;
else if (EVisualIsARGB(cw->a.visual))
else if (eo->argb)
mode = WINDOW_ARGB;
else if (cw->opacity != OPAQUE)
mode = WINDOW_TRANS;
@ -1434,7 +1429,7 @@ ECompMgrWinSetPicts(EObj * eo)
if (draw == None)
return;
pictfmt = XRenderFindVisualFormat(disp, cw->a.visual);
pictfmt = XRenderFindVisualFormat(disp, WinGetVisual(eo->win));
pa.subwindow_mode = IncludeInferiors;
cw->picture = XRenderCreatePicture(disp, draw,
pictfmt, CPSubwindowMode, &pa);
@ -1456,7 +1451,6 @@ void
ECompMgrWinNew(EObj * eo)
{
ECmWinInfo *cw;
XWindowAttributes attr;
if (!Mode_compmgr.active) /* FIXME - Here? */
return;
@ -1464,9 +1458,6 @@ ECompMgrWinNew(EObj * eo)
if (eo->inputonly || eo->win == VRoot.win)
return;
if (!XGetWindowAttributes(disp, EobjGetXwin(eo), &attr))
return;
cw = Ecalloc(1, sizeof(ECmWinInfo));
if (!cw)
return;
@ -1475,11 +1466,7 @@ ECompMgrWinNew(EObj * eo)
eo->cmhook = cw;
cw->damaged = 0;
cw->a.depth = attr.depth;
cw->a.visual = attr.visual;
cw->a.border_width = attr.border_width;
cw->bw = WinGetBorderWidth(eo->win);
if (eo->type == EOBJ_TYPE_EXT &&
Conf_compmgr.override_redirect.mode == ECM_OR_UNREDIRECTED)
@ -1596,13 +1583,13 @@ ECompMgrWinConfigure(EObj * eo, XEvent * ev)
change_xy = eo->x != x || eo->y != y;
change_wh = eo->w != w || eo->h != h;
change_bw = cw->a.border_width != bw;
change_bw = cw->bw != bw;
eo->x = x;
eo->y = y;
eo->w = w;
eo->h = h;
cw->a.border_width = bw;
cw->bw = bw;
ECompMgrWinMoveResize(eo, change_xy, change_wh, change_bw);
}
@ -1739,9 +1726,7 @@ ECompMgrWinDamage(EObj * eo, XEvent * ev __UNUSED__)
{
parts = ERegionCreate();
XDamageSubtract(dpy, cw->damage, None, parts);
ERegionTranslate(parts,
eo->x + cw->a.border_width,
eo->y + cw->a.border_width);
ERegionTranslate(parts, eo->x + cw->bw, eo->y + cw->bw);
#if 0 /* ENABLE_SHADOWS - FIXME - This is not right, remove? */
if (Mode_compmgr.shadow_mode == ECM_SHADOWS_SHARP)
{

View File

@ -299,12 +299,14 @@ EobjRegister(Window xwin, int type)
if (type == EOBJ_TYPE_EXT && !attr.override_redirect)
return NULL;
win = ERegisterWindow(xwin, &attr);
if (!win)
return NULL;
eo = Ecalloc(1, sizeof(EObj));
if (!eo)
return eo;
win = ERegisterWindow(xwin);
if (attr.class == InputOnly)
eo->inputonly = 1;

View File

@ -48,6 +48,7 @@ struct _eobj
unsigned noredir:1; /* Do not redirect */
unsigned shadow:1; /* Enable shadows */
unsigned fade:1;
unsigned argb:1;
#if USE_COMPOSITE
unsigned int opacity;
void *cmhook;

View File

@ -72,17 +72,10 @@ EwinEventsConfigure(EWin * ewin, int mode)
}
static EWin *
EwinCreate(Win win, Window xwin, int type)
EwinCreate(int type)
{
EWin *ewin;
if (!win)
{
win = ERegisterWindow(xwin);
if (!win)
return NULL;
}
ewin = Ecalloc(1, sizeof(EWin));
ewin->type = type;
@ -101,13 +94,6 @@ EwinCreate(Win win, Window xwin, int type)
ewin->lh = -1;
ewin->ll = -1;
ewin->client.win = win;
ewin->client.x = -1;
ewin->client.y = -1;
ewin->client.w = -1;
ewin->client.h = -1;
ewin->client.grav = NorthWestGravity;
ewin->icccm.need_input = 1;
ewin->icccm.width.min = 0;
@ -138,13 +124,20 @@ EwinCreate(Win win, Window xwin, int type)
}
static int
EwinGetAttributes(EWin * ewin)
EwinGetAttributes(EWin * ewin, Win win, Window xwin)
{
XWindowAttributes xwa;
if (!XGetWindowAttributes(disp, _EwinGetClientXwin(ewin), &xwa))
return -1;
if (!win)
{
win = ERegisterWindow(xwin, NULL);
if (!win)
return -1;
}
EGetWindowAttributes(win, &xwa);
ewin->client.win = win;
ewin->client.x = ewin->lx = xwa.x;
ewin->client.y = ewin->ly = xwa.y;
ewin->client.w = ewin->lw = xwa.width;
@ -152,7 +145,6 @@ EwinGetAttributes(EWin * ewin)
ewin->client.bw = xwa.border_width;
ewin->client.cmap = xwa.colormap;
ewin->client.grav = NorthWestGravity;
ewin->client.argb = EVisualIsARGB(xwa.visual);
if (EventDebug(EDBUG_TYPE_SNAPS))
Eprintf("Snap get attr %#lx: %4d+%4d %4dx%4d: %s\n",
@ -199,16 +191,17 @@ EwinManage(EWin * ewin)
if (ewin->state.docked)
ewin->inh_wm.b.border = 1;
if (ewin->client.argb && Conf.argb_client_mode > 0)
if (EVisualIsARGB(WinGetVisual(_EwinGetClientWin(ewin))))
{
if (!XGetWindowAttributes(disp, _EwinGetClientXwin(ewin), &win_attr))
return;
ewin->o.argb = 1;
EGetWindowAttributes(_EwinGetClientWin(ewin), &win_attr);
frame =
ECreateVisualWindow(VRoot.win, ewin->client.x, ewin->client.y,
ewin->client.w, ewin->client.h, 1, &win_attr);
ewin->win_container =
ECreateVisualWindow(frame, ewin->client.x, ewin->client.y,
ewin->client.w, ewin->client.h, 0, &win_attr);
ECreateVisualWindow(frame, 0, 0, ewin->client.w, ewin->client.h,
0, &win_attr);
if (Conf.argb_client_mode == 1)
ewin->inh_wm.b.border = 1;
@ -219,8 +212,7 @@ EwinManage(EWin * ewin)
ECreateWindow(VRoot.win, ewin->client.x, ewin->client.y,
ewin->client.w, ewin->client.h, 1);
ewin->win_container =
ECreateWindow(frame, ewin->client.x, ewin->client.y,
ewin->client.w, ewin->client.h, 0);
ECreateWindow(frame, 0, 0, ewin->client.w, ewin->client.h, 0);
}
EoInit(ewin, EOBJ_TYPE_EWIN, frame, ewin->client.x, ewin->client.y,
@ -680,7 +672,7 @@ EwinStateUpdate(EWin * ewin)
}
void
AddToFamily(EWin * ewin, Window win)
AddToFamily(EWin * ewin, Window xwin)
{
EWin *ewin2;
EWin **lst;
@ -693,13 +685,13 @@ AddToFamily(EWin * ewin, Window win)
if (ewin)
EwinCleanup(ewin);
else
ewin = EwinCreate(0, win, EWIN_TYPE_NORMAL);
ewin = EwinCreate(EWIN_TYPE_NORMAL);
if (!ewin)
goto done;
if (EwinGetAttributes(ewin))
if (EwinGetAttributes(ewin, NULL, xwin))
{
Eprintf("Window is gone %#lx\n", win);
Eprintf("Window is gone %#lx\n", xwin);
/* We got here by MapRequest. DestroyNotify should follow. */
goto done;
}
@ -952,11 +944,11 @@ AddInternalToFamily(Win win, const char *bname, int type, void *ptr,
EGrabServer();
ewin = EwinCreate(win, None, type);
ewin = EwinCreate(type);
if (!ewin)
goto done;
EwinGetAttributes(ewin);
EwinGetAttributes(ewin, win, None);
EwinGetHints(ewin);
EwinManage(ewin);

View File

@ -74,7 +74,6 @@ struct _ewin
int grav;
Colormap cmap;
long event_mask;
unsigned argb:1;
} client;
struct

View File

@ -2706,7 +2706,7 @@ IconboxObjSwinManage(Iconbox * ib, Window xwin)
#if DEBUG_SYSTRAY
Eprintf("IconboxObjSwinManage %#lx\n", xwin);
#endif
win = ERegisterWindow(xwin);
win = ERegisterWindow(xwin, NULL);
if (win == NoWin)
return win;

View File

@ -213,7 +213,7 @@ SetupX(const char *dstr)
VRoot.depth = RRoot.depth;
VRoot.cmap = RRoot.cmap;
RRoot.win = ERegisterWindow(RRoot.xwin);
RRoot.win = ERegisterWindow(RRoot.xwin, NULL);
if (Mode.wm.window)
{
@ -231,7 +231,7 @@ SetupX(const char *dstr)
CWOverrideRedirect | CWSaveUnder |
CWBackingStore | CWColormap | CWBackPixel |
CWBorderPixel, &attr);
VRoot.win = ERegisterWindow(VRoot.xwin);
VRoot.win = ERegisterWindow(VRoot.xwin, NULL);
/* Enable eesh and edox to pix up the virtual root */
Esnprintf(buf, sizeof(buf), "%#lx", VRoot.xwin);

45
src/x.c
View File

@ -52,6 +52,7 @@ struct _xwin
Window xwin;
Win parent;
int x, y, w, h;
int bw;
char mapped;
char in_use;
signed char do_del;
@ -79,6 +80,18 @@ WinGetXwin(const Win win)
return win->xwin;
}
int
WinGetBorderWidth(const Win win)
{
return win->bw;
}
int
WinGetDepth(const Win win)
{
return win->depth;
}
Visual *
WinGetVisual(const Win win)
{
@ -623,7 +636,7 @@ EDestroyWin(Win win)
}
Win
ERegisterWindow(Window xwin)
ERegisterWindow(Window xwin, XWindowAttributes * pxwa)
{
EXID *xid;
XWindowAttributes xwa;
@ -632,12 +645,18 @@ ERegisterWindow(Window xwin)
if (xid)
goto done;
XGetWindowAttributes(disp, xwin, &xwa);
if (!pxwa)
{
pxwa = &xwa;
if (!XGetWindowAttributes(disp, xwin, pxwa))
goto done;
}
#if 0
Eprintf("ERegisterWindow %#lx %d+%d %dx%d\n", win, x, y, w, h);
#endif
xid = EXidSet(xwin, None, xwa.x, xwa.y, xwa.width, xwa.height, xwa.depth,
xwa.visual, xwa.colormap);
xid = EXidSet(xwin, None, pxwa->x, pxwa->y, pxwa->width, pxwa->height,
pxwa->depth, pxwa->visual, pxwa->colormap);
xid->attached = 1;
done:
@ -819,6 +838,24 @@ EGetGeometry(Win win, Window * root_return, int *x, int *y,
return 1;
}
void
EGetWindowAttributes(Win win, XWindowAttributes * pxwa)
{
EXID *xid = win;
if (!xid)
return;
pxwa->x = xid->x;
pxwa->y = xid->y;
pxwa->width = xid->w;
pxwa->height = xid->h;
pxwa->border_width = xid->bw;
pxwa->depth = xid->depth;
pxwa->visual = xid->visual;
pxwa->colormap = xid->cmap;
}
void
EConfigureWindow(Win win, unsigned int mask, XWindowChanges * wc)
{

View File

@ -32,6 +32,8 @@ Win ELookupXwin(Window xwin);
#define Xwin(win) WinGetXwin(win)
Window WinGetXwin(const Win win);
int WinGetBorderWidth(const Win win);
int WinGetDepth(const Win win);
Visual *WinGetVisual(const Win win);
Colormap WinGetCmap(const Win win);
@ -48,7 +50,7 @@ void EFlush(void);
void ESync(void);
Time EGetTimestamp(void);
Win ERegisterWindow(Window xwin);
Win ERegisterWindow(Window xwin, XWindowAttributes * pxwa);
void EUnregisterWindow(Win win);
void EUnregisterXwin(Window xwin);
typedef void (EventCallbackFunc) (Win win, XEvent * ev, void *prm);
@ -81,6 +83,7 @@ void EReparentWindow(Win win, Win parent, int x, int y);
int EGetGeometry(Win win, Window * root_return,
int *x, int *y, int *w, int *h, int *bw,
int *depth);
void EGetWindowAttributes(Win win, XWindowAttributes * pxwa);
void EConfigureWindow(Win win, unsigned int mask,
XWindowChanges * wc);
void ESetWindowBackgroundPixmap(Win win, Pixmap pmap);
@ -95,8 +98,6 @@ int EDrawableCheck(Drawable draw, int grab);
#define ESelectInput(win, event_mask) \
XSelectInput(disp, Xwin(win), event_mask)
#define EGetWindowAttributes(win, xwa) \
XGetWindowAttributes(disp, Xwin(win), xwa)
#define EChangeWindowAttributes(win, mask, attr) \
XChangeWindowAttributes(disp, Xwin(win), mask, attr)
#define ESetWindowBorderWidth(win, bw) \
@ -139,6 +140,8 @@ Window EXWindowGetParent(Window xwin);
int EXGetGeometry(Window xwin, Window * root_return,
int *x, int *y, int *w, int *h, int *bw,
int *depth);
#define EXGetWindowAttributes(win, xwa) \
XGetWindowAttributes(disp, Xwin(win), xwa)
void EXCopyArea(Drawable src, Drawable dst, int sx, int sy,
unsigned int w, unsigned int h, int dx, int dy);