win32: fix gdk_win32_window_raise

When calling gtk_window_present(), gdk_win32_window_raise did not
actually raise the window anymore. Replacing BringWindowToTop() with
SetForegroundWindow() fixes this.

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.

Additional goodies of SetForeGroundWindow:
- it brings the window to the front when the process owning the
  window to raise 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 the process owning the window to raise
  is *not* the foreground process (for example when gtk_window_present
  is called from a g_timeout_add callback function)

https://bugzilla.gnome.org/show_bug.cgi?id=665760
This commit is contained in:
Dieter Verfaillie 2011-12-20 23:02:46 +01:00
parent a3cbaa5956
commit fb87d9c901

View File

@ -1822,6 +1822,7 @@ gdk_window_win32_clear_region (GdkWindow *window,
g_free (rectangles);
}
static void
gdk_win32_window_raise (GdkWindow *window)
{
@ -1835,7 +1836,11 @@ gdk_win32_window_raise (GdkWindow *window)
0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
else if (((GdkWindowObject *)window)->accept_focus)
API_CALL (BringWindowToTop, (GDK_WINDOW_HWND (window)));
/* Do not wrap this in an API_CALL macro as SetForegroundWindow might
* fail when for example dragging a window belonging to a different
* application at the time of a gtk_window_present() call due to focus
* stealing prevention. */
SetForegroundWindow (GDK_WINDOW_HWND (window));
else
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
0, 0, 0, 0,