diff options
| -rw-r--r-- | plugins/unityshell/src/AbstractLauncherIcon.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/DesktopLauncherIcon.h | 5 | ||||
| -rw-r--r-- | plugins/unityshell/src/GeisAdapter.cpp | 7 | ||||
| -rw-r--r-- | plugins/unityshell/src/IconRenderer.cpp | 4 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherController.cpp | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherIcon.cpp | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherIcon.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/MockLauncherIcon.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelTray.cpp | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/SwitcherController.cpp | 13 | ||||
| -rw-r--r-- | plugins/unityshell/src/SwitcherModel.cpp | 21 | ||||
| -rw-r--r-- | plugins/unityshell/src/SwitcherModel.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 40 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/unityshell.xml.in | 2 |
15 files changed, 81 insertions, 25 deletions
diff --git a/plugins/unityshell/src/AbstractLauncherIcon.h b/plugins/unityshell/src/AbstractLauncherIcon.h index 0538775f4..e7155dad8 100644 --- a/plugins/unityshell/src/AbstractLauncherIcon.h +++ b/plugins/unityshell/src/AbstractLauncherIcon.h @@ -147,7 +147,7 @@ public: virtual std::string NameForWindow (Window window) = 0; - virtual bool HasWindowOnViewport() = 0; + virtual const bool HasWindowOnViewport() = 0; virtual bool IsSpacer() = 0; diff --git a/plugins/unityshell/src/DesktopLauncherIcon.h b/plugins/unityshell/src/DesktopLauncherIcon.h index 20ecb0f65..85e3f0bc6 100644 --- a/plugins/unityshell/src/DesktopLauncherIcon.h +++ b/plugins/unityshell/src/DesktopLauncherIcon.h @@ -37,6 +37,11 @@ public: virtual nux::Color BackgroundColor(); virtual nux::Color GlowColor(); + const bool HasWindowOnViewport() + { + return true; + } + bool ShowInSwitcher() { return true; diff --git a/plugins/unityshell/src/GeisAdapter.cpp b/plugins/unityshell/src/GeisAdapter.cpp index b1031bf7b..f9ba65616 100644 --- a/plugins/unityshell/src/GeisAdapter.cpp +++ b/plugins/unityshell/src/GeisAdapter.cpp @@ -45,9 +45,10 @@ void GeisAdapter::Run() { int fd = -1; - GeisStatus status; + GeisStatus status = GEIS_STATUS_NOT_SUPPORTED; - status = geis_configuration_get_value(_root_instance, GEIS_CONFIG_UNIX_FD, &fd); + if (_root_instance != nullptr) + status = geis_configuration_get_value(_root_instance, GEIS_CONFIG_UNIX_FD, &fd); if (status != GEIS_STATUS_SUCCESS) return; @@ -466,7 +467,7 @@ GeisAdapter::RegisterRootInstance() GEIS_XCB_FULL_WINDOW, &xcb_win_info }; - GeisInstance instance; + GeisInstance instance = nullptr; status = geis_init(&win_info, &instance); if (status != GEIS_STATUS_SUCCESS) diff --git a/plugins/unityshell/src/IconRenderer.cpp b/plugins/unityshell/src/IconRenderer.cpp index f7a3739b9..8e4839ba4 100644 --- a/plugins/unityshell/src/IconRenderer.cpp +++ b/plugins/unityshell/src/IconRenderer.cpp @@ -816,7 +816,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, break; GfxContext.QRP_1Tex(markerX, - center - ((texture->GetHeight() * scale) / 2), + center - ((texture->GetHeight() * scale) / 2) - 1, (float) texture->GetWidth() * scale, (float) texture->GetHeight() * scale, texture->GetDeviceTexture(), @@ -831,7 +831,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, nux::Color color = nux::color::LightGrey * alpha; GfxContext.QRP_1Tex((geo.x + geo.width) - local::arrow_rtl->GetWidth(), - markerCenter - (local::arrow_rtl->GetHeight() / 2), + markerCenter - (local::arrow_rtl->GetHeight() / 2) - 1, (float) local::arrow_rtl->GetWidth(), (float) local::arrow_rtl->GetHeight(), local::arrow_rtl->GetDeviceTexture(), diff --git a/plugins/unityshell/src/LauncherController.cpp b/plugins/unityshell/src/LauncherController.cpp index 69f8e9c39..47308927c 100644 --- a/plugins/unityshell/src/LauncherController.cpp +++ b/plugins/unityshell/src/LauncherController.cpp @@ -136,7 +136,7 @@ Controller::Impl::Impl(Display* display) launcher_window_->SetBackgroundColor(nux::color::Transparent); launcher_window_->ShowWindow(true); launcher_window_->EnableInputWindow(true, "launcher", false, false); - launcher_window_->InputWindowEnableStruts(true); + launcher_window_->InputWindowEnableStruts(false); launcher_window_->SetEnterFocusInputArea(raw_launcher); launcher_->SetModel(model_.get()); diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index f03049283..98fdd9b07 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -167,7 +167,7 @@ LauncherIcon::~LauncherIcon() } } -bool +const bool LauncherIcon::HasWindowOnViewport() { return _has_visible_window; diff --git a/plugins/unityshell/src/LauncherIcon.h b/plugins/unityshell/src/LauncherIcon.h index 4ebfe0999..6c6555b4c 100644 --- a/plugins/unityshell/src/LauncherIcon.h +++ b/plugins/unityshell/src/LauncherIcon.h @@ -109,7 +109,7 @@ public: virtual std::string NameForWindow (Window window) { return std::string(); } - bool HasWindowOnViewport(); + const bool HasWindowOnViewport(); virtual bool IsSpacer() { diff --git a/plugins/unityshell/src/MockLauncherIcon.h b/plugins/unityshell/src/MockLauncherIcon.h index bf3d6013e..5fbba0ed9 100644 --- a/plugins/unityshell/src/MockLauncherIcon.h +++ b/plugins/unityshell/src/MockLauncherIcon.h @@ -113,7 +113,7 @@ public: return 7; } - bool HasWindowOnViewport() + const bool HasWindowOnViewport() { return false; } diff --git a/plugins/unityshell/src/PanelTray.cpp b/plugins/unityshell/src/PanelTray.cpp index 5052b833a..def92f18a 100644 --- a/plugins/unityshell/src/PanelTray.cpp +++ b/plugins/unityshell/src/PanelTray.cpp @@ -95,6 +95,7 @@ PanelTray::~PanelTray() if (_tray) { g_signal_handler_disconnect(na_tray_get_manager(_tray), _tray_icon_added_id); + g_object_unref (_tray); _tray = NULL; } diff --git a/plugins/unityshell/src/SwitcherController.cpp b/plugins/unityshell/src/SwitcherController.cpp index 1db95fa3b..0b1be0c89 100644 --- a/plugins/unityshell/src/SwitcherController.cpp +++ b/plugins/unityshell/src/SwitcherController.cpp @@ -70,14 +70,27 @@ void Controller::OnBackgroundUpdate(GVariant* data, Controller* self) self->view_->background_color = self->bg_color_; } +bool IsOnOtherViewport (AbstractLauncherIcon* icon) +{ + return !icon->HasWindowOnViewport(); +} + void Controller::Show(ShowMode show, SortMode sort, bool reverse, std::vector<AbstractLauncherIcon*> results) { if (sort == SortMode::FOCUS_ORDER) + { std::sort(results.begin(), results.end(), CompareSwitcherItemsPriority); + } + + if (show == ShowMode::CURRENT_VIEWPORT) + { + results.erase(std::remove_if(results.begin(), results.end(), IsOnOtherViewport), results.end()); + } model_.reset(new SwitcherModel(results)); model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged)); + model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT); SelectFirstItem(); diff --git a/plugins/unityshell/src/SwitcherModel.cpp b/plugins/unityshell/src/SwitcherModel.cpp index ede1ec87d..0e683d47a 100644 --- a/plugins/unityshell/src/SwitcherModel.cpp +++ b/plugins/unityshell/src/SwitcherModel.cpp @@ -35,6 +35,7 @@ SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon*> icons) { detail_selection = false; detail_selection_index = 0; + only_detail_on_viewport = false; for (auto icon : _inner) icon->Reference(); @@ -114,12 +115,23 @@ SwitcherModel::CompareWindowsByActive (guint32 first, guint32 second) return WindowManager::Default ()->GetWindowActiveNumber (first) > WindowManager::Default ()->GetWindowActiveNumber (second); } +bool +WindowOnOtherViewport(Window xid) +{ + return !WindowManager::Default()->IsWindowOnCurrentDesktop(xid); +} + std::vector<Window> SwitcherModel::DetailXids() { std::vector<Window> results; results = Selection()->RelatedXids (); + if (only_detail_on_viewport) + { + results.erase(std::remove_if(results.begin(), results.end(), WindowOnOtherViewport), results.end()); + } + std::sort (results.begin (), results.end (), &CompareWindowsByActive); // swap so we focus the last focused window first @@ -134,7 +146,10 @@ SwitcherModel::DetailSelectionWindow () { if (!detail_selection || DetailXids ().empty()) return 0; - + + if (detail_selection_index > DetailXids().size() - 1) + return 0; + return DetailXids()[detail_selection_index]; } @@ -173,7 +188,7 @@ SwitcherModel::NextDetail () if (!detail_selection()) return; - if (detail_selection_index < Selection()->RelatedXids ().size () - 1) + if (detail_selection_index < DetailXids().size() - 1) detail_selection_index = detail_selection_index + 1; else detail_selection_index = 0; @@ -187,7 +202,7 @@ void SwitcherModel::PrevDetail () if (detail_selection_index >= (unsigned int) 1) detail_selection_index = detail_selection_index - 1; else - detail_selection_index = Selection()->RelatedXids ().size () - 1; + detail_selection_index = DetailXids().size() - 1; } void diff --git a/plugins/unityshell/src/SwitcherModel.h b/plugins/unityshell/src/SwitcherModel.h index 923954395..1f5cfe0bf 100644 --- a/plugins/unityshell/src/SwitcherModel.h +++ b/plugins/unityshell/src/SwitcherModel.h @@ -45,6 +45,7 @@ public: nux::Property<bool> detail_selection; nux::Property<unsigned int> detail_selection_index; + nux::Property<bool> only_detail_on_viewport; // Icons are owned externally and assumed valid for life of switcher. // When AbstractLauncherIcon is complete, it will be passed as a shared pointer and this diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 325a10c3d..649ef561b 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -305,7 +305,10 @@ UnityScreen::UnityScreen(CompScreen* screen) BackgroundEffectHelper::updates_enabled = true; - ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_SHOWN, [&](GVariant * args) { dash_is_open_ = true; }); + ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_SHOWN, [&](GVariant * args) { + dash_is_open_ = true; + RaiseInputWindows(); + }); ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_HIDDEN, [&](GVariant * args) { dash_is_open_ = false; }); LOG_INFO(logger) << "UnityScreen constructed: " << timer.ElapsedSeconds() << "s"; } @@ -1301,23 +1304,26 @@ bool UnityScreen::altTabInitiateCommon(CompAction *action, grab_index_ = screen->pushGrab (screen->invisibleCursor(), "unity-switcher"); if (!grab_index_) return false; + + std::vector<unity::launcher::AbstractLauncherIcon*> results = launcher_controller_->GetAltTabIcons(); - screen->addAction (&optionGetAltTabRight ()); - screen->addAction (&optionGetAltTabDetailStart ()); - screen->addAction (&optionGetAltTabDetailStop ()); - screen->addAction (&optionGetAltTabLeft ()); + screen->addAction(&optionGetAltTabRight()); + screen->addAction(&optionGetAltTabDetailStart()); + screen->addAction(&optionGetAltTabDetailStop()); + screen->addAction(&optionGetAltTabLeft()); // maybe check launcher position/hide state? int device = screen->outputDeviceForPoint (pointerX, pointerY); switcher_controller_->SetWorkspace(nux::Geometry(screen->outputDevs()[device].x1() + 100, - screen->outputDevs()[device].y1() + 100, - screen->outputDevs()[device].width() - 200, - screen->outputDevs()[device].height() - 200)); + screen->outputDevs()[device].y1() + 100, + screen->outputDevs()[device].width() - 200, + screen->outputDevs()[device].height() - 200)); + + switcher::ShowMode show_mode = optionGetAltTabBiasViewport() ? switcher::ShowMode::CURRENT_VIEWPORT : switcher::ShowMode::ALL; - std::vector<AbstractLauncherIcon*> results = launcher_controller_->GetAltTabIcons(); - switcher_controller_->Show(switcher::ShowMode::ALL, - switcher::SortMode::FOCUS_ORDER, false, results); + RaiseInputWindows(); + switcher_controller_->Show(show_mode, switcher::SortMode::FOCUS_ORDER, false, results); return true; } @@ -1555,6 +1561,18 @@ const CompWindowList& UnityScreen::getWindowPaintList() return pl; } +void UnityScreen::RaiseInputWindows() +{ + std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); + + for (auto window : xwns) + { + CompWindow* cwin = screen->findWindow(window); + if (cwin) + cwin->raise(); + } +} + /* detect occlusions * * core passes down the PAINT_WINDOW_OCCLUSION_DETECTION diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 2970e6c1a..e79e7aaba 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -158,6 +158,8 @@ public: void preparePaint (int ms); void paintFboForOutput (CompOutput *output); + void RaiseInputWindows(); + void handleCompizEvent (const char *pluginName, const char *eventName, diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in index f3d5cf6af..a99bb7691 100644 --- a/plugins/unityshell/unityshell.xml.in +++ b/plugins/unityshell/unityshell.xml.in @@ -106,7 +106,7 @@ <default>true</default> </option> <option name="alt_tab_bias_viewport" type="bool"> - <_short>Bias alt-tab sorting to prefer windows on the current viewport</_short> + <_short>Bias alt-tab to prefer windows on the current viewport</_short> <_long>fixme</_long> <default>false</default> </option> |
