~didrocks/unity/launcher-bug-fix-fest

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
/*
 * Copyright (C) 2010 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 PANEL_MENU_VIEW_H
#define PANEL_MENU_VIEW_H

#include <Nux/View.h>
#include <map>
#include <set>

#include "IndicatorObjectProxy.h"
#include "Introspectable.h"
#include "PanelIndicatorObjectView.h"
#include "StaticCairoText.h"
#include "WindowButtons.h"
#include "PanelTitlebarGrabAreaView.h"
#include "PluginAdapter.h"

#include <libbamf/libbamf.h>

class PanelMenuView : public PanelIndicatorObjectView
{
public:
  // This contains all the menubar logic for the Panel. Mainly it contains
  // the following states:
  // 1. Unmaximized window + no mouse hover
  // 2. Unmaximized window + mouse hover
  // 3. Unmaximized window + active menu (Alt+F/arrow key nav)
  // 4. Maximized window + no mouse hover
  // 5. Maximized window + mouse hover
  // 6. Maximized window + active menu
  //
  // It also deals with undecorating maximized windows (and redecorating them
  // on unmaximize)

  PanelMenuView (int padding = 6);
  ~PanelMenuView ();

  void FullRedraw ();

  virtual long ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
  virtual void Draw (nux::GraphicsEngine& GfxContext, bool force_draw);
  virtual void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
  virtual long PostLayoutManagement (long LayoutResult);
  
  void SetProxy (IndicatorObjectProxy *proxy);
 
  void OnEntryAdded (IndicatorObjectEntryProxy *proxy);
  void OnEntryMoved (IndicatorObjectEntryProxy *proxy);
  void OnEntryRemoved (IndicatorObjectEntryProxy *proxy);
  void OnEntryRefreshed (PanelIndicatorObjectEntryView *view);
  void OnActiveChanged (PanelIndicatorObjectEntryView *view, bool is_active);
  void OnActiveWindowChanged (BamfView *old_view, BamfView *new_view);
  void OnNameChanged (gchar* new_name, gchar* old_name);

  void OnSpreadInitiate ();
  void OnSpreadTerminate ();
  void OnWindowMinimized (guint32 xid);
  void OnWindowUnminimized (guint32 xid);
  void OnWindowUnmapped (guint32 xid);
  void OnWindowMaximized (guint32 xid);
  void OnWindowRestored  (guint32 xid);
  void OnWindowMoved (guint32 xid);
  
  guint32 GetMaximizedWindow ();

  void OnMaximizedGrab (int x, int y);
  void OnMouseDoubleClicked ();
  void OnMouseMiddleClicked ();

  void Refresh ();
  void AllMenusClosed ();
  
  void OnCloseClicked ();
  void OnMinimizeClicked ();
  void OnRestoreClicked ();
  void OnWindowButtonsRedraw ();
  void SetMonitor (int monitor);
  bool GetControlsActive ();

protected:
  const gchar * GetName ();
  const gchar * GetChildsName ();
  void          AddProperties (GVariantBuilder *builder);

private:
  gchar * GetActiveViewName ();
  static void OnPlaceViewShown (GVariant *data, PanelMenuView *self);
  static void OnPlaceViewHidden (GVariant *data, PanelMenuView *self);
  void UpdateShowNow (bool ignore);
  static gboolean UpdateActiveWindowPosition (PanelMenuView *self);
  
private:
  BamfMatcher* _matcher;

  nux::AbstractPaintLayer *_title_layer;
  nux::HLayout            *_menu_layout;
  nux::CairoGraphics       _util_cg;
  nux::IntrusiveSP<nux::IOpenGLBaseTexture> _gradient_texture;
  nux::BaseTexture        *_title_tex;

  bool _is_inside;
  bool _is_grabbed;
  bool _is_maximized; 
  bool _is_own_window;
  PanelIndicatorObjectEntryView *_last_active_view;

  WindowButtons * _window_buttons;
  PanelTitlebarGrabArea * _panel_titlebar_grab_area;

  std::map<guint32, bool> _decor_map;
  std::set<guint32> _maximized_set;
  int _padding;
  gpointer _name_changed_callback_instance;
  gulong _name_changed_callback_id;

  int _last_width;
  int _last_height;

  bool _places_showing;
  bool _show_now_activated;

  bool _we_control_active;
  int  _monitor;
  guint32 _active_xid;
  guint32 _active_moved_id;
  nux::Geometry _monitor_geo;
};
#endif