diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-10 14:26:20 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-10 14:26:20 +0100 |
| commit | 31a09f59233d7e79c817c0bf819875d0a8a1d439 (patch) | |
| tree | 458fa2ee86b4ad53cdce1a21b91566737d23d311 /plugins | |
| parent | a29e73958fb7fe2f37f2afb9f345f8708aaeff16 (diff) | |
UnityScreen:
Fixed bugs: - LP: #1286158 - LP: #925454 (bzr r3702.6.2)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 79 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 4 |
2 files changed, 80 insertions, 3 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 37328a3c8..d5797f0a5 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -52,6 +52,7 @@ #include "launcher/XdndStartStopNotifierImp.h" #include "CompizShortcutModeller.h" #include "GnomeKeyGrabber.h" +#include "RawPixel.h" #include "decorations/DecorationsDataPool.h" #include "decorations/DecorationsManager.h" @@ -138,6 +139,8 @@ const unsigned int SCROLL_UP_BUTTON = 7; const int MAX_BUFFER_AGE = 11; const int FRAMES_TO_REDRAW_ON_RESUME = 10; const std::string RELAYOUT_TIMEOUT = "relayout-timeout"; +const RawPixel SCALE_PADDING = 40_em; +const RawPixel SCALE_SPACING = 20_em; } // namespace local } // anon namespace @@ -267,6 +270,7 @@ UnityScreen::UnityScreen(CompScreen* screen) ScreenInterface::setHandler(screen); CompositeScreenInterface::setHandler(cScreen); GLScreenInterface::setHandler(gScreen); + ScaleScreenInterface::setHandler(sScreen); PluginAdapter::Initialize(screen); AddChild(&WindowManager::Default()); @@ -876,9 +880,8 @@ void UnityScreen::paintDisplay() if (CompWindow* window = screen->findWindow(target->xid)) { UnityWindow *unity_window = UnityWindow::get(window); - double scale = target->result.width / static_cast<double>(target->geo.width); double parent_alpha = switcher_controller_->Opacity(); - unity_window->paintThumbnail(target->result, target->alpha, parent_alpha, scale, + unity_window->paintThumbnail(target->result, target->alpha, parent_alpha, target->scale, target->decoration_height, target->selected); } } @@ -3559,7 +3562,77 @@ void UnityScreen::outputChangeNotify() ScheduleRelayout(500); } -void UnityScreen::OnDashRealized () +bool UnityScreen::layoutSlotsAndAssignWindows() +{ + auto const& scaled_windows = sScreen->getWindows(); + + for (auto const& output : screen->outputDevs()) + { + ui::LayoutWindow::Vector layout_windows; + int monitor = UScreen::GetDefault()->GetMonitorAtPosition(output.centerX(), output.centerY()); + double monitor_scale = unity_settings_.em(monitor)->DPIScale(); + + for (ScaleWindow *sw : scaled_windows) + { + if (sw->window->outputDevice() == static_cast<int>(output.id())) + { + UnityWindow::get(sw->window)->deco_win_->scaled = true; + layout_windows.emplace_back(std::make_shared<LayoutWindow>(sw->window->id())); + } + } + + auto max_bounds = NuxGeometryFromCompRect(output.workArea()); + + if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER) + { + int monitor_width = unity_settings_.LauncherWidth(monitor); + max_bounds.x += monitor_width; + max_bounds.width -= monitor_width; + } + + nux::Geometry final_bounds; + ui::LayoutSystem layout; + layout.max_row_height = max_bounds.height; + layout.spacing = local::SCALE_SPACING.CP(monitor_scale); + int padding = local::SCALE_PADDING.CP(monitor_scale); + max_bounds.Expand(-padding, -padding); + layout.LayoutWindows(layout_windows, max_bounds, final_bounds); + + auto lw_it = layout_windows.begin(); + for (auto const& sw : scaled_windows) + { + if (lw_it == layout_windows.end()) + break; + + LayoutWindow::Ptr const& lw = *lw_it; + + if (sw->window->id() != lw->xid) + continue; + + ScaleSlot slot(CompRectFromNuxGeo(lw->result)); + slot.scale = lw->scale; + + float sx = lw->geo.width * slot.scale; + float sy = lw->geo.height * slot.scale; + float cx = (slot.x1() + slot.x2()) / 2; + float cy = (slot.y1() + slot.y2()) / 2; + + CompWindow *w = sw->window; + cx += w->input().left * slot.scale; + cy += w->input().top * slot.scale; + + slot.setGeometry(cx - sx / 2, cy - sy / 2, sx, sy); + slot.filled = true; + + sw->setSlot(slot); + ++lw_it; + } + } + + return true; +} + +void UnityScreen::OnDashRealized() { /* stack any windows named "onboard" above us */ for (CompWindow *w : screen->windows ()) diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 5a8e22b91..b6e72602e 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -106,6 +106,7 @@ class UnityScreen : public ScreenInterface, public CompositeScreenInterface, public GLScreenInterface, + public ScaleScreenInterface, public BaseSwitchScreen, public PluginClassHandler <UnityScreen, CompScreen>, public CompAction::Container, @@ -169,6 +170,9 @@ public: void enterShowDesktopMode (); void leaveShowDesktopMode (CompWindow *w); + /* window scaling */ + bool layoutSlotsAndAssignWindows(); + bool showMenuBarInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool showMenuBarTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool showLauncherKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
