From d0769b125519a5ca935fe663a5b685b68f842378 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 28 Jan 2011 11:30:40 +0100 Subject: don't initiate dragging on special icons as you can't reorganize them (LP: #709119) Fixes LP: #709119 (bzr r798.2.1) --- src/Launcher.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Launcher.cpp b/src/Launcher.cpp index 165c1d517..8e0f82646 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -1886,7 +1886,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) + if (drag_icon + && (drag_icon->Type () == LauncherIcon::TYPE_FAVORITE + || drag_icon->Type () == LauncherIcon::TYPE_APPLICATION)) { StartIconDrag (drag_icon); _launcher_action_state = ACTION_DRAG_ICON; -- cgit v1.2.3 From 8c7a5092f1e94e1078495abf1cca477fc6e8ac01 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 28 Jan 2011 14:11:23 +0100 Subject: Drag only autorized launcher and do it only if Left click is used. (LP: #709179, #709119) (bzr r798.2.2) --- src/Launcher.cpp | 11 ++++++++--- src/LauncherIcon.cpp | 21 ++++++++++++++++++++- src/LauncherIcon.h | 4 ++++ 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Launcher.cpp b/src/Launcher.cpp index 8e0f82646..cc5b11404 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -1886,9 +1886,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 - && (drag_icon->Type () == LauncherIcon::TYPE_FAVORITE - || drag_icon->Type () == LauncherIcon::TYPE_APPLICATION)) + // nux doesn't give nux::GetEventButton (button_flags) there, relying + // on an internal LauncherIcon property then + if (drag_icon && drag_icon->Draggable () && drag_icon->ReadyToDrag ()) { StartIconDrag (drag_icon); _launcher_action_state = ACTION_DRAG_ICON; @@ -2034,6 +2034,11 @@ void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned { SetTimeStruct (&_drag_end_time); } + + if (_icon_mouse_down && _launcher_action_state == ACTION_DRAG_ICON) + { + _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags)); + } _icon_mouse_down = 0; } diff --git a/src/LauncherIcon.cpp b/src/LauncherIcon.cpp index bb85dc6d0..1510d8ec5 100644 --- a/src/LauncherIcon.cpp +++ b/src/LauncherIcon.cpp @@ -69,6 +69,7 @@ LauncherIcon::LauncherIcon(Launcher* launcher) _tooltip = new nux::Tooltip (); _icon_type = TYPE_NONE; _sort_priority = 0; + _ready_to_drag = false; _quicklist = new QuicklistView (); _quicklist_is_initialized = false; @@ -327,7 +328,11 @@ void LauncherIcon::RecvMouseLeave () void LauncherIcon::RecvMouseDown (int button) { - if (button == 3) + if (button == 1) + { + _ready_to_drag = true; + } + else if (button == 3) { _tooltip->ShowWindow (false); @@ -381,6 +386,7 @@ void LauncherIcon::RecvMouseUp (int button) if (_quicklist->IsVisible ()) _quicklist->CaptureMouseDownAnyWhereElse (true); } + _ready_to_drag = false; } void LauncherIcon::HideTooltip () @@ -619,6 +625,19 @@ LauncherIcon::GetProgress () return _progress; } +bool +LauncherIcon::ReadyToDrag () +{ + return _ready_to_drag; +} + +bool +LauncherIcon::Draggable () +{ + return _icon_type == LauncherIcon::TYPE_FAVORITE + || _icon_type == LauncherIcon::TYPE_APPLICATION; +} + std::list LauncherIcon::Menus () { return GetMenus (); diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h index 0708fd62a..a8246d84a 100644 --- a/src/LauncherIcon.h +++ b/src/LauncherIcon.h @@ -104,6 +104,9 @@ public: float GetProgress (); + bool ReadyToDrag (); + bool Draggable (); + bool GetQuirk (Quirk quirk); struct timespec GetQuirkTime (Quirk quirk); @@ -201,6 +204,7 @@ private: guint _center_stabilize_handle; bool _quicklist_is_initialized; bool _has_visible_window; + bool _ready_to_drag; nux::Point3 _center; nux::Point3 _last_stable; -- cgit v1.2.3 From ce639078a0cca915dd78b12bdefd86ff01119439 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 28 Jan 2011 16:20:23 +0100 Subject: fix left click only in Launcher class only (bzr r798.2.3) --- src/Launcher.cpp | 14 ++++++-------- src/Launcher.h | 1 + src/LauncherIcon.cpp | 21 +-------------------- src/LauncherIcon.h | 4 ---- 4 files changed, 8 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Launcher.cpp b/src/Launcher.cpp index cc5b11404..b1ff6fb2b 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,9 +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); - // nux doesn't give nux::GetEventButton (button_flags) there, relying - // on an internal LauncherIcon property then - if (drag_icon && drag_icon->Draggable () && drag_icon->ReadyToDrag ()) + // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying + // on an internal Launcher property then + if (drag_icon && (_last_button_press == 1)) { StartIconDrag (drag_icon); _launcher_action_state = ACTION_DRAG_ICON; @@ -2034,11 +2037,6 @@ void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned { SetTimeStruct (&_drag_end_time); } - - if (_icon_mouse_down && _launcher_action_state == ACTION_DRAG_ICON) - { - _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags)); - } _icon_mouse_down = 0; } 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/LauncherIcon.cpp b/src/LauncherIcon.cpp index 1510d8ec5..bb85dc6d0 100644 --- a/src/LauncherIcon.cpp +++ b/src/LauncherIcon.cpp @@ -69,7 +69,6 @@ LauncherIcon::LauncherIcon(Launcher* launcher) _tooltip = new nux::Tooltip (); _icon_type = TYPE_NONE; _sort_priority = 0; - _ready_to_drag = false; _quicklist = new QuicklistView (); _quicklist_is_initialized = false; @@ -328,11 +327,7 @@ void LauncherIcon::RecvMouseLeave () void LauncherIcon::RecvMouseDown (int button) { - if (button == 1) - { - _ready_to_drag = true; - } - else if (button == 3) + if (button == 3) { _tooltip->ShowWindow (false); @@ -386,7 +381,6 @@ void LauncherIcon::RecvMouseUp (int button) if (_quicklist->IsVisible ()) _quicklist->CaptureMouseDownAnyWhereElse (true); } - _ready_to_drag = false; } void LauncherIcon::HideTooltip () @@ -625,19 +619,6 @@ LauncherIcon::GetProgress () return _progress; } -bool -LauncherIcon::ReadyToDrag () -{ - return _ready_to_drag; -} - -bool -LauncherIcon::Draggable () -{ - return _icon_type == LauncherIcon::TYPE_FAVORITE - || _icon_type == LauncherIcon::TYPE_APPLICATION; -} - std::list LauncherIcon::Menus () { return GetMenus (); diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h index a8246d84a..0708fd62a 100644 --- a/src/LauncherIcon.h +++ b/src/LauncherIcon.h @@ -104,9 +104,6 @@ public: float GetProgress (); - bool ReadyToDrag (); - bool Draggable (); - bool GetQuirk (Quirk quirk); struct timespec GetQuirkTime (Quirk quirk); @@ -204,7 +201,6 @@ private: guint _center_stabilize_handle; bool _quicklist_is_initialized; bool _has_visible_window; - bool _ready_to_drag; nux::Point3 _center; nux::Point3 _last_stable; -- cgit v1.2.3 From 72fe82abd0f38b165deb1ffd07b8bed0788296cd Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 28 Jan 2011 16:41:25 +0100 Subject: only enable drag if other launcher with the same type (bzr r798.2.4) --- src/Launcher.cpp | 2 +- src/LauncherModel.cpp | 15 +++++++++++++++ src/LauncherModel.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Launcher.cpp b/src/Launcher.cpp index b1ff6fb2b..b31e384fc 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -1891,7 +1891,7 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_ // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying // on an internal Launcher property then - if (drag_icon && (_last_button_press == 1)) + if (drag_icon && (_last_button_press == 1) && _model->IconHasSister (drag_icon)) { StartIconDrag (drag_icon); _launcher_action_state = ACTION_DRAG_ICON; diff --git a/src/LauncherModel.cpp b/src/LauncherModel.cpp index 834a6e12e..cf888bd96 100644 --- a/src/LauncherModel.cpp +++ b/src/LauncherModel.cpp @@ -119,6 +119,21 @@ LauncherModel::Sort (SortFunc func) order_changed.emit (); } +bool +LauncherModel::IconHasSister (LauncherIcon *icon) +{ + iterator it; + + for (it = begin (); it != end (); 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 (); -- cgit v1.2.3 From 538aed496477aee2e3be872fac8a915478c23194 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 28 Jan 2011 17:14:16 +0100 Subject: considering that the shelf can have the same LauncherIcon type that the main area (bzr r798.2.5) --- src/LauncherModel.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/LauncherModel.cpp b/src/LauncherModel.cpp index cf888bd96..6bb7676d9 100644 --- a/src/LauncherModel.cpp +++ b/src/LauncherModel.cpp @@ -122,9 +122,22 @@ LauncherModel::Sort (SortFunc func) bool LauncherModel::IconHasSister (LauncherIcon *icon) { + iterator (LauncherModel::*begin_it)(void); + iterator (LauncherModel::*end_it)(void); iterator it; - for (it = begin (); it != end (); 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 ()) -- cgit v1.2.3