aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Screen.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2018-04-11 00:10:20 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-05-24 09:42:24 +0200
commit82dc00539c12323bb8daa8e0ada6e8eab8561e09 (patch)
treeddc5a99d50ee33951794c36d257e7468b130b03a /nx-X11/programs/Xserver/hw/nxagent/Screen.c
parent82c4c28ea726444c355835a5a0850b9dd6865e9a (diff)
downloadnx-libs-82dc00539c12323bb8daa8e0ada6e8eab8561e09.tar.gz
nx-libs-82dc00539c12323bb8daa8e0ada6e8eab8561e09.tar.bz2
nx-libs-82dc00539c12323bb8daa8e0ada6e8eab8561e09.zip
nxagent: use XAllocSizeHints() instead of XSizeHints struct
This is the preferred way. It ensures, that a) the data is zeroed b) a correct size in case xlib is changing the size of the structure in future releases
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Screen.c188
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;