(!1654) Xnest: replace XSetStandardProperties() by xcb functions
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									ae44aaa61d
								
							
						
					
					
						commit
						d55900ade6
					
				| 
						 | 
				
			
			@ -20,6 +20,8 @@ is" without express or implied warranty.
 | 
			
		|||
#include <X11/Xdefs.h>
 | 
			
		||||
#include <X11/Xproto.h>
 | 
			
		||||
 | 
			
		||||
#include <xcb/xcb_icccm.h>
 | 
			
		||||
 | 
			
		||||
#include "mi/mi_priv.h"
 | 
			
		||||
#include "mi/mipointer_priv.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +148,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
 | 
			
		|||
    int i, j, depthIndex;
 | 
			
		||||
    unsigned long valuemask;
 | 
			
		||||
    XWindowAttributes gattributes;
 | 
			
		||||
    XSizeHints sizeHints;
 | 
			
		||||
    VisualID defaultVisual;
 | 
			
		||||
    int rootDepth;
 | 
			
		||||
    miPointerScreenPtr PointPriv;
 | 
			
		||||
| 
						 | 
				
			
			@ -401,20 +402,47 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
 | 
			
		|||
        if (!xnestWindowName)
 | 
			
		||||
            xnestWindowName = argv[0];
 | 
			
		||||
 | 
			
		||||
        sizeHints.flags = PPosition | PSize | PMaxSize;
 | 
			
		||||
        sizeHints.x = xnestX + POSITION_OFFSET;
 | 
			
		||||
        sizeHints.y = xnestY + POSITION_OFFSET;
 | 
			
		||||
        sizeHints.width = sizeHints.max_width = xnestWidth;
 | 
			
		||||
        sizeHints.height = sizeHints.max_height = xnestHeight;
 | 
			
		||||
        xcb_size_hints_t sizeHints = {
 | 
			
		||||
            .flags = XCB_ICCCM_SIZE_HINT_P_POSITION | XCB_ICCCM_SIZE_HINT_P_SIZE | XCB_ICCCM_SIZE_HINT_P_MAX_SIZE,
 | 
			
		||||
            .x = xnestX + POSITION_OFFSET,
 | 
			
		||||
            .y = xnestY + POSITION_OFFSET,
 | 
			
		||||
            .width = sizeHints.max_width = xnestWidth,
 | 
			
		||||
            .height = sizeHints.max_height = xnestHeight,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
 | 
			
		||||
            sizeHints.flags |= USPosition;
 | 
			
		||||
            sizeHints.flags |= XCB_ICCCM_SIZE_HINT_US_POSITION;
 | 
			
		||||
        if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
 | 
			
		||||
            sizeHints.flags |= USSize;
 | 
			
		||||
        XSetStandardProperties(xnestDisplay,
 | 
			
		||||
                               xnestDefaultWindows[pScreen->myNum],
 | 
			
		||||
                               xnestWindowName,
 | 
			
		||||
                               xnestWindowName,
 | 
			
		||||
                               xnestIconBitmap, argv, argc, &sizeHints);
 | 
			
		||||
            sizeHints.flags |= XCB_ICCCM_SIZE_HINT_US_SIZE;
 | 
			
		||||
 | 
			
		||||
        const size_t windowNameLen = strlen(xnestWindowName);
 | 
			
		||||
 | 
			
		||||
        xcb_icccm_set_wm_name_checked(xnestUpstreamInfo.conn,
 | 
			
		||||
                                      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]);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,3 +147,36 @@ uint32_t xnest_create_pixmap_from_bitmap_data(
 | 
			
		|||
    xcb_free_gc(conn, gc);
 | 
			
		||||
    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,
 | 
			
		||||
                                         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 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue