* Platform/X11/X11GLNative.cs: Completed support for NET WM WindowState

modes.
This commit is contained in:
the_fiddler 2008-04-25 22:09:13 +00:00
parent 0457b857b7
commit 6293fbadc3

View file

@ -49,8 +49,9 @@ namespace OpenTK.Platform.X11
IntPtr _atom_wm_state_maximized_horizontal; IntPtr _atom_wm_state_maximized_horizontal;
IntPtr _atom_wm_state_maximized_vertical; IntPtr _atom_wm_state_maximized_vertical;
IntPtr _atom_state_enable = (IntPtr)1; static readonly IntPtr _atom_state_remove = (IntPtr)0;
IntPtr _atom_state_toggle = (IntPtr)2; static readonly IntPtr _atom_state_add = (IntPtr)1;
static readonly IntPtr _atom_state_toggle = (IntPtr)2;
// Number of pending events. // Number of pending events.
int pending = 0; int pending = 0;
@ -74,9 +75,9 @@ namespace OpenTK.Platform.X11
// Fields used for fullscreen mode changes. // Fields used for fullscreen mode changes.
int pre_fullscreen_width, pre_fullscreen_height; int pre_fullscreen_width, pre_fullscreen_height;
bool fullscreen = false; //bool fullscreen = false;
OpenTK.WindowState _window_state; OpenTK.WindowState _window_state, _previous_window_state;
OpenTK.WindowBorder _window_border, _previous_window_border; OpenTK.WindowBorder _window_border, _previous_window_border;
#endregion #endregion
@ -380,35 +381,36 @@ namespace OpenTK.Platform.X11
public bool Fullscreen public bool Fullscreen
{ {
get get
{ {
return fullscreen; return false;
//return fullscreen;
} }
set set
{ {
if (value && !fullscreen) // if (value && !fullscreen)
{ // {
Debug.Print("Going fullscreen"); // Debug.Print("Going fullscreen");
Debug.Indent(); // Debug.Indent();
DisableWindowDecorations(); // DisableWindowDecorations();
pre_fullscreen_height = this.Height; // pre_fullscreen_height = this.Height;
pre_fullscreen_width = this.Width; // pre_fullscreen_width = this.Width;
//Functions.XRaiseWindow(this.window.Display, this.Handle); // //Functions.XRaiseWindow(this.window.Display, this.Handle);
Functions.XMoveResizeWindow(this.window.Display, this.Handle, 0, 0, // Functions.XMoveResizeWindow(this.window.Display, this.Handle, 0, 0,
DisplayDevice.Default.Width, DisplayDevice.Default.Height); // DisplayDevice.Default.Width, DisplayDevice.Default.Height);
Debug.Unindent(); // Debug.Unindent();
fullscreen = true; // fullscreen = true;
} // }
else if (!value && fullscreen) // else if (!value && fullscreen)
{ // {
Debug.Print("Going windowed"); // Debug.Print("Going windowed");
Debug.Indent(); // Debug.Indent();
Functions.XMoveResizeWindow(this.window.Display, this.Handle, 0, 0, // Functions.XMoveResizeWindow(this.window.Display, this.Handle, 0, 0,
pre_fullscreen_width, pre_fullscreen_height); // pre_fullscreen_width, pre_fullscreen_height);
pre_fullscreen_height = pre_fullscreen_width = 0; // pre_fullscreen_height = pre_fullscreen_width = 0;
EnableWindowDecorations(); // EnableWindowDecorations();
Debug.Unindent(); // Debug.Unindent();
fullscreen = false; // fullscreen = false;
} // }
/* /*
Debug.Print(value ? "Going fullscreen" : "Going windowed"); Debug.Print(value ? "Going fullscreen" : "Going windowed");
IntPtr state_atom = Functions.XInternAtom(this.window.Display, "_NET_WM_STATE", false); IntPtr state_atom = Functions.XInternAtom(this.window.Display, "_NET_WM_STATE", false);
@ -599,18 +601,18 @@ namespace OpenTK.Platform.X11
IntPtr bytes_after; IntPtr bytes_after;
IntPtr prop = IntPtr.Zero; IntPtr prop = IntPtr.Zero;
IntPtr atom; IntPtr atom;
int maximized;
bool minimized;
XWindowAttributes attributes; XWindowAttributes attributes;
bool fullscreen = false;
maximized = 0; int maximized = 0;
minimized = false; bool minimized = false;
Functions.XGetWindowProperty(window.Display, window.WindowHandle, Functions.XGetWindowProperty(window.Display, window.WindowHandle,
_atom_wm_state, IntPtr.Zero, new IntPtr (256), false, _atom_wm_state, IntPtr.Zero, new IntPtr (256), false,
IntPtr.Zero, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop); IntPtr.Zero, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
if ((long)nitems > 0 && prop != IntPtr.Zero) if ((long)nitems > 0 && prop != IntPtr.Zero)
{ {
Debug.Print("nitems: {0}", nitems.ToString());
for (int i = 0; i < (long)nitems; i++) for (int i = 0; i < (long)nitems; i++)
{ {
atom = (IntPtr)Marshal.ReadIntPtr(prop, i * IntPtr.Size); atom = (IntPtr)Marshal.ReadIntPtr(prop, i * IntPtr.Size);
@ -627,16 +629,16 @@ namespace OpenTK.Platform.X11
if (minimized) if (minimized)
return WindowState.Minimized; return WindowState.Minimized;
else if (fullscreen) // Must come before maximized!
return OpenTK.WindowState.Fullscreen;
else if (maximized == 2) else if (maximized == 2)
return OpenTK.WindowState.Maximized; return OpenTK.WindowState.Maximized;
else if (fullscreen)
return OpenTK.WindowState.Fullscreen;
/*
attributes = new XWindowAttributes(); attributes = new XWindowAttributes();
Functions.XGetWindowAttributes(window.Display, window.WindowHandle, ref attributes); Functions.XGetWindowAttributes(window.Display, window.WindowHandle, ref attributes);
if (attributes.map_state == MapState.IsUnmapped) if (attributes.map_state == MapState.IsUnmapped)
return (OpenTK.WindowState)(-1); return (OpenTK.WindowState)(-1);
*/
return OpenTK.WindowState.Normal; return OpenTK.WindowState.Normal;
} }
set set
@ -654,7 +656,7 @@ namespace OpenTK.Platform.X11
else if (current_state == OpenTK.WindowState.Fullscreen) else if (current_state == OpenTK.WindowState.Fullscreen)
{ {
WindowBorder = _previous_window_border; WindowBorder = _previous_window_border;
Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_toggle, Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_remove,
_atom_wm_state_fullscreen, _atom_wm_state_fullscreen,
IntPtr.Zero); IntPtr.Zero);
} }
@ -671,7 +673,7 @@ namespace OpenTK.Platform.X11
break; break;
case OpenTK.WindowState.Maximized: case OpenTK.WindowState.Maximized:
Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_enable, Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_add,
_atom_wm_state_maximized_horizontal, _atom_wm_state_maximized_horizontal,
_atom_wm_state_maximized_vertical); _atom_wm_state_maximized_vertical);
@ -687,11 +689,10 @@ namespace OpenTK.Platform.X11
case WindowState.Fullscreen: case WindowState.Fullscreen:
_previous_window_border = this.WindowBorder; _previous_window_border = this.WindowBorder;
this.WindowBorder = WindowBorder.Hidden; this.WindowBorder = WindowBorder.Hidden;
Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_enable, Functions.SendNetWMMessage(window, _atom_wm_state, _atom_state_add,
_atom_wm_state_fullscreen, _atom_wm_state_fullscreen, IntPtr.Zero);
IntPtr.Zero);
break; break;
} }