Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-04-25 13:44:42

T200proX7
Member
Registered: 2020-11-10
Posts: 6

Problem with window positioning wmctrl + xwininfo on some applications

Hi guys,

I have written a script for positioning windows under Xfce / xfwm. I have of course done the calculation for the window frames here. The script works very well. However, it is unfortunately the case that for some windows the positioning does not fit.

To illustrate the problem with an example, see as follows. We have here once Xterminal and once Geany. In both cases I position the windows with wmctrl to x: 0, y: 0 with l: 1276, h: 676.

If I determine the position by xwininfo query after performing the positioning, however, I get a different result for Xterminal. If I perform the positioning of Xterminal afterwards again with wmctrl, then the positioning and the result of the query are correct.

With Geany (and various other applications) the positioning works immediately. In 90% of the cases the positioning works. In the remaining 10% it works in the best case only the second time.

################ POSITION XTERMINAL NR. 1 ################ 

$ wmctrl -r :ACTIVE: -e 0,0,0,1276,676
$ xwininfo -id "$(xdotool getactivewindow)"

xwininfo: Window id: 0x3800634 "Terminal"

  Absolute upper-left X:  2
  Absolute upper-left Y:  28
  Relative upper-left X:  2
  Relative upper-left Y:  28
  Width: 1275
  Height: 674
  Depth: 32
  Visual: 0x6af
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x3800002 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +2+28  -3843+28  -3843-738  +2-738
  -geometry 157x36+0+0

----------------------------------------------------

################ POSITION XTERMINAL NR. 2 ################ 

$ wmctrl -r :ACTIVE: -e 0,0,0,1276,676
$ xwininfo -id "$(xdotool getactivewindow)"

xwininfo: Window id: 0x3800634 "Terminal"

  Absolute upper-left X:  2
  Absolute upper-left Y:  28
  Relative upper-left X:  2
  Relative upper-left Y:  28
  Width: 1276
  Height: 676
  Depth: 32
  Visual: 0x6af
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x3800002 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +2+28  -3842+28  -3842-736  +2-736
  -geometry 157x36+0+0

----------------------------------------------------

################ POSITION GEANY NR. 1 ################ 

$ sleep 2 && wmctrl -r :ACTIVE: -e 0,0,0,1276,676
$ sleep 2 && xwininfo -id "$(xdotool getactivewindow)"

xwininfo: Window id: 0x460000c "*unbenannt - Geany"

  Absolute upper-left X:  2
  Absolute upper-left Y:  28
  Relative upper-left X:  2
  Relative upper-left Y:  28
  Width: 1276
  Height: 676
  Depth: 24
  Visual: 0x50d
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x460000b (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +2+28  -3842+28  -3842-736  +2-736
  -geometry 1276x676+0+0

Does anyone have any idea how to solve this or why there is such behavior? Has anyone already recognized this situation? Any idea for a workaround?

Thanks,
Regards

Offline

#2 2022-04-25 16:19:21

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: Problem with window positioning wmctrl + xwininfo on some applications

Is the problem only in the query or is it visually noticeable? Could you try fetching window ID with:

xprop -root _NET_ACTIVE_WINDOW

I say this because foreign tools like wmctrl or xdotool prepend an extra zero or two in wid's hex representation, which sometimes messes up your entire script, or causes their output to be slightly incorrect.

Also, why don't you try resizing with xdotool?

Another thing you'd probably want to keep in mind is that if you're doing this for apps on their initial startup, then devilspie2 might come in handy.

Last edited by KBar (2022-04-25 16:23:15)


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#3 2022-04-26 19:28:20

T200proX7
Member
Registered: 2020-11-10
Posts: 6

Re: Problem with window positioning wmctrl + xwininfo on some applications

Hello and thank you for your answer

xwininfo: Window id: 0x360448d "Terminal"
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x360448d, 0x0

As you can see, the IDs are identical. So this should fit. If it did not fit, the window (the size) would not be adjusted at all.

What I noticed in the upper code box: The last line of xwininfo "-geometry" shows with the terminal only: "157x36+0+0" and with Geany the identical size to width and height. Thats kind of strange.

Thanks for the info with devilspie2. No I don't change the window when starting the program but it's still a good hint that there is such a program and to know the name of it.

I will try resizing with xdotool and see if that fixes the problem. I will let you know as soon as I have tried it.

Offline

#4 2022-04-26 19:48:20

T200proX7
Member
Registered: 2020-11-10
Posts: 6

Re: Problem with window positioning wmctrl + xwininfo on some applications

I resized the window with xdotool and the result was unfortunately the same. See below:

$ xdotool windowsize 56640653 1276 676
$ xwininfo -id "$(xdotool getactivewindow)"

xwininfo: Window id: 0x360448d "Terminal"

  Absolute upper-left X:  2
  Absolute upper-left Y:  28
  Relative upper-left X:  2
  Relative upper-left Y:  28
  Width: 1275
  Height: 674
  Depth: 32
  Visual: 0x6af
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x3600002 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +2+28  -3843+28  -3843-738  +2-738
  -geometry 157x36+0+0

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 8 queries executed - Memory usage: 547.95 KiB (Peak: 548.58 KiB) ]