Author: toshok
Date: 2006-11-13 23:42:13 -0500 (Mon, 13 Nov 2006)
New Revision: 67812

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2006-11-13  Chris Toshok  <[EMAIL PROTECTED]>

        [ fixes bug #79745 ]
        
        * NotifyIcon.cs: lots of cleanup.

        * X11Structs.cs: add an enum for XEMBED messages.

        * XplatUIX11.cs: reindent one of the giant switch statements, it
        was taking up an additional tab stop, and this file is already way
        too wide for my laptop's screen.

        Also, add handling for the XEmbed EMBEDDED_NOTIFY message.  When
        we get it, resize the hwnd to the WMNormalHints max_width/height.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-14 01:34:06 UTC (rev 67811)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-14 04:42:13 UTC (rev 67812)
@@ -1,3 +1,18 @@
+2006-11-13  Chris Toshok  <[EMAIL PROTECTED]>
+
+       [ fixes bug #79745 ]
+       
+       * NotifyIcon.cs: lots of cleanup.
+
+       * X11Structs.cs: add an enum for XEMBED messages.
+
+       * XplatUIX11.cs: reindent one of the giant switch statements, it
+       was taking up an additional tab stop, and this file is already way
+       too wide for my laptop's screen.
+
+       Also, add handling for the XEmbed EMBEDDED_NOTIFY message.  When
+       we get it, resize the hwnd to the WMNormalHints max_width/height.
+
 2006-11-13  Jackson Harper  <[EMAIL PROTECTED]>
 
        * TextBoxBase.cs: Compute the value changes for the mouse wheel

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs    
2006-11-14 01:34:06 UTC (rev 67811)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs    
2006-11-14 04:42:13 UTC (rev 67812)
@@ -58,8 +58,10 @@
                                is_visible = false;
                                rect = new Rectangle(0, 0, 1, 1);
 
-                               CreateControl();
+                               FormBorderStyle = FormBorderStyle.None;
 
+                               //CreateControl();
+
                                SizeChanged += new 
EventHandler(HandleSizeChanged);
 
                                // Events that need to be sent to our parent
@@ -142,30 +144,21 @@
                        }
 
                        internal void CalculateIconRect() {
-                               if (owner != null && owner.icon != null) {
-                                       int             x;
-                                       int             y;
-                                       int             size;
+                               int             x;
+                               int             y;
+                               int             size;
 
-                                       // Icons are always square. Try to 
center them in the window
-                                       if (ClientRectangle.Width < 
ClientRectangle.Height) {
-                                               size = ClientRectangle.Width;
-                                       } else {
-                                               size = ClientRectangle.Height;
-                                       }
-                                       x = this.ClientRectangle.Width / 2 - 
size / 2;
-                                       y = this.ClientRectangle.Height / 2 - 
size / 2;
-                                       rect = new Rectangle(x, y, size, size);
-
-                                       // Force our window to be square
-                                       if (Width != size) {
-                                               this.Width = size;
-                                       }
-
-                                       if (Height != size) {
-                                               this.Height = size;
-                                       }
+                               // Icons are always square. Try to center them 
in the window
+                               if (ClientRectangle.Width < 
ClientRectangle.Height) {
+                                       size = ClientRectangle.Width;
+                               } else {
+                                       size = ClientRectangle.Height;
                                }
+                               x = this.ClientRectangle.Width / 2 - size / 2;
+                               y = this.ClientRectangle.Height / 2 - size / 2;
+                               rect = new Rectangle(x, y, size, size);
+
+                               Bounds = new Rectangle (0, 0, size, size);
                        }
 
                        internal override void OnPaintInternal (PaintEventArgs 
e) {
@@ -185,7 +178,7 @@
 
 
                        private void HandleSizeChanged(object sender, EventArgs 
e) {
-                               CalculateIconRect();
+                               owner.Recalculate ();
                        }
 
                        private void HandleClick(object sender, EventArgs e) {
@@ -235,29 +228,28 @@
                #endregion      // Public Constructors
 
                #region Private Methods
-               private void ShowSystray(bool property_changed) {
-                       if (property_changed) {
-                               window.CalculateIconRect();
-                       }
+               private void Recalculate () 
+               {
+                       window.CalculateIconRect ();
 
-                       if (systray_active) {
-                               if (property_changed) {
-                                       UpdateSystray();
-                               }
-                               return;
-                       }
+                       if (systray_active)
+                               UpdateSystray ();
+               }
 
-                       if (icon == null) {
+               private void ShowSystray()
+               {
+                       systray_active = true;
+
+                       if (icon == null)
                                return;
-                       }
 
                        icon_bitmap = icon.ToBitmap();
 
-                       systray_active = true;
                        XplatUI.SystrayAdd(window.Handle, text, icon, out 
tooltip);
                }
 
-               private void HideSystray() {
+               private void HideSystray()
+               {
                        if (!systray_active) {
                                return;
                        }
@@ -266,7 +258,8 @@
                        XplatUI.SystrayRemove(window.Handle, ref tooltip);
                }
 
-               private void UpdateSystray() {
+               private void UpdateSystray()
+               {
                        if (icon_bitmap != null) {
                                icon_bitmap.Dispose();
                        }
@@ -305,7 +298,12 @@
                        set {
                                if (icon != value) {
                                        icon = value;
-                                       ShowSystray(true);
+                                       if (text == string.Empty && icon == 
null) {
+                                               HideSystray ();
+                                       }
+                                       else {
+                                               Recalculate ();
+                                       }
                                }
                        }
                }
@@ -325,7 +323,7 @@
                                        if (text == string.Empty && icon == 
null) {
                                                HideSystray();
                                        } else {
-                                               ShowSystray(true);
+                                               Recalculate ();
                                        }
                                }
                        }
@@ -346,7 +344,7 @@
                                        window.is_visible = value;
 
                                        if (visible) {
-                                               ShowSystray(false);
+                                               ShowSystray ();
                                        } else {
                                                HideSystray();
                                        }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs    
2006-11-14 01:34:06 UTC (rev 67811)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs    
2006-11-14 04:42:13 UTC (rev 67812)
@@ -1533,4 +1533,20 @@
                Both                    = 3
        }
 
+       internal enum XEmbedMessage {
+               EmbeddedNotify = 0,
+               WindowActivate = 1,
+               WindowDeactivate = 2,
+               RequestFocus = 3,
+               FocusIn = 4,
+               FocusOut = 5,
+               FocusNext = 6,
+               FocusPrev = 7,
+               /* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
+               ModalityOn = 10,
+               ModalityOff = 11,
+               RegisterAccelerator = 12,
+               UnregisterAccelerator = 13,
+               ActivateAccelerator = 14
+       }
 }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2006-11-14 01:34:06 UTC (rev 67811)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2006-11-14 04:42:13 UTC (rev 67812)
@@ -45,6 +45,7 @@
 #undef DriverDebugCreate
 #undef DriverDebugDestroy
 #undef DriverDebugThreads
+#undef DriverDebugXEmbed
 
 using System;
 using System.ComponentModel;
@@ -1402,220 +1403,220 @@
                                        continue;
 
                                switch (xevent.type) {
-                                       case XEventName.Expose:
-                                               AddExpose (hwnd, 
xevent.ExposeEvent.window == hwnd.ClientWindow, xevent.ExposeEvent.x, 
xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
-                                               break;
+                               case XEventName.Expose:
+                                       AddExpose (hwnd, 
xevent.ExposeEvent.window == hwnd.ClientWindow, xevent.ExposeEvent.x, 
xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+                                       break;
 
-                                       case XEventName.SelectionClear: {
-                                               // Should we do something?
+                               case XEventName.SelectionClear: {
+                                       // Should we do something?
+                                       break;
+                               }
+
+                               case XEventName.SelectionRequest: {
+                                       if (Dnd.HandleSelectionRequestEvent 
(ref xevent))
                                                break;
-                                       }
+                                       XEvent sel_event;
 
-                                       case XEventName.SelectionRequest: {
-                                               if 
(Dnd.HandleSelectionRequestEvent (ref xevent))
-                                                       break;
-                                               XEvent sel_event;
+                                       sel_event = new XEvent();
+                                       sel_event.SelectionEvent.type = 
XEventName.SelectionNotify;
+                                       sel_event.SelectionEvent.send_event = 
true;
+                                       sel_event.SelectionEvent.display = 
DisplayHandle;
+                                       sel_event.SelectionEvent.selection = 
xevent.SelectionRequestEvent.selection;
+                                       sel_event.SelectionEvent.target = 
xevent.SelectionRequestEvent.target;
+                                       sel_event.SelectionEvent.requestor = 
xevent.SelectionRequestEvent.requestor;
+                                       sel_event.SelectionEvent.time = 
xevent.SelectionRequestEvent.time;
+                                       sel_event.SelectionEvent.property = 
IntPtr.Zero;
 
-                                               sel_event = new XEvent();
-                                               sel_event.SelectionEvent.type = 
XEventName.SelectionNotify;
-                                               
sel_event.SelectionEvent.send_event = true;
-                                               
sel_event.SelectionEvent.display = DisplayHandle;
-                                               
sel_event.SelectionEvent.selection = xevent.SelectionRequestEvent.selection;
-                                               sel_event.SelectionEvent.target 
= xevent.SelectionRequestEvent.target;
-                                               
sel_event.SelectionEvent.requestor = xevent.SelectionRequestEvent.requestor;
-                                               sel_event.SelectionEvent.time = 
xevent.SelectionRequestEvent.time;
-                                               
sel_event.SelectionEvent.property = IntPtr.Zero;
+                                       // Seems that some apps support asking 
for supported types
+                                       if (xevent.SelectionEvent.target == 
TARGETS) {
+                                               int[]   atoms;
+                                               int     atom_count;
 
-                                               // Seems that some apps support 
asking for supported types
-                                               if 
(xevent.SelectionEvent.target == TARGETS) {
-                                                       int[]   atoms;
-                                                       int     atom_count;
+                                               atoms = new int[5];
+                                               atom_count = 0;
 
-                                                       atoms = new int[5];
-                                                       atom_count = 0;
+                                               if (Clipboard.Item is String) {
+                                                       atoms[atom_count++] = 
(int)Atom.XA_STRING;
+                                                       atoms[atom_count++] = 
(int)OEMTEXT;
+                                                       atoms[atom_count++] = 
(int)UNICODETEXT;
+                                               } else if (Clipboard.Item is 
Image) {
+                                                       atoms[atom_count++] = 
(int)Atom.XA_PIXMAP;
+                                                       atoms[atom_count++] = 
(int)Atom.XA_BITMAP;
+                                               } else {
+                                                       // FIXME - handle other 
types
+                                               }
 
-                                                       if (Clipboard.Item is 
String) {
-                                                               
atoms[atom_count++] = (int)Atom.XA_STRING;
-                                                               
atoms[atom_count++] = (int)OEMTEXT;
-                                                               
atoms[atom_count++] = (int)UNICODETEXT;
-                                                       } else if 
(Clipboard.Item is Image) {
-                                                               
atoms[atom_count++] = (int)Atom.XA_PIXMAP;
-                                                               
atoms[atom_count++] = (int)Atom.XA_BITMAP;
-                                                       } else {
-                                                               // FIXME - 
handle other types
-                                                       }
+                                               XChangeProperty(DisplayHandle, 
xevent.SelectionEvent.requestor, (IntPtr)xevent.SelectionRequestEvent.property, 
(IntPtr)xevent.SelectionRequestEvent.target, 32, PropertyMode.Replace, atoms, 
atom_count);
+                                       } else if (Clipboard.Item is string) {
+                                               IntPtr  buffer;
+                                               int     buflen;
 
-                                                       
XChangeProperty(DisplayHandle, xevent.SelectionEvent.requestor, 
(IntPtr)xevent.SelectionRequestEvent.property, 
(IntPtr)xevent.SelectionRequestEvent.target, 32, PropertyMode.Replace, atoms, 
atom_count);
-                                               } else if (Clipboard.Item is 
string) {
-                                                       IntPtr  buffer;
-                                                       int     buflen;
+                                               buflen = 0;
 
-                                                       buflen = 0;
+                                               if 
(xevent.SelectionRequestEvent.target == (IntPtr)Atom.XA_STRING) {
+                                                       Byte[] bytes;
 
-                                                       if 
(xevent.SelectionRequestEvent.target == (IntPtr)Atom.XA_STRING) {
-                                                               Byte[] bytes;
+                                                       bytes = new 
ASCIIEncoding().GetBytes((string)Clipboard.Item);
+                                                       buffer = 
Marshal.AllocHGlobal(bytes.Length);
+                                                       buflen = bytes.Length;
 
-                                                               bytes = new 
ASCIIEncoding().GetBytes((string)Clipboard.Item);
-                                                               buffer = 
Marshal.AllocHGlobal(bytes.Length);
-                                                               buflen = 
bytes.Length;
-
-                                                               for (int i = 0; 
i < buflen; i++) {
-                                                                       
Marshal.WriteByte(buffer, i, bytes[i]);
-                                                               }
-                                                       } else if 
(xevent.SelectionRequestEvent.target == OEMTEXT) {
-                                                               // FIXME - this 
should encode into ISO2022
-                                                               buffer = 
Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
-                                                               while 
(Marshal.ReadByte(buffer, buflen) != 0) {
-                                                                       
buflen++;
-                                                               }
-                                                       } else if 
(xevent.SelectionRequestEvent.target == UNICODETEXT) {
-                                                               buffer = 
Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
-                                                               while 
(Marshal.ReadByte(buffer, buflen) != 0) {
-                                                                       
buflen++;
-                                                               }
-                                                       } else {
-                                                               buffer = 
IntPtr.Zero;
+                                                       for (int i = 0; i < 
buflen; i++) {
+                                                               
Marshal.WriteByte(buffer, i, bytes[i]);
                                                        }
-
-                                                       if (buffer != 
IntPtr.Zero) {
-                                                               
XChangeProperty(DisplayHandle, xevent.SelectionRequestEvent.requestor, 
(IntPtr)xevent.SelectionRequestEvent.property, 
(IntPtr)xevent.SelectionRequestEvent.target, 8, PropertyMode.Replace, buffer, 
buflen);
-                                                               
sel_event.SelectionEvent.property = xevent.SelectionRequestEvent.property;
-                                                               
Marshal.FreeHGlobal(buffer);
+                                               } else if 
(xevent.SelectionRequestEvent.target == OEMTEXT) {
+                                                       // FIXME - this should 
encode into ISO2022
+                                                       buffer = 
Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
+                                                       while 
(Marshal.ReadByte(buffer, buflen) != 0) {
+                                                               buflen++;
                                                        }
-                                               } else if (Clipboard.Item is 
Image) {
-                                                       if 
(xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
-                                                               // FIXME - 
convert image and store as property
-                                                       } else if 
(xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
-                                                               // FIXME - 
convert image and store as property
+                                               } else if 
(xevent.SelectionRequestEvent.target == UNICODETEXT) {
+                                                       buffer = 
Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
+                                                       while 
(Marshal.ReadByte(buffer, buflen) != 0) {
+                                                               buflen++;
                                                        }
+                                               } else {
+                                                       buffer = IntPtr.Zero;
                                                }
 
-                                               XSendEvent(DisplayHandle, 
xevent.SelectionRequestEvent.requestor, false, new IntPtr 
((int)EventMask.NoEventMask), ref sel_event);
-                                               break;
+                                               if (buffer != IntPtr.Zero) {
+                                                       
XChangeProperty(DisplayHandle, xevent.SelectionRequestEvent.requestor, 
(IntPtr)xevent.SelectionRequestEvent.property, 
(IntPtr)xevent.SelectionRequestEvent.target, 8, PropertyMode.Replace, buffer, 
buflen);
+                                                       
sel_event.SelectionEvent.property = xevent.SelectionRequestEvent.property;
+                                                       
Marshal.FreeHGlobal(buffer);
+                                               }
+                                       } else if (Clipboard.Item is Image) {
+                                               if 
(xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
+                                                       // FIXME - convert 
image and store as property
+                                               } else if 
(xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
+                                                       // FIXME - convert 
image and store as property
+                                               }
                                        }
 
-                                       case XEventName.SelectionNotify: {
-                                               if (Clipboard.Enumerating) {
-                                                       Clipboard.Enumerating = 
false;
-                                                       if 
(xevent.SelectionEvent.property != IntPtr.Zero) {
-                                                               
XDeleteProperty(DisplayHandle, FosterParent, 
(IntPtr)xevent.SelectionEvent.property);
-                                                               if 
(!Clipboard.Formats.Contains(xevent.SelectionEvent.property)) {
-                                                                       
Clipboard.Formats.Add(xevent.SelectionEvent.property);
-                                                                       #if 
DriverDebugExtra
-                                                                               
Console.WriteLine("Got supported clipboard atom format: {0}", 
xevent.SelectionEvent.property);
-                                                                       #endif
-                                                               }
+                                       XSendEvent(DisplayHandle, 
xevent.SelectionRequestEvent.requestor, false, new IntPtr 
((int)EventMask.NoEventMask), ref sel_event);
+                                       break;
+                               }
+
+                               case XEventName.SelectionNotify: {
+                                       if (Clipboard.Enumerating) {
+                                               Clipboard.Enumerating = false;
+                                               if 
(xevent.SelectionEvent.property != IntPtr.Zero) {
+                                                       
XDeleteProperty(DisplayHandle, FosterParent, 
(IntPtr)xevent.SelectionEvent.property);
+                                                       if 
(!Clipboard.Formats.Contains(xevent.SelectionEvent.property)) {
+                                                               
Clipboard.Formats.Add(xevent.SelectionEvent.property);
+                                                               #if 
DriverDebugExtra
+                                                               
Console.WriteLine("Got supported clipboard atom format: {0}", 
xevent.SelectionEvent.property);
+                                                               #endif
                                                        }
-                                               } else if 
(Clipboard.Retrieving) {
-                                                       Clipboard.Retrieving = 
false;
-                                                       if 
(xevent.SelectionEvent.property != IntPtr.Zero) {
-                                                               
TranslatePropertyToClipboard(xevent.SelectionEvent.property);
-                                                       } else {
-                                                               Clipboard.Item 
= null;
-                                                       }
+                                               }
+                                       } else if (Clipboard.Retrieving) {
+                                               Clipboard.Retrieving = false;
+                                               if 
(xevent.SelectionEvent.property != IntPtr.Zero) {
+                                                       
TranslatePropertyToClipboard(xevent.SelectionEvent.property);
                                                } else {
-                                                       
Dnd.HandleSelectionNotifyEvent (ref xevent);
+                                                       Clipboard.Item = null;
                                                }
-                                               break;
+                                       } else {
+                                               Dnd.HandleSelectionNotifyEvent 
(ref xevent);
                                        }
+                                       break;
+                               }
 
-                                       case XEventName.MapNotify: {
-                                               if (hwnd.client_window == 
xevent.MapEvent.window) {
-                                                       hwnd.mapped = true;
-                                               }
-                                               break;
+                               case XEventName.MapNotify: {
+                                       if (hwnd.client_window == 
xevent.MapEvent.window) {
+                                               hwnd.mapped = true;
                                        }
+                                       break;
+                               }
 
-                                       case XEventName.UnmapNotify: {
-                                               if (hwnd.client_window == 
xevent.MapEvent.window) {
-                                                       hwnd.mapped = false;
-                                               }
-                                               break;
+                               case XEventName.UnmapNotify: {
+                                       if (hwnd.client_window == 
xevent.MapEvent.window) {
+                                               hwnd.mapped = false;
                                        }
+                                       break;
+                               }
 
-                                       case XEventName.KeyRelease:
-                                               if (!detectable_key_auto_repeat 
&& XPending (DisplayHandle) != 0) {
-                                                       XEvent nextevent = new 
XEvent ();
+                               case XEventName.KeyRelease:
+                                       if (!detectable_key_auto_repeat && 
XPending (DisplayHandle) != 0) {
+                                               XEvent nextevent = new XEvent 
();
 
-                                                       XPeekEvent 
(DisplayHandle, ref nextevent);
+                                               XPeekEvent (DisplayHandle, ref 
nextevent);
 
-                                                       if (nextevent.type == 
XEventName.KeyPress &&
-                                                       
nextevent.KeyEvent.keycode == xevent.KeyEvent.keycode &&
-                                                       nextevent.KeyEvent.time 
== xevent.KeyEvent.time) {
-                                                               continue;
-                                                       }
+                                               if (nextevent.type == 
XEventName.KeyPress &&
+                                                   nextevent.KeyEvent.keycode 
== xevent.KeyEvent.keycode &&
+                                                   nextevent.KeyEvent.time == 
xevent.KeyEvent.time) {
+                                                       continue;
                                                }
-                                               goto case XEventName.KeyPress;
+                                       }
+                                       goto case XEventName.KeyPress;
                                        
-                                       case XEventName.MotionNotify: {
-                                               XEvent peek;
+                               case XEventName.MotionNotify: {
+                                       XEvent peek;
 
-                                               if (hwnd.Queue.Count > 0) {
-                                                       peek = 
hwnd.Queue.Peek();
-                                                       if (peek.AnyEvent.type 
== XEventName.MotionNotify) {
-                                                               continue;
-                                                       }
+                                       if (hwnd.Queue.Count > 0) {
+                                               peek = hwnd.Queue.Peek();
+                                               if (peek.AnyEvent.type == 
XEventName.MotionNotify) {
+                                                       continue;
                                                }
-                                               goto case XEventName.KeyPress;
                                        }
+                                       goto case XEventName.KeyPress;
+                               }
 
-                                       case XEventName.KeyPress:
-                                       case XEventName.ButtonPress:
-                                       case XEventName.ButtonRelease:
-                                       case XEventName.EnterNotify:
-                                       case XEventName.LeaveNotify:
-                                       case XEventName.CreateNotify:
-                                       case XEventName.DestroyNotify:
-                                       case XEventName.FocusIn:
-                                       case XEventName.FocusOut:
-                                       case XEventName.ClientMessage:
-                                       case XEventName.ReparentNotify:
-                                               hwnd.Queue.Enqueue (xevent);
-                                               break;
+                               case XEventName.KeyPress:
+                               case XEventName.ButtonPress:
+                               case XEventName.ButtonRelease:
+                               case XEventName.EnterNotify:
+                               case XEventName.LeaveNotify:
+                               case XEventName.CreateNotify:
+                               case XEventName.DestroyNotify:
+                               case XEventName.FocusIn:
+                               case XEventName.FocusOut:
+                               case XEventName.ClientMessage:
+                               case XEventName.ReparentNotify:
+                                       hwnd.Queue.Enqueue (xevent);
+                                       break;
 
-                                       case XEventName.ConfigureNotify:
-                                               AddConfigureNotify(xevent);
-                                               break;
+                               case XEventName.ConfigureNotify:
+                                       AddConfigureNotify(xevent);
+                                       break;
 
-                                       case XEventName.PropertyNotify:
-                                               if (xevent.PropertyEvent.atom 
== _NET_ACTIVE_WINDOW) {
-                                                       IntPtr  actual_atom;
-                                                       int     actual_format;
-                                                       IntPtr  nitems;
-                                                       IntPtr  bytes_after;
-                                                       IntPtr  prop = 
IntPtr.Zero;
-                                                       IntPtr  prev_active;;
+                               case XEventName.PropertyNotify:
+                                       if (xevent.PropertyEvent.atom == 
_NET_ACTIVE_WINDOW) {
+                                               IntPtr  actual_atom;
+                                               int     actual_format;
+                                               IntPtr  nitems;
+                                               IntPtr  bytes_after;
+                                               IntPtr  prop = IntPtr.Zero;
+                                               IntPtr  prev_active;;
 
-                                                       prev_active = 
ActiveWindow;
-                                                       
XGetWindowProperty(DisplayHandle, RootWindow, _NET_ACTIVE_WINDOW, IntPtr.Zero, 
new IntPtr (1), false, (IntPtr)Atom.XA_WINDOW, out actual_atom, out 
actual_format, out nitems, out bytes_after, ref prop);
-                                                       if (((long)nitems > 0) 
&& (prop != IntPtr.Zero)) {
-                                                               ActiveWindow = 
Hwnd.GetHandleFromWindow((IntPtr)Marshal.ReadInt32(prop));
-                                                               XFree(prop);
+                                               prev_active = ActiveWindow;
+                                               
XGetWindowProperty(DisplayHandle, RootWindow, _NET_ACTIVE_WINDOW, IntPtr.Zero, 
new IntPtr (1), false, (IntPtr)Atom.XA_WINDOW, out actual_atom, out 
actual_format, out nitems, out bytes_after, ref prop);
+                                               if (((long)nitems > 0) && (prop 
!= IntPtr.Zero)) {
+                                                       ActiveWindow = 
Hwnd.GetHandleFromWindow((IntPtr)Marshal.ReadInt32(prop));
+                                                       XFree(prop);
 
-                                                               if (prev_active 
!= ActiveWindow) {
-                                                                       if 
(prev_active != IntPtr.Zero) {
-                                                                               
PostMessage(prev_active, Msg.WM_ACTIVATE, 
(IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
-                                                                       }
-                                                                       if 
(ActiveWindow != IntPtr.Zero) {
-                                                                               
PostMessage(ActiveWindow, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, 
IntPtr.Zero);
-                                                                       }
+                                                       if (prev_active != 
ActiveWindow) {
+                                                               if (prev_active 
!= IntPtr.Zero) {
+                                                                       
PostMessage(prev_active, Msg.WM_ACTIVATE, 
(IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
                                                                }
-                                                               if 
(ModalWindows.Count == 0) {
-                                                                       break;
-                                                               } else {
-                                                                       // 
Modality handling, if we are modal and the new active window is one
-                                                                       // of 
ours but not the modal one, switch back to the modal window
+                                                               if 
(ActiveWindow != IntPtr.Zero) {
+                                                                       
PostMessage(ActiveWindow, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, 
IntPtr.Zero);
+                                                               }
+                                                       }
+                                                       if (ModalWindows.Count 
== 0) {
+                                                               break;
+                                                       } else {
+                                                               // Modality 
handling, if we are modal and the new active window is one
+                                                               // of ours but 
not the modal one, switch back to the modal window
 
-                                                                       if 
(NativeWindow.FindWindow(ActiveWindow) != null) {
-                                                                               
if (ActiveWindow != (IntPtr)ModalWindows.Peek()) {
-                                                                               
        Activate((IntPtr)ModalWindows.Peek());
-                                                                               
}
+                                                               if 
(NativeWindow.FindWindow(ActiveWindow) != null) {
+                                                                       if 
(ActiveWindow != (IntPtr)ModalWindows.Peek()) {
+                                                                               
Activate((IntPtr)ModalWindows.Peek());
                                                                        }
-                                                                       break;
                                                                }
+                                                               break;
                                                        }
                                                }
-                                               break;
+                                       }
+                                       break;
 
                                }
                        }
@@ -3726,12 +3727,23 @@
                                                return true;
                                        }
 
-                                       #if dontcare
                                        if  
(xevent.ClientMessageEvent.message_type == _XEMBED) {
-                                               Console.WriteLine("GOT EMBED 
MESSAGE {0:X}", xevent.ClientMessageEvent.ptr2.ToInt32());
-                                               break;
+#if DriverDebugXEmbed
+                                               Console.WriteLine("GOT EMBED 
MESSAGE {0:X}, detail {1:X}", xevent.ClientMessageEvent.ptr2.ToInt32(), 
xevent.ClientMessageEvent.ptr3.ToInt32());
+#endif
+
+                                               if 
(xevent.ClientMessageEvent.ptr2.ToInt32() == (int)XEmbedMessage.EmbeddedNotify) 
{
+                                                       XSizeHints hints = new 
XSizeHints();
+                                                       IntPtr dummy;
+
+                                                       
XGetWMNormalHints(DisplayHandle, hwnd.whole_window, ref hints, out dummy);
+
+                                                       hwnd.width = 
hints.max_width;
+                                                       hwnd.height = 
hints.max_height;
+                                                       hwnd.ClientRect = 
Rectangle.Empty;
+                                                       SendMessage(msg.hwnd, 
Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
+                                               }
                                        }
-                                       #endif
 
                                        if  
(xevent.ClientMessageEvent.message_type == WM_PROTOCOLS) {
                                                if 
(xevent.ClientMessageEvent.ptr1 == WM_DELETE_WINDOW) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to