awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.36k stars 598 forks source link

jetbrains dialogs do not respect window position #2934

Open glpub opened 4 years ago

glpub commented 4 years ago

Output of awesome --version: awesome v4.3 (Too long) • Compiled against Lua 5.3.5 (running with Lua 5.3) • D-Bus support: ✔ • execinfo support: ✔ • xcb-randr version: 1.6 • LGI version: 0.9.2

jetbrains - at least any of 2019.*

How to reproduce the issue: Open dialog window, eg. "File -> Open...", close it and open again. Repeat few times. Every time dialog moves to new position, it seems the new coordinates are: newX = oldX + borderWidth newY = oldY + borderWidth + titleBarHeight

I made rule for debug: `
rule = { class = "jetbrains-.", instance = "jetbrains-.", type = "dialog" }, callback = function(c) print("**") local geometry = c:geometry() print("x = " .. tostring(geometry['x'])) print("y = " .. tostring(geometry['y'])) print("w = " .. tostring(geometry['width'])) print("h = " .. tostring(geometry['height']))

            local h = c.size_hints
            print()
            print("user_position.x = " .. tostring(h.user_position["x"]))
            print("user_position.y = " .. tostring(h.user_position["y"]))
    end
},

`

output of the rule: `


x = 604 y = 203 w = 624 h = 706

user_position.x = 604 user_position.y = 203


x = 605 y = 236 w = 624 h = 706

user_position.x = 605 user_position.y = 236


x = 606 y = 269 w = 624 h = 706

user_position.x = 606 user_position.y = 269 `

Expected result - dialog should stay on the same position

Actually not sure if that awesome wm bug, I also have looked into jetbrains sourcecode, it gets coordinates of dialog window without decoration, so I need advise where to dig.

psychon commented 4 years ago

Actually not sure if that awesome wm bug, I also have looked into jetbrains sourcecode, it gets coordinates of dialog window without decoration, so I need advise where to dig.

Do you have a pointer to this source code? What exactly does it do?

AwesomeWM is a bit special in that it actually uses X11 window borders. Not much else does so these days. Thus, code "out there" easily assumes that the window border is zero and gets positions wrong. (The position of a window in X11 is the position of the top left corner of the window. Thus, with a border width of e.g. 10, the window border starts at (x-10,y-10).)

Also relevant could be the WM_NORMAL_HINTS of the window in question and whether it places itself before generating a MapRequest or afterwards. I am actually not sure how the coordinates should be interpreted in a ConfigureRequest when a window border is involved...

glpub commented 4 years ago

Do you have a pointer to this source code?

Entry point to save position and size of window Entry point to restore position

What exactly does it do?

On dialog show it gets saved position and size and sets that values to the window. On dialog dispose it does the opposite, get size and position of the window and saves it.

AwesomeWM is a bit special in that it actually uses X11 window borders. Not much else does so these days. Thus, code "out there" easily assumes that the window border is zero and gets positions wrong. (The position of a window in X11 is the position of the top left corner of the window. Thus, with a border width of e.g. 10, the window border starts at (x-10,y-10).)

Yes, it seems that JDK knows nothing about window decoration and returns position of java window itself, not including borders and titlebar. At least that I got while ran jetbrains in debuger.

glpub commented 4 years ago

I checked how the dialogs behave in i3 and sway

i3 makes opposite to awesome - it shifts the window to upper left way, sway just centers the dialogs and do not use those position hints

So i'm stuck here. Any suggestions?

Aire-One commented 4 years ago

I'm currently working with IntelliJ IDEA 2019.2.4. My config has no-borders and no-titlebars for intellij (working on a separate tag, with only the intellij window).

Open dialog window, eg. "File -> Open...", close it and open again. Repeat few times. Every time dialog moves to new position, it seems the new coordinates are: newX = oldX + borderWidth newY = oldY + borderWidth + titleBarHeight

I can't reproduce this behavior, so I guess your analyses was correct: the shift comes from borders/titlebars.

With awesome we have this rules stuff that can help you mitigate this issue. I suggest you to use the placement property (or "force" it with the callback) to set the dialogs position.

ghost commented 3 years ago

I have a similar issue with Android studio and I fixed it with:

   {
      rule = { class = "jetbrains-studio", name="^win[0-9]+$" },
      properties = { 
         placement = awful.placement.no_offscreen,
         border_width = 0,
         titlebars_enabled = false
      }
   },
comod commented 3 years ago

Unfortunately this issue is even more annoying with a Second Screen. 9/10 times dialogs Open centered and sometimes on the second(!) screen in the left top corner. Some dialogs are completely weird resized (1.5x of rhe actual screensize 😅 ). Every other Program works fine. Only jetbrains products make such a trouble