Back to index

unity  6.0.0
WindowManager.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00017  */
00018 
00019 #ifndef WINDOW_MANAGER_H
00020 #define WINDOW_MANAGER_H
00021 
00022 #include <Nux/Nux.h>
00023 #include <gdk/gdkx.h>
00024 #include <core/core.h>
00025 
00026 #include "unity-shared/Introspectable.h"
00027 
00028 class WindowManager : public unity::debug::Introspectable
00029 {
00030   // This is a glue interface that breaks the dependancy of Unity with Compiz
00031   // Basically it has a default implementation that does nothing useful, but
00032   // the idea is that unity.cpp uses SetDefault() early enough in it's
00033   // initialization so the things that require it get a usable implementation
00034 
00035 public:
00036   WindowManager() :
00037     m_MoveResizeAtom(XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
00038                                  "_NET_WM_MOVERESIZE", FALSE))
00039   {
00040   };
00041 
00042   enum class FocusVisibility
00043   {
00044     OnlyVisible,
00045     ForceUnminimizeInvisible,
00046     ForceUnminimizeOnCurrentDesktop
00047   };
00048 
00049   static WindowManager* Default();
00050   static void           SetDefault(WindowManager* manager);
00051 
00052   virtual guint32 GetActiveWindow() = 0;
00053 
00054   virtual bool IsWindowMaximized(guint32 xid) = 0;
00055   virtual bool IsWindowDecorated(guint32 xid) = 0;
00056   virtual bool IsWindowOnCurrentDesktop(guint32 xid) = 0;
00057   virtual bool IsWindowObscured(guint32 xid) = 0;
00058   virtual bool IsWindowMapped(guint32 xid) = 0;
00059   virtual bool IsWindowVisible(guint32 xid) = 0;
00060   virtual bool IsWindowOnTop(guint32 xid) = 0;
00061   virtual bool IsWindowClosable(guint32 xid) = 0;
00062   virtual bool IsWindowMinimizable(guint32 xid) = 0;
00063   virtual bool IsWindowMaximizable(guint32 xid) = 0;
00064 
00065   virtual void ShowDesktop() = 0;
00066 
00067   virtual void Restore(guint32 xid) = 0;
00068   virtual void RestoreAt(guint32 xid, int x, int y) = 0;
00069   virtual void Minimize(guint32 xid) = 0;
00070   virtual void Close(guint32 xid) = 0;
00071 
00072   virtual void Activate(guint32 xid) = 0;
00073   virtual void Raise(guint32 xid) = 0;
00074   virtual void Lower(guint32 xid) = 0;
00075 
00076   virtual void TerminateScale() = 0;
00077   virtual bool IsScaleActive() = 0;
00078   virtual bool IsScaleActiveForGroup() = 0;
00079 
00080   virtual void InitiateExpo() = 0;
00081   virtual bool IsExpoActive() = 0;
00082 
00083   virtual void FocusWindowGroup(std::vector<Window> windows, FocusVisibility, int monitor = -1, bool only_top_win = true) = 0;
00084   virtual bool ScaleWindowGroup(std::vector<Window> windows, int state, bool force) = 0;
00085 
00086   virtual void Decorate(guint32 xid) {};
00087   virtual void Undecorate(guint32 xid) {};
00088 
00089   virtual bool IsScreenGrabbed() = 0;
00090   virtual bool IsViewPortSwitchStarted() = 0;
00091 
00092   virtual void MoveResizeWindow(guint32 xid, nux::Geometry geometry) = 0;
00093   void StartMove(guint32 xid, int, int);
00094 
00095   virtual int GetWindowMonitor(guint32 xid) const = 0;
00096   virtual nux::Geometry GetWindowGeometry(guint32 xid) const = 0;
00097   virtual nux::Geometry GetWindowSavedGeometry(guint32 xid) const = 0;
00098   virtual nux::Geometry GetScreenGeometry() const = 0;
00099   virtual nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const = 0;
00100 
00101   virtual unsigned long long GetWindowActiveNumber(guint32 xid) = 0;
00102 
00103   virtual void SetWindowIconGeometry(Window window, nux::Geometry const& geo) = 0;
00104 
00105   virtual void CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) = 0;
00106 
00107   virtual int WorkspaceCount() = 0;
00108 
00109   virtual bool saveInputFocus() = 0;
00110   virtual bool restoreInputFocus() = 0;
00111 
00112   // Signals
00113   sigc::signal<void, guint32> window_mapped;
00114   sigc::signal<void, guint32> window_unmapped;
00115   sigc::signal<void, guint32> window_maximized;
00116   sigc::signal<void, guint32> window_restored;
00117   sigc::signal<void, guint32> window_minimized;
00118   sigc::signal<void, guint32> window_unminimized;
00119   sigc::signal<void, guint32> window_shaded;
00120   sigc::signal<void, guint32> window_unshaded;
00121   sigc::signal<void, guint32> window_shown;
00122   sigc::signal<void, guint32> window_hidden;
00123   sigc::signal<void, guint32> window_resized;
00124   sigc::signal<void, guint32> window_moved;
00125   sigc::signal<void, guint32> window_focus_changed;
00126   sigc::signal<void, guint32> window_decorated;
00127   sigc::signal<void, guint32> window_undecorated;
00128 
00129   sigc::signal<void> initiate_spread;
00130   sigc::signal<void> terminate_spread;
00131 
00132   sigc::signal<void> initiate_expo;
00133   sigc::signal<void> terminate_expo;
00134 
00135   sigc::signal<void> compiz_screen_grabbed;
00136   sigc::signal<void> compiz_screen_ungrabbed;
00137   sigc::signal<void> compiz_screen_viewport_switch_started;
00138   sigc::signal<void> compiz_screen_viewport_switch_ended;
00139 
00140   sigc::signal<void, const char*, const char*, CompOption::Vector&> compiz_event;
00141 
00142 protected:
00143   std::string GetName() const;
00144   virtual void AddProperties(GVariantBuilder* builder) = 0;
00145 
00146 private:
00147   Atom m_MoveResizeAtom;
00148 };
00149 
00150 #endif // WINDOW_MANAGER_H