From 0f187cf5b034ff3f6912d2c55678f019d513cd45 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 20 Sep 2015 20:28:51 +1000 Subject: [PATCH] Remove WindowBorder since we never used it. --- OpenTK/INativeWindow.cs | 6 -- OpenTK/NativeWindow.cs | 19 ---- OpenTK/Platform/MacOS/CarbonGLNative.cs | 25 ----- OpenTK/Platform/Windows/WinGLNative.cs | 81 +++------------- OpenTK/Platform/X11/X11GLNative.cs | 118 ------------------------ 5 files changed, 15 insertions(+), 234 deletions(-) diff --git a/OpenTK/INativeWindow.cs b/OpenTK/INativeWindow.cs index 630cfe209..b517d2518 100644 --- a/OpenTK/INativeWindow.cs +++ b/OpenTK/INativeWindow.cs @@ -56,9 +56,6 @@ namespace OpenTK { /// Gets or sets the for this window. WindowState WindowState { get; set; } - - /// Gets or sets the for this window. - WindowBorder WindowBorder { get; set; } /// Gets or sets a structure the contains the external bounds of this window, in screen coordinates. /// External bounds include the title bar, borders and drawing area of the window. @@ -144,9 +141,6 @@ namespace OpenTK { /// Occurs when the property of the window changes. event EventHandler FocusedChanged; - /// Occurs when the property of the window changes. - event EventHandler WindowBorderChanged; - /// Occurs when the property of the window changes. event EventHandler WindowStateChanged; diff --git a/OpenTK/NativeWindow.cs b/OpenTK/NativeWindow.cs index c22ff1694..283566b7e 100644 --- a/OpenTK/NativeWindow.cs +++ b/OpenTK/NativeWindow.cs @@ -198,12 +198,6 @@ namespace OpenTK { set { EnsureUndisposed(); implementation.Width = value; } } - /// Gets or states the border of the NativeWindow. - public WindowBorder WindowBorder { - get { return implementation.WindowBorder; } - set { implementation.WindowBorder = value; } - } - /// Gets the of this window. public IWindowInfo WindowInfo { get { EnsureUndisposed(); return implementation.WindowInfo; } @@ -285,9 +279,6 @@ namespace OpenTK { /// Occurs when the property of the window changes. public event EventHandler VisibleChanged; - /// Occurs when the property of the window changes. - public event EventHandler WindowBorderChanged; - /// Occurs when the property of the window changes. public event EventHandler WindowStateChanged; @@ -389,12 +380,6 @@ namespace OpenTK { if (VisibleChanged != null) VisibleChanged(this, e); } - /// Called when the WindowBorder of this NativeWindow has changed. - /// Not used. - protected virtual void OnWindowBorderChanged(EventArgs e) { - if (WindowBorderChanged != null) WindowBorderChanged(this, e); - } - /// Called when the WindowState of this NativeWindow has changed. /// Not used. protected virtual void OnWindowStateChanged(EventArgs e) { @@ -436,8 +421,6 @@ namespace OpenTK { private void OnVisibleChangedInternal(object sender, EventArgs e) { OnVisibleChanged(e); } - private void OnWindowBorderChangedInternal(object sender, EventArgs e) { OnWindowBorderChanged(e); } - private void OnWindowStateChangedInternal(object sender, EventArgs e) { OnWindowStateChanged(e); } private bool Events { @@ -458,7 +441,6 @@ namespace OpenTK { implementation.Resize += OnResizeInternal; implementation.TitleChanged += OnTitleChangedInternal; implementation.VisibleChanged += OnVisibleChangedInternal; - implementation.WindowBorderChanged += OnWindowBorderChangedInternal; implementation.WindowStateChanged += OnWindowStateChangedInternal; events = true; } else if (events) { @@ -474,7 +456,6 @@ namespace OpenTK { implementation.Resize -= OnResizeInternal; implementation.TitleChanged -= OnTitleChangedInternal; implementation.VisibleChanged -= OnVisibleChangedInternal; - implementation.WindowBorderChanged -= OnWindowBorderChangedInternal; implementation.WindowStateChanged -= OnWindowStateChangedInternal; events = false; } else { diff --git a/OpenTK/Platform/MacOS/CarbonGLNative.cs b/OpenTK/Platform/MacOS/CarbonGLNative.cs index 02ebed4cd..ecb19b880 100644 --- a/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -939,30 +939,6 @@ namespace OpenTK.Platform.MacOS OnResize(); } - public WindowBorder WindowBorder - { - get - { - return windowBorder; - } - set - { - if (windowBorder == value) - return; - - windowBorder = value; - - if (windowBorder == WindowBorder.Resizable) - { - API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.Resizable | WindowAttributes.FullZoom, - WindowAttributes.NoAttributes); - } - - if (WindowBorderChanged != null) - WindowBorderChanged(this, EventArgs.Empty); - } - } - #region --- Event wrappers --- private void OnKeyPress(KeyPressEventArgs keyPressArgs) @@ -1030,7 +1006,6 @@ namespace OpenTK.Platform.MacOS public event EventHandler ClientSizeChanged; public event EventHandler VisibleChanged; public event EventHandler FocusedChanged; - public event EventHandler WindowBorderChanged; public event EventHandler WindowStateChanged; public event EventHandler KeyPress; public event EventHandler MouseEnter; diff --git a/OpenTK/Platform/Windows/WinGLNative.cs b/OpenTK/Platform/Windows/WinGLNative.cs index 40c22f7c8..826935650 100644 --- a/OpenTK/Platform/Windows/WinGLNative.cs +++ b/OpenTK/Platform/Windows/WinGLNative.cs @@ -49,8 +49,6 @@ namespace OpenTK.Platform.Windows bool class_registered, disposed, exists; WinWindowInfo window, child_window; WindowBorder windowBorder = WindowBorder.Resizable; - Nullable previous_window_border; // Set when changing to fullscreen state. - Nullable deferred_window_border; // Set to avoid changing borders during fullscreen state. WindowState windowState = WindowState.Normal; bool borderless_maximized_window_state = false; // Hack to get maximized mode with hidden border (not normally possible). bool focused; @@ -156,7 +154,7 @@ namespace OpenTK.Platform.Windows case SizeMessage.RESTORED: new_state = borderless_maximized_window_state ? WindowState.Maximized : WindowState.Normal; break; case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break; - case SizeMessage.MAXIMIZED: new_state = WindowBorder == WindowBorder.Hidden ? + case SizeMessage.MAXIMIZED: new_state = windowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized; break; } @@ -458,24 +456,13 @@ namespace OpenTK.Platform.Windows } } - void HideBorder() { + void SetBorder( WindowBorder border ) { suppress_resize++; - WindowBorder = WindowBorder.Hidden; + WindowBorder = border; ProcessEvents(); suppress_resize--; } - void RestoreBorder() { - suppress_resize++; - WindowBorder = - deferred_window_border.HasValue ? deferred_window_border.Value : - previous_window_border.HasValue ? previous_window_border.Value : - WindowBorder; - ProcessEvents(); - suppress_resize--; - deferred_window_border = previous_window_border = null; - } - void ResetWindowState() { suppress_resize++; WindowState = WindowState.Normal; @@ -621,28 +608,9 @@ namespace OpenTK.Platform.Windows break; case WindowState.Maximized: - // Note: if we use the MAXIMIZE command and the window border is Hidden (i.e. WS_POPUP), - // we will enter fullscreen mode - we don't want that! As a workaround, we'll resize the window - // manually to cover the whole working area of the current monitor. - // Reset state to avoid strange interactions with fullscreen/minimized windows. ResetWindowState(); - - if (WindowBorder == WindowBorder.Hidden) - { - IntPtr current_monitor = API.MonitorFromWindow(window.WindowHandle, MonitorFrom.Nearest); - MonitorInfo info = new MonitorInfo(); - info.Size = MonitorInfo.SizeInBytes; - API.GetMonitorInfo(current_monitor, ref info); - - previous_bounds = Bounds; - borderless_maximized_window_state = true; - Bounds = info.Work.ToRectangle(); - } - else - { - command = ShowWindowCommand.MAXIMIZE; - } + command = ShowWindowCommand.MAXIMIZE; break; case WindowState.Minimized: @@ -656,24 +624,20 @@ namespace OpenTK.Platform.Windows // Reset state to avoid strange side-effects from maximized/minimized windows. ResetWindowState(); - previous_bounds = Bounds; - previous_window_border = WindowBorder; - HideBorder(); + SetBorder( WindowBorder.Hidden ); + command = ShowWindowCommand.MAXIMIZE; - API.SetForegroundWindow(window.WindowHandle); - break; } - if (command != 0) + if( command != 0 ) API.ShowWindow(window.WindowHandle, command); // Restore previous window border or apply pending border change when leaving fullscreen mode. - if (exiting_fullscreen) { - RestoreBorder(); - } + if( exiting_fullscreen ) + SetBorder( WindowBorder.Resizable ); // Restore previous window size/location if necessary if (command == ShowWindowCommand.RESTORE && previous_bounds != Rectangle.Empty) { @@ -683,18 +647,9 @@ namespace OpenTK.Platform.Windows } } - public WindowBorder WindowBorder { - get { return windowBorder; } + WindowBorder WindowBorder { set { - // Do not allow border changes during fullscreen mode. - // Defer them for when we leave fullscreen. - if (WindowState == WindowState.Fullscreen) { - deferred_window_border = value; - return; - } - - if (windowBorder == value) - return; + if (windowBorder == value) return; // We wish to avoid making an invisible window visible just to change the border. // However, it's a good idea to make a visible window invisible temporarily, to @@ -705,17 +660,11 @@ namespace OpenTK.Platform.Windows // change the border, then go back to maximized/minimized. WindowState state = WindowState; ResetWindowState(); - WindowStyle style = WindowStyle.ClipChildren | WindowStyle.ClipSiblings; - - switch (value) { - case WindowBorder.Resizable: - style |= WindowStyle.OverlappedWindow; - break; - - case WindowBorder.Hidden: - style |= WindowStyle.Popup; - break; + if( value == WindowBorder.Resizable ) { + style |= WindowStyle.OverlappedWindow; + } else { + style |= WindowStyle.Popup; } // Make sure client size doesn't change when changing the border style. diff --git a/OpenTK/Platform/X11/X11GLNative.cs b/OpenTK/Platform/X11/X11GLNative.cs index 088a83497..1b76b779b 100644 --- a/OpenTK/Platform/X11/X11GLNative.cs +++ b/OpenTK/Platform/X11/X11GLNative.cs @@ -53,11 +53,6 @@ namespace OpenTK.Platform.X11 { IntPtr net_wm_state_fullscreen; IntPtr net_wm_state_maximized_horizontal; IntPtr net_wm_state_maximized_vertical; - - IntPtr net_wm_allowed_actions; - IntPtr net_wm_action_resize; - IntPtr net_wm_action_maximize_horizontally; - IntPtr net_wm_action_maximize_vertically; IntPtr net_wm_icon; IntPtr net_frame_extents; @@ -204,10 +199,6 @@ namespace OpenTK.Platform.X11 { net_wm_state_fullscreen = API.XInternAtom(window.Display, "_NET_WM_STATE_FULLSCREEN", false); net_wm_state_maximized_horizontal = API.XInternAtom(window.Display, "_NET_WM_STATE_MAXIMIZED_HORZ", false); net_wm_state_maximized_vertical = API.XInternAtom(window.Display, "_NET_WM_STATE_MAXIMIZED_VERT", false); - net_wm_allowed_actions = API.XInternAtom(window.Display, "_NET_WM_ALLOWED_ACTIONS", false); - net_wm_action_resize = API.XInternAtom(window.Display, "_NET_WM_ACTION_RESIZE", false); - net_wm_action_maximize_horizontally = API.XInternAtom(window.Display, "_NET_WM_ACTION_MAXIMIZE_HORZ", false); - net_wm_action_maximize_vertically = API.XInternAtom(window.Display, "_NET_WM_ACTION_MAXIMIZE_VERT", false); net_wm_icon = API.XInternAtom(window.Display, "_NEW_WM_ICON", false); net_frame_extents = API.XInternAtom(window.Display, "_NET_FRAME_EXTENTS", false); motif_wm_hints = API.XInternAtom(window.Display, "_MOTIF_WM_HINTS", true); @@ -250,82 +241,6 @@ namespace OpenTK.Platform.X11 { else Debug.Print("KeyCode {0} (Keysym: {1}, {2}) not mapped.", e.KeyEvent.keycode, (XKey)keysym, (XKey)keysym2); } - - bool IsWindowBorderHidden { - get { - // Test if decorations have been disabled through Motif. - if (motif_wm_hints != IntPtr.Zero) { - // TODO: How to check if MotifWMHints decorations have been really disabled? - if (_decorations_hidden) - return true; - } - - // Some WMs remove decorations when the transient_for hint is set. Most new ones do not (but those - // should obey the Motif hint). Anyway, if this hint is set, we say the decorations have been remove - // although there is a slight chance this is not the case. - IntPtr transient_for_parent; - API.XGetTransientForHint(window.Display, window.WindowHandle, out transient_for_parent); - if (transient_for_parent != IntPtr.Zero) - return true; - - return false; - } - } - - void DisableWindowDecorations() { - if (DisableMotifDecorations()) { - Debug.Print("Removed decorations through motif."); - _decorations_hidden = true; - } - - // Some WMs remove decorations when this hint is set. Doesn't hurt to try. - API.XSetTransientForHint(this.window.Display, this.Handle, this.window.RootWindow); - - if (_decorations_hidden) { - API.XUnmapWindow(this.window.Display, this.Handle); - API.XMapWindow(this.window.Display, this.Handle); - } - } - - bool DisableMotifDecorations() { - IntPtr atom = motif_wm_hints; - if (atom != IntPtr.Zero) { - //Functions.XGetWindowProperty(window.Display, window.WindowHandle, atom, IntPtr.Zero, IntPtr.Zero, false, - MotifWmHints hints = new MotifWmHints(); - hints.flags = (IntPtr)MotifFlags.Decorations; - API.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, - ref hints, Marshal.SizeOf(hints) / IntPtr.Size); - return true; - } - return false; - } - - void EnableWindowDecorations() { - if (EnableMotifDecorations()) { - Debug.Print("Activated decorations through motif."); - _decorations_hidden = false; - } - - API.XSetTransientForHint(this.window.Display, this.Handle, IntPtr.Zero); - if (!_decorations_hidden) { - API.XUnmapWindow(this.window.Display, this.Handle); - API.XMapWindow(this.window.Display, this.Handle); - } - } - - bool EnableMotifDecorations() { - IntPtr atom = motif_wm_hints; - if (atom != IntPtr.Zero) { - //Functions.XDeleteProperty(this.window.Display, this.Handle, atom); - MotifWmHints hints = new MotifWmHints(); - hints.flags = (IntPtr)MotifFlags.Decorations; - hints.decorations = (IntPtr)MotifDecorations.All; - API.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, - ref hints, Marshal.SizeOf(hints) / IntPtr.Size); - return true; - } - return false; - } static void DeleteIconPixmaps(IntPtr display, IntPtr window) { IntPtr wmHints_ptr = API.XGetWMHints(display, window); @@ -716,13 +631,6 @@ namespace OpenTK.Platform.X11 { net_wm_state_maximized_vertical); API.XSync(window.Display, false); - // We can't resize the window if its border is fixed, so make it resizable first. - bool temporary_resizable = false; - WindowBorder previous_state = WindowBorder; - if (WindowBorder != WindowBorder.Resizable) { - temporary_resizable = true; - WindowBorder = WindowBorder.Resizable; - } switch (value) { case OpenTK.WindowState.Normal: @@ -742,41 +650,15 @@ namespace OpenTK.Platform.X11 { break; case OpenTK.WindowState.Fullscreen: - //_previous_window_border = this.WindowBorder; - //this.WindowBorder = WindowBorder.Hidden; API.SendNetWMMessage(window, net_wm_state, _add, net_wm_state_fullscreen, IntPtr.Zero); API.XRaiseWindow(window.Display, window.WindowHandle); break; } - - if (temporary_resizable) - WindowBorder = previous_state; - ProcessEvents(); } } - public WindowBorder WindowBorder { - get { return IsWindowBorderHidden ? WindowBorder.Hidden : WindowBorder.Resizable; } - set { - if (WindowBorder == value) return; - - if (WindowBorder == WindowBorder.Hidden) - EnableWindowDecorations(); - if( value == WindowBorder.Resizable ) { - Debug.Print("Making WindowBorder resizable."); - SetWindowMinMax(_min_width, _min_height, -1, -1); - } else { - Debug.Print("Making WindowBorder hidden."); - DisableWindowDecorations(); - } - - if (WindowBorderChanged != null) - WindowBorderChanged(this, EventArgs.Empty); - } - } - public event EventHandler Load; public event EventHandler Unload; public event EventHandler Move;