summaryrefslogtreecommitdiff
path: root/src/winrules.h
blob: 18506a807113bed38e3086e52b7304c9b9ec060f (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
/*
 * winrules plugin for compiz
 *
 * Copyright (C) 2007 Bellegarde Cedric (gnumdk (at) gmail.com)
 * Copyright (C) 2009 Sam Spilsbury (smspillaz@gmail.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#include <core/core.h>
#include <core/atoms.h>
#include <composite/composite.h>
#include <X11/Xatom.h>
#include "winrules_options.h"


class WinrulesScreen :
    public PluginClassHandler <WinrulesScreen, CompScreen>,
    public WinrulesOptions,
    public ScreenInterface
{
    public:

	WinrulesScreen (CompScreen *screen);

	void
	handleEvent (XEvent *event);

	void
	matchExpHandlerChanged ();

	void
	matchPropertyChanged (CompWindow *w);

	void
	setProtocols (unsigned int protocols,
		      Window       id);

	void
	optionChanged (CompOption	        *option,
		       WinrulesOptions::Options num);	
};

#define WINRULES_SCREEN(screen)					       \
    WinrulesScreen *ws = WinrulesScreen::get(screen);

class WinrulesWindow :
    public PluginClassHandler <WinrulesWindow, CompWindow>,
    public WindowInterface
{
    public:

	WinrulesWindow (CompWindow *window);

	CompWindow *window;

	void
	getAllowedActions (unsigned int &,
			   unsigned int &);

	bool is ();

	void setNoFocus (int optNum);

	void setNoAlpha (int optNum);

	void
	updateState (int optNum,
		     int mask);

	void
	setAllowedActions (int        optNum,
			   int        action);

	bool
	matchSizeValue (CompOption::Value::Vector matches,
			CompOption::Value::Vector widthValues,
			CompOption::Value::Vector heightValues,
			int	   		  *width,
			int	   		  *height);

	bool
	matchSize (int	      *width,
		   int	      *height);

	void
	updateWindowSize (int        width,
			  int        height);

	bool applyRules ();

	unsigned int allowedActions;
	unsigned int stateSetMask;
	unsigned int protocolSetMask;

	bool oldIsFocussable;
	bool hasAlpha;
};

#define WINRULES_WINDOW(window)					       \
    WinrulesWindow *ww = WinrulesWindow::get(window);

class WinrulesPluginVTable:
    public CompPlugin::VTableForScreenAndWindow <WinrulesScreen, WinrulesWindow>
{
    public:

	bool init ();
};