Xnest: replace XCreateWindow() by use xcb_create_window()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-30 14:30:46 +02:00
parent 04c6cc145e
commit 646ced96b1
3 changed files with 63 additions and 40 deletions

View File

@ -13,6 +13,9 @@ is" without express or implied warranty.
*/ */
#include <dix-config.h> #include <dix-config.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xdefs.h> #include <X11/Xdefs.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
@ -137,7 +140,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
int numVisuals, numDepths; int numVisuals, numDepths;
int i, j, depthIndex; int i, j, depthIndex;
unsigned long valuemask; unsigned long valuemask;
XSetWindowAttributes attributes;
XWindowAttributes gattributes; XWindowAttributes gattributes;
XSizeHints sizeHints; XSizeHints sizeHints;
VisualID defaultVisual; VisualID defaultVisual;
@ -360,29 +362,35 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
if (xnestDoFullGeneration) { if (xnestDoFullGeneration) {
xcb_params_cw_t attributes = {
.back_pixel = xnestUpstreamInfo.screenInfo->white_pixel,
.event_mask = xnestEventMask,
.colormap = xnestDefaultVisualColormap(xnestDefaultVisual(pScreen)),
};
valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP; valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
attributes.background_pixel = xnestUpstreamInfo.screenInfo->white_pixel;
attributes.event_mask = xnestEventMask;
attributes.colormap =
xnestDefaultVisualColormap(xnestDefaultVisual(pScreen));
if (xnestParentWindow != 0) { if (xnestParentWindow != 0) {
xnestDefaultWindows[pScreen->myNum] = xnestParentWindow; xnestDefaultWindows[pScreen->myNum] = xnestParentWindow;
XSelectInput(xnestDisplay, xnestDefaultWindows[pScreen->myNum], XSelectInput(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
xnestEventMask); xnestEventMask);
} }
else else {
xnestDefaultWindows[pScreen->myNum] = xnestDefaultWindows[pScreen->myNum] = xcb_generate_id(xnestUpstreamInfo.conn);
XCreateWindow(xnestDisplay, xcb_aux_create_window(xnestUpstreamInfo.conn,
xnestUpstreamInfo.screenInfo->root, pScreen->rootDepth,
xnestX + POSITION_OFFSET, xnestDefaultWindows[pScreen->myNum],
xnestY + POSITION_OFFSET, xnestUpstreamInfo.screenInfo->root,
xnestWidth, xnestHeight, xnestX + POSITION_OFFSET,
xnestBorderWidth, xnestY + POSITION_OFFSET,
pScreen->rootDepth, xnestWidth,
InputOutput, xnestHeight,
xnestDefaultVisual(pScreen), xnestBorderWidth,
valuemask, &attributes); XCB_WINDOW_CLASS_INPUT_OUTPUT,
xnestDefaultVisual(pScreen)->visualid,
valuemask,
&attributes);
}
if (!xnestWindowName) if (!xnestWindowName)
xnestWindowName = argv[0]; xnestWindowName = argv[0];
@ -405,17 +413,23 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
XMapWindow(xnestDisplay, xnestDefaultWindows[pScreen->myNum]); XMapWindow(xnestDisplay, xnestDefaultWindows[pScreen->myNum]);
valuemask = XCB_CW_BACK_PIXMAP | XCB_CW_COLORMAP; valuemask = XCB_CW_BACK_PIXMAP | XCB_CW_COLORMAP;
attributes.background_pixmap = xnestScreenSaverPixmap; attributes.back_pixmap = xnestScreenSaverPixmap;
attributes.colormap = xnestUpstreamInfo.screenInfo->default_colormap; attributes.colormap = xnestUpstreamInfo.screenInfo->default_colormap;
xnestScreenSaverWindows[pScreen->myNum] =
XCreateWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum] = xcb_generate_id(xnestUpstreamInfo.conn);
xnestDefaultWindows[pScreen->myNum], xcb_aux_create_window(xnestUpstreamInfo.conn,
0, 0, xnestWidth, xnestHeight, 0, xnestUpstreamInfo.screenInfo->root_depth,
xnestUpstreamInfo.screenInfo->root_depth, xnestScreenSaverWindows[pScreen->myNum],
InputOutput, DefaultVisual(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
xnestUpstreamInfo.screenId), 0,
valuemask, 0,
&attributes); xnestWidth,
xnestHeight,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
xnestUpstreamInfo.screenInfo->root_visual,
valuemask,
&attributes);
} }
if (!xnestCreateDefaultColormap(pScreen)) if (!xnestCreateDefaultColormap(pScreen))

View File

@ -13,6 +13,9 @@ is" without express or implied warranty.
*/ */
#include <dix-config.h> #include <dix-config.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xdefs.h> #include <X11/Xdefs.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
@ -27,6 +30,7 @@ is" without express or implied warranty.
#include "region.h" #include "region.h"
#include "Xnest.h" #include "Xnest.h"
#include "xnest-xcb.h"
#include "Display.h" #include "Display.h"
#include "Screen.h" #include "Screen.h"
@ -74,7 +78,7 @@ Bool
xnestCreateWindow(WindowPtr pWin) xnestCreateWindow(WindowPtr pWin)
{ {
unsigned long mask; unsigned long mask;
XSetWindowAttributes attributes; xcb_params_cw_t attributes = { 0 };
Visual *visual; Visual *visual;
ColormapPtr pCmap; ColormapPtr pCmap;
@ -114,18 +118,21 @@ xnestCreateWindow(WindowPtr pWin)
} }
} }
xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay, xnestWindowPriv(pWin)->window = xcb_generate_id(xnestUpstreamInfo.conn);
xnestWindowParent(pWin), xcb_aux_create_window(xnestUpstreamInfo.conn,
pWin->origin.x - pWin->drawable.depth,
wBorderWidth(pWin), xnestWindowPriv(pWin)->window,
pWin->origin.y - xnestWindowParent(pWin),
wBorderWidth(pWin), pWin->origin.x - wBorderWidth(pWin),
pWin->drawable.width, pWin->origin.y - wBorderWidth(pWin),
pWin->drawable.height, pWin->drawable.width,
pWin->borderWidth, pWin->drawable.height,
pWin->drawable.depth, pWin->borderWidth,
pWin->drawable.class, pWin->drawable.class,
visual, mask, &attributes); (visual ? visual->visualid : 0),
mask,
&attributes);
xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin);
xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin);
xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin);

View File

@ -22,6 +22,7 @@ srcs = [
x11_xcb_dep = dependency('x11-xcb', required: true) x11_xcb_dep = dependency('x11-xcb', required: true)
xcb_dep = dependency('xcb', required: true) xcb_dep = dependency('xcb', required: true)
xcb_aux_dep = dependency('xcb-aux', required: true)
executable( executable(
'Xnest', 'Xnest',
@ -31,6 +32,7 @@ executable(
common_dep, common_dep,
xnest_dep, xnest_dep,
xcb_dep, xcb_dep,
xcb_aux_dep,
x11_xcb_dep, x11_xcb_dep,
], ],
link_with: [ link_with: [