Xnest: replace XSetStandardProperties() by xcb functions
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
a05b912d06
commit
415594fd67
|
@ -20,6 +20,8 @@ is" without express or implied warranty.
|
||||||
#include <X11/Xdefs.h>
|
#include <X11/Xdefs.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
#include "mi/mi_priv.h"
|
#include "mi/mi_priv.h"
|
||||||
#include "mi/mipointer_priv.h"
|
#include "mi/mipointer_priv.h"
|
||||||
|
|
||||||
|
@ -146,7 +148,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
|
||||||
int i, j, depthIndex;
|
int i, j, depthIndex;
|
||||||
unsigned long valuemask;
|
unsigned long valuemask;
|
||||||
XWindowAttributes gattributes;
|
XWindowAttributes gattributes;
|
||||||
XSizeHints sizeHints;
|
|
||||||
VisualID defaultVisual;
|
VisualID defaultVisual;
|
||||||
int rootDepth;
|
int rootDepth;
|
||||||
miPointerScreenPtr PointPriv;
|
miPointerScreenPtr PointPriv;
|
||||||
|
@ -401,20 +402,47 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
|
||||||
if (!xnestWindowName)
|
if (!xnestWindowName)
|
||||||
xnestWindowName = argv[0];
|
xnestWindowName = argv[0];
|
||||||
|
|
||||||
sizeHints.flags = PPosition | PSize | PMaxSize;
|
xcb_size_hints_t sizeHints = {
|
||||||
sizeHints.x = xnestX + POSITION_OFFSET;
|
.flags = XCB_ICCCM_SIZE_HINT_P_POSITION | XCB_ICCCM_SIZE_HINT_P_SIZE | XCB_ICCCM_SIZE_HINT_P_MAX_SIZE,
|
||||||
sizeHints.y = xnestY + POSITION_OFFSET;
|
.x = xnestX + POSITION_OFFSET,
|
||||||
sizeHints.width = sizeHints.max_width = xnestWidth;
|
.y = xnestY + POSITION_OFFSET,
|
||||||
sizeHints.height = sizeHints.max_height = xnestHeight;
|
.width = sizeHints.max_width = xnestWidth,
|
||||||
|
.height = sizeHints.max_height = xnestHeight,
|
||||||
|
};
|
||||||
|
|
||||||
if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
|
if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
|
||||||
sizeHints.flags |= USPosition;
|
sizeHints.flags |= XCB_ICCCM_SIZE_HINT_US_POSITION;
|
||||||
if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
|
if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
|
||||||
sizeHints.flags |= USSize;
|
sizeHints.flags |= XCB_ICCCM_SIZE_HINT_US_SIZE;
|
||||||
XSetStandardProperties(xnestDisplay,
|
|
||||||
xnestDefaultWindows[pScreen->myNum],
|
const size_t windowNameLen = strlen(xnestWindowName);
|
||||||
xnestWindowName,
|
|
||||||
xnestWindowName,
|
xcb_icccm_set_wm_name_checked(xnestUpstreamInfo.conn,
|
||||||
xnestIconBitmap, argv, argc, &sizeHints);
|
xnestDefaultWindows[pScreen->myNum],
|
||||||
|
XCB_ATOM_STRING,
|
||||||
|
8,
|
||||||
|
windowNameLen,
|
||||||
|
xnestWindowName);
|
||||||
|
|
||||||
|
xcb_icccm_set_wm_icon_name_checked(xnestUpstreamInfo.conn,
|
||||||
|
xnestDefaultWindows[pScreen->myNum],
|
||||||
|
XCB_ATOM_STRING,
|
||||||
|
8,
|
||||||
|
windowNameLen,
|
||||||
|
xnestWindowName);
|
||||||
|
|
||||||
|
xnest_set_command(xnestUpstreamInfo.conn,
|
||||||
|
xnestDefaultWindows[pScreen->myNum],
|
||||||
|
argv, argc);
|
||||||
|
|
||||||
|
xcb_icccm_wm_hints_t wmhints = {
|
||||||
|
.icon_pixmap = xnestIconBitmap,
|
||||||
|
.flags = XCB_ICCCM_WM_HINT_ICON_PIXMAP,
|
||||||
|
};
|
||||||
|
|
||||||
|
xcb_icccm_set_wm_hints_checked(xnestUpstreamInfo.conn,
|
||||||
|
xnestDefaultWindows[pScreen->myNum],
|
||||||
|
&wmhints);
|
||||||
|
|
||||||
xcb_map_window(xnestUpstreamInfo.conn, xnestDefaultWindows[pScreen->myNum]);
|
xcb_map_window(xnestUpstreamInfo.conn, xnestDefaultWindows[pScreen->myNum]);
|
||||||
|
|
||||||
|
|
|
@ -147,3 +147,36 @@ uint32_t xnest_create_pixmap_from_bitmap_data(
|
||||||
xcb_free_gc(conn, gc);
|
xcb_free_gc(conn, gc);
|
||||||
return pix;
|
return pix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xnest_set_command(
|
||||||
|
xcb_connection_t *conn,
|
||||||
|
xcb_window_t window,
|
||||||
|
char **argv,
|
||||||
|
int argc)
|
||||||
|
{
|
||||||
|
int i = 0, nbytes = 0;
|
||||||
|
|
||||||
|
for (i = 0, nbytes = 0; i < argc; i++)
|
||||||
|
nbytes += strlen(argv[i]) + 1;
|
||||||
|
|
||||||
|
if (nbytes >= (2^16) - 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char buf[nbytes+1];
|
||||||
|
char *bp = buf;
|
||||||
|
|
||||||
|
/* copy arguments into single buffer */
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
strcpy(bp, argv[i]);
|
||||||
|
bp += strlen(argv[i]) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_change_property(conn,
|
||||||
|
XCB_PROP_MODE_REPLACE,
|
||||||
|
window,
|
||||||
|
XCB_ATOM_WM_COMMAND,
|
||||||
|
XCB_ATOM_STRING,
|
||||||
|
8,
|
||||||
|
nbytes,
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
|
|
@ -32,4 +32,6 @@ uint32_t xnest_create_pixmap_from_bitmap_data(xcb_connection_t *conn, uint32_t d
|
||||||
const char *data, uint32_t width, uint32_t height,
|
const char *data, uint32_t width, uint32_t height,
|
||||||
uint32_t fg, uint32_t bg, uint16_t depth);
|
uint32_t fg, uint32_t bg, uint16_t depth);
|
||||||
|
|
||||||
|
void xnest_set_command(xcb_connection_t *conn, xcb_window_t window, char ** argv, int argc);
|
||||||
|
|
||||||
#endif /* __XNEST__XCB_H */
|
#endif /* __XNEST__XCB_H */
|
||||||
|
|
Loading…
Reference in New Issue