[ros-diffs] [fireball] 44118: [SWM] - Move out the code for setting foreground window into a separate helper function SwmBringToFront. Call it from SwmSetForeground and SwmShowWindow.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Nov 12 20:11:28 CET 2009


Author: fireball
Date: Thu Nov 12 20:11:28 2009
New Revision: 44118

URL: http://svn.reactos.org/svn/reactos?rev=44118&view=rev
Log:
[SWM]
- Move out the code for setting foreground window into a separate helper function SwmBringToFront. Call it from SwmSetForeground and SwmShowWindow.

Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c

Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c?rev=44118&r1=44117&r2=44118&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] Thu Nov 12 20:11:28 2009
@@ -422,10 +422,58 @@
 
 VOID
 NTAPI
+SwmBringToFront(PSWM_WINDOW SwmWin)
+{
+    PSWM_WINDOW Previous;
+    struct region *OldVisible;
+
+    /* Save previous focus window */
+    Previous = CONTAINING_RECORD(SwmWindows.Flink, SWM_WINDOW, Entry);
+
+    /* It's already on top */
+    if (Previous->hwnd == SwmWin->hwnd)
+    {
+        DPRINT1("hwnd %x is already on top\n", SwmWin->hwnd);
+        return;
+    }
+
+    DPRINT1("Setting %x as foreground, previous window was %x\n", SwmWin->hwnd, Previous->hwnd);
+
+    /* Remove it from the list */
+    RemoveEntryList(&SwmWin->Entry);
+
+    /* Add it to the head of the list */
+    InsertHeadList(&SwmWindows, &SwmWin->Entry);
+
+    /* Subtruct old visible from the new one to find region for updating */
+    OldVisible = create_empty_region();
+    set_region_rect(OldVisible, &SwmWin->Window);
+
+    subtract_region(OldVisible, OldVisible, SwmWin->Visible);
+
+    /* Make it fully visible */
+    free_region(SwmWin->Visible);
+    SwmWin->Visible = create_empty_region();
+    set_region_rect(SwmWin->Visible, &SwmWin->Window);
+
+    /* If update region is not empty - draw missing parts */
+    if (!is_region_empty(OldVisible))
+    {
+        DPRINT1("Intersection isn't empty\n");
+        SwmInvalidateRegion(SwmWin, OldVisible, NULL);
+    }
+
+    free_region(OldVisible);
+
+    /* Update previous window's visible region */
+    SwmRecalculateVisibility(Previous);
+}
+
+VOID
+NTAPI
 SwmSetForeground(HWND hWnd)
 {
-    PSWM_WINDOW SwmWin, Previous;
-    struct region *OldVisible;
+    PSWM_WINDOW SwmWin;
 
     /* Acquire the lock */
     SwmAcquire();
@@ -440,48 +488,7 @@
         return;
     }
 
-    /* Save previous focus window */
-    Previous = CONTAINING_RECORD(SwmWindows.Flink, SWM_WINDOW, Entry);
-
-    /* It's already on top */
-    if (Previous->hwnd == hWnd)
-    {
-        DPRINT1("hwnd %x is already on top\n", hWnd);
-        /* Release the lock */
-        SwmRelease();
-        return;
-    }
-
-    DPRINT1("Setting %x as foreground, previous window was %x\n", hWnd, Previous->hwnd);
-
-    /* Remove it from the list */
-    RemoveEntryList(&SwmWin->Entry);
-
-    /* Add it to the head of the list */
-    InsertHeadList(&SwmWindows, &SwmWin->Entry);
-
-    /* Subtruct old visible from the new one to find region for updating */
-    OldVisible = create_empty_region();
-    set_region_rect(OldVisible, &SwmWin->Window);
-
-    subtract_region(OldVisible, OldVisible, SwmWin->Visible);
-
-    /* Make it fully visible */
-    free_region(SwmWin->Visible);
-    SwmWin->Visible = create_empty_region();
-    set_region_rect(SwmWin->Visible, &SwmWin->Window);
-
-    /* If update region is not empty - draw missing parts */
-    if (!is_region_empty(OldVisible))
-    {
-        DPRINT1("Intersection isn't empty\n");
-        SwmInvalidateRegion(SwmWin, OldVisible, NULL);
-    }
-
-    free_region(OldVisible);
-
-    /* Update previous window's visible region */
-    SwmRecalculateVisibility(Previous);
+    SwmBringToFront(SwmWin);
 
     /* Release the lock */
     SwmRelease();
@@ -573,6 +580,7 @@
     {
         /* Change state from hidden to visible */
         Win->Hidden = FALSE;
+        SwmBringToFront(Win);
     }
     else if (!Show && !Win->Hidden)
     {




More information about the Ros-diffs mailing list