[haiku-commits] Re: r38168 - haiku/trunk/src/servers/app

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 17 Aug 2010 09:37:11 +0200

Am 17.08.2010 08:23, schrieb clemens.zeidler@xxxxxxxxxxxxxx:
Author: czeidler
Date: 2010-08-17 08:23:06 +0200 (Tue, 17 Aug 2010)
New Revision: 38168
Changeset: http://dev.haiku-os.org/changeset/38168

Modified:
    haiku/trunk/src/servers/app/Desktop.cpp
    haiku/trunk/src/servers/app/Desktop.h
Log:
Add function to find a window in the app server by the client looper port id. 
Need this for the stacking api e.g. to stack window x on window y.



Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-08-17 06:12:30 UTC (rev 
38167)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-08-17 06:23:06 UTC (rev 
38168)
@@ -2484,6 +2484,18 @@
  }


+Window*
+Desktop::WindowForClientLooperPort(port_id port)
+{
+       for (Window* window = fAllWindows.FirstWindow(); window != NULL;
+                       window = window->NextWindow(kAllWindowList)) {
+               if (window->ServerWindow()->ClientLooperPort() == port)
+                       return window;
+       }
+       return NULL;
+}

Please take care of proper locking!! This is a public method, so it should lock the Desktop thread before obtaining info from the window list. If it does not lock itself, add a comment what locking is required by the caller. I didn't see in the next commits that you have the Desktop write-locked when calling this. If you process message codes in the ServerWindow thread, the Desktop is read-locked by default, unless you add the message code to the small list of codes that trigger write locking before entering the big message switch.

Best regards,
-Stephan

Other related posts: