xpra icon
Bug tracker and wiki

#2141 closed defect (fixed)

Small improvements to window position on client

Reported by: Mark Harkin Owned by: Mark Harkin
Priority: minor Milestone: 2.5
Component: client Version: 2.4.x
Keywords: Cc:


These are less PR's and more pointers for fixing the underlying issues.

Java AWT is very old and assumes 1 screen per 1 monitor. However, Xpra uses 1 screen across multiple monitors, while this is valid it doesn't play nice with Java AWT Toolkit which centers windows on the screen and not the monitors. The case I have fixed this for is a window centering across 2 side-by-side monitors. The window is repositioned to the center of the 1st monitor when centered across the screen (with a magic number margin of error of 10px). Maybe this could be implemented better, only for java awt windows and with an environment variable flag to have it off by default?

When I had a frameless java window that could be moved by dragging it, it was jumping uncontrollably (#1941). Windows would sometimes jump with the title bar above the screen out of view. I don't think this is/should be allowed by any OS. I haven't yet considered a monitor above yet but my hack to fix this was:

Attachments (2)

MainWindow.java (623 bytes) - added by Antoine Martin 20 months ago.
awt test case based on the example from #1975
firefox_dropdown.png (5.5 KB) - added by Mark Harkin 20 months ago.

Download all attachments as: .zip

Change History (9)

Changed 20 months ago by Antoine Martin

Attachment: MainWindow.java added

awt test case based on the example from #1975

comment:1 Changed 20 months ago by Antoine Martin

Owner: changed from Antoine Martin to Mark Harkin

Java clearly ignores the xinerama data (#496), just like it does with DPI, so we need to fixup the window position instead.
r21614 merges your patch after making some small changes:

  • add environment variable to disable this behaviour: XPRA_AWT_RECENTER
  • refactor the existing AWT window detection code, and only apply the workaround to AWT windows
  • move position adjustment to a method we can re-use from both setup_window and adjusted_position
  • be more defensive and don't assume screens and monitors are always present, only recenter if there is more than one monitor

@mjharkin: does that work for you?
I've used the example Java class above and got it to center on the first monitor.

comment:2 Changed 20 months ago by Antoine Martin

As for the second issue, r21616 prevents that, but it is only enabled by default on macos and mswindows for now. Many X11 window managers will let you move windows as long as you can see an edge of it.

Changed 20 months ago by Mark Harkin

Attachment: firefox_dropdown.png added

comment:3 Changed 20 months ago by Mark Harkin

That's great thanks, r21614 and r21616 work as expected.

2 more changes I've made (and I think the only remaining changes for the python client are):

1: an issue with the Options drop down in Firefox while maximized is causing it to be pushed to the next screen. Attached screenshot of the menu when not maximized shows it overshooting the window. Since this is in the transparent area I just hacked the code to allow monitor width +1
Not sure how or if you want to handle this one.

2: small updates to the tray menu. Allowing SHOW_CLOSE as env variable and reducing icon size in the start submenu to same as the rest of the tray menu.

comment:4 Changed 20 months ago by Antoine Martin

  • the drop down in Firefox is fixed more properly in trunk with r21631 (this was caused by r13669 + r13670 for #1284) - I'll try to come up with something more suitable for backporting to v2.4.x
  • making the "close" menu entry an option was merged in r21632.
  • as for the icon size, the more correct fix is in r21636.

@mjharkin: can I close this ticket?

comment:5 Changed 20 months ago by Mark Harkin

Resolution: fixed
Status: newclosed

Yes, all 3 fixes are now working as expected. Thanks.

comment:6 Changed 19 months ago by Mark Harkin

Resolution: fixed
Status: closedreopened

Originally tested r21616 with the env variable set, but should default correctly so reopening.


I think this should be:


comment:7 Changed 19 months ago by Antoine Martin

Resolution: fixed
Status: reopenedclosed

oops, sorry about that.
r21785 enables it everywhere by default since most Linux DEs seem to no longer allow windows to be moved using the frame.

Note: See TracTickets for help on using tickets.