~mial/ubuntu/oneiric/unity/bug-791810

« back to all changes in this revision

Viewing changes to src/PluginAdapter.h

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
 
/*
3
 
 * Copyright (C) 2010 Canonical Ltd
4
 
 *
5
 
 * This program is free software: you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 3 as
7
 
 * published by the Free Software Foundation.
8
 
 *
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.
13
 
 *
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/>.
16
 
 *
17
 
 * Authored by: Jason Smith <jason.smith@canonical.com>
18
 
 */
19
 
 
20
1
#ifndef PLUGINADAPTER_H
21
2
#define PLUGINADAPTER_H
22
3
 
23
4
/* Compiz */
24
5
#include <core/core.h>
25
 
#include <core/atoms.h>
26
6
 
27
7
#include <sigc++/sigc++.h>
28
8
 
29
 
#include "WindowManager.h"
30
 
 
31
 
typedef struct
32
 
{
33
 
  unsigned long flags;
34
 
  unsigned long functions;
35
 
  unsigned long decorations;
36
 
  long input_mode;
37
 
  unsigned long status;
38
 
} MotifWmHints, MwmHints;
39
 
 
40
 
class MultiActionList
41
 
{
42
 
public:
43
 
 
44
 
  MultiActionList(int n) :
45
 
    m_ActionList(n),
46
 
    _primary_action(NULL) {};
47
 
 
48
 
  void InitiateAll(CompOption::Vector& extraArgs, int state);
49
 
  void TerminateAll(CompOption::Vector& extraArgs);
50
 
 
51
 
  void AddNewAction(CompAction*, bool primary);
52
 
  void RemoveAction(CompAction*);
53
 
private:
54
 
 
55
 
  std::list <CompAction*> m_ActionList;
56
 
  CompAction*              _primary_action;
57
 
};
58
 
 
59
 
 
60
 
class PluginAdapter : public sigc::trackable, public WindowManager
61
 
{
62
 
public:
63
 
  static PluginAdapter* Default();
64
 
 
65
 
  static void Initialize(CompScreen* screen);
66
 
 
67
 
  nux::Property<bool> bias_active_to_viewport;
68
 
 
69
 
  ~PluginAdapter();
70
 
 
71
 
  void SetScaleAction(MultiActionList& scale);
72
 
  void SetExpoAction(MultiActionList& expo);
73
 
 
74
 
  void SetShowHandlesAction(CompAction* action)
75
 
  {
76
 
    _grab_show_action = action;
77
 
  }
78
 
  void SetHideHandlesAction(CompAction* action)
79
 
  {
80
 
    _grab_hide_action = action;
81
 
  }
82
 
  void SetToggleHandlesAction(CompAction* action)
83
 
  {
84
 
    _grab_toggle_action = action;
85
 
  }
86
 
 
87
 
  void OnWindowClosed (CompWindow *);
88
 
  void OnScreenGrabbed();
89
 
  void OnScreenUngrabbed();
90
 
 
91
 
  void OnShowDesktop ();
92
 
  void OnLeaveDesktop ();
93
 
 
94
 
  void TerminateScale();
95
 
  bool IsScaleActive();
96
 
 
97
 
  void InitiateExpo();
98
 
  bool IsExpoActive();
99
 
 
100
 
  void ShowGrabHandles(CompWindow* window, bool use_timer);
101
 
  void HideGrabHandles(CompWindow* window);
102
 
  void ToggleGrabHandles(CompWindow* window);
103
 
 
104
 
  void Notify(CompWindow* window, CompWindowNotify notify);
105
 
  void NotifyMoved(CompWindow* window, int x, int y);
106
 
  void NotifyResized(CompWindow* window, int x, int y, int w, int h);
107
 
  void NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state);
108
 
  void NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option);
109
 
  void NotifyNewDecorationState(guint32 xid);
110
 
 
111
 
  void Decorate(guint32 xid);
112
 
  void Undecorate(guint32 xid);
113
 
 
114
 
  // WindowManager implementation
115
 
  bool IsWindowMaximized(guint xid);
116
 
  bool IsWindowDecorated(guint xid);
117
 
  bool IsWindowOnCurrentDesktop(guint xid);
118
 
  bool IsWindowObscured(guint xid);
119
 
  bool IsWindowMapped(guint xid);
120
 
  bool IsWindowVisible(guint32 xid);
121
 
  void Restore(guint32 xid);
122
 
  void Minimize(guint32 xid);
123
 
  void Close(guint32 xid);
124
 
  void Activate(guint32 xid);
125
 
  void Raise(guint32 xid);
126
 
  void Lower(guint32 xid);
127
 
  void ShowDesktop();
128
 
 
129
 
  void SetWindowIconGeometry(Window window, nux::Geometry const& geo);
130
 
 
131
 
  void FocusWindowGroup(std::vector<Window> windows, FocusVisibility);
132
 
  bool ScaleWindowGroup(std::vector<Window> windows, int state, bool force);
133
 
 
134
 
  bool IsScreenGrabbed();
135
 
  bool IsViewPortSwitchStarted();
136
 
 
137
 
  unsigned long long GetWindowActiveNumber (guint32 xid);
138
 
 
139
 
  bool MaximizeIfBigEnough(CompWindow* window);
140
 
 
141
 
  nux::Geometry GetWindowGeometry(guint32 xid);
142
 
  nux::Geometry GetScreenGeometry();
143
 
  
144
 
  void CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any);
145
 
 
146
 
  int WorkspaceCount();
147
 
 
148
 
  void SetCoverageAreaBeforeAutomaximize(float area);
149
 
 
150
 
  bool saveInputFocus ();
151
 
  bool restoreInputFocus ();
152
 
 
 
9
class PluginAdapter : public sigc::trackable
 
10
{
 
11
public:
 
12
    static PluginAdapter * Default ();
 
13
 
 
14
    static void Initialize (CompScreen *screen);
 
15
 
 
16
    ~PluginAdapter();
 
17
    
 
18
    std::string * MatchStringForXids (std::list<Window> *windows);
 
19
    
 
20
    void SetScaleAction (CompAction *scale);
 
21
    
 
22
    void SetExpoAction (CompAction *expo);
 
23
    
 
24
    void InitiateScale (std::string *match);
 
25
    
 
26
    void InitiateExpo ();
 
27
    
153
28
protected:
154
 
  PluginAdapter(CompScreen* screen);
 
29
    PluginAdapter(CompScreen *screen);
155
30
 
156
31
private:
157
 
  std::string MatchStringForXids(std::vector<Window> *windows);
158
 
  void InitiateScale(std::string const& match, int state = 0);
159
 
 
160
 
  bool CheckWindowIntersection(nux::Geometry const& region, CompWindow* window);
161
 
  void SetMwmWindowHints(Window xid, MotifWmHints* new_hints);
162
 
 
163
 
  CompScreen* m_Screen;
164
 
  MultiActionList m_ExpoActionList;
165
 
  MultiActionList m_ScaleActionList;
166
 
 
167
 
  bool _spread_state;
168
 
  bool _expo_state;
169
 
  bool _vp_switch_started;
170
 
 
171
 
  CompAction* _grab_show_action;
172
 
  CompAction* _grab_hide_action;
173
 
  CompAction* _grab_toggle_action;
174
 
 
175
 
  float _coverage_area_before_automaximize;
176
 
 
177
 
  bool _in_show_desktop;
178
 
  CompWindow* _last_focused_window;
179
 
 
180
 
  std::map<guint32, unsigned int> _window_decoration_state;
181
 
 
182
 
  static PluginAdapter* _default;
 
32
    CompScreen *m_Screen;
 
33
    CompAction *m_ExpoAction;
 
34
    CompAction *m_ScaleAction;
 
35
    
 
36
    static PluginAdapter *_default;
183
37
};
184
38
 
185
39
#endif