Merge lp:~didrocks/unity/fix-661049 into lp:unity

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 793
Proposed branch: lp:~didrocks/unity/fix-661049
Merge into: lp:unity
Diff against target: 149 lines (+65/-10)
3 files modified
src/PanelMenuView.cpp (+1/-0)
src/PanelTitlebarGrabAreaView.cpp (+50/-8)
src/PanelTitlebarGrabAreaView.h (+14/-2)
To merge this branch: bzr merge lp:~didrocks/unity/fix-661049
Reviewer Review Type Date Requested Status
Gord Allott Pending
Review via email: mp+47530@code.launchpad.net

Description of the change

Enabling double click on the launcher to restore a maximized window
(LP: #661049)

This isn't the best fix as nux seems to have some broken piece in
OnMouseDoubleClick but rather a temporary solution. Fixing it in nux will enable
us to depend on system setup and such. For now, the faked double-click time is
500ms.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/PanelMenuView.cpp'
--- src/PanelMenuView.cpp 2011-01-25 15:35:00 +0000
+++ src/PanelMenuView.cpp 2011-01-26 14:21:33 +0000
@@ -78,6 +78,7 @@
7878
79 _panel_titlebar_grab_area = new PanelTitlebarGrabArea ();79 _panel_titlebar_grab_area = new PanelTitlebarGrabArea ();
80 _panel_titlebar_grab_area->mouse_down.connect (sigc::mem_fun (this, &PanelMenuView::OnMaximizedGrab));80 _panel_titlebar_grab_area->mouse_down.connect (sigc::mem_fun (this, &PanelMenuView::OnMaximizedGrab));
81 _panel_titlebar_grab_area->mouse_doubleclick.connect (sigc::mem_fun (this, &PanelMenuView::OnRestoreClicked));
8182
82 win_manager = WindowManager::Default ();83 win_manager = WindowManager::Default ();
8384
8485
=== modified file 'src/PanelTitlebarGrabAreaView.cpp'
--- src/PanelTitlebarGrabAreaView.cpp 2010-12-30 15:57:11 +0000
+++ src/PanelTitlebarGrabAreaView.cpp 2011-01-26 14:21:33 +0000
@@ -15,6 +15,7 @@
15 *15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
18 * Authored by: Didier Roche <didier.roche@canonical.com>
18 */19 */
1920
20#include "Nux/Nux.h"21#include "Nux/Nux.h"
@@ -30,6 +31,8 @@
3031
31#include <glib.h>32#include <glib.h>
3233
34#define DELTA_MOUSE_DOUBLE_CLICK 500000000
35
33enum36enum
34{37{
35 BUTTON_CLOSE=0,38 BUTTON_CLOSE=0,
@@ -40,7 +43,16 @@
4043
41PanelTitlebarGrabArea::PanelTitlebarGrabArea ()44PanelTitlebarGrabArea::PanelTitlebarGrabArea ()
42: InputArea (NUX_TRACKER_LOCATION)45: InputArea (NUX_TRACKER_LOCATION)
43{46{
47 // FIXME: the two following functions should be used instead of the insane trick with fixed value. But nux is broken
48 // right now and we need jay to focus on other things
49 /*InputArea::EnableDoubleClick (true);
50 InputArea::OnMouseDoubleClick.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseDoubleClick));*/
51 InputArea::OnMouseClick.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseClick));
52 _last_click_time.tv_sec = 0;
53 _last_click_time.tv_nsec = 0;
54
55 // connect the *Click events before the *Down ones otherwise, weird race happens
44 InputArea::OnMouseDown.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseDown));56 InputArea::OnMouseDown.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseDown));
45}57}
4658
@@ -49,6 +61,43 @@
49{61{
50}62}
5163
64void PanelTitlebarGrabArea::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
65{
66 mouse_down.emit (x, y);
67}
68
69void PanelTitlebarGrabArea::RecvMouseDoubleClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
70{
71 mouse_doubleclick.emit ();
72}
73
74// TODO: can be safely removed once OnMouseDoubleClick is fixed in nux
75void PanelTitlebarGrabArea::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
76{
77 struct timespec event_time, delta;
78 clock_gettime(CLOCK_MONOTONIC, &event_time);
79 delta = time_diff (_last_click_time, event_time);
80
81 if ((delta.tv_sec == 0) && (delta.tv_nsec < DELTA_MOUSE_DOUBLE_CLICK))
82 RecvMouseDoubleClick (x, y, button_flags, key_flags);
83
84 _last_click_time.tv_sec = event_time.tv_sec;
85 _last_click_time.tv_nsec = event_time.tv_nsec;
86}
87
88struct timespec PanelTitlebarGrabArea::time_diff (struct timespec start, struct timespec end)
89{
90 struct timespec temp;
91 if ((end.tv_nsec - start.tv_nsec) < 0) {
92 temp.tv_sec = end.tv_sec - start.tv_sec-1;
93 temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
94 } else {
95 temp.tv_sec = end.tv_sec - start.tv_sec;
96 temp.tv_nsec = end.tv_nsec - start.tv_nsec;
97 }
98 return temp;
99}
100
52const gchar *101const gchar *
53PanelTitlebarGrabArea::GetName ()102PanelTitlebarGrabArea::GetName ()
54{103{
@@ -72,10 +121,3 @@
72 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));121 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
73 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));122 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
74}123}
75
76void PanelTitlebarGrabArea::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
77{
78 mouse_down.emit (x, y);
79}
80
81
82124
=== modified file 'src/PanelTitlebarGrabAreaView.h'
--- src/PanelTitlebarGrabAreaView.h 2010-12-30 15:57:11 +0000
+++ src/PanelTitlebarGrabAreaView.h 2011-01-26 14:21:33 +0000
@@ -15,11 +15,16 @@
15 *15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
18 * Authored by: Didier Roche <didier.roche@canonical.com>
18 */19 */
1920
20#ifndef PANEL_TITLEBAR_GRAB_AREA_H21#ifndef PANEL_TITLEBAR_GRAB_AREA_H
21#define PANEL_TITLEBAR_GRAB_AREA_H_H22#define PANEL_TITLEBAR_GRAB_AREA_H_H
2223
24
25// TODO: remove once double click will work in nux
26#include <time.h>
27
23#include <Nux/View.h>28#include <Nux/View.h>
2429
25#include "Introspectable.h"30#include "Introspectable.h"
@@ -34,13 +39,20 @@
34 ~PanelTitlebarGrabArea ();39 ~PanelTitlebarGrabArea ();
3540
36 sigc::signal <void, int, int> mouse_down;41 sigc::signal <void, int, int> mouse_down;
42 sigc::signal <void> mouse_doubleclick;
3743
38protected:44protected:
45 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
46 void RecvMouseDoubleClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
47 // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux
48 void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
49 struct timespec time_diff (struct timespec start, struct timespec end);
50
51 struct timespec _last_click_time;
52
39 const gchar * GetName ();53 const gchar * GetName ();
40 const gchar * GetChildsName ();54 const gchar * GetChildsName ();
41 void AddProperties (GVariantBuilder *builder);55 void AddProperties (GVariantBuilder *builder);
42
43 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
44};56};
4557
46#endif58#endif