3
* Author : Guillaume "iXce" Seguin
4
* Email : ixce@beryl-project.org
6
* Ported to compiz by : Patrick "marex" Niklaus
7
* Email : marex@beryl-project.org
9
* Ported to C++ by : Travis Watkins
10
* Email : amaranth@ubuntu.com
12
* Copyright (C) 2009 Guillaume Seguin
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31
#include <core/core.h>
32
#include <core/pluginclasshandler.h>
34
#include "snap_options.h"
37
* The window we should snap too if snapping to windows
39
#define SNAP_WINDOW_TYPE (CompWindowTypeNormalMask | \
40
CompWindowTypeToolbarMask | \
41
CompWindowTypeMenuMask | \
42
CompWindowTypeUtilMask)
44
#define VerticalSnap (1L << 0)
45
#define HorizontalSnap (1L << 1)
47
#define MoveGrab (1L << 0)
48
#define ResizeGrab (1L << 1)
59
* Position, start, end meanings are specific to type :
60
* - LeftEdge/RightEdge : position : x, start/end : y1/y2
61
* - TopEdge/BottomEdge : position : y, start/end : x1/x2
62
* id/passed are used during visibility detection when adding edges
63
* snapped is straight forward
80
public ScreenInterface,
81
public PluginClassHandler <SnapScreen, CompScreen>,
87
SnapScreen (CompScreen *s);
89
void handleEvent (XEvent *event);
90
bool enableSnapping (CompAction *action, CompAction::State state,
91
CompOption::Vector &options);
92
bool disableSnapping (CompAction *action, CompAction::State state,
93
CompOption::Vector &options);
94
void optionChanged (CompOption *opt, SnapOptions::Options num);
97
// used to allow moving windows without snapping
102
public WindowInterface,
103
public PluginClassHandler <SnapWindow, CompWindow>
106
SnapWindow (CompWindow *window);
109
void resizeNotify (int dx, int dy, int dwidth, int dheight);
110
void moveNotify (int dx, int dy, bool immediate);
111
void grabNotify (int x, int y, unsigned int state, unsigned int mask);
112
void ungrabNotify ();
118
std::list<Edge> edges;
123
// dx/dy/dw/dh when a window is resisting to user
130
CompWindow::Geometry snapGeometry;
133
// internal, avoids infinite notify loops
137
void move (int dx, int dy);
138
void resize (int dx, int dy, int dwidth, int dheight);
140
void addEdge (Window id, int position, int start, int end,
141
EdgeType type, bool screenEdge);
142
void addRegionEdges (Edge *parent, CompRegion region);
143
void updateWindowsEdges ();
144
void updateScreenEdges ();
146
void moveCheckNearestEdge (int position, int start, int end,
147
bool before, EdgeType type,
149
void moveCheckEdges ();
150
void resizeCheckNearestEdge (int position, int start, int end,
151
bool before, EdgeType type,
153
void resizeCheckEdges (int dx, int dy, int dwidth, int dheight);
156
#define SNAP_SCREEN(s) \
157
SnapScreen *ss = SnapScreen::get (s)
159
#define SNAP_WINDOW(w) \
160
SnapWindow *sw = SnapWindow::get (w)
162
class SnapPluginVTable :
163
public CompPlugin::VTableForScreenAndWindow <SnapScreen, SnapWindow>