Repository: pwr-Solaar/Solaar

Issue:
Main window is... weird on tiling WMs (or when resizing)
**Information**

- Solaar version (`git describe --tags` if cloned from Solaar repository): 1.0.2
- Distribution: ArchLinux
- Kernel version (ex. `uname -srmo`): `Linux 5.7.0-arch1-1 x86_64 GNU/Linux`
- Output of `solaar show`:
```
Unifying Receiver
  Device path  : /dev/hidraw0
  USB id       : 046d:c52b
  Serial       : EB4B9034
    Firmware   : 24.10.B0036
    Bootloader : 01.08
    Other      : AA.AC
  Has 3 paired device(s) out of a maximum of 6.
  Notifications: wireless, software present (0x000900)
  Device activity counters: 1=186, 3=162

  1: Wireless Solar Keyboard K750
     Codename     : K750
     Kind         : keyboard
     Wireless PID : 400F
     Protocol     : HID++ 2.0
     Polling rate : 20 ms (50Hz)
     Serial number: C7F3E57A
          Firmware: RQK 42.01.B0023
        Bootloader: DFU 00.02.B0003
     The power switch is located on the edge of top right corner.
     Supports 13 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: FEATURE INFO           {0002}   
         3: DEVICE FW VERSION      {0003}   
         4: DEVICE NAME            {0005}   
         5: REPROG CONTROLS        {1B00}   
         6: REPROG CONTROLS V2 2   {1B02}   
         7: WIRELESS DEVICE STATUS {1D4B}   
         8: unknown:1DF3           {1DF3}   hidden
         9: FN INVERSION           {40A0}   
        10: ENCRYPTION             {4100}   
        11: SOLAR DASHBOARD        {4301}   
        12: KEYBOARD LAYOUT        {4520}   
     Has 10 reprogrammable keys:
         0: unknown:009A               => unknown:006F                  is FN, FN sensitive
         1: unknown:009B               => unknown:0070                  is FN, FN sensitive
         2: unknown:0098               => unknown:006D                  is FN, FN sensitive, reprogrammable
         3: MAC DASHBOARD              => SnapLeft                      is FN, FN sensitive, reprogrammable
         4: Previous                   => Previous                      is FN, FN sensitive
         5: Play/Pause                 => Play/Pause                    is FN, FN sensitive
         6: Next                       => Next                          is FN, FN sensitive
         7: Mute                       => Mute                          is FN, FN sensitive
         8: Volume Down                => Volume Down                   is FN, FN sensitive
         9: Volume Up                  => Volume Up                     is FN, FN sensitive
     Battery status unavailable.

  2: Performance Mouse MX
     Codename     : Performance MX
     Kind         : mouse
     Wireless PID : 101A
     Protocol     : HID++ 1.0
     Polling rate : 8 ms (125Hz)
     Serial number: 7885318E
     The power switch is located on the base.
     Battery: unknown (device is offline).

  3: MX Vertical Advanced Ergonomic Mouse
     Codename     : MX Vertical
     Kind         : mouse
     Wireless PID : 407B
     Protocol     : HID++ 4.5
     Polling rate : 8 ms (125Hz)
     Serial number: 3F6AFAA6
        Bootloader: BOT 78.00.B0009
          Firmware: MPM 16.00.B0009
             Other: 
     Supports 34 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
         3: DEVICE NAME            {0005}   
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: CRYPTO ID              {0021}   
         7: DEVICE FRIENDLY NAME   {0007}   
         8: BATTERY STATUS         {1000}   
         9: unknown:1002           {1002}   
        10: REPROG CONTROLS V4     {1B04}   
        11: PERSISTENT REMAPPABLE ACTION {1C00}   
        12: CHANGE HOST            {1814}   
        13: HOSTS INFO             {1815}   
        14: unknown:2250           {2250}   
        15: unknown:18B1           {18B1}   internal, hidden
        16: VERTICAL SCROLLING     {2100}   
            Roller type: standard
            Ratchet per turn: 24
            Scroll lines: 0
        17: LOWRES WHEEL           {2130}   
            Wheel Reports: HID
        18: ADJUSTABLE DPI         {2201}   
        19: DEVICE RESET           {1802}   internal, hidden
        20: unknown:1803           {1803}   internal, hidden
        21: CONFIG DEVICE PROPS    {1806}   internal, hidden
        22: unknown:1813           {1813}   internal, hidden
        23: OOBSTATE               {1805}   internal, hidden
        24: unknown:1830           {1830}   internal, hidden
        25: unknown:1890           {1890}   internal, hidden
        26: unknown:1891           {1891}   internal, hidden
        27: unknown:18A1           {18A1}   internal, hidden
        28: unknown:1DF3           {1DF3}   internal, hidden
        29: unknown:1E00           {1E00}   hidden
        30: unknown:1EB0           {1EB0}   internal, hidden
        31: unknown:1E22           {1E22}   internal, hidden
        32: unknown:1861           {1861}   internal, hidden
        33: unknown:18C0           {18C0}   internal, hidden
     Has 7 reprogrammable keys:
         0: LEFT CLICK                , default: LeftClick                   => LEFT CLICK                
             mse, reprogrammable, pos:0, group:1, gmask:1
         1: RIGHT CLICK               , default: RightClick                  => RIGHT CLICK               
             mse, reprogrammable, pos:0, group:1, gmask:1
         2: MIDDLE BUTTON             , default: MiddleMouseButton           => MIDDLE BUTTON             
             mse, reprogrammable, divertable, persistently divertable, pos:0, group:2, gmask:3
         3: BACK AS BUTTON 4          , default: BackEx                      => BACK AS BUTTON 4          
             mse, reprogrammable, divertable, persistently divertable, pos:0, group:2, gmask:3
         4: FORWARD AS BUTTON 5       , default: BrowserForwardEx            => FORWARD AS BUTTON 5       
             mse, reprogrammable, divertable, persistently divertable, pos:0, group:2, gmask:3
         5: unknown:00FD              , default: unknown:00D2                => unknown:00FD              
             mse, reprogrammable, divertable, persistently divertable, pos:0, group:2, gmask:3
         6: unknown:00D7              , default: unknown:00B4                => unknown:00D7              
             divertable, virtual, pos:0, group:3, gmask:0
     Battery: 90%, discharging.


```

**Describe the bug**

The main window is buggy/weird on a tiling WM. It seems that the size of the content is hardcoded, so much of the window is just transparent content (where the root background is displayed).
Example screenshot of just the solaar window:

![2020-06-06T15:41:59,795110206+02:00](https://user-images.githubusercontent.com/730811/83945632-82b8cb00-a7fb-11ea-85b5-c97d53250697.png)

Note that this is *not* a screenshot of my entire desktop; it's just solaar. The background you're seeing there is just pseudo-transparency inside the window.

**To Reproduce**
Steps to reproduce the behavior:
1. On a tiling window manager...
2. Run `solaar`

**Additional context**

Looks like the window control sizes are hardcoded to a default window size and don't react to the window resizing properly. For example, making a floating window wider results in this:

![2020-06-06T15:39:53,513626209+02:00](https://user-images.githubusercontent.com/730811/83945660-b562c380-a7fb-11ea-8d26-ad18fda9e951.png)

Again, whitespace is part of the window, it just looks like the main content won't expand.


Discussion:
It's not that the sizes are completely hardcoded but there are minimum and maximum sizes.

I take this to be a bug in GTK, not in Solaar.   If there is a really good reason to go over the maximum sizes then GTK should override them.  Or maybe it is lack of communication between your window manager and GTK?

If someone with good knowledge of GTK has a suggestion on how window sizes should be specified, please speak up.   

The code for the window size is in window.py
```
	geometry = Gdk.Geometry()
	geometry.min_width = 600
	geometry.min_height = 320
	geometry.max_width = 1000
	geometry.max_height = 600
	window.set_geometry_hints(vbox, geometry, Gdk.WindowHints.MIN_SIZE | Gdk.WindowHints.MAX_SIZE)
	window.set_position(Gtk.WindowPosition.CENTER)
```

Hmmm... the concept of maximum window size does not really exist in tiling window managers; windows occupy the space they're given.

(This is much unlike floating window managers, where you just have "empty" space too).

Why is the window size constrained by solaar anyway?
Probably because that's what is done in GTK.
Aside from Telegrams call-popup, I don't think I've **ever**  encountered windows that restrict a maximum size.

Would it represent any issue just dropping the maximum size? (Seems to be an optional hint given the snippet above).

I really don't see any reason to add limitations to users unless there's some trade-off.

Plus, that would get rid of the misbehaviour in tiling window managers :)
I'm not against that.
@FFY00 Any comments?
Go for it. It is something that has bothered me from time to time. The maximum size does not play well with hidpi.

See my screenshot: https://i.imgur.com/8zXajQA.jpg

Thankfully I have a really big screen, so the maximum size is reasonable. But if I had a laptop (small screen) with hidpi (for eg. 4k) without plain scaling, it would be tiny. The main screen in the screenshot is 4k, so you can see the ratios. Since the maximum size is given in pixels there we would have to do some calculations to scale properly, not sure if Gtk has a way to do this automatically.

Anyway, I do not see any reason for the maximum to be there, and I would rather just remove it.

Resolving patch:
diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py
--- a/lib/solaar/ui/window.py
+++ b/lib/solaar/ui/window.py
@@ -346,9 +346,7 @@ def _create(delete_action):
 	geometry = Gdk.Geometry()
 	geometry.min_width = 600
 	geometry.min_height = 320
-	geometry.max_width = 1000
-	geometry.max_height = 600
-	window.set_geometry_hints(vbox, geometry, Gdk.WindowHints.MIN_SIZE | Gdk.WindowHints.MAX_SIZE)
+	window.set_geometry_hints(vbox, geometry, Gdk.WindowHints.MIN_SIZE)
 	window.set_position(Gtk.WindowPosition.CENTER)
 
 	style = window.get_style_context()


Test patch: