mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Remove WindowBorder since we never used it.
This commit is contained in:
parent
b0a180b1db
commit
0f187cf5b0
@ -56,9 +56,6 @@ namespace OpenTK {
|
||||
|
||||
/// <summary> Gets or sets the <see cref="OpenTK.WindowState"/> for this window. </summary>
|
||||
WindowState WindowState { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the <see cref="OpenTK.WindowBorder"/> for this window. </summary>
|
||||
WindowBorder WindowBorder { get; set; }
|
||||
|
||||
/// <summary> Gets or sets a <see cref="System.Drawing.Rectangle"/> 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. </summary>
|
||||
@ -144,9 +141,6 @@ namespace OpenTK {
|
||||
/// <summary> Occurs when the <see cref="Focused"/> property of the window changes. </summary>
|
||||
event EventHandler<EventArgs> FocusedChanged;
|
||||
|
||||
/// <summary> Occurs when the <see cref="WindowBorder"/> property of the window changes. </summary>
|
||||
event EventHandler<EventArgs> WindowBorderChanged;
|
||||
|
||||
/// <summary> Occurs when the <see cref="WindowState"/> property of the window changes. </summary>
|
||||
event EventHandler<EventArgs> WindowStateChanged;
|
||||
|
||||
|
@ -198,12 +198,6 @@ namespace OpenTK {
|
||||
set { EnsureUndisposed(); implementation.Width = value; }
|
||||
}
|
||||
|
||||
/// <summary> Gets or states the border of the NativeWindow. </summary>
|
||||
public WindowBorder WindowBorder {
|
||||
get { return implementation.WindowBorder; }
|
||||
set { implementation.WindowBorder = value; }
|
||||
}
|
||||
|
||||
/// <summary> Gets the <see cref="OpenTK.Platform.IWindowInfo"/> of this window. </summary>
|
||||
public IWindowInfo WindowInfo {
|
||||
get { EnsureUndisposed(); return implementation.WindowInfo; }
|
||||
@ -285,9 +279,6 @@ namespace OpenTK {
|
||||
/// <summary> Occurs when the <see cref="Visible"/> property of the window changes. </summary>
|
||||
public event EventHandler<EventArgs> VisibleChanged;
|
||||
|
||||
/// <summary> Occurs when the <see cref="WindowBorder"/> property of the window changes. </summary>
|
||||
public event EventHandler<EventArgs> WindowBorderChanged;
|
||||
|
||||
/// <summary> Occurs when the <see cref="WindowState"/> property of the window changes. </summary>
|
||||
public event EventHandler<EventArgs> WindowStateChanged;
|
||||
|
||||
@ -389,12 +380,6 @@ namespace OpenTK {
|
||||
if (VisibleChanged != null) VisibleChanged(this, e);
|
||||
}
|
||||
|
||||
/// <summary> Called when the WindowBorder of this NativeWindow has changed. </summary>
|
||||
/// <param name="e">Not used.</param>
|
||||
protected virtual void OnWindowBorderChanged(EventArgs e) {
|
||||
if (WindowBorderChanged != null) WindowBorderChanged(this, e);
|
||||
}
|
||||
|
||||
/// <summary> Called when the WindowState of this NativeWindow has changed. </summary>
|
||||
/// <param name="e">Not used.</param>
|
||||
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 {
|
||||
|
@ -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<EventArgs> ClientSizeChanged;
|
||||
public event EventHandler<EventArgs> VisibleChanged;
|
||||
public event EventHandler<EventArgs> FocusedChanged;
|
||||
public event EventHandler<EventArgs> WindowBorderChanged;
|
||||
public event EventHandler<EventArgs> WindowStateChanged;
|
||||
public event EventHandler<KeyPressEventArgs> KeyPress;
|
||||
public event EventHandler<EventArgs> MouseEnter;
|
||||
|
@ -49,8 +49,6 @@ namespace OpenTK.Platform.Windows
|
||||
bool class_registered, disposed, exists;
|
||||
WinWindowInfo window, child_window;
|
||||
WindowBorder windowBorder = WindowBorder.Resizable;
|
||||
Nullable<WindowBorder> previous_window_border; // Set when changing to fullscreen state.
|
||||
Nullable<WindowBorder> 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.
|
||||
|
@ -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<EventArgs> Load;
|
||||
public event EventHandler<EventArgs> Unload;
|
||||
public event EventHandler<EventArgs> Move;
|
||||
|
Loading…
x
Reference in New Issue
Block a user