~brandontschaefer/unity/bump-to-new-nux-abi

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
 * Copyright (C) 2010-2012 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
 */

#ifndef UNITYSHARED_WINDOW_MANAGER_H
#define UNITYSHARED_WINDOW_MANAGER_H

#include <memory>
#include <vector>
#include <sigc++/sigc++.h>

// To bring in nux::Geometry we first need the Rect header, then Utils.
#include <NuxCore/Rect.h>
#include <NuxCore/Property.h>
#include <Nux/Utils.h>

#ifdef USE_X11
#include <X11/Xlib.h>
#else
typedef unsigned long Window;
typedef unsigned long Atom;
#endif

#include "unity-shared/Introspectable.h"

namespace unity
{
class WindowManager;
typedef std::shared_ptr<WindowManager> WindowManagerPtr;

// This function is used by the static Default method on the WindowManager
// class, and uses link time to make sure there is a function available.
WindowManagerPtr create_window_manager();

class WindowManager : public debug::Introspectable
{
  // This is a glue interface that breaks the dependancy of Unity with Compiz
  // Basically it has a default implementation that does nothing useful, but
  // the idea is that unity.cpp uses SetDefault() early enough in it's
  // initialization so the things that require it get a usable implementation

public:
  virtual ~WindowManager() {}

  enum class FocusVisibility
  {
    OnlyVisible,
    ForceUnminimizeInvisible,
    ForceUnminimizeOnCurrentDesktop
  };

  enum class Edge : unsigned
  {
    LEFT,
    RIGHT,
    TOP,
    BOTTOM
  };

  static WindowManager& Default();

  virtual Window GetActiveWindow() const = 0;
  virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;

  virtual int  MonitorGeometryIn(nux::Geometry const& geo) const = 0;
  virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const = 0;

  virtual bool IsWindowMaximized(Window window_id) const = 0;
  virtual bool IsWindowVerticallyMaximized(Window window_id) const = 0;
  virtual bool IsWindowHorizontallyMaximized(Window window_id) const = 0;
  virtual bool IsWindowDecorated(Window window_id) const = 0;
  virtual bool IsWindowOnCurrentDesktop(Window window_id) const = 0;
  virtual bool IsWindowObscured(Window window_id) const = 0;
  virtual bool IsWindowMapped(Window window_id) const = 0;
  virtual bool IsWindowVisible(Window window_id) const = 0;
  virtual bool IsWindowOnTop(Window window_id) const = 0;
  virtual bool IsWindowShaded(Window window_id) const = 0;
  virtual bool IsWindowClosable(Window window_id) const = 0;
  virtual bool IsWindowMinimized(Window window_id) const = 0;
  virtual bool IsWindowMinimizable(Window window_id) const = 0;
  virtual bool IsWindowMaximizable(Window window_id) const = 0;
  virtual bool HasWindowDecorations(Window window_id) const = 0;

  virtual void ShowDesktop() = 0;
  virtual bool InShowDesktop() const = 0;

  virtual void ShowActionMenu(Time, Window, unsigned button, nux::Point const&) = 0;
  virtual void Maximize(Window window_id) = 0;
  virtual void VerticallyMaximize(Window window_id) = 0;
  virtual void HorizontallyMaximize(Window window_id) = 0;
  virtual void Restore(Window window_id) = 0;
  virtual void RestoreAt(Window window_id, int x, int y) = 0;
  virtual void Minimize(Window window_id) = 0;
  virtual void UnMinimize(Window window_id) = 0;
  virtual void Shade(Window window_id) = 0;
  virtual void UnShade(Window window_id) = 0;
  virtual void Close(Window window_id) = 0;

  virtual void Activate(Window window_id) = 0;
  virtual void Raise(Window window_id) = 0;
  virtual void Lower(Window window_id) = 0;
  virtual void RestackBelow(Window window_id, Window sibiling_id) = 0;

  virtual void TerminateScale() = 0;
  virtual bool IsScaleActive() const = 0;
  virtual bool IsScaleActiveForGroup() const = 0;

  virtual void InitiateExpo() = 0;
  virtual void TerminateExpo() = 0;
  virtual bool IsExpoActive() const = 0;

  virtual bool IsWallActive() const = 0;

  virtual bool IsAnyWindowMoving() const = 0;

  virtual void FocusWindowGroup(std::vector<Window> const& windows,
                                FocusVisibility, int monitor = -1,
                                bool only_top_win = true) = 0;
  virtual bool ScaleWindowGroup(std::vector<Window> const& windows,
                                int state, bool force) = 0;

  virtual bool IsScreenGrabbed() const = 0;
  virtual bool IsViewPortSwitchStarted() const = 0;

  virtual void MoveResizeWindow(Window window_id, nux::Geometry geometry) = 0;
  virtual void StartMove(Window window_id, int x, int y) = 0;
  virtual void UnGrabMousePointer(Time, int button, int x, int y) = 0;

  virtual int GetWindowMonitor(Window window_id) const = 0;
  virtual nux::Geometry GetWindowGeometry(Window window_id) const = 0;
  virtual nux::Geometry GetWindowSavedGeometry(Window window_id) const = 0;
  virtual nux::Size GetWindowDecorationSize(Window window_id, Edge) const = 0;
  virtual nux::Geometry GetScreenGeometry() const = 0;
  virtual nux::Geometry GetWorkAreaGeometry(Window window_id = 0) const = 0;

  virtual uint64_t GetWindowActiveNumber(Window window_id) const = 0;

  virtual void SetWindowIconGeometry(Window window, nux::Geometry const& geo) = 0;

  virtual void CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) = 0;

  virtual int WorkspaceCount() const = 0;

  virtual nux::Point GetCurrentViewport() const = 0;
  virtual void SetViewportSize(int horizontal, int vertical) = 0;
  virtual int GetViewportHSize() const = 0;
  virtual int GetViewportVSize() const = 0;

  virtual bool SaveInputFocus() = 0;
  virtual bool RestoreInputFocus() = 0;

  virtual std::string GetWindowName(Window window_id) const = 0;
  virtual bool IsOnscreenKeyboard(Window window_id) const = 0;

  virtual std::string GetStringProperty(Window, Atom) const = 0;
  virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0;

  virtual void UnmapAllNoNuxWindowsSync() = 0;


  // Nux Modifiers, Nux Keycode (= X11 KeySym)
  nux::Property<std::pair<unsigned, unsigned>> close_window_key;
  nux::Property<std::pair<unsigned, unsigned>> activate_indicators_key;
  nux::Property<nux::Color> average_color;

  // Signals
  sigc::signal<void, Window> window_mapped;
  sigc::signal<void, Window> window_unmapped;
  sigc::signal<void, Window> window_maximized;
  sigc::signal<void, Window> window_restored;
  sigc::signal<void, Window> window_minimized;
  sigc::signal<void, Window> window_unminimized;
  sigc::signal<void, Window> window_shaded;
  sigc::signal<void, Window> window_unshaded;
  sigc::signal<void, Window> window_shown;
  sigc::signal<void, Window> window_hidden;
  sigc::signal<void, Window> window_resized;
  sigc::signal<void, Window> window_moved;
  sigc::signal<void, Window> window_focus_changed;

  sigc::signal<void> show_desktop_changed;

  sigc::signal<void> initiate_spread;
  sigc::signal<void> terminate_spread;

  sigc::signal<void> initiate_expo;
  sigc::signal<void> terminate_expo;

  sigc::signal<void> screen_grabbed;
  sigc::signal<void> screen_ungrabbed;
  sigc::signal<void> screen_viewport_switch_started;
  sigc::signal<void> screen_viewport_switch_ended;
  sigc::signal<void, int, int> viewport_layout_changed;

protected:
  std::string GetName() const;
  virtual void AddProperties(debug::IntrospectionData& introspection) = 0;

};

}

#endif // UNITYSHARED_WINDOW_MANAGER_H