Xnest: move per-screen upstream frame window into separate screen private struct
Start collecting the per-screen data into an own struct. Leaving this struct in a global array (just like the individual fields) right now, because several places still need to iterate over it. In later steps might move into a per screen's devPrivate. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
409d4b7cdf
commit
6f20cee79c
|
|
@ -96,7 +96,7 @@ xnestCreateColormap(ColormapPtr pCmap)
|
|||
xcb_create_colormap(xnestUpstreamInfo.conn,
|
||||
(pVisual->class & DynamicClass) ? XCB_COLORMAP_ALLOC_ALL : XCB_COLORMAP_ALLOC_NONE,
|
||||
cmap,
|
||||
xnestDefaultWindows[pCmap->pScreen->myNum],
|
||||
xnest_screen_priv(pCmap->pScreen)->upstream_frame_window,
|
||||
xnest_visual_map_to_upstream(pVisual->vid));
|
||||
|
||||
switch (pVisual->class) {
|
||||
|
|
@ -212,6 +212,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
|||
{
|
||||
xnestInstalledColormapWindows icws;
|
||||
int numWindows;
|
||||
struct xnest_screen_info *screenPriv = xnest_screen_priv(pScreen);
|
||||
|
||||
icws.cmapIDs = xallocarray(pScreen->maxInstalledCmaps, sizeof(Colormap));
|
||||
icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
|
||||
|
|
@ -221,7 +222,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
|||
icws.windows = xallocarray(icws.numWindows + 1, sizeof(xcb_window_t));
|
||||
icws.index = 0;
|
||||
WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws);
|
||||
icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
|
||||
icws.windows[icws.numWindows] = screenPriv->upstream_frame_window;
|
||||
numWindows = icws.numWindows + 1;
|
||||
}
|
||||
else {
|
||||
|
|
@ -235,7 +236,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
|||
free(xnestOldInstalledColormapWindows);
|
||||
|
||||
xnest_wm_colormap_windows(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
icws.windows,
|
||||
numWindows);
|
||||
|
||||
|
|
@ -265,7 +266,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
|||
|
||||
uint32_t cmap = xnestColormap(pCmap);
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
XCB_CW_COLORMAP,
|
||||
&cmap);
|
||||
}
|
||||
|
|
@ -281,7 +282,7 @@ xnestSetScreenSaverColormapWindow(ScreenPtr pScreen)
|
|||
free(xnestOldInstalledColormapWindows);
|
||||
|
||||
xnest_wm_colormap_windows(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
xnest_screen_priv(pScreen)->upstream_frame_window,
|
||||
&xnestScreenSaverWindows[pScreen->myNum],
|
||||
1);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
|||
|
||||
xcb_aux_change_gc(xnestUpstreamInfo.conn, xnestBitmapGC, valuemask, &values);
|
||||
|
||||
uint32_t const winId = xnestDefaultWindows[pScreen->myNum];
|
||||
uint32_t const winId = xnest_screen_priv(pScreen)->upstream_frame_window;
|
||||
|
||||
Pixmap const source = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, source, winId, pCursor->bits->width, pCursor->bits->height);
|
||||
|
|
@ -134,7 +134,7 @@ xnestSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
|
|||
uint32_t cursor = xnestCursor(pCursor, pScreen);
|
||||
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
xnest_screen_priv(pScreen)->upstream_frame_window,
|
||||
XCB_CW_CURSOR,
|
||||
&cursor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight,
|
|||
xcb_query_best_size(
|
||||
xnestUpstreamInfo.conn,
|
||||
class,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
xnest_screen_priv(pScreen)->upstream_frame_window,
|
||||
*pWidth,
|
||||
*pHeight),
|
||||
&err);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
|
|||
xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
|
||||
for (i = 0; i < xnestNumScreens; i++)
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[i],
|
||||
xnest_screen_by_id(i)->upstream_frame_window,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&xnestEventMask);
|
||||
break;
|
||||
|
|
@ -226,7 +226,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
|
|||
xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK;
|
||||
for (i = 0; i < xnestNumScreens; i++)
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[i],
|
||||
xnest_screen_by_id(i)->upstream_frame_window,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&xnestEventMask);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
|||
if (width && height) {
|
||||
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||
xcb_create_pixmap(xnestUpstreamInfo.conn, depth, pixmap,
|
||||
xnestDefaultWindows[pScreen->myNum], width, height);
|
||||
xnest_screen_priv(pScreen)->upstream_frame_window, width, height);
|
||||
xnestPixmapPriv(pPixmap)->pixmap = pixmap;
|
||||
}
|
||||
else
|
||||
|
|
@ -85,7 +85,7 @@ xnestModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
|
|||
if(!xnestPixmapPriv(pPixmap)->pixmap && width > 0 && height > 0) {
|
||||
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||
xcb_create_pixmap(xnestUpstreamInfo.conn, depth, pixmap,
|
||||
xnestDefaultWindows[pPixmap->drawable.pScreen->myNum],
|
||||
xnest_screen_priv(pPixmap->drawable.pScreen)->upstream_frame_window,
|
||||
width, height);
|
||||
xnestPixmapPriv(pPixmap)->pixmap = pixmap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ xnestPointerProc(DeviceIntPtr pDev, int onoff)
|
|||
xnestEventMask |= XNEST_POINTER_EVENT_MASK;
|
||||
for (i = 0; i < xnestNumScreens; i++)
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[i],
|
||||
xnest_screen_by_id(i)->upstream_frame_window,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&xnestEventMask);
|
||||
break;
|
||||
|
|
@ -115,7 +115,7 @@ xnestPointerProc(DeviceIntPtr pDev, int onoff)
|
|||
xnestEventMask &= ~XNEST_POINTER_EVENT_MASK;
|
||||
for (i = 0; i < xnestNumScreens; i++)
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[i],
|
||||
xnest_screen_by_id(i)->upstream_frame_window,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&xnestEventMask);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ is" without express or implied warranty.
|
|||
#include "Args.h"
|
||||
#include "mipointrst.h"
|
||||
|
||||
xcb_window_t xnestDefaultWindows[MAXSCREENS];
|
||||
xcb_window_t xnestScreenSaverWindows[MAXSCREENS];
|
||||
DevPrivateKeyRec xnestScreenCursorFuncKeyRec;
|
||||
DevScreenPrivateKeyRec xnestScreenCursorPrivKeyRec;
|
||||
|
|
@ -58,7 +57,7 @@ xnestScreen(xcb_window_t window)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < xnestNumScreens; i++)
|
||||
if (xnestDefaultWindows[i] == window)
|
||||
if (xnest_screen_by_id(i)->upstream_frame_window == window)
|
||||
return screenInfo.screens[i];
|
||||
|
||||
return NULL;
|
||||
|
|
@ -415,18 +414,20 @@ breakout:
|
|||
|
||||
valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
|
||||
|
||||
struct xnest_screen_info *screenPriv = xnest_screen_priv(pScreen);
|
||||
|
||||
if (xnestParentWindow != 0) {
|
||||
xnestDefaultWindows[pScreen->myNum] = xnestParentWindow;
|
||||
screenPriv->upstream_frame_window = xnestParentWindow;
|
||||
xcb_change_window_attributes(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&xnestEventMask);
|
||||
}
|
||||
else {
|
||||
xnestDefaultWindows[pScreen->myNum] = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||
screenPriv->upstream_frame_window = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||
xcb_aux_create_window(xnestUpstreamInfo.conn,
|
||||
pScreen->rootDepth,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
xnestUpstreamInfo.screenInfo->root,
|
||||
xnestGeometry.x + POSITION_OFFSET,
|
||||
xnestGeometry.y + POSITION_OFFSET,
|
||||
|
|
@ -462,21 +463,21 @@ breakout:
|
|||
const size_t windowNameLen = strlen(xnestWindowName);
|
||||
|
||||
xcb_icccm_set_wm_name_checked(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
XCB_ATOM_STRING,
|
||||
8,
|
||||
windowNameLen,
|
||||
xnestWindowName);
|
||||
|
||||
xcb_icccm_set_wm_icon_name_checked(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
XCB_ATOM_STRING,
|
||||
8,
|
||||
windowNameLen,
|
||||
xnestWindowName);
|
||||
|
||||
xnest_set_command(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
argv, argc);
|
||||
|
||||
xcb_icccm_wm_hints_t wmhints = {
|
||||
|
|
@ -485,10 +486,10 @@ breakout:
|
|||
};
|
||||
|
||||
xcb_icccm_set_wm_hints_checked(xnestUpstreamInfo.conn,
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
&wmhints);
|
||||
|
||||
xcb_map_window(xnestUpstreamInfo.conn, xnestDefaultWindows[pScreen->myNum]);
|
||||
xcb_map_window(xnestUpstreamInfo.conn, screenPriv->upstream_frame_window);
|
||||
|
||||
valuemask = XCB_CW_BACK_PIXMAP | XCB_CW_COLORMAP;
|
||||
attributes.back_pixmap = xnestScreenSaverPixmap;
|
||||
|
|
@ -498,7 +499,7 @@ breakout:
|
|||
xcb_aux_create_window(xnestUpstreamInfo.conn,
|
||||
xnestUpstreamInfo.screenInfo->root_depth,
|
||||
xnestScreenSaverWindows[pScreen->myNum],
|
||||
xnestDefaultWindows[pScreen->myNum],
|
||||
screenPriv->upstream_frame_window,
|
||||
0,
|
||||
0,
|
||||
xnestGeometry.width,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ is" without express or implied warranty.
|
|||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
extern xcb_window_t xnestDefaultWindows[MAXSCREENS];
|
||||
extern xcb_window_t xnestScreenSaverWindows[MAXSCREENS];
|
||||
|
||||
ScreenPtr xnestScreen(xcb_window_t window);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ extern DevPrivateKeyRec xnestWindowPrivateKeyRec;
|
|||
#define xnestWindowParent(pWin) \
|
||||
((pWin)->parent ? \
|
||||
xnestWindow((pWin)->parent) : \
|
||||
xnestDefaultWindows[pWin->drawable.pScreen->myNum])
|
||||
xnest_screen_priv(pWin->drawable.pScreen)->upstream_frame_window)
|
||||
|
||||
#define xnestWindowSiblingAbove(pWin) \
|
||||
((pWin)->prevSib ? xnestWindow((pWin)->prevSib) : XCB_WINDOW_NONE)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "XNGC.h"
|
||||
#include "Display.h"
|
||||
|
||||
struct xnest_screen_info xnestScreens[MAXSCREENS] = { 0 };
|
||||
struct xnest_upstream_info xnestUpstreamInfo = { 0 };
|
||||
xnest_visual_t *xnestVisualMap;
|
||||
int xnestNumVisualMap;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,24 @@
|
|||
#include <xcb/xcb.h>
|
||||
|
||||
#include "include/list.h"
|
||||
#include "include/scrnintstr.h"
|
||||
|
||||
struct xnest_event_queue {
|
||||
struct xorg_list entry;
|
||||
xcb_generic_event_t *event;
|
||||
};
|
||||
|
||||
struct xnest_screen_info {
|
||||
/* the FRAME window isn't the ROOT window - it's where the ROOT window
|
||||
is created into:
|
||||
|
||||
on startup the core will call xnestCreateWindow() with pWin->parent == NULL,
|
||||
which means we're creating the screen's ROOT window. This approach makes
|
||||
several things easier, eg. embedding Xnest into another application, or maybe
|
||||
even adding some control widgets (eg. scroll bars) */
|
||||
xcb_window_t upstream_frame_window;
|
||||
};
|
||||
|
||||
struct xnest_upstream_info {
|
||||
xcb_connection_t *conn;
|
||||
int screenId;
|
||||
|
|
@ -22,8 +34,17 @@ struct xnest_upstream_info {
|
|||
struct xnest_event_queue eventQueue;
|
||||
};
|
||||
|
||||
extern struct xnest_screen_info xnestScreens[MAXSCREENS];
|
||||
extern struct xnest_upstream_info xnestUpstreamInfo;
|
||||
|
||||
static inline struct xnest_screen_info *xnest_screen_by_id(int idx) {
|
||||
return &xnestScreens[idx];
|
||||
}
|
||||
|
||||
static inline struct xnest_screen_info *xnest_screen_priv(ScreenPtr pScreen) {
|
||||
return xnest_screen_by_id(pScreen->myNum); // should use devPrivates
|
||||
}
|
||||
|
||||
/* connect to upstream X server */
|
||||
Bool xnest_upstream_setup(const char* displayName);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue