summaryrefslogtreecommitdiff
path: root/src
diff options
authorDidier Roche <didier.roche@canonical.com>2011-01-28 17:38:00 +0100
committerDidier Roche <didier.roche@canonical.com>2011-01-28 17:38:00 +0100
commit27a5c813c184ee469c1a1041ed1883793a366d35 (patch)
treeb22ab5725ae902875394a339ff8b3def39e10ba4 /src
parent44c30627949a92ca283aeae6b7dad549ac0c279b (diff)
parent538aed496477aee2e3be872fac8a915478c23194 (diff)
Enable dragging the LauncherIcon only in the same area and between the same Launcher types. Also, only drag on left click (LP: #709179, 709119)
(bzr r800)
Diffstat (limited to 'src')
-rw-r--r--src/Launcher.cpp7
-rw-r--r--src/Launcher.h1
-rw-r--r--src/LauncherModel.cpp28
-rw-r--r--src/LauncherModel.h2
4 files changed, 37 insertions, 1 deletions
diff --git a/src/Launcher.cpp b/src/Launcher.cpp
index 165c1d517..b31e384fc 100644
--- a/src/Launcher.cpp
+++ b/src/Launcher.cpp
@@ -281,6 +281,7 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE
_window_over_launcher = false;
_render_drag_window = false;
_backlight_always_on = false;
+ _last_button_press = 0;
// 0 out timers to avoid wonky startups
@@ -1825,6 +1826,7 @@ void Launcher::UpdateDragWindowPosition (int x, int y)
void Launcher::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
+ _last_button_press = nux::GetEventButton (button_flags);
SetMousePosition (x, y);
MouseDownLogic (x, y, button_flags, key_flags);
@@ -1850,6 +1852,7 @@ void Launcher::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned lo
_launcher_action_state = ACTION_NONE;
_dnd_delta_x = 0;
_dnd_delta_y = 0;
+ _last_button_press = 0;
EnsureHoverState ();
EnsureAnimation ();
}
@@ -1886,7 +1889,9 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_
{
LauncherIcon *drag_icon = MouseIconIntersection ((int) (GetGeometry ().x / 2.0f), y);
- if (drag_icon)
+ // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying
+ // on an internal Launcher property then
+ if (drag_icon && (_last_button_press == 1) && _model->IconHasSister (drag_icon))
{
StartIconDrag (drag_icon);
_launcher_action_state = ACTION_DRAG_ICON;
diff --git a/src/Launcher.h b/src/Launcher.h
index 12f3a64f6..6663fa6a8 100644
--- a/src/Launcher.h
+++ b/src/Launcher.h
@@ -304,6 +304,7 @@ private:
int _launcher_drag_delta;
int _dnd_security;
int _enter_y;
+ int _last_button_press;
nux::BaseTexture* _icon_bkg_texture;
nux::BaseTexture* _icon_shine_texture;
diff --git a/src/LauncherModel.cpp b/src/LauncherModel.cpp
index 834a6e12e..6bb7676d9 100644
--- a/src/LauncherModel.cpp
+++ b/src/LauncherModel.cpp
@@ -119,6 +119,34 @@ LauncherModel::Sort (SortFunc func)
order_changed.emit ();
}
+bool
+LauncherModel::IconHasSister (LauncherIcon *icon)
+{
+ iterator (LauncherModel::*begin_it)(void);
+ iterator (LauncherModel::*end_it)(void);
+ iterator it;
+
+ if (IconShouldShelf (icon))
+ {
+ begin_it = &LauncherModel::shelf_begin;
+ end_it = &LauncherModel::shelf_end;
+ }
+ else
+ {
+ begin_it = &LauncherModel::main_begin;
+ end_it = &LauncherModel::main_end;
+ }
+
+ for (it = (this->*begin_it) (); it != (this->*end_it) (); it++)
+ {
+ if ((*it != icon)
+ && (*it)->Type () == icon->Type ())
+ return true;
+ }
+
+ return false;
+}
+
int
LauncherModel::Size ()
{
diff --git a/src/LauncherModel.h b/src/LauncherModel.h
index a63138e73..4a06b8c5e 100644
--- a/src/LauncherModel.h
+++ b/src/LauncherModel.h
@@ -43,6 +43,8 @@ public:
void OnIconRemove (LauncherIcon *icon);
+ bool IconHasSister (LauncherIcon *icon);
+
iterator begin ();
iterator end ();
reverse_iterator rbegin ();