Opened 2 years ago

Closed 20 months ago

Last modified 20 months ago

#14419 closed defect (fixed)

Dialogs are centered wrong on a dual screen system [wxGTK]

Reported by: lanurmi Owned by:
Priority: normal Milestone: 3.0.0
Component: wxGTK Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

wxSplashScreen is centered in the center of the whole desktop, not in the center of either screen on a dual screen system. That means the splash screen is basically 50%/50% on both screens when the resolutions are equal.

Attachments (1)

centre.diff download (611 bytes) - added by lanurmi 2 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 2 years ago by vadz

Is this really wxSplashScreen-specific? Looking at the code it just calls the usual Centre() functions so it seems like they are broken... Could you please check how do the centred dialogs in the dialogs sample behave?

comment:2 Changed 2 years ago by lanurmi

  • Summary changed from wxSplashScreen is centered wrong on a dual screen system [wxGTK] to Dialogs are centered wrong on a dual screen system [wxGTK]

Kind-of-yes and no, it seems. The centered dialogs of the dialogs sample are indeed centered wrong, but apparently the window manager (Metacity) moves the dialogs enough to keep them on the left-hand-side screen. But this doesn't happen for a splash screen, perhaps because it doesn't have a titlebar.

In any case, I adjusted the summary.

comment:3 Changed 2 years ago by vadz

This is bad news, I thought we fixed centring some time ago... What system exactly do you use? Could you please try to trace into wxWidgets code to see what goes wrong inside Centre() (probably display size determination but I'm not sure)?

TIA!

comment:4 Changed 2 years ago by lanurmi

I am using CentOS 6.2 (32-bit). Its gtk version is gtk2-2.18.9-6.el6, in case that matters.

The problem seems to be that wxDisplay::GetClientArea() (called from wxTopLevelWindowBase::DoCentre()) returns the total width of both physical screens.

I am attaching a one-line patch that fixes the problem for me (for both the splash screen and dialogs). However, if it's GetClientArea that is actually broken, then this patch is only an ugly workaround.

Changed 2 years ago by lanurmi

comment:5 Changed 2 years ago by vadz

  • Milestone set to 3.0

The bug is definitely in GetClientArea(), it must always return a subrectangle of the rectangle returned by GetGeometry().

Looking at the code it seems that we could have the behaviour you observe if _NET_WORKAREA is not supported by the WM as then wxClientDisplayRect() returns the entire combined size of all displays. Could you please confirm that this is what happens in your case?

comment:6 Changed 2 years ago by lanurmi

Today I debugged what happens in wxClientDisplayRect(). It seems that _NET_WORKAREA is supported, and XGetWindowProperty() gets successfully called. But what it returns though workareas[2] is the total width of both screens.

(Sorry about the delay with my answer.)

comment:7 Changed 2 years ago by vadz

Sorry, no idea where to go from there. We could just use GTK for this function in wxGTK, I guess...

comment:8 Changed 20 months ago by vadz

The spec clearly says that the work area 'SHOULD' be included in the total area so it's clear that the WM is not compliant but it probably doesn't help in practice, so I'll add a hack to ensure that we always use the intersection of the work area returned with the total display rect. At the very least this will help with the WMs that don't support _NET_WORKAREA at all.

Please retest and reopen if it still doesn't work after I commit my changes, TIA!

comment:9 Changed 20 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73282]) Ensure that client display rectangle is always less than its total area.

Under Unix we could return client display rectangle that was bigger than the
entire display size as it corresponded to the total screen size when
_NET_WORKAREA was not supported or was not correctly implemented by the WM.

Fix this by explicitly intersecting the client rect with the total one.

Closes #14419.

comment:10 Changed 20 months ago by lanurmi

Tested with the splash sample, and it seems to be working properly now. Thanks!

Note: See TracTickets for help on using tickets.