Non-resizable window hints


#1

Hi Jules,

What do you think of adding the following lines in LinuxComponentPeer::setBounds ?

[code] hints->width = ww; // + windowBorder.getLeftAndRight();
hints->height = wh; // + windowBorder.getTopAndBottom();
hints->x = wx;// - windowBorder.getLeft();
hints->y = wy;// - windowBorder.getTop();

  •            if ((getStyleFlags() & windowIsResizable) == 0) { 
    
  •             hints->min_width  = hints->max_width  = hints->width;
    
  •              hints->min_height = hints->max_height = hints->height;
    
  •             hints->flags |= PMinSize|PMaxSize;
    
  •            }
    
  •            XSetWMNormalHints (display, windowH, hints);
              XFree (hints);
          }
    
          XMoveResizeWindow (display, windowH,
    

[/code]

That way the windowmanager does not allow me anymore to resize non-resizable windows


#2

Ah, very cunning. I like it.


#3

…although, you may have a window that can be resized, e.g. by a juce resizer comp, and that won’t be detected here, although you may still want to let the WM resize it. Not sure what a good fix for that would be…


#4

mmm right, the resizer component is not working anymore with this fix. Applying the change only for windows with a titlebar helps for the juce file browser and other non-native resizable juce dialogs , but it does not help for windows with a native titlebar and a resizer comp


#5

I think windows without a titlebar will just have to deal with whatever the WM does to them. I’d be happy to put this in:

if ((getStyleFlags() & (windowHasTitleBar | windowIsResizable)) == windowHasTitleBar) { hints->min_width = hints->max_width = hints->width; hints->min_height = hints->max_height = hints->height; hints->flags |= PMinSize | PMaxSize; }

(Assuming it doesn’t interfere with things like maximise/minimise?)


#6

Hi Jules,

After some further testing, I just noticed that:

  • the windowBorder argument was indeed useful for the call to XMoveResizeWindow as the (x,y) argument to this function is the position of the decorated window, with its titlebar and border:

XMoveResizeWindow (display, windowH, wx - windowBorder.getLeft(), wy - windowBorder.getTop(), ww,// + windowBorder.getLeftAndRight(), wh);// + windowBorder.getTopAndBottom());

If not done, the window will move by a few pixels each time it is resized, which is a bit annoying !

  • the “if (!mapped)” for the windowmanager hints should be replaced by “if (1)” (or something like if (!mapped || w != ww || h != wh)) in order to make sure that the window size hintz are updated when the window is resized – otherwise the window border does not get resized.

#7

Ok - so the position needs the border adjustment, but the size doesn’t?..


#8

yes, the size must not take into account the decoration (I know, what a mess…)