! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
libxfcegui4: xfce_gtk_window_center_on_monitor doesn't always really center w...
Status:
RESOLVED: WONTFIX
Product:
Libxfcegui4
Component:
General

Comments

Description Stefan Stuhr 2006-01-07 19:14:49 CET
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:
Comment 1 Stefan Stuhr 2006-01-07 19:15:41 CET
Created attachment 385 
Proposed patch
Comment 2 Brian J. Tarricone (not reading bugmail) 2006-01-07 19:49:16 CET
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.
Comment 3 Stefan Stuhr 2006-01-07 20:33:23 CET
(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?
Comment 4 Stefan Stuhr 2006-01-07 20:41:25 CET
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.
Comment 5 Stefan Stuhr 2006-01-07 20:53:42 CET
Created attachment 387 
Updated proposed patch

Removed some unnecesarry code.
Comment 6 Harold Aling 2007-09-23 18:52:48 CEST
(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?
Comment 7 Nick Schermer editbugs 2014-12-03 09:20:14 CET
Close bug reports of archived products.

Bug #1314

Reported by:
Stefan Stuhr
Reported on: 2006-01-07
Last modified on: 2014-12-03

People

Assignee:
Xfce Bug Triage
CC List:
1 user

Version

Version:
unspecified

Attachments

Proposed patch (951 bytes, patch)
2006-01-07 19:15 CET , Stefan Stuhr
no flags
Example using PyGTK/PyXfce (1.20 KB, text/x-python)
2006-01-07 20:41 CET , Stefan Stuhr
no flags
Updated proposed patch (1.17 KB, patch)
2006-01-07 20:53 CET , Stefan Stuhr
no flags

Additional information