2
// Copyright (C) 2009 Jason Smith
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
using System.Collections.Generic;
20
using System.ComponentModel;
21
using System.Runtime.InteropServices;
25
using Docky.Windowing;
32
public static class Window_Extensions
34
public static int Area (this Wnck.Window self)
36
Gdk.Rectangle geo = self.EasyGeometry ();
37
return geo.Width * geo.Height;
40
public static Gdk.Rectangle EasyGeometry (this Window self)
43
self.GetGeometry (out geo.X, out geo.Y, out geo.Width, out geo.Height);
47
public static void SetWorkaroundGeometry (this Wnck.Window window, WindowGravity gravity, WindowMoveResizeMask mask,
48
int x, int y, int width, int height)
50
// This is very weird. Don't know when they will fix it. You must subtract the top and left
51
// frame extents from a move operation to get the window to actually show in the right spot.
52
// Save for maybe kwin, I think only compiz uses Viewports anyhow, so this is ok.
53
int [] extents = window.FrameExtents ();
55
x -= extents [(int) Position.Left];
56
y -= extents [(int) Position.Top];
58
window.SetGeometry (gravity, mask, x, y, width, height);
61
public static int [] FrameExtents (this Wnck.Window window)
63
return GetCardinalProperty (window, X11Atoms.Instance._NET_FRAME_EXTENTS);
66
public static int [] GetCardinalProperty (this Wnck.Window window, IntPtr atom)
68
X11Atoms atoms = X11Atoms.Instance;
73
IntPtr nitems, bytes_after;
74
int [] extents = new int[12];
76
IntPtr window_handle = (IntPtr) window.Xid;
78
display = Xlib.GdkDisplayXDisplay (Gdk.Screen.Default.Display);
81
Xlib.XGetWindowProperty (display, window_handle, atom, (IntPtr) 0,
82
(IntPtr) System.Int32.MaxValue, false, atoms.XA_CARDINAL, out type, out format,
83
out nitems, out bytes_after, out prop_return);
85
if (type == atoms.XA_CARDINAL && format == 32) {
86
extents = new int [(int) nitems];
87
for (int i = 0; i < (int) nitems; i++) {
88
extents [i] = Marshal.ReadInt32 (prop_return, i * IntPtr.Size);