~ps-jenkins/compiz/latestsnapshot-10.9.9daily13.06.1913.04-0ubuntu1

2121 by Dennis Kasprzyk
Added missing license headers.
1
/*
2
 * Copyright © 2008 Dennis Kasprzyk
3
 * Copyright © 2007 Novell, Inc.
4
 *
5
 * Permission to use, copy, modify, distribute, and sell this software
6
 * and its documentation for any purpose is hereby granted without
7
 * fee, provided that the above copyright notice appear in all copies
8
 * and that both that copyright notice and this permission notice
9
 * appear in supporting documentation, and that the name of
10
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11
 * distribution of the software without specific, written prior permission.
12
 * Dennis Kasprzyk makes no representations about the suitability of this
13
 * software for any purpose. It is provided "as is" without express or
14
 * implied warranty.
15
 *
16
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
 *
24
 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25
 *          David Reveman <davidr@novell.com>
26
 */
27
2016 by Dennis Kasprzyk
Cleanup CompScreen public API and move header to core/screen.h
28
#include <core/screen.h>
2017 by Dennis Kasprzyk
Cleanup CompWindow public API and move header to core/window.h
29
#include <core/window.h>
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
30
#include <core/atoms.h>
31
#include "privatescreen.h"
32
#include "privatewindow.h"
33
34
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
35
CompScreenImpl::closeWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
36
		      CompAction::State  state,
37
		      CompOption::Vector &options)
38
{
39
    CompWindow   *w;
40
    Window       xid;
41
    unsigned int time;
42
43
    xid  = CompOption::getIntOptionNamed (options, "window");
44
    time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
45
46
    w = screen->findTopLevelWindow (xid);
47
    if (w && (w->priv->actions  & CompWindowActionCloseMask))
48
	w->close (time);
49
50
    return true;
51
}
52
53
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
54
CompScreenImpl::unmaximizeWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
55
			   CompAction::State  state,
56
			   CompOption::Vector &options)
57
{
58
    CompWindow *w;
59
    Window     xid;
60
61
    xid = CompOption::getIntOptionNamed (options, "window");
62
63
    w = screen->findTopLevelWindow (xid);
64
    if (w)
65
	w->maximize (0);
66
67
    return true;
68
}
69
70
bool
3585.4.1 by MC Return
Added a new keyboard shortcut named unmaximize_or_minimize_window_key
71
CompScreenImpl::unmaximizeOrMinimizeWin (CompAction         *action,
3585.4.4 by MC Return
Fixed indentation
72
					 CompAction::State  state,
73
					 CompOption::Vector &options)
3585.4.1 by MC Return
Added a new keyboard shortcut named unmaximize_or_minimize_window_key
74
{
75
    CompWindow *w;
76
    Window     xid;
77
78
    xid = CompOption::getIntOptionNamed (options, "window");
79
80
    w = screen->findTopLevelWindow (xid);
3585.4.5 by MC Return
Simplified the unmaximizeOrMinimizeWin function by checking if (w) just once
81
    if (w)
82
    {
3585.4.10 by MC Return
Cleaned up pointless if statement
83
	if (w->priv->state & MAXIMIZE_STATE)
3585.4.9 by MC Return
Added brackets for better readability
84
	{
3585.4.5 by MC Return
Simplified the unmaximizeOrMinimizeWin function by checking if (w) just once
85
	    w->maximize (0);
3585.4.9 by MC Return
Added brackets for better readability
86
	}
3585.4.5 by MC Return
Simplified the unmaximizeOrMinimizeWin function by checking if (w) just once
87
	else if (w->actions () & CompWindowActionMinimizeMask)
3585.4.9 by MC Return
Added brackets for better readability
88
	{
3585.4.5 by MC Return
Simplified the unmaximizeOrMinimizeWin function by checking if (w) just once
89
	    w->minimize ();
3585.4.9 by MC Return
Added brackets for better readability
90
	}
3585.4.5 by MC Return
Simplified the unmaximizeOrMinimizeWin function by checking if (w) just once
91
    }
3585.4.1 by MC Return
Added a new keyboard shortcut named unmaximize_or_minimize_window_key
92
    return true;
93
}
94
95
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
96
CompScreenImpl::minimizeWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
97
			 CompAction::State  state,
98
			 CompOption::Vector &options)
99
{
100
    CompWindow *w;
101
    Window     xid;
102
103
    xid = CompOption::getIntOptionNamed (options, "window");
104
105
    w = screen->findTopLevelWindow (xid);
106
    if (w && (w->actions () & CompWindowActionMinimizeMask))
107
	w->minimize ();
108
109
    return true;
110
}
111
112
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
113
CompScreenImpl::maximizeWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
114
			 CompAction::State  state,
115
			 CompOption::Vector &options)
116
{
117
    CompWindow *w;
118
    Window     xid;
119
120
    xid = CompOption::getIntOptionNamed (options, "window");
121
122
    w = screen->findTopLevelWindow (xid);
123
    if (w)
124
	w->maximize (MAXIMIZE_STATE);
125
126
    return true;
127
}
128
129
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
130
CompScreenImpl::maximizeWinHorizontally (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
131
				     CompAction::State  state,
132
				     CompOption::Vector &options)
133
{
134
    CompWindow *w;
135
    Window     xid;
136
137
    xid = CompOption::getIntOptionNamed (options, "window");
138
139
    w = screen->findTopLevelWindow (xid);
140
    if (w)
141
	w->maximize (w->state () | CompWindowStateMaximizedHorzMask);
142
143
    return true;
144
}
145
146
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
147
CompScreenImpl::maximizeWinVertically (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
148
				   CompAction::State  state,
149
				   CompOption::Vector &options)
150
{
151
    CompWindow *w;
152
    Window     xid;
153
154
    xid = CompOption::getIntOptionNamed (options, "window");
155
156
    w = screen->findTopLevelWindow (xid);
157
    if (w)
158
	w->maximize (w->state () | CompWindowStateMaximizedVertMask);
159
160
    return true;
161
}
162
163
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
164
CompScreenImpl::showDesktop (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
165
			 CompAction::State  state,
166
			 CompOption::Vector &options)
167
{
2961.6.6 by Alan Griffiths
Another attempt to use AbstractCompScreen - this time as the "screen" global
168
    if (screen->showingDesktopMask() == 0)
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
169
	screen->enterShowDesktopMode ();
170
    else
171
	screen->leaveShowDesktopMode (NULL);
172
173
    return true;
174
}
175
176
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
177
CompScreenImpl::raiseWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
178
		      CompAction::State  state,
179
		      CompOption::Vector &options)
180
{
181
    CompWindow *w;
182
    Window     xid;
183
184
    xid = CompOption::getIntOptionNamed (options, "window");
185
186
    w = screen->findTopLevelWindow (xid);
187
    if (w)
188
	w->raise ();
189
190
    return true;
191
}
192
193
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
194
CompScreenImpl::lowerWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
195
		      CompAction::State  state,
196
		      CompOption::Vector &options)
197
{
198
    CompWindow *w;
199
    Window     xid;
200
201
    xid = CompOption::getIntOptionNamed (options, "window");
202
203
    w = screen->findTopLevelWindow (xid);
204
    if (w)
205
	w->lower ();
206
207
    return true;
208
}
209
210
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
211
CompScreenImpl::windowMenu (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
212
			CompAction::State  state,
213
			CompOption::Vector &options)
214
{
215
    CompWindow *w;
216
    Window     xid;
217
218
    xid = CompOption::getIntOptionNamed (options, "window");
219
220
    w = screen->findTopLevelWindow (xid);
2961.6.6 by Alan Griffiths
Another attempt to use AbstractCompScreen - this time as the "screen" global
221
    if (w && screen->grabsEmpty ())
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
222
    {
223
	int  x, y, button;
224
	Time time;
225
226
	time   = CompOption::getIntOptionNamed (options, "time", CurrentTime);
227
	button = CompOption::getIntOptionNamed (options, "button", 0);
228
	x      = CompOption::getIntOptionNamed (options, "x",
2974.2.57 by smspillaz
Now that geometry and serverGeometry both return the same thing, the changes
229
						w->geometry ().x ());
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
230
	y      = CompOption::getIntOptionNamed (options, "y",
2974.2.57 by smspillaz
Now that geometry and serverGeometry both return the same thing, the changes
231
						w->geometry ().y ());
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
232
233
	screen->toolkitAction (Atoms::toolkitActionWindowMenu,
234
			       time, w->id (), button, x, y);
235
    }
236
237
    return true;
238
}
239
240
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
241
CompScreenImpl::toggleWinMaximized (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
242
				CompAction::State  state,
243
				CompOption::Vector &options)
244
{
245
    CompWindow *w;
246
    Window     xid;
247
248
    xid = CompOption::getIntOptionNamed (options, "window");
249
250
    w = screen->findTopLevelWindow (xid);
251
    if (w)
252
    {
253
	if ((w->priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
254
	    w->maximize (0);
255
	else
256
	    w->maximize (MAXIMIZE_STATE);
257
    }
258
259
    return true;
260
}
261
262
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
263
CompScreenImpl::toggleWinMaximizedHorizontally (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
264
					    CompAction::State  state,
265
					    CompOption::Vector &options)
266
{
267
    CompWindow *w;
268
    Window     xid;
269
270
    xid = CompOption::getIntOptionNamed (options, "window");
271
272
    w = screen->findTopLevelWindow (xid);
273
    if (w)
274
	w->maximize (w->priv->state ^ CompWindowStateMaximizedHorzMask);
275
276
    return true;
277
}
278
279
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
280
CompScreenImpl::toggleWinMaximizedVertically (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
281
					  CompAction::State  state,
282
					  CompOption::Vector &options)
283
{
284
    CompWindow *w;
285
    Window     xid;
286
287
    xid = CompOption::getIntOptionNamed (options, "window");
288
289
    w = screen->findTopLevelWindow (xid);
290
    if (w)
291
	w->maximize (w->priv->state ^ CompWindowStateMaximizedVertMask);
292
293
    return true;
294
}
295
296
bool
2961.6.7 by Alan Griffiths
Separated out Implementation class from CompScreen
297
CompScreenImpl::shadeWin (CompAction         *action,
1992 by Dennis Kasprzyk
Merge CompCore and CompDisplay into CompScreen class.
298
		      CompAction::State  state,
299
		      CompOption::Vector &options)
300
{
301
    CompWindow *w;
302
    Window     xid;
303
304
    xid = CompOption::getIntOptionNamed (options, "window");
305
306
    w = screen->findTopLevelWindow (xid);
307
    if (w && (w->priv->actions & CompWindowActionShadeMask))
308
    {
309
	w->priv->state ^= CompWindowStateShadedMask;
310
	w->updateAttributes (CompStackingUpdateModeNone);
311
    }
312
313
    return true;
314
}