summaryrefslogtreecommitdiff
diff options
authorBrandon Schaefer <brandon.schaefer@canonical.com>2013-01-28 15:57:38 -0800
committerBrandon Schaefer <brandon.schaefer@canonical.com>2013-01-28 15:57:38 -0800
commitc40a09f7382b29b5a19ab29ed87459af7e38b285 (patch)
tree3190816e3131abd88b30ade1c618c0003c014cd4
parentbbdf3c6f929cab813e117bc5945c56615ac381e5 (diff)
* The main reason, is the DashView has to take up the PanelHeight, so when the
launcher icons are resized, part of the window buttons get cut off from mouse events. * Created a class OverlayWindowButtons which will sit in the DashView/HudView to handle mouse events for the window buttons. * TODO: We need to refactor the PanelMenuView to extract window button logic (dealing with overlays). Fixes LP: #1101310 (bzr r3080.1.2)
-rw-r--r--dash/CMakeLists.txt2
-rw-r--r--dash/DashView.cpp26
-rw-r--r--dash/DashView.h19
-rw-r--r--hud/CMakeLists.txt2
-rw-r--r--hud/HudView.cpp6
-rw-r--r--hud/HudView.h3
-rw-r--r--panel/PanelMenuView.cpp3
-rw-r--r--panel/PanelMenuView.h2
-rw-r--r--tests/autopilot/unity/tests/test_panel.py16
-rw-r--r--unity-shared/CMakeLists.txt1
-rw-r--r--unity-shared/OverlayWindowButtons.cpp76
-rw-r--r--unity-shared/OverlayWindowButtons.h53
12 files changed, 189 insertions, 20 deletions
diff --git a/dash/CMakeLists.txt b/dash/CMakeLists.txt
index de9af3a3a..be7736bdb 100644
--- a/dash/CMakeLists.txt
+++ b/dash/CMakeLists.txt
@@ -56,4 +56,4 @@ add_pch(pch/dash_pch.hh dash-lib)
# Standalone variant
#
add_executable (dash StandaloneDash.cpp)
-target_link_libraries (dash dash-lib unity-shared)
+target_link_libraries (dash dash-lib unity-shared unity-shared-standalone)
diff --git a/dash/DashView.cpp b/dash/DashView.cpp
index 467d1e90d..40073d20e 100644
--- a/dash/DashView.cpp
+++ b/dash/DashView.cpp
@@ -20,6 +20,7 @@
#include "DashView.h"
#include "DashViewPrivate.h"
+#include "FilterExpanderLabel.h"
#include <math.h>
@@ -31,13 +32,12 @@
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/RadioOptionFilter.h>
-#include "FilterExpanderLabel.h"
#include "unity-shared/DashStyle.h"
#include "unity-shared/KeyboardUtil.h"
-#include "unity-shared/UnitySettings.h"
-#include "unity-shared/UBusMessages.h"
#include "unity-shared/PreviewStyle.h"
#include "unity-shared/PanelStyle.h"
+#include "unity-shared/UBusMessages.h"
+#include "unity-shared/UnitySettings.h"
namespace unity
{
@@ -126,6 +126,7 @@ DashView::DashView()
, animate_split_value_(0.0)
, animate_preview_container_value_(0.0)
, animate_preview_value_(0.0)
+ , overlay_window_buttons_(new OverlayWindowButtons())
{
renderer_.SetOwner(this);
renderer_.need_redraw.connect([this] () {
@@ -493,6 +494,8 @@ void DashView::AboutToShow()
ClosePreview();
}
+ overlay_window_buttons_->AboutToShow();
+
renderer_.AboutToShow();
}
@@ -520,6 +523,8 @@ void DashView::AboutToHide()
{
ClosePreview();
}
+
+ overlay_window_buttons_->AboutToHide();
}
void DashView::SetupViews()
@@ -728,6 +733,8 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw
nux::GetPainter().PopBackgroundStack();
}
+ overlay_window_buttons_->QueueDraw();
+
graphics_engine.PopClippingRectangle();
renderer_.DrawInnerCleanup(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo);
@@ -1089,11 +1096,6 @@ void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned lo
geo.width += style.GetDashRightTileWidth();
geo.height += style.GetDashBottomTileHeight();
}
-
- if (!geo.IsPointInside(x, y))
- {
- ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
- }
}
void DashView::OnActivateRequest(GVariant* args)
@@ -1518,6 +1520,7 @@ void DashView::AddProperties(GVariantBuilder* builder)
wrapper.add("right-border-width", style.GetDashRightTileWidth());
wrapper.add("bottom-border-height", style.GetDashBottomTileHeight());
wrapper.add("preview_displaying", preview_displaying_);
+ wrapper.add("dash_maximized", style.always_maximised());
}
nux::Area* DashView::KeyNavIteration(nux::KeyNavDirection direction)
@@ -1719,7 +1722,12 @@ nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol,
nux::Area* DashView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
{
nux::Area* view = nullptr;
- if (preview_displaying_)
+
+ if (overlay_window_buttons_->GetGeometry().IsInside(mouse_position))
+ {
+ return overlay_window_buttons_->FindAreaUnderMouse(mouse_position, event_type);
+ }
+ else if (preview_displaying_)
{
nux::Point newpos = mouse_position;
view = dynamic_cast<nux::Area*>(preview_container_.GetPointer())->FindAreaUnderMouse(newpos, event_type);
diff --git a/dash/DashView.h b/dash/DashView.h
index ee0484463..67fefd958 100644
--- a/dash/DashView.h
+++ b/dash/DashView.h
@@ -28,17 +28,20 @@
#include <UnityCore/HomeLens.h>
#include <UnityCore/GLibSource.h>
-#include "unity-shared/BackgroundEffectHelper.h"
-#include "unity-shared/SearchBar.h"
-#include "unity-shared/Introspectable.h"
-#include "unity-shared/BGHash.h"
#include "LensBar.h"
#include "LensView.h"
-#include "unity-shared/UBusWrapper.h"
-#include "unity-shared/OverlayRenderer.h"
-#include "UnityCore/Preview.h"
#include "previews/PreviewContainer.h"
#include "PreviewStateMachine.h"
+#include "UnityCore/Preview.h"
+
+#include "unity-shared/BackgroundEffectHelper.h"
+#include "unity-shared/BGHash.h"
+#include "unity-shared/Introspectable.h"
+#include "unity-shared/OverlayRenderer.h"
+#include "unity-shared/SearchBar.h"
+#include "unity-shared/UBusWrapper.h"
+#include "unity-shared/OverlayWindowButtons.h"
+
namespace na = nux::animation;
@@ -185,6 +188,8 @@ private:
std::unique_ptr<na::AnimateValue<float>> preview_animation_;
float animate_preview_value_;
+
+ nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;
};
diff --git a/hud/CMakeLists.txt b/hud/CMakeLists.txt
index da692e2a8..6f0742659 100644
--- a/hud/CMakeLists.txt
+++ b/hud/CMakeLists.txt
@@ -34,4 +34,4 @@ add_pch(pch/hud_pch.hh hud-lib)
# Standalone variant
#
add_executable (hud StandaloneHud.cpp)
-target_link_libraries (hud hud-lib unity-shared)
+target_link_libraries (hud hud-lib unity-shared unity-shared-standalone)
diff --git a/hud/HudView.cpp b/hud/HudView.cpp
index 02b7fca4a..33796e156 100644
--- a/hud/HudView.cpp
+++ b/hud/HudView.cpp
@@ -67,6 +67,7 @@ View::View()
, selected_button_(0)
, show_embedded_icon_(true)
, keyboard_stole_focus_(false)
+ , overlay_window_buttons_(new OverlayWindowButtons())
{
renderer_.SetOwner(this);
renderer_.need_redraw.connect([this] () {
@@ -345,12 +346,14 @@ nux::Geometry View::GetBestFitGeometry(nux::Geometry const& for_geo)
void View::AboutToShow()
{
visible_ = true;
+ overlay_window_buttons_->AboutToShow();
renderer_.AboutToShow();
}
void View::AboutToHide()
{
visible_ = false;
+ overlay_window_buttons_->AboutToHide();
renderer_.AboutToHide();
}
@@ -484,6 +487,9 @@ void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw)
{
GetLayout()->ProcessDraw(gfx_context, force_draw);
}
+
+ overlay_window_buttons_->QueueDraw();
+
gfx_context.PopClippingRectangle();
renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry());
diff --git a/hud/HudView.h b/hud/HudView.h
index 1dc9f07c0..8161187fa 100644
--- a/hud/HudView.h
+++ b/hud/HudView.h
@@ -29,6 +29,7 @@
#include "HudButton.h"
#include "HudAbstractView.h"
#include "unity-shared/OverlayRenderer.h"
+#include "unity-shared/OverlayWindowButtons.h"
#include "unity-shared/SearchBar.h"
#include "unity-shared/UBusWrapper.h"
@@ -121,6 +122,8 @@ private:
bool show_embedded_icon_;
bool activated_signal_sent_;
bool keyboard_stole_focus_;
+
+ nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;
};
diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp
index 6f12aedd1..333c00852 100644
--- a/panel/PanelMenuView.cpp
+++ b/panel/PanelMenuView.cpp
@@ -356,8 +356,9 @@ bool PanelMenuView::DrawWindowButtons() const
WindowManager& wm = WindowManager::Default();
bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive());
+ // TODO: We need to refactor this code to extract the window button logic
if (overlay_showing_)
- return true;
+ return false;
if (we_control_active_ && is_maximized_ && !screen_grabbed &&
!launcher_keynav_ && !switcher_showing_)
diff --git a/panel/PanelMenuView.h b/panel/PanelMenuView.h
index 549b445f2..c7d083ad1 100644
--- a/panel/PanelMenuView.h
+++ b/panel/PanelMenuView.h
@@ -28,9 +28,9 @@
#include "PanelIndicatorsView.h"
#include "unity-shared/StaticCairoText.h"
+#include "unity-shared/WindowButtons.h"
#include "PanelTitlebarGrabAreaView.h"
#include "unity-shared/UBusWrapper.h"
-#include "unity-shared/WindowButtons.h"
namespace unity
{
diff --git a/tests/autopilot/unity/tests/test_panel.py b/tests/autopilot/unity/tests/test_panel.py
index b53d752af..a49c760cf 100644
--- a/tests/autopilot/unity/tests/test_panel.py
+++ b/tests/autopilot/unity/tests/test_panel.py
@@ -298,6 +298,22 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
self.assertWinButtonsInOverlayMode(True)
+ def test_window_buttons_work_in_dash_after_launcher_resize(self):
+ """When the launcher icons are resized, the window
+ buttons must still work in the dash."""
+
+ self.set_unity_option("icon_size", 25)
+ self.dash.ensure_visible()
+ self.addCleanup(self.dash.ensure_hidden)
+
+ dash_max = self.dash.view.dash_maximized
+ if dash_max:
+ self.panel.window_buttons.maximize.mouse_click()
+ else:
+ self.panel.window_buttons.unmaximize.mouse_click()
+
+ self.assertThat(dash_max, Eventually(Equals(self.dash.view.dash_maximized)))
+
def test_window_buttons_show_with_hud(self):
"""Window buttons must be shown when the HUD is open."""
self.hud.ensure_visible()
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index 32559e729..ead1ec981 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -39,6 +39,7 @@ set (UNITY_SHARED_SOURCES
LayoutSystem.cpp
LineSeparator.cpp
OverlayRenderer.cpp
+ OverlayWindowButtons.cpp
PanelStyle.cpp
PlacesVScrollBar.cpp
PlacesOverlayVScrollBar.cpp
diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp
new file mode 100644
index 000000000..3be37af81
--- /dev/null
+++ b/unity-shared/OverlayWindowButtons.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
+ *
+ */
+
+#include "OverlayWindowButtons.h"
+#include "PanelStyle.h"
+#include "UScreen.h"
+
+const int MAIN_LEFT_PADDING = 4;
+const int MENUBAR_PADDING = 4;
+
+namespace unity
+{
+
+OverlayWindowButtons::OverlayWindowButtons()
+ : nux::BaseWindow("OverlayWindowButtons")
+ , window_buttons_(new WindowButtons())
+{
+ UpdateGeometry();
+ SetBackgroundColor(nux::color::Transparent);
+}
+
+void OverlayWindowButtons::UpdateGeometry()
+{
+ int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
+ nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor);
+
+ SetX(geo.x + MAIN_LEFT_PADDING);
+ SetY(geo.y + MENUBAR_PADDING);
+ SetHeight(panel::Style::Instance().panel_height);
+
+ window_buttons_->monitor = monitor;
+}
+
+void OverlayWindowButtons::AboutToShow()
+{
+ UpdateGeometry();
+ ShowWindow(true);
+ PushToFront();
+ QueueDraw();
+}
+
+void OverlayWindowButtons::AboutToHide()
+{
+ ShowWindow(false);
+ PushToBack();
+ QueueDraw();
+}
+
+nux::Area* OverlayWindowButtons::FindAreaUnderMouse(nux::Point const& mouse_position,
+ nux::NuxEventType event_type)
+{
+ return window_buttons_->FindAreaUnderMouse(mouse_position, event_type);
+}
+
+void OverlayWindowButtons::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
+{
+ window_buttons_->ProcessDraw(gfx_context, true);
+}
+
+} // namespace unity
diff --git a/unity-shared/OverlayWindowButtons.h b/unity-shared/OverlayWindowButtons.h
new file mode 100644
index 000000000..6a1901bdc
--- /dev/null
+++ b/unity-shared/OverlayWindowButtons.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
+ *
+ */
+
+#ifndef OVERLAY_WINDOW_BUTTONS
+#define OVERLAY_WINDOW_BUTTONS
+
+#include "Nux/Nux.h"
+#include "Nux/BaseWindow.h"
+
+#include "WindowButtons.h"
+
+namespace unity
+{
+
+class OverlayWindowButtons : public nux::BaseWindow
+{
+public:
+ OverlayWindowButtons();
+
+ void AboutToShow();
+ void AboutToHide();
+
+ nux::Area* FindAreaUnderMouse(nux::Point const& mouse_position,
+ nux::NuxEventType event_type);
+
+protected:
+ void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
+
+private:
+ void UpdateGeometry();
+
+ nux::ObjectPtr<WindowButtons> window_buttons_;
+};
+
+} // namespace unity
+
+#endif // OVERLAY_WINDOW_BUTTONS