1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
25 using System.Runtime.InteropServices;
26 using System.Windows.Forms;
28 namespace System.Windows.Forms.X11Internal {
30 internal class X11RootHwnd : X11Hwnd
32 public X11RootHwnd (X11Display display, IntPtr window_handle) : base (display)
34 WholeWindow = ClientWindow = window_handle;
36 Xlib.XSelectInput(display.Handle, WholeWindow, new IntPtr ((int)EventMask.PropertyChangeMask));
39 public override void CreateWindow (CreateParams cp)
41 // we don't do anything here
44 public override void PropertyChanged (XEvent xevent)
46 if (xevent.PropertyEvent.atom == Display.Atoms._NET_ACTIVE_WINDOW) {
51 IntPtr prop = IntPtr.Zero;
53 Xlib.XGetWindowProperty (Display.Handle, WholeWindow,
54 Display.Atoms._NET_ACTIVE_WINDOW, IntPtr.Zero, new IntPtr (1), false,
55 Display.Atoms.XA_WINDOW, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
57 if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
58 // FIXME - is this 64 bit clean?
59 Display.SetActiveWindow ((X11Hwnd)Hwnd.ObjectFromHandle((IntPtr)Marshal.ReadInt32(prop)));
63 else if (xevent.PropertyEvent.atom == Display.Atoms._NET_SUPPORTED) {
64 // we'll need to refetch the supported protocols list
65 refetch_net_supported = true;
66 _net_supported = null;
69 base.PropertyChanged (xevent);
72 bool refetch_net_supported = true;
73 IntPtr[] _net_supported;
74 public IntPtr[] _NET_SUPPORTED {
76 if (refetch_net_supported) {
77 _net_supported = GetAtomListProperty (Display.Atoms._NET_SUPPORTED);
78 refetch_net_supported = false;
81 return _net_supported;