2007-01-02 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / Hwnd.cs
index c6e6213ee8597ef9fc15981079b519339f92e2da..3a03e010af2bca3f14755a6126e2e4ae965d5ab1 100644 (file)
@@ -75,9 +75,16 @@ namespace System.Windows.Forms {
                internal bool           zombie; /* X11 only flag.  true if the X windows have been destroyed but we haven't been Disposed */
                internal Region         user_clip;
                internal static Bitmap  bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+               internal static Graphics bmp_g = Graphics.FromImage (bmp);
                internal XEventQueue    queue;
+               internal bool           no_activate;    // For Win32, popup windows will not steal focus
+               internal WindowExStyles initial_ex_style;
                #endregion      // Local Variables
 
+               // locks for some operations (used in XplatUIX11.cs)
+               internal object configure_lock = new object ();
+               internal object expose_lock = new object ();
+
                #region Constructors and destructors
                public Hwnd() {
                        x = 0;
@@ -121,10 +128,6 @@ namespace System.Windows.Forms {
                #endregion
 
                #region Static Methods
-               public void SetObjectWindow(Hwnd obj, IntPtr window) {
-                       windows[window] = obj;
-               }
-
                public static Hwnd ObjectFromWindow(IntPtr window) {
                        Hwnd rv;
                        lock (windows) {
@@ -177,13 +180,8 @@ namespace System.Windows.Forms {
 
                        if (menu != null) {
                                int menu_height = menu.Rect.Height;
-                               if (menu_height == 0) {
-                                       Graphics g;
-
-                                       g = Graphics.FromImage(bmp);
-                                       menu_height = ThemeEngine.Current.CalcMenuBarSize(g, menu, client_rect.Width);
-                                       g.Dispose();
-                               }
+                               if (menu_height == 0)
+                                       menu_height = ThemeEngine.Current.CalcMenuBarSize(bmp_g, menu, client_rect.Width);
 
                                rect.Y -= menu_height;
                                rect.Height += menu_height;
@@ -270,9 +268,11 @@ namespace System.Windows.Forms {
 
                                zombie = false;
 
-                               lock (windows) {
-                                       if (windows[client_window] == null) {
-                                               windows[client_window] = this;
+                               if (client_window != IntPtr.Zero) {
+                                       lock (windows) {
+                                               if (windows[client_window] == null) {
+                                                       windows[client_window] = this;
+                                               }
                                        }
                                }
                        }
@@ -301,10 +301,6 @@ namespace System.Windows.Forms {
                        get {
                                return expose_pending;
                        }
-
-                       set {
-                               expose_pending = value;
-                       }
                }
 
                public IntPtr Handle {
@@ -448,10 +444,6 @@ namespace System.Windows.Forms {
                        get {
                                return nc_expose_pending;
                        }
-
-                       set {
-                               nc_expose_pending = value;
-                       }
                }
 
                public Hwnd Parent {
@@ -522,9 +514,11 @@ namespace System.Windows.Forms {
 
                                zombie = false;
 
-                               lock (windows) {
-                                       if (windows[whole_window] == null) {
-                                               windows[whole_window] = this;
+                               if (whole_window != IntPtr.Zero) {
+                                       lock (windows) {
+                                               if (windows[whole_window] == null) {
+                                                       windows[whole_window] = this;
+                                               }
                                        }
                                }
                        }