xfce_gtk_window_center_on_monitor in libxfcegui4 (which doesn't seem to have it's own bugzilla component, btw.) uses the window width and height returned by gtk_widget_size_request when calculating where to position the window. The problem is that often windows are bigger than that. They may have been resized by the user, or gtk_window_set_default_size may have been called. The result is that the window get's positioned as if it hadn't been resized, that is, it isn't centered on the monitor. Instead, the width and height returned by gtk_window_get_size should be used. Proposed patch follows. Reproducible: Always Steps to Reproduce:
Created attachment 385 Proposed patch
gtk_window_get_size() returns the value of the size at the last configure event. Since xfce_gtk_window_center_on_monitor() is usually called before the window is even mapped, this won't provide accurate results. This also doesn't take into account the size of the window decorations, so it'll be slightly off-center. gdk_window_get_frame_extents() would seem to make the most sense, but I don't recall how well that works before the window is mapped.
(In reply to comment #2) > gtk_window_get_size() returns the value of the size at the last configure event. > Since xfce_gtk_window_center_on_monitor() is usually called before the window > is even mapped, this won't provide accurate results. It seems to work here. > This also doesn't take > into account the size of the window decorations, so it'll be slightly off-center. How is that different from the way it is now?
Created attachment 386 Example using PyGTK/PyXfce Example with two test dialogs. Test 1 is positioned with xfce4.gui.gtk_window_center_on_monitor_with_pointer. Test 2 uses gtk_window_get_size (window.get_size in PyGTK) to center the window. The Test 2 dialog first show up when the Test 1 dialog is closed. There's a Refresh button in the two windows, try to resize the windows and press Refresh, to reposition the windows using the respective methods.
Created attachment 387 Updated proposed patch Removed some unnecesarry code.
(In reply to comment #5) > Created an attachment (id=387) [details] > Updated proposed patch > > Removed some unnecesarry code. Is this fixed in the current version?
Close bug reports of archived products.