We can just check the return value.
* XplatUIX11.cs: don't throw exceptions from GetWindowState.
Instead return -1.
* XplatUI.cs: Add note about additional return value for
GetWindowState.
2006-10-29 Chris Toshok <toshok@ximian.com>
svn path=/trunk/mcs/; revision=67092
+2006-10-29 Chris Toshok <toshok@ximian.com>
+
+ * Form.cs: remove the try-catch's around calls to GetWindowState.
+ We can just check the return value.
+
+ * XplatUIX11.cs: don't throw exceptions from GetWindowState.
+ Instead return -1.
+
+ * XplatUI.cs: Add note about additional return value for
+ GetWindowState.
+
2006-10-29 Chris Toshok <toshok@ximian.com>
* Control.cs (CreateHandle): when we create our handle, we also
if (window_manager != null)
return window_manager.GetWindowState ();
- try {
- window_state = XplatUI.GetWindowState(Handle);
- }
-
- catch(NotSupportedException) {
- }
+ FormWindowState new_state = XplatUI.GetWindowState(Handle);
+ if (new_state != (FormWindowState)(-1))
+ window_state = new_state;
}
return window_state;
return;
}
- try {
- XplatUI.SetWindowState(Handle, value);
- }
-
- catch(NotSupportedException) {
- }
+ XplatUI.SetWindowState(Handle, value);
}
}
}
driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
}
+ /* this method can (and does, on X11) return
+ * (FormWindowState)(-1), when the state of the window
+ * cannot be determined (in the X11 case, when the
+ * window isn't mapped.) Checking for the additional
+ * return value is less expensive than
+ * throwing/catching an exception. */
internal static FormWindowState GetWindowState(IntPtr handle) {
#if DriverDebug
Console.WriteLine("GetWindowState({0}): Called", Window(handle));
mwmHints.functions = (IntPtr)functions;
mwmHints.decorations = (IntPtr)decorations;
- FormWindowState current_state = FormWindowState.Normal;
- try {
- current_state = GetWindowState (hwnd.Handle);
- }
- catch (NotSupportedException) {
- }
+ FormWindowState current_state = GetWindowState (hwnd.Handle);
+ if (current_state == (FormWindowState)(-1))
+ current_state = FormWindowState.Normal;
client_rect = hwnd.ClientRect;
lock (XlibLock) {
attributes = new XWindowAttributes();
XGetWindowAttributes(DisplayHandle, hwnd.client_window, ref attributes);
if (attributes.map_state == MapState.IsUnmapped) {
- throw new NotSupportedException("Cannot retrieve the state of an unmapped window");
+ return (FormWindowState)(-1);
}
hwnd = Hwnd.ObjectFromHandle(handle);
- try {
- current_state = GetWindowState(handle);
- }
- catch (NotSupportedException) {
- current_state = (FormWindowState)(-1);
- }
+ current_state = GetWindowState(handle);
if (current_state == state) {
return;