diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Screen.c | 188 |
1 files changed, 116 insertions, 72 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 39a5b7763..cd50c9698 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -376,8 +376,8 @@ Window nxagentCreateIconWindow(void) unsigned long valuemask; char* window_name; XTextProperty windowName; - XSizeHints sizeHints; - XWMHints wmHints; + XSizeHints* sizeHints; + XWMHints* wmHints; Window w; Mask mask; @@ -416,26 +416,40 @@ Window nxagentCreateIconWindow(void) window_name = nxagentWindowName; XStringListToTextProperty(&window_name, 1, &windowName); - sizeHints.flags = PMinSize | PMaxSize; - sizeHints.min_width = sizeHints.max_width = 1; - sizeHints.min_height = sizeHints.max_height = 1; - wmHints.flags = IconPixmapHint | IconMaskHint; - wmHints.initial_state = IconicState; - wmHints.icon_pixmap = nxagentIconPixmap; - - if (useXpmIcon) + + if ((sizeHints = XAllocSizeHints())) { - wmHints.icon_mask = nxagentIconShape; - wmHints.flags = IconPixmapHint | IconMaskHint; + sizeHints->flags = PMinSize | PMaxSize; + sizeHints->min_width = sizeHints->max_width = 1; + sizeHints->min_height = sizeHints->max_height = 1; } - else + + if ((wmHints = XAllocWMHints())) { - wmHints.flags = StateHint | IconPixmapHint; + wmHints->flags = IconPixmapHint | IconMaskHint; + wmHints->initial_state = IconicState; + wmHints->icon_pixmap = nxagentIconPixmap; + + if (useXpmIcon) + { + wmHints->icon_mask = nxagentIconShape; + wmHints->flags = IconPixmapHint | IconMaskHint; + } + else + { + wmHints->flags = StateHint | IconPixmapHint; + } } XSetWMProperties(nxagentDisplay, w, &windowName, &windowName, - NULL , 0 , &sizeHints, &wmHints, NULL); + NULL , 0 , sizeHints, wmHints, NULL); + + if (sizeHints) + XFree(sizeHints); + + if (wmHints) + XFree(wmHints); /* * Enable events from the icon window. @@ -839,8 +853,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, unsigned long valuemask; XSetWindowAttributes attributes; XWindowAttributes gattributes; - XSizeHints sizeHints; - XWMHints wmHints; + XSizeHints* sizeHints; + XWMHints* wmHints; Mask mask; Bool resetAgentPosition = False; @@ -1866,52 +1880,61 @@ N/A XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask); } - sizeHints.flags = PPosition | PMinSize | PMaxSize; - sizeHints.x = nxagentOption(X) + POSITION_OFFSET; - sizeHints.y = nxagentOption(Y) + POSITION_OFFSET; - sizeHints.min_width = MIN_NXAGENT_WIDTH; - sizeHints.min_height = MIN_NXAGENT_HEIGHT; - - sizeHints.width = nxagentOption(RootWidth); - sizeHints.height = nxagentOption(RootHeight); - - if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1) - { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - } - else + if ((sizeHints = XAllocSizeHints())) { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); - } + sizeHints->flags = PPosition | PMinSize | PMaxSize; + sizeHints->x = nxagentOption(X) + POSITION_OFFSET; + sizeHints->y = nxagentOption(Y) + POSITION_OFFSET; + sizeHints->min_width = MIN_NXAGENT_WIDTH; + sizeHints->min_height = MIN_NXAGENT_HEIGHT; + + sizeHints->width = nxagentOption(RootWidth); + sizeHints->height = nxagentOption(RootHeight); - if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) - sizeHints.flags |= USPosition; - if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) - sizeHints.flags |= USSize; + if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1) + { + sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + } + else + { + sizeHints->max_width = nxagentOption(RootWidth); + sizeHints->max_height = nxagentOption(RootHeight); + } + if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) + sizeHints->flags |= USPosition; + if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) + sizeHints->flags |= USSize; + } /* FIXME: deprecated, replaced by XSetWmProperties() */ XSetStandardProperties(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], nxagentWindowName, nxagentWindowName, nxagentIconPixmap, - argv, argc, &sizeHints); + argv, argc, sizeHints); - wmHints.icon_pixmap = nxagentIconPixmap; + if (sizeHints) + XFree(sizeHints); - if (useXpmIcon) - { - wmHints.icon_mask = nxagentIconShape; - wmHints.flags = IconPixmapHint | IconMaskHint; - } - else + if ((wmHints = XAllocWMHints())) { - wmHints.flags = IconPixmapHint; - } + wmHints->icon_pixmap = nxagentIconPixmap; - XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &wmHints); + if (useXpmIcon) + { + wmHints->icon_mask = nxagentIconShape; + wmHints->flags = IconPixmapHint | IconMaskHint; + } + else + { + wmHints->flags = IconPixmapHint; + } + + XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], wmHints); + XFree(wmHints); + } /* * Clear the window but let it unmapped. We'll map it @@ -4531,49 +4554,73 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, void nxagentSetWMNormalHints(int screen, int width, int height) { - XSizeHints sizeHints; + XSizeHints* sizeHints = XAllocSizeHints(); + + if (!sizeHints) + return; /* * Change agent window size and size hints. */ - sizeHints.flags = PPosition | PMinSize | PMaxSize; - sizeHints.x = nxagentOption(X); - sizeHints.y = nxagentOption(Y); + sizeHints->flags = PPosition | PMinSize | PMaxSize; + sizeHints->x = nxagentOption(X); + sizeHints->y = nxagentOption(Y); - sizeHints.min_width = MIN_NXAGENT_WIDTH; - sizeHints.min_height = MIN_NXAGENT_HEIGHT; + sizeHints->min_width = MIN_NXAGENT_WIDTH; + sizeHints->min_height = MIN_NXAGENT_HEIGHT; - sizeHints.width = width; - sizeHints.height = height; + sizeHints->width = width; + sizeHints->height = height; if (nxagentOption(DesktopResize) == 1) { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); } else { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); + sizeHints->max_width = nxagentOption(RootWidth); + sizeHints->max_height = nxagentOption(RootHeight); } if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) { - sizeHints.flags |= USPosition; + sizeHints->flags |= USPosition; } if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) { - sizeHints.flags |= USSize; + sizeHints->flags |= USSize; } - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], &sizeHints); + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints); + + XFree(sizeHints); +} + +/* + set maxsize in WMNormalSizeHints + Note: this will _drop_ all existing hints since XSetWMNormalHints() + replaces any existing property +*/ +void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheight) +{ + XSizeHints* sizeHints; + + if ((sizeHints = XAllocSizeHints())) + { + sizeHints->flags = PMaxSize; + sizeHints->max_width = maxwidth; + sizeHints->max_height = maxheight; + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], + sizeHints); + XFree(sizeHints); + } } void nxagentShadowAdaptToRatio(void) { - XSizeHints sizeHints; ScreenPtr pScreen; RegionRec region; BoxRec box; @@ -4585,12 +4632,9 @@ void nxagentShadowAdaptToRatio(void) nxagentShadowCreateMainWindow(pScreen, screenInfo.screens[0]->root, nxagentShadowWidth, nxagentShadowHeight); - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - - sizeHints.flags = PMaxSize; - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &sizeHints); + nxagentSetWMNormalHintsMaxsize(pScreen, + WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); box.x1 = 0; box.y1 = 0; |