After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665760 - gtk_window_present no longer raises Window above of other applications' windows
gtk_window_present no longer raises Window above of other applications' windows
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.24.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-12-07 23:13 UTC by Daniel Atallah
Modified: 2012-01-25 19:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
(gtk-2-24) win32: fix gdk_win32_window_raise (2.17 KB, patch)
2011-12-20 22:04 UTC, Dieter Verfaillie
committed Details | Review
GtkStatusIcon test (450 bytes, text/plain)
2011-12-20 22:05 UTC, Dieter Verfaillie
  Details
g_timeout_add test (328 bytes, text/plain)
2011-12-20 22:05 UTC, Dieter Verfaillie
  Details

Description Daniel Atallah 2011-12-07 23:13:52 UTC
Some time between GTK+ 2.16.6 and GTK+ 2.24.8 (I believe that this change probably happened quite a while ago), the behavior of gtk_window_present changed such that it will no longer raise a window to the top of the stack of desktop windows (including other applications); instead it only raises to the top of the windows of the current application.

Perhaps the following example will make it more clear:

Pidgin has a system tray icon which, when double-clicked, will show and hide the Buddy List (using gtk_window_present()).

With GTK+ 2.16.6, double-clicking on the icon will raise the Buddy List above all other windows and give it focus regardless of which application currently has focus.

With GTK+ 2.24.8, double-clicking on the icon will raise the Buddy List only above other Pidgin Windows, so if, e.g. a Firefox is obscuring it, it will remain behind the Firefox window.
Comment 1 Dieter Verfaillie 2011-12-20 22:03:17 UTC
Turns out that obscuring a test app's window with the console window that
started said test app does not reproduce this bug, but obscuring the test
app's window with for example windows explorer does.

Then traced this to the BringWindowToTop() call in
gdk/win32/gdkwindow-win32.c:1838. Replacing that with a
SetForegroundWindow() as suggested by datallah on #win32 seems
to be doing the "right thing (tm)".

During testing, we also discovered that sometimes SetForeGroundWindow()
will (correctly) refuse to raise the window and fail(for example: sometimes
when dragging a different application at the time of a gtk_window_present()
call). To prevent a GdkWarning from being produced, usage of the API_CALL
macro has been removed for this case.

Behaviour of SetForegroundWindow():
- it brings the window to the front when the process is the
  foreground process (for example when gtk_window_present is
  called from a GtkStatusIcon's activate signal handler)
- it limits itself to flashing the task bar button associated
  with the window if not (for example when gtk_window_present
  is called from a g_timeout_add callback function)

All this simply didn't work with BringWindowToTop().

I'll attach 2 test programs illustrating this and off course,
the patch (tested on windows XP an 7).
Comment 2 Dieter Verfaillie 2011-12-20 22:04:15 UTC
Created attachment 203987 [details] [review]
(gtk-2-24) win32: fix gdk_win32_window_raise
Comment 3 Dieter Verfaillie 2011-12-20 22:05:11 UTC
Created attachment 203988 [details]
GtkStatusIcon test
Comment 4 Dieter Verfaillie 2011-12-20 22:05:55 UTC
Created attachment 203989 [details]
g_timeout_add test
Comment 5 Alexander Larsson 2011-12-22 07:41:20 UTC
Looks good to me. We should fix it in master too.
Comment 6 Daniel Atallah 2012-01-03 15:58:28 UTC
I've been able to validate that the patch fixes the issue I was experiencing.
Comment 7 Dieter Verfaillie 2012-01-25 19:34:21 UTC
Committed as
fb87d9c90153dcfd2e126c5bca9ad2d4ffbdfdff on gtk-2-24 branch and
fe1907708c4edb5a97184a2e027b7a028a7b5554 on master