diff options
| author | Didier Roche <didier.roche@canonical.com> | 2011-03-07 18:40:13 +0100 |
|---|---|---|
| committer | Didier Roche <didier.roche@canonical.com> | 2011-03-07 18:40:13 +0100 |
| commit | 548500899177ebab1d934c98eb3a1e0bc3758961 (patch) | |
| tree | d942a7c9643737cf2aca6246fb645a37296f46b7 | |
| parent | eeb51d47a3a9b5e91bdf42ef866bf5a3183ea32f (diff) | |
| parent | a470a747c8a19b17249be48fc1cb9a8a4e5bb1aa (diff) | |
Import upstream version 3.6.2upstream-3.6.2
(bzr r55.4.46)
33 files changed, 556 insertions, 219 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 72d1780e7..443ed4ecd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ subdirs (services tests tools doc) set (PROJECT_NAME "unity") set (UNITY_MAJOR 3) set (UNITY_MINOR 6) -set (UNITY_MICRO 0) +set (UNITY_MICRO 2) set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}") set (UNITY_API_VERSION "3.0") diff --git a/com.canonical.Unity.gschema.xml b/com.canonical.Unity.gschema.xml index cdd04ace3..e165b3965 100644 --- a/com.canonical.Unity.gschema.xml +++ b/com.canonical.Unity.gschema.xml @@ -14,7 +14,7 @@ </schema> <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> <key type="as" name="favorites"> - <default>[ 'ubiquity-gtkui.desktop', 'nautilus.desktop', 'firefox.desktop', 'ubuntuone-control-panel-gtk.desktop', 'tomboy.desktop' ]</default> + <default>[ 'ubiquity-gtkui.desktop', 'nautilus-home.desktop', 'firefox.desktop', 'ubuntuone-control-panel-gtk.desktop', 'tomboy.desktop' ]</default> <summary>List of desktop file ids for favorites on the launcher.</summary> <description>These applications are shown in the Launcher by default.</description> </key> diff --git a/src/DeviceLauncherIcon.cpp b/src/DeviceLauncherIcon.cpp index 13e4b154b..f95863d8c 100644 --- a/src/DeviceLauncherIcon.cpp +++ b/src/DeviceLauncherIcon.cpp @@ -104,6 +104,7 @@ DeviceLauncherIcon::GetMenus () { std::list<DbusmenuMenuitem *> result; DbusmenuMenuitem *menu_item; + GDrive *drive; menu_item = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Open")); @@ -124,6 +125,19 @@ DeviceLauncherIcon::GetMenus () result.push_back (menu_item); } + drive = g_volume_get_drive (_volume); + if (drive && g_drive_can_stop (drive)) + { + menu_item = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Safely Remove")); + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); + g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (&DeviceLauncherIcon::OnDriveStop), this); + result.push_back (menu_item); + g_object_unref (drive); + } + return result; } @@ -233,14 +247,18 @@ DeviceLauncherIcon::OnEjectReady (GObject *object, void DeviceLauncherIcon::Eject () { - g_debug ("%s", G_STRLOC); + GMountOperation *mount_op; + + mount_op = gtk_mount_operation_new(NULL); + g_volume_eject_with_operation (_volume, (GMountUnmountFlags)0, - NULL, + mount_op, NULL, (GAsyncReadyCallback)OnEjectReady, this); - g_debug ("%s", G_STRLOC); + + g_object_unref(mount_op); } void @@ -252,9 +270,7 @@ DeviceLauncherIcon::OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon void DeviceLauncherIcon::OnEject (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self) { - g_debug ("%s", G_STRLOC); self->Eject (); - g_debug ("%s", G_STRLOC); } void @@ -262,3 +278,36 @@ DeviceLauncherIcon::OnRemoved (GVolume *volume, DeviceLauncherIcon *self) { self->Remove (); } + +void +DeviceLauncherIcon::OnDriveStop (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self) +{ + self->StopDrive (); +} + +void +DeviceLauncherIcon::StopDrive () +{ + GDrive *drive; + + drive = g_volume_get_drive (_volume); + g_drive_stop (drive, + (GMountUnmountFlags)0, + NULL, + NULL, + (GAsyncReadyCallback)OnStopDriveReady, + this); + g_object_unref (drive); +} + +void +DeviceLauncherIcon::OnStopDriveReady (GObject *object, + GAsyncResult *result, + DeviceLauncherIcon *self) +{ + GDrive *drive; + + drive = g_volume_get_drive (self->_volume); + g_drive_stop_finish (drive, result, NULL); + g_object_unref (drive); +} diff --git a/src/DeviceLauncherIcon.h b/src/DeviceLauncherIcon.h index d966699a3..ae31943d0 100644 --- a/src/DeviceLauncherIcon.h +++ b/src/DeviceLauncherIcon.h @@ -43,11 +43,14 @@ private: void ActivateLauncherIcon (); void ShowMount (GMount *mount); void Eject (); + void StopDrive (); static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); static void OnEject (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); static void OnRemoved (GVolume *volume, DeviceLauncherIcon *self); static void OnMountReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); static void OnEjectReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); + static void OnDriveStop (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); + static void OnStopDriveReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); private: GVolume *_volume; diff --git a/src/Launcher.cpp b/src/Launcher.cpp index cc78fe927..dec84f8c5 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -304,6 +304,8 @@ Launcher::Launcher (nux::BaseWindow* parent, _autoscroll_handle = 0; _redraw_handle = 0; _focus_keynav_handle = 0; + _single_finger_hold_handle = 0; + _single_finger_hold_timer = NULL; _floating = false; _hovered = false; _hidden = false; @@ -321,7 +323,7 @@ Launcher::Launcher (nux::BaseWindow* parent, _backlight_mode = BACKLIGHT_NORMAL; _last_button_press = 0; _selection_atom = 0; - + // set them to 1 instead of 0 to avoid :0 in case something is racy _trigger_width = 1; _trigger_height = 1; @@ -1348,6 +1350,8 @@ gboolean Launcher::TapOnSuper () void Launcher::StartKeyShowLauncher () { + bool was_hidden = _hidden; + _super_show_launcher = true; QueueDraw (); SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION); @@ -1355,6 +1359,10 @@ void Launcher::StartKeyShowLauncher () g_source_remove (_redraw_handle); _redraw_handle = g_timeout_add (SUPER_TAP_DURATION, &Launcher::DrawLauncherTimeout, this); EnsureHiddenState (); + + // don't lock on mouseover state to avoid locking it the pointer was already there but not moved + if (was_hidden) + _mouseover_launcher_locked = false; } void Launcher::EndKeyShowLauncher () @@ -1434,7 +1442,7 @@ void Launcher::SetHidden (bool hidden) { if (hidden == _hidden) return; - + // auto lock/unlock the launcher depending on the state switch if (hidden) { @@ -1467,6 +1475,31 @@ gboolean Launcher::OnAutohideTimeout (gpointer data) return false; } +int +Launcher::GetMouseX () +{ + return _mouse_position.x; +} + +int +Launcher::GetMouseY () +{ + return _mouse_position.y; +} + +gboolean +Launcher::SingleFingerHoldTimeout (gpointer data) +{ + Launcher* self = (Launcher*) data; + + LauncherIcon* launcher_icon = 0; + launcher_icon = self->MouseIconIntersection (self->GetMouseX (), + self->GetMouseY ()); + launcher_icon->OpenQuicklist (); + + return false; +} + gboolean Launcher::DrawLauncherTimeout (gpointer data) { Launcher *self = (Launcher*) data; @@ -1507,7 +1540,7 @@ Launcher::CheckIntersectWindow (CompWindow *window) if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ()) return false; - if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height))) + if (CompRegion (window->serverInputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height))) return true; return false; @@ -2651,16 +2684,34 @@ void Launcher::RecvMouseWheel(int x, int y, int wheel_delta, unsigned long butto EnsureAnimation (); } -void +gboolean Launcher::CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state) { - if (_super_show_launcher) + if (!_super_show_launcher) + return false; + + LauncherModel::iterator it; + int i; + + // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier + for (it = _model->begin (), i = 0; it != _model->end (); it++, i++) { - RecvKeyPressed (key_sym, key_code, key_state); - QueueDraw (); + if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code) + { + if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask)) + (*it)->OpenInstance (); + else + (*it)->Activate (); + // disable the "tap on super" check + _times[TIME_TAP_SUPER].tv_sec = 0; + _times[TIME_TAP_SUPER].tv_nsec = 0; + return true; + } } + + return false; } void @@ -2688,7 +2739,7 @@ Launcher::RecvKeyPressed (unsigned int key_sym, // down (move selection down and unfold launcher if needed) case NUX_VK_DOWN: - if (_current_icon_index < _model->Size ()) + if (_current_icon_index < _model->Size () - 1) { _current_icon_index++; NeedRedraw (); @@ -2749,26 +2800,7 @@ Launcher::RecvKeyPressed (unsigned int key_sym, leaveKeyNavMode (false); break; - // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier default: - { - if (_super_show_launcher && !TapOnSuper ()) - { - int i; - for (it = _model->begin (), i = 0; it != _model->end (); it++, i++) - { - if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code) - { - if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask)) - (*it)->OpenInstance (); - else - (*it)->Activate (); - } - } - } - - - } break; } } @@ -2796,9 +2828,16 @@ void Launcher::EventLogic () return; LauncherIcon* launcher_icon = 0; + bool should_lock_launcher = false; - if (_mouse_inside_launcher) + if (_mouse_inside_launcher) { launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); + // indicate if the mouse should relock the launcher or not (it doesn't explicitely lock the launcher + // when it's entering the launcher. This is for the case: Super reveals the launcher, mouse doesn't move) + if (_icon_under_mouse && !_hidden) + should_lock_launcher = true; + } + if (_icon_under_mouse && (_icon_under_mouse != launcher_icon)) { @@ -2812,8 +2851,8 @@ void Launcher::EventLogic () launcher_icon->MouseEnter.emit (); launcher_icon->_mouse_inside = true; _icon_under_mouse = launcher_icon; - // reset trigger has the mouse moved to another item (only if the launcher is supposed to be seen) - if (!_hidden) + // reset trigger only when in right context + if (should_lock_launcher) _mouseover_launcher_locked = true; } } @@ -2823,6 +2862,18 @@ void Launcher::MouseDownLogic (int x, int y, unsigned long button_flags, unsigne LauncherIcon* launcher_icon = 0; launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); + // this takes care of the one-finger-hold "event" on a launcher-icon + if (_single_finger_hold_handle == 0) + { + _single_finger_hold_handle = g_timeout_add (SINGLE_FINGER_HOLD_DURATION, + &Launcher::SingleFingerHoldTimeout, + this); + if (_single_finger_hold_timer) + g_timer_destroy (_single_finger_hold_timer); + + _single_finger_hold_timer = g_timer_new (); + } + if (launcher_icon) { _icon_mouse_down = launcher_icon; @@ -2835,6 +2886,51 @@ void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned LauncherIcon* launcher_icon = 0; launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y); + // this takes care of the one-finger-hold "event" on a launcher-icon + if (_single_finger_hold_timer) + { + // user "released" before single-finger-hold threshold + if (g_timer_elapsed (_single_finger_hold_timer, NULL) < (float) SINGLE_FINGER_HOLD_DURATION / 1000.0) + { + + // remove callback + if (_single_finger_hold_handle > 0) + { + g_source_remove (_single_finger_hold_handle); + _single_finger_hold_handle = 0; + } + } + // user "released" after single-finger-hold threshold... + else + { + // remove timer + g_timer_destroy (_single_finger_hold_timer); + _single_finger_hold_timer = NULL; + + // remove callback + if (_single_finger_hold_handle > 0) + { + g_source_remove (_single_finger_hold_handle); + _single_finger_hold_handle = 0; + } + + // ... don't start app, just return + _icon_mouse_down = 0; + return; + } + + // remove timer + g_timer_destroy (_single_finger_hold_timer); + _single_finger_hold_timer = NULL; + + // remove callback + if (_single_finger_hold_handle > 0) + { + g_source_remove (_single_finger_hold_handle); + _single_finger_hold_handle = 0; + } + } + if (_icon_mouse_down && (_icon_mouse_down == launcher_icon)) { _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags)); diff --git a/src/Launcher.h b/src/Launcher.h index b8e9aeed1..758370162 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -39,6 +39,7 @@ #define ANIM_DURATION_LONG 350 #define SUPER_TAP_DURATION 250 +#define SINGLE_FINGER_HOLD_DURATION 1000 #define MAX_SUPERKEY_LABELS 10 @@ -127,7 +128,7 @@ public: void SetAutoHideAnimation (AutoHideAnimation animation); AutoHideAnimation GetAutoHideAnimation (); - void CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state); + gboolean CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state); nux::BaseWindow* GetParent () { return _parent; }; @@ -151,6 +152,8 @@ public: void exitKeyNavMode (); // Connected to signal OnEndFocus + int GetMouseX (); + int GetMouseY (); sigc::signal<void, char *, LauncherIcon *> launcher_dropped; sigc::signal<void> selection_change; @@ -220,7 +223,8 @@ private: static gboolean DrawLauncherTimeout (gpointer data); static gboolean StrutHack (gpointer data); static gboolean MoveFocusToKeyNavModeTimeout (gpointer data); - + static gboolean SingleFingerHoldTimeout (gpointer data); + void SetMousePosition (int x, int y); bool MouseBeyondDragThreshold (); @@ -457,6 +461,8 @@ private: guint _autoscroll_handle; guint _focus_keynav_handle; guint _redraw_handle; + guint _single_finger_hold_handle; + GTimer* _single_finger_hold_timer; nux::Point2 _mouse_position; nux::Point2 _trigger_mouse_position; diff --git a/src/PanelHomeButton.cpp b/src/PanelHomeButton.cpp index 38c39f11b..2a9d27d09 100644 --- a/src/PanelHomeButton.cpp +++ b/src/PanelHomeButton.cpp @@ -61,6 +61,20 @@ PanelHomeButton::~PanelHomeButton () } void +PanelHomeButton::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) +{ + nux::Geometry geo = GetGeometry (); + + GfxContext.PushClippingRectangle (geo); + + nux::GetPainter ().PaintBackground (GfxContext, geo); + + nux::TextureArea::Draw (GfxContext, force_draw); + + GfxContext.PopClippingRectangle (); +} + +void PanelHomeButton::Refresh () { int width = BUTTON_WIDTH; diff --git a/src/PanelHomeButton.h b/src/PanelHomeButton.h index ed0044f91..aaacc112c 100644 --- a/src/PanelHomeButton.h +++ b/src/PanelHomeButton.h @@ -34,12 +34,11 @@ public: PanelHomeButton (); ~PanelHomeButton (); - void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags); - - void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags); + void Draw (nux::GraphicsEngine& GfxContext, bool force_draw); + void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags); + void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags); void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags); - void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); protected: diff --git a/src/PanelMenuView.cpp b/src/PanelMenuView.cpp index 5b3064eb7..85f7c469e 100644 --- a/src/PanelMenuView.cpp +++ b/src/PanelMenuView.cpp @@ -59,7 +59,9 @@ PanelMenuView::PanelMenuView (int padding) _is_inside (false), _is_maximized (false), _is_own_window (false), - _last_active_view (NULL) + _last_active_view (NULL), + _last_width (0), + _last_height (0) { WindowManager *win_manager; @@ -201,8 +203,6 @@ long PanelMenuView::PostLayoutManagement (long LayoutResult) _panel_titlebar_grab_area->SetGeometry (geo.x, geo.y, geo.width, geo.height); - Refresh (); - if (_is_inside) NeedRedraw (); @@ -216,6 +216,13 @@ PanelMenuView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) int button_width = _padding + _window_buttons->GetContentWidth () + _padding; float factor = 4; button_width /= factor; + + if (geo.width != _last_width || geo.height != _last_height) + { + _last_width = geo.width; + _last_height = geo.height; + Refresh (); + } GfxContext.PushClippingRectangle (geo); diff --git a/src/PanelMenuView.h b/src/PanelMenuView.h index 9e243c3f5..e262954fa 100644 --- a/src/PanelMenuView.h +++ b/src/PanelMenuView.h @@ -116,5 +116,8 @@ private: int _padding; gpointer _name_changed_callback_instance; gulong _name_changed_callback_id; + + int _last_width; + int _last_height; }; #endif diff --git a/src/PanelTitlebarGrabAreaView.cpp b/src/PanelTitlebarGrabAreaView.cpp index ea160c777..581106111 100644 --- a/src/PanelTitlebarGrabAreaView.cpp +++ b/src/PanelTitlebarGrabAreaView.cpp @@ -48,7 +48,7 @@ PanelTitlebarGrabArea::PanelTitlebarGrabArea () // right now and we need jay to focus on other things /*InputArea::EnableDoubleClick (true); InputArea::OnMouseDoubleClick.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseDoubleClick));*/ - InputArea::OnMouseClick.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseClick)); + InputArea::OnMouseUp.connect (sigc::mem_fun (this, &PanelTitlebarGrabArea::RecvMouseUp)); _last_click_time.tv_sec = 0; _last_click_time.tv_nsec = 0; @@ -78,7 +78,7 @@ void PanelTitlebarGrabArea::RecvMouseDoubleClick (int x, int y, unsigned long bu } // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux -void PanelTitlebarGrabArea::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags) +void PanelTitlebarGrabArea::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags) { struct timespec event_time, delta; clock_gettime(CLOCK_MONOTONIC, &event_time); diff --git a/src/PanelTitlebarGrabAreaView.h b/src/PanelTitlebarGrabAreaView.h index 9615571ba..4d3c62d98 100644 --- a/src/PanelTitlebarGrabAreaView.h +++ b/src/PanelTitlebarGrabAreaView.h @@ -46,7 +46,7 @@ protected: void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); void RecvMouseDoubleClick (int x, int y, unsigned long button_flags, unsigned long key_flags); // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux - void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags); + void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); struct timespec time_diff (struct timespec start, struct timespec end); struct timespec _last_click_time; diff --git a/src/PanelView.h b/src/PanelView.h index 3876c1140..6e3e84abc 100644 --- a/src/PanelView.h +++ b/src/PanelView.h @@ -40,12 +40,12 @@ public: PanelView (NUX_FILE_LINE_PROTO); ~PanelView (); - 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); + long ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo); + void Draw (nux::GraphicsEngine& GfxContext, bool force_draw); + void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw); - virtual void PreLayoutManagement (); - virtual long PostLayoutManagement (long LayoutResult); + void PreLayoutManagement (); + long PostLayoutManagement (long LayoutResult); void OnObjectAdded (IndicatorObjectProxy *proxy); void OnMenuPointerMoved (int x, int y); diff --git a/src/PlaceEntry.h b/src/PlaceEntry.h index 73fc36691..886651c5f 100644 --- a/src/PlaceEntry.h +++ b/src/PlaceEntry.h @@ -116,6 +116,9 @@ public: virtual void ForeachGlobalGroup (GroupForeachCallback slot) = 0; virtual void ForeachGlobalResult (ResultForeachCallback slot) = 0; + virtual void GetResult (const void *id, ResultForeachCallback slot) = 0; + virtual void GetGlobalResult (const void *id, ResultForeachCallback slot) = 0; + // Signals sigc::signal<void, bool> active_changed; diff --git a/src/PlaceEntryHome.cpp b/src/PlaceEntryHome.cpp index 39135a06e..e61dadb90 100644 --- a/src/PlaceEntryHome.cpp +++ b/src/PlaceEntryHome.cpp @@ -121,6 +121,8 @@ PlaceEntryHome::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceE { PlaceEntryGroupHome our_group (entry); + _id_to_entry[result.GetId ()] = entry; + result_added.emit (this, our_group, result); } @@ -130,6 +132,8 @@ PlaceEntryHome::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, Plac { PlaceEntryGroupHome our_group (entry); + _id_to_entry.erase (result.GetId ()); + result_removed (this, our_group, result); } @@ -247,4 +251,33 @@ PlaceEntryHome::ForeachGroup (GroupForeachCallback slot) void PlaceEntryHome::ForeachResult (ResultForeachCallback slot) { + std::vector<PlaceEntry *>::iterator it, eit = _entries.end (); + + _foreach_callback = slot; + + for (it = _entries.begin (); it != eit; ++it) + { + (*it)->ForeachGlobalResult (sigc::mem_fun (this, &PlaceEntryHome::OnForeachResult)); + } +} + +void +PlaceEntryHome::OnForeachResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result) +{ + PlaceEntryGroupHome our_group (entry); + + _foreach_callback (this, our_group, result); +} + +void +PlaceEntryHome::GetResult (const void *id, ResultForeachCallback slot) +{ + PlaceEntry *entry = _id_to_entry[id]; + + _foreach_callback = slot; + + if (entry) + { + entry->GetGlobalResult (id, sigc::mem_fun (this, &PlaceEntryHome::OnForeachResult)); + } } diff --git a/src/PlaceEntryHome.h b/src/PlaceEntryHome.h index 47dd1528b..0334f37a9 100644 --- a/src/PlaceEntryHome.h +++ b/src/PlaceEntryHome.h @@ -66,6 +66,9 @@ public: void ForeachGlobalGroup (GroupForeachCallback slot) { }; void ForeachGlobalResult (ResultForeachCallback slot) { }; + void GetResult (const void *id, ResultForeachCallback slot); + void GetGlobalResult (const void *id, ResultForeachCallback slot) {}; + private: void LoadExistingEntries (); void OnPlaceAdded (Place *place); @@ -74,13 +77,16 @@ private: void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); + void OnForeachResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); - // FIXME: I know this is horrible but I can't fix it this week, have a much better plan for next public: PlaceFactory *_factory; std::map<char *, gchar *> _hints; std::vector<PlaceEntry *> _entries; + std::map<const void *, PlaceEntry *> _id_to_entry; + + ResultForeachCallback _foreach_callback; }; #endif // PLACE_ENTRY_HOME_H diff --git a/src/PlaceEntryRemote.cpp b/src/PlaceEntryRemote.cpp index 45889189a..e986f0729 100644 --- a/src/PlaceEntryRemote.cpp +++ b/src/PlaceEntryRemote.cpp @@ -577,6 +577,56 @@ PlaceEntryRemote::ForeachGlobalResult (ResultForeachCallback slot) } } +void +PlaceEntryRemote::GetResult (const void *id, ResultForeachCallback slot) +{ + guint n_group; + DeeModelIter *iter = (DeeModelIter *)id; + DeeModelIter *group_iter; + + n_group = dee_model_get_uint32 (_results_model, iter, RESULT_GROUP_ID); + group_iter = dee_model_get_iter_at_row (_groups_model, n_group); + + if (!group_iter) + { + g_warning ("%s: Result %s does not have a valid group (%d). This is not a good thing.", + G_STRFUNC, + dee_model_get_string (_results_model, iter, RESULT_URI), + n_group); + return; + } + + PlaceEntryGroupRemote group (_groups_model, group_iter); + PlaceEntryResultRemote result (_results_model, iter); + + slot (this, group, result); +} + +void +PlaceEntryRemote::GetGlobalResult (const void *id, ResultForeachCallback slot) +{ + guint n_group; + DeeModelIter *iter = (DeeModelIter *)id; + DeeModelIter *group_iter; + + n_group = dee_model_get_uint32 (_global_results_model, iter, RESULT_GROUP_ID); + group_iter = dee_model_get_iter_at_row (_global_groups_model, n_group); + + if (!group_iter) + { + g_warning ("%s: Result %s does not have a valid group (%d). This is not a good thing.", + G_STRFUNC, + dee_model_get_string (_global_results_model, iter, RESULT_URI), + n_group); + return; + } + + PlaceEntryGroupRemote group (_global_groups_model, group_iter); + PlaceEntryResultRemote result (_global_results_model, iter); + + slot (this, group, result); +} + /* Other methods */ bool PlaceEntryRemote::IsValid () diff --git a/src/PlaceEntryRemote.h b/src/PlaceEntryRemote.h index 7ef418220..397c2b86b 100644 --- a/src/PlaceEntryRemote.h +++ b/src/PlaceEntryRemote.h @@ -70,6 +70,9 @@ public: void ForeachGlobalGroup (GroupForeachCallback slot); void ForeachGlobalResult (ResultForeachCallback slot); + void GetResult (const void *id, ResultForeachCallback slot); + void GetGlobalResult (const void *id, ResultForeachCallback slot); + /* Other methods */ bool IsValid (); const gchar * GetPath (); diff --git a/src/PlacesGroup.cpp b/src/PlacesGroup.cpp index 7b0fd7048..f90123297 100644 --- a/src/PlacesGroup.cpp +++ b/src/PlacesGroup.cpp @@ -54,8 +54,7 @@ PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL) _idle_id (0), _is_expanded (true), _n_visible_items_in_unexpand_mode (0), - _n_total_items (0), - _child_unexpand_height (0) + _n_total_items (0) { PlacesStyle *style = PlacesStyle::GetDefault (); nux::BaseTexture *arrow = style->GetGroupUnexpandIcon (); @@ -103,7 +102,8 @@ PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL) PlacesGroup::~PlacesGroup () { - + if (_idle_id) + g_source_remove (_idle_id); } void @@ -210,11 +210,7 @@ long PlacesGroup::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo) { long ret = TraverseInfo; - if (GetGeometry ().IsPointInside (ievent.e_x, ievent.e_y) - || !_child_unexpand_height) - { - ret = _group_layout->ProcessEvent (ievent, TraverseInfo, ProcessEventInfo); - } + ret = _group_layout->ProcessEvent (ievent, TraverseInfo, ProcessEventInfo); return ret; } @@ -243,22 +239,6 @@ PlacesGroup::SetCounts (guint n_visible_items_in_unexpand_mode, guint n_total_it Relayout (); } - -void -PlacesGroup::SetChildUnexpandHeight (guint height) -{ - if (_child_unexpand_height == height) - return; - - _child_unexpand_height = height; - - if (!_is_expanded) - { - _is_expanded = true; - SetExpanded (false); - } -} - bool PlacesGroup::GetExpanded () { @@ -277,23 +257,8 @@ PlacesGroup::SetExpanded (bool is_expanded) Refresh (); - if (_content_layout) - { - _content_layout->SetMaximumHeight (_is_expanded ? nux::AREA_MAX_HEIGHT : _child_unexpand_height); - SetMaximumHeight (_is_expanded ? nux::AREA_MAX_HEIGHT - : _header_layout->GetGeometry ().height + _child_unexpand_height); - - ComputeChildLayout (); - _group_layout->ComputeChildLayout (); - _content_layout->ComputeChildLayout (); - _content_layout->QueueDraw (); - _group_layout->QueueDraw (); - QueueDraw (); - } - _expand_icon->SetTexture (_is_expanded ? style->GetGroupUnexpandIcon () : style->GetGroupExpandIcon ()); - expanded.emit (); } diff --git a/src/PlacesGroup.h b/src/PlacesGroup.h index 5165c4fa6..b6782fa58 100644 --- a/src/PlacesGroup.h +++ b/src/PlacesGroup.h @@ -48,8 +48,6 @@ public: void SetCounts (guint n_visible_items_in_unexpand_mode, guint n_total_items); - void SetChildUnexpandHeight (guint height); - void SetExpanded (bool is_expanded); bool GetExpanded (); @@ -83,7 +81,6 @@ private: bool _is_expanded; guint _n_visible_items_in_unexpand_mode; guint _n_total_items; - guint _child_unexpand_height; }; #endif diff --git a/src/PlacesGroupController.cpp b/src/PlacesGroupController.cpp index c13edd37c..f1375beba 100644 --- a/src/PlacesGroupController.cpp +++ b/src/PlacesGroupController.cpp @@ -25,9 +25,10 @@ static const guint kPadding = 4; -PlacesGroupController::PlacesGroupController (PlaceEntryGroup& group) -: _group (NULL), - _load_icons_id (0) +PlacesGroupController::PlacesGroupController (PlaceEntry *entry, PlaceEntryGroup& group) +: _entry (entry), + _group (NULL), + _check_tiles_id (0) { PlacesStyle *style = PlacesStyle::GetDefault (); @@ -36,7 +37,6 @@ PlacesGroupController::PlacesGroupController (PlaceEntryGroup& group) _group = new PlacesGroup (NUX_TRACKER_LOCATION); _group->SetName(group.GetName ()); _group->SetIcon (group.GetIcon ()); - _group->SetChildUnexpandHeight (style->GetTileHeight () + kPadding * 3); nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION); layout->ForceChildrenSize (true); @@ -53,14 +53,14 @@ PlacesGroupController::PlacesGroupController (PlaceEntryGroup& group) _group->SetVisible (false); _group->SetExpanded (false); - _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::LoadIcons)); - style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::LoadIcons)); + _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles)); + style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles)); } PlacesGroupController::~PlacesGroupController () { - if (_load_icons_id) - g_source_remove (_load_icons_id); + if (_check_tiles_id) + g_source_remove (_check_tiles_id); } const void * @@ -76,26 +76,22 @@ PlacesGroupController::GetGroup () } void -PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result) +PlacesGroupController::AddTile (PlaceEntry *ignore, + PlaceEntryGroup& group, + PlaceEntryResult& result) { + PlacesStyle *style = PlacesStyle::GetDefault (); + gchar *result_name; const gchar *result_icon; PlacesSimpleTile *tile; - PlacesStyle *style = PlacesStyle::GetDefault (); - bool defer_load; - if (_group->GetExpanded ()) - defer_load = false; - else - defer_load = (_id_to_tile.size () + 1) > style->GetDefaultNColumns (); - result_name = g_markup_escape_text (result.GetName (), -1); result_icon = result.GetIcon (); tile = new PlacesSimpleTile (result_icon, result_name, - style->GetTileIconSize (), - defer_load); + style->GetTileIconSize ()); tile->SetURI (result.GetURI ()); tile->QueueRelayout (); @@ -104,29 +100,53 @@ PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& resu _group->GetChildLayout ()->AddView (tile); _group->Relayout (); _group->SetVisible (true); - _group->SetCounts (6, _id_to_tile.size ()); g_free (result_name); } void +PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result) +{ + PlacesStyle *style = PlacesStyle::GetDefault (); + + if (!_group->GetExpanded () + && _id_to_tile.size () >= (guint)style->GetDefaultNColumns ()) + { + _queue.push_back (result.GetId ()); + } + else + { + AddTile (_entry, group, result); + } + + _group->SetCounts (style->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ()); +} + +void PlacesGroupController::RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result) { - PlacesTile *tile; + std::vector<const void *>::iterator it; + PlacesTile *tile = NULL; - tile = _id_to_tile[result.GetId ()]; - if (!tile) - return; - - _id_to_tile.erase (result.GetId ()); + it = std::find (_queue.begin (), _queue.end (), result.GetId ()); - _group->GetChildLayout ()->RemoveChildObject (tile); - _group->Relayout (); - _group->SetCounts (6, _id_to_tile.size ()); - _group->SetVisible (_id_to_tile.size ()); + if (it != _queue.end ()) + { + _queue.erase (it); + } + else if ((tile = _id_to_tile[result.GetId ()])) + { + _id_to_tile.erase (result.GetId ()); + + _group->GetChildLayout ()->RemoveChildObject (tile); + _group->Relayout (); + _group->SetVisible (_id_to_tile.size ()); + } - if (!_load_icons_id) - _load_icons_id = g_timeout_add (0, (GSourceFunc)LoadIconsTimeout, this); + if (!_check_tiles_id) + _check_tiles_id = g_timeout_add (0, (GSourceFunc)CheckTilesTimeout, this); + + _group->SetCounts (PlacesStyle::GetDefault ()->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ()); } void @@ -136,35 +156,54 @@ PlacesGroupController::Clear () } void -PlacesGroupController::LoadIcons () +PlacesGroupController::CheckTiles () { PlacesStyle *style = PlacesStyle::GetDefault (); - int n_to_show, i = 0; -// std::map<const void *, PlacesTile *>::iterator it, eit = _id_to_tile.end (); - nux::GridHLayout *layout = static_cast<nux::GridHLayout *> (_group->GetChildLayout ()); - std::list<nux::Area *>::iterator it, eit = layout->GetChildren ().end (); + guint n_to_show; if (_group->GetExpanded ()) - n_to_show = _id_to_tile.size (); + n_to_show = _id_to_tile.size () + _queue.size (); else n_to_show = style->GetDefaultNColumns (); - for (it = layout->GetChildren ().begin (); it != eit; ++it) + if (_id_to_tile.size () == n_to_show) { - //static_cast<PlacesSimpleTile *> (it->second)->LoadIcon (); - static_cast<PlacesSimpleTile *> (*it)->LoadIcon (); + // Hoorah + } + else if (_id_to_tile.size () < n_to_show) + { + while (_id_to_tile.size () < n_to_show && _queue.size ()) + { + _entry->GetResult ((*_queue.begin ()), sigc::mem_fun (this, &PlacesGroupController::AddTile)); + _queue.erase (_queue.begin ()); + } + } + else // Remove some + { + while (_id_to_tile.size () != n_to_show) + { + std::map<const void *, PlacesTile *>::reverse_iterator it; - i++; - if (i > n_to_show) - break; + it = _id_to_tile.rbegin (); + + if (it != _id_to_tile.rend ()) + { + _group->GetChildLayout ()->RemoveChildObject ((*it).second); + } + + _queue.insert (_queue.begin (), (*it).first); + _id_to_tile.erase ((*it).first); + } } + + _group->Relayout (); } gboolean -PlacesGroupController::LoadIconsTimeout (PlacesGroupController *self) +PlacesGroupController::CheckTilesTimeout (PlacesGroupController *self) { - self->_load_icons_id = 0; - self->LoadIcons (); + self->_check_tiles_id = 0; + self->CheckTiles (); return FALSE; } diff --git a/src/PlacesGroupController.h b/src/PlacesGroupController.h index c70280282..94e94b2a6 100644 --- a/src/PlacesGroupController.h +++ b/src/PlacesGroupController.h @@ -30,7 +30,7 @@ class PlacesGroupController : public nux::Object, public Introspectable { public: - PlacesGroupController (PlaceEntryGroup& group); + PlacesGroupController (PlaceEntry *entry, PlaceEntryGroup& group); ~PlacesGroupController (); const void * GetId (); @@ -46,14 +46,17 @@ protected: void AddProperties (GVariantBuilder *builder); private: - void LoadIcons (); - static gboolean LoadIconsTimeout (PlacesGroupController *self); + void AddTile (PlaceEntry *ignore, PlaceEntryGroup& group, PlaceEntryResult& result); + void CheckTiles (); + static gboolean CheckTilesTimeout (PlacesGroupController *self); private: + PlaceEntry *_entry; PlacesGroup *_group; const void *_id; std::map<const void *, PlacesTile *> _id_to_tile; - guint _load_icons_id; + guint _check_tiles_id; + std::vector<const void *> _queue; }; #endif // PLACES_GROUP_CONTROLLER_H diff --git a/src/PlacesResultsController.cpp b/src/PlacesResultsController.cpp index 6ec476409..1a2c3670e 100644 --- a/src/PlacesResultsController.cpp +++ b/src/PlacesResultsController.cpp @@ -55,9 +55,9 @@ PlacesResultsController::GetView () } void -PlacesResultsController::AddGroup (PlaceEntryGroup& group) +PlacesResultsController::AddGroup (PlaceEntry *entry, PlaceEntryGroup& group) { - PlacesGroupController *controller = new PlacesGroupController (group); + PlacesGroupController *controller = new PlacesGroupController (entry, group); _id_to_group[group.GetId ()] = controller; _results_view->AddGroup (controller->GetGroup ()); @@ -65,7 +65,7 @@ PlacesResultsController::AddGroup (PlaceEntryGroup& group) } void -PlacesResultsController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result) +PlacesResultsController::AddResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result) { PlacesGroupController *controller = _id_to_group[group.GetId ()]; @@ -78,7 +78,7 @@ PlacesResultsController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& re } void -PlacesResultsController::RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result) +PlacesResultsController::RemoveResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result) { PlacesGroupController *controller = _id_to_group[group.GetId ()]; diff --git a/src/PlacesResultsController.h b/src/PlacesResultsController.h index ff723d726..d8bec6ef7 100644 --- a/src/PlacesResultsController.h +++ b/src/PlacesResultsController.h @@ -37,9 +37,9 @@ public: void SetView (PlacesResultsView *view); PlacesResultsView * GetView (); - void AddGroup (PlaceEntryGroup& group); - void AddResult (PlaceEntryGroup& group, PlaceEntryResult& result); - void RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result); + void AddGroup (PlaceEntry *entry, PlaceEntryGroup& group); + void AddResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); + void RemoveResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); // Clears all the current groups and results void Clear (); diff --git a/src/PlacesSearchBar.cpp b/src/PlacesSearchBar.cpp index 2197215c7..84ad5191a 100644 --- a/src/PlacesSearchBar.cpp +++ b/src/PlacesSearchBar.cpp @@ -178,8 +178,7 @@ PlacesSearchBar::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw) void PlacesSearchBar::SetActiveEntry (PlaceEntry *entry, guint section_id, - const char *search_string, - bool ignore_search) + const char *search_string) { std::map<gchar *, gchar *> hints; @@ -199,15 +198,11 @@ PlacesSearchBar::SetActiveEntry (PlaceEntry *entry, res = g_strdup_printf (search_template, tmp); _hint->SetText (res); - - if (!ignore_search) - { - _entry->SetActiveSection (section_id); - _entry->SetSearch (search_string ? search_string : "", hints); - } - _pango_entry->SetText (search_string ? search_string : ""); + _entry->SetActiveSection (section_id); + _entry->SetSearch (search_string ? search_string : "", hints); + _entry->ForeachSection (sigc::mem_fun (this, &PlacesSearchBar::OnSectionAdded)); if (_combo->IsVisible ()) _combo->SetSelectionIndex (section_id); diff --git a/src/PlacesSearchBar.h b/src/PlacesSearchBar.h index 665eebd64..6ca4e9ea1 100644 --- a/src/PlacesSearchBar.h +++ b/src/PlacesSearchBar.h @@ -52,8 +52,7 @@ public: void SetActiveEntry (PlaceEntry *entry, guint section_id, - const char *search_string, - bool ignore=false); + const char *search_string); sigc::signal<void, const char *> search_changed; diff --git a/src/PlacesView.cpp b/src/PlacesView.cpp index dd0a9952e..82b96dcf7 100644 --- a/src/PlacesView.cpp +++ b/src/PlacesView.cpp @@ -84,7 +84,7 @@ PlacesView::PlacesView (PlaceFactory *factory) rop.Blend = true; rop.SrcBlend = GL_ONE; rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; - _bg_layer = new nux::ColorLayer (nux::Color (0.0f, 0.0f, 0.0f, 0.90f), true, rop); + _bg_layer = new nux::ColorLayer (nux::Color (0.0f, 0.0f, 0.0f, 0.9f), true, rop); } // Register for all the events @@ -170,7 +170,7 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) nux::BaseTexture *icon = style->GetDashFullscreenIcon (); nux::TexCoordXForm texxform; - { + { // Background nux::Geometry bg = geo; bg.width -= corner->GetWidth (); bg.height -= corner->GetHeight (); @@ -179,7 +179,7 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) nux::GetPainter ().RenderSinglePaintLayer (GfxContext, bg, _bg_layer); } - { + { // Corner texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap (nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); @@ -192,7 +192,7 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) nux::Color::White); } - { + { // Fullscreen toggle GfxContext.QRP_1Tex (geo.x + geo.width - corner->GetWidth (), geo.y + geo.height - corner->GetHeight (), icon->GetWidth (), @@ -202,7 +202,7 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) nux::Color::White); } - { + { // Bottom repeated texture int real_width = geo.width - corner->GetWidth (); int offset = real_width % bottom->GetWidth (); @@ -218,7 +218,7 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw) nux::Color::White); } - { + { // Right repeated texture int real_height = geo.height - corner->GetHeight (); int offset = real_height % right->GetHeight (); @@ -291,12 +291,10 @@ PlacesView::SetActiveEntry (PlaceEntry *entry, guint section_id, const char *sea _entry = entry; _entry->SetActive (true); - _search_bar->SetActiveEntry (_entry, section_id, search_string, (_entry == _home_entry)); + _search_bar->SetActiveEntry (_entry, section_id, search_string); _entry->ForeachGroup (sigc::mem_fun (this, &PlacesView::OnGroupAdded)); - - if (_entry != _home_entry) - _entry->ForeachResult (sigc::mem_fun (this, &PlacesView::OnResultAdded)); + _entry->ForeachResult (sigc::mem_fun (this, &PlacesView::OnResultAdded)); _group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded)); _result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded)); @@ -374,7 +372,7 @@ PlacesView::SetSizeMode (SizeMode size_mode) void PlacesView::OnGroupAdded (PlaceEntry *entry, PlaceEntryGroup& group) { - _results_controller->AddGroup (group); + _results_controller->AddGroup (entry, group); } void @@ -384,7 +382,7 @@ PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntry if (g_str_has_prefix (result.GetURI (), "unity-install")) return; - _results_controller->AddResult (group, result); + _results_controller->AddResult (entry, group, result); } void @@ -394,7 +392,7 @@ PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEnt if (g_str_has_prefix (result.GetURI (), "unity-install")) return; - _results_controller->RemoveResult (group, result); + _results_controller->RemoveResult (entry, group, result); } void diff --git a/src/unityshell.cpp b/src/unityshell.cpp index 6c73779fa..799fa3222 100644 --- a/src/unityshell.cpp +++ b/src/unityshell.cpp @@ -181,6 +181,8 @@ UnityScreen::damageNuxRegions () void UnityScreen::handleEvent (XEvent *event) { + bool skip_other_plugins = false; + switch (event->type) { case FocusIn: @@ -193,13 +195,15 @@ UnityScreen::handleEvent (XEvent *event) case KeyPress: KeySym key_sym; if (XLookupString (&(event->xkey), NULL, 0, &key_sym, 0) > 0) - launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state); + skip_other_plugins = launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state); break; } - screen->handleEvent (event); + // avoid further propagation (key conflict for instance) + if (!skip_other_plugins) + screen->handleEvent (event); - if (screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL)) + if (!skip_other_plugins && screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL)) { wt->ProcessForeignEvent (event, NULL); } @@ -566,6 +570,12 @@ UnityScreen::NeedsRelayout () } void +UnityScreen::ScheduleRelayout (guint timeout) +{ + g_timeout_add (timeout, &UnityScreen::RelayoutTimeout, this); +} + +void UnityScreen::Relayout () { GdkScreen *scr; @@ -665,7 +675,7 @@ OnMonitorChanged (GdkScreen* screen, gpointer data) { UnityScreen* uscreen = (UnityScreen*) data; - uscreen->NeedsRelayout (); + uscreen->ScheduleRelayout (500); } void @@ -673,7 +683,7 @@ OnSizeChanged (GdkScreen* screen, gpointer data) { UnityScreen* uscreen = (UnityScreen*) data; - uscreen->NeedsRelayout (); + uscreen->ScheduleRelayout (500); } UnityScreen::UnityScreen (CompScreen *screen) : @@ -760,14 +770,14 @@ UnityScreen::UnityScreen (CompScreen *screen) : g_timeout_add (0, &UnityScreen::initPluginActions, this); g_timeout_add (5000, (GSourceFunc) write_logger_data_to_disk, NULL); - g_signal_connect_swapped (gdk_screen_get_default (), - "monitors-changed", - G_CALLBACK (OnMonitorChanged), - this); - g_signal_connect_swapped (gdk_screen_get_default (), - "size-changed", - G_CALLBACK (OnSizeChanged), - this); + g_signal_connect (gdk_screen_get_default (), + "monitors-changed", + G_CALLBACK (OnMonitorChanged), + this); + g_signal_connect (gdk_screen_get_default (), + "size-changed", + G_CALLBACK (OnSizeChanged), + this); END_FUNCTION (); } @@ -867,7 +877,7 @@ void UnityScreen::initLauncher (nux::NThread* thread, void* InitData) self->launcher->SetHideMode (Launcher::LAUNCHER_HIDE_DODGE_WINDOWS); self->launcher->SetLaunchAnimation (Launcher::LAUNCH_ANIMATION_PULSE); self->launcher->SetUrgentAnimation (Launcher::URGENT_ANIMATION_WIGGLE); - g_timeout_add (2000, &UnityScreen::RelayoutTimeout, self); + self->ScheduleRelayout (2000); g_timeout_add (2000, &UnityScreen::strutHackTimeout, self); END_FUNCTION (); diff --git a/src/unityshell.h b/src/unityshell.h index fce0b04a9..9dade73c4 100644 --- a/src/unityshell.h +++ b/src/unityshell.h @@ -130,6 +130,8 @@ class UnityScreen : void NeedsRelayout (); + void ScheduleRelayout (guint timeout); + protected: const gchar* GetName (); diff --git a/tools/migrate_favorites.py b/tools/migrate_favorites.py index 7fae599fa..8b9d1450e 100755 --- a/tools/migrate_favorites.py +++ b/tools/migrate_favorites.py @@ -21,12 +21,13 @@ LAST_MIGRATION = '3.2.10' def get_log_file(): ''' open the log file and return it ''' - data_path = "%s/unity" % BaseDirectory.xdg_data_home + data_path = "%s/unity" % BaseDirectory.xdg_cache_home if not os.path.isdir(data_path): os.makedirs(data_path) try: return open("%s/migration_script.log" % data_path, "a") - except IOError: + except (IOError, OSError), e: + print "Can't put log in %s, will print those manually. Error is: %s" % (data_path, e) return None def migrating_chapter_log(name, apps_list, migration_list, log_file): @@ -39,6 +40,8 @@ def log(message, log_file): ''' log if log_file present''' if log_file: log_file.write("%s\n" % message) + else: + print message def get_desktop_dir(): ''' no python binding from xdg to get the desktop directory? ''' @@ -187,8 +190,12 @@ if migration_level < '3.2.0': for candidate in lucid_favorites_list: candidate_path = '/apps/netbook-launcher/favorites/%s' % candidate if (candidate and client.get_string('%s/type' % candidate_path) == 'application'): - launcher_location = client.get_string('%s/desktop_file' % candidate_path) - if launcher_location: + try: + launcher_location = client.get_string('%s/desktop_file' % candidate_path) + except GError, e: + log("Dont migrate %s: %s" % (candidate_path, e), log_file) + continue + if launcher_location: apps_list = register_new_app(launcher_location, apps_list, log_file) # get GNOME panel favorites and convert them @@ -197,13 +204,17 @@ if migration_level < '3.2.0': migrating_chapter_log("gnome-panel items", apps_list, candidate_objects, log_file) for candidate in candidate_objects: candidate_path = '/apps/panel/objects/%s' % candidate - if (candidate and client.get_string('%s/object_type' % candidate_path) == 'launcher-object' - and client.get_string('%s/toplevel_id' % candidate_path) in panel_list): - launcher_location = client.get_string('%s/launcher_location' % candidate_path) - if launcher_location: - if not launcher_location.startswith('/'): - launcher_location = os.path.expanduser('~/.gnome2/panel2.d/default/launchers/%s' % launcher_location) - apps_list = register_new_app(launcher_location, apps_list, log_file) + try: + if (candidate and client.get_string('%s/object_type' % candidate_path) == 'launcher-object' + and client.get_string('%s/toplevel_id' % candidate_path) in panel_list): + launcher_location = client.get_string('%s/launcher_location' % candidate_path) + if launcher_location: + if not launcher_location.startswith('/'): + launcher_location = os.path.expanduser('~/.gnome2/panel2.d/default/launchers/%s' % launcher_location) + apps_list = register_new_app(launcher_location, apps_list, log_file) + except GError, e: + log("Dont migrate %s: %s" % (candidate_path, e), log_file) + continue # get GNOME desktop launchers desktop_dir = get_desktop_dir() diff --git a/tools/unity.cmake b/tools/unity.cmake index 8d537290c..c86df5dff 100755 --- a/tools/unity.cmake +++ b/tools/unity.cmake @@ -39,7 +39,10 @@ well_known_local_path = ("%s/share/unity" % supported_prefix, "%s/lib/*unity*" % supported_prefix, "%s/share/dbus-1/services/*Unity*" % supported_prefix, "%s/bin/*unity*" % supported_prefix, - "%s/share/man/man1/*unity*" % supported_prefix + "%s/share/man/man1/*unity*" % supported_prefix, + "%s/lib/*nux*" % supported_prefix, + "%s/pkgconfig/nux*" % supported_prefix, + "%s/include/Nux*" % supported_prefix ) diff --git a/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp b/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp index f0806db72..c260be814 100644 --- a/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp +++ b/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp @@ -298,6 +298,13 @@ Unity::MT::GrabHandleGroup::layout () return layout; } +/* Super speed hack */ +static bool +sortPointers (const CompWindow *p1, const CompWindow *p2) +{ + return (void *) p1 < (void *) p2; +} + void UnityMTGrabHandlesScreen::handleEvent (XEvent *event) { @@ -341,15 +348,26 @@ UnityMTGrabHandlesScreen::handleEvent (XEvent *event) if (event->xproperty.atom == Atoms::clientListStacking) { CompWindowVector invalidated (0); - /* Window removed or added, update all windows */ - if (screen->clientList (true).size () != mLastClientListStacking.size ()) - invalidated = mLastClientListStacking; + CompWindowVector clients = screen->clientList (true); + CompWindowVector oldClients = mLastClientListStacking; + CompWindowVector clientListStacking = screen->clientList (true); + /* Windows can be removed and added from the client list + * here at the same time (eg hide/unhide launcher ... racy) + * so we need to check if the client list contains the same + * windows as it used to. Sort both lists and compare ... */ + + std::sort (clients.begin (), clients.end (), sortPointers); + std::sort (oldClients.begin (), + oldClients.end (), sortPointers); + + if (clients != mLastClientListStacking) + invalidated = clients; else { - CompWindowVector::const_iterator cit = screen->clientList (true).begin (); + CompWindowVector::const_iterator cit = clientListStacking.begin (); CompWindowVector::const_iterator oit = mLastClientListStacking.begin (); - for (; cit != screen->clientList (true).end (); cit++, oit++) + for (; cit != clientListStacking.end (); cit++, oit++) { /* All clients from this point onwards in cit are invalidated * so splice the list to the end of the new client list @@ -362,14 +380,13 @@ UnityMTGrabHandlesScreen::handleEvent (XEvent *event) } foreach (CompWindow *w, invalidated) - { - if (UnityMTGrabHandlesWindow::get (w)) - UnityMTGrabHandlesWindow::get (w)->restackHandles (); - } + UnityMTGrabHandlesWindow::get (w)->restackHandles (); - mLastClientListStacking = screen->clientList (true); + mLastClientListStacking = clients; } + break; + case ButtonPress: if (event->xbutton.button != 1) @@ -448,6 +465,23 @@ UnityMTGrabHandlesScreen::preparePaint (int msec) cScreen->preparePaint (msec); } +bool +UnityMTGrabHandlesWindow::allowHandles () +{ + /* Not on windows we can't move or resize */ + if (!(window->actions () & CompWindowActionResizeMask)) + return false; + + if (!(window->actions () & CompWindowActionMoveMask)) + return false; + + /* Not on override redirect windows */ + if (window->overrideRedirect ()) + return false; + + return true; +} + void UnityMTGrabHandlesWindow::getOutputExtents (CompWindowExtents &output) { @@ -688,9 +722,16 @@ UnityMTGrabHandlesScreen::showHandles (CompAction *action, 0)); if (w) - UnityMTGrabHandlesWindow::get (w)->showHandles (); + { + UMTGH_WINDOW (w); - mMoreAnimate = true; + if (!uw->allowHandles ()) + return false; + + uw->showHandles (); + + mMoreAnimate = true; + } return true; } @@ -769,5 +810,5 @@ UnityMTGrabHandlesPluginVTable::init () !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) return false; - return false; + return true; } diff --git a/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.h b/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.h index 42b817344..5b5e3aa5d 100644 --- a/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.h +++ b/utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.h @@ -135,8 +135,8 @@ class UnityMTGrabHandlesScreen : std::vector <Unity::MT::TextureSize> mHandleTextures; std::map <Window, Unity::MT::GrabHandle *> mInputHandles; - CompWindowVector mLastClientListStacking; - Atom mCompResizeWindowAtom; + CompWindowVector mLastClientListStacking; + Atom mCompResizeWindowAtom; bool mMoreAnimate; }; @@ -161,6 +161,8 @@ class UnityMTGrabHandlesWindow : public: + bool allowHandles (); + void grabNotify (int, int, unsigned int, unsigned int); void ungrabNotify (); |
