summaryrefslogtreecommitdiff
path: root/src/Display.cs
blob: 5831b3251de1e96b2618e5301fcbb90296b860f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Compiz
{
	//From Mono.Unix and poll(2)
	[Flags]
	public enum PollEvents : short {
		POLLIN      = 0x0001, // There is data to read
		POLLPRI     = 0x0002, // There is urgent data to read
		POLLOUT     = 0x0004, // Writing now will not block
		POLLERR     = 0x0008, // Error condition
		POLLHUP     = 0x0010, // Hung up
		POLLNVAL    = 0x0020, // Invalid request; fd not open
		// XPG4.2 definitions (via _XOPEN_SOURCE)
		POLLRDNORM  = 0x0040, // Normal data may be read
		POLLRDBAND  = 0x0080, // Priority data may be read
		POLLWRNORM  = 0x0100, // Writing now will not block
		POLLWRBAND  = 0x0200, // Priority data may be written
	}

	public delegate bool CallBackProc (IntPtr closure);

	public class Display
	{
		public IntPtr Handle;

		//TODO: use events here?
		public virtual void HandleEvent ()
		{
		}

		[DllImport("compiz")]
			protected extern static void addScreenToDisplay (IntPtr display, IntPtr s);

		[DllImport("compiz")]
			protected extern static int compAddWatchFd (int fd, PollEvents events, CallBackProc callBack, IntPtr closure);

		public int AddWatch (int fd, PollEvents events, CallBackProc cb, IntPtr closure)
		{
			return compAddWatchFd (fd, events, cb, closure);
		}

		[DllImport("compiz")]
			protected extern static void compRemoveWatchFd (int handle);

		public void RemoveWatch (int handle)
		{
			compRemoveWatchFd (handle);
		}

		[DllImport("compiz")]
			protected extern static void focusDefaultWindow (IntPtr display);

		public void FocusDefaultWindow ()
		{
			focusDefaultWindow (Handle);
		}

		[DllImport("compiz")]
			protected extern static void updateModifierMappings (IntPtr display);

		public void UpdateModifierMappings ()
		{
			updateModifierMappings (Handle);
		}

		[DllImport("compiz")]
			protected extern static void warpPointer (IntPtr display, int dx, int dy);

		public void WarpPointer (int dx, int dy)
		{
			warpPointer (Handle, dx, dy);
		}
	}

	//make these CamelCase before using them
	public enum DisplayOption
	{
		active_plugins,
			texture_filter,
			click_to_focus,
			autoraise,
			autoraise_delay,
			close_window,
			main_menu,
			run_dialog,
			command0,
			run_command0,
			command1,
			run_command1,
			command2,
			run_command2,
			command3,
			run_command3,
			command4,
			run_command4,
			command5,
			run_command5,
			command6,
			run_command6,
			command7,
			run_command7,
			command8,
			run_command8,
			command9,
			run_command9,
			command10,
			run_command10,
			command11,
			run_command11,
			slow_animations,
			lower_window,
			unmaximize_window,
			minimize_window,
			maximize_window,
			maximize_window_horz,
			maximize_window_vert,
			opacity_increase,
			opacity_decrease,
			screenshot,
			run_screenshot,
			window_screenshot,
			run_window_screenshot,
			window_menu,
			show_desktop,
			raise_on_click,
			audible_bell,
			toggle_window_maximized,
			toggle_window_maximized_horz,
			toggle_window_maximized_vert,
			hide_skip_taskbar_windows,
			toggle_window_shaded,
			//num = 54,
	}

	[StructLayout (LayoutKind.Explicit, Pack=1)]
	public unsafe struct CompDisplay
	{
		[FieldOffset (0)]
		public IntPtr Display;
		[FieldOffset (4)]
		public CompScreen* Screens;

		//[FieldOffset (80)]
		//public fixed uint Atoms[?];

		[FieldOffset (4512)]
		public IntPtr HandleEvent;

		[FieldOffset (4516)]
		public IntPtr privates;
	}
}