summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CMakeLists.txt1
-rw-r--r--unity-shared/EMConverter.cpp4
-rw-r--r--unity-shared/EMConverter.h4
-rw-r--r--unity-shared/OverlayWindowButtons.cpp8
-rw-r--r--unity-shared/OverlayWindowButtons.h2
-rw-r--r--unity-shared/RawPixel.cpp50
-rw-r--r--unity-shared/RawPixel.h48
-rw-r--r--unity-shared/UScreen.cpp11
-rw-r--r--unity-shared/UScreen.h2
9 files changed, 126 insertions, 4 deletions
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index 27ed8abc0..51fc3e7bc 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -50,6 +50,7 @@ set (UNITY_SHARED_SOURCES
PlacesOverlayVScrollBar.cpp
PreviewStyle.cpp
RatingsButton.cpp
+ RawPixel.cpp
ResizingBaseWindow.cpp
SearchBar.cpp
SearchBarSpinner.cpp
diff --git a/unity-shared/EMConverter.cpp b/unity-shared/EMConverter.cpp
index 42d50449a..e873729e0 100644
--- a/unity-shared/EMConverter.cpp
+++ b/unity-shared/EMConverter.cpp
@@ -86,7 +86,7 @@ double EMConverter::GetDPI() const
return dpi_;
}
-int EMConverter::EMToPixels(double em) const
+double EMConverter::EMToPixels(double em) const
{
return (em * pixels_per_em_);
}
@@ -96,7 +96,7 @@ double EMConverter::PixelsToBaseEM(int pixels) const
return (pixels / base_pixels_per_em_);
}
-int EMConverter::ConvertPixels(int pixels) const
+double EMConverter::ConvertPixels(int pixels) const
{
double pixels_em = PixelsToBaseEM(pixels);
return EMToPixels(pixels_em);
diff --git a/unity-shared/EMConverter.h b/unity-shared/EMConverter.h
index 0c5bc1b06..3231b028f 100644
--- a/unity-shared/EMConverter.h
+++ b/unity-shared/EMConverter.h
@@ -34,7 +34,7 @@ public:
int GetFontSize() const;
double GetDPI() const;
- int ConvertPixels(int pixels) const;
+ double ConvertPixels(int pixels) const;
double DPIScale() const;
double PtToPx(int pt);
@@ -43,7 +43,7 @@ private:
void UpdatePixelsPerEM();
void UpdateBasePixelsPerEM();
- int EMToPixels(double em) const;
+ double EMToPixels(double em) const;
double PixelsToBaseEM(int pixels) const;
double pixels_per_em_;
diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp
index 97616548e..8363a77b9 100644
--- a/unity-shared/OverlayWindowButtons.cpp
+++ b/unity-shared/OverlayWindowButtons.cpp
@@ -45,6 +45,14 @@ OverlayWindowButtons::OverlayWindowButtons()
SetBackgroundColor(nux::color::Transparent);
}
+bool OverlayWindowButtons::IsVisibleOnMonitor(unsigned int monitor) const
+{
+ if (window_buttons_->monitor == monitor)
+ return true;
+
+ return false;
+}
+
void OverlayWindowButtons::UpdateGeometry()
{
int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
diff --git a/unity-shared/OverlayWindowButtons.h b/unity-shared/OverlayWindowButtons.h
index 6035283fb..5c0666bc2 100644
--- a/unity-shared/OverlayWindowButtons.h
+++ b/unity-shared/OverlayWindowButtons.h
@@ -40,6 +40,8 @@ public:
nux::Area* FindAreaUnderMouse(nux::Point const& mouse_position,
nux::NuxEventType event_type);
+ bool IsVisibleOnMonitor(unsigned int monitor) const;
+
protected:
void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
diff --git a/unity-shared/RawPixel.cpp b/unity-shared/RawPixel.cpp
new file mode 100644
index 000000000..a267eaf9f
--- /dev/null
+++ b/unity-shared/RawPixel.cpp
@@ -0,0 +1,50 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2014 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 "RawPixel.h"
+
+namespace unity
+{
+
+RawPixel operator"" _em(long double pixel)
+{
+ return RawPixel(pixel);
+}
+
+RawPixel operator"" _em(unsigned long long pixel)
+{
+ return RawPixel(pixel);
+}
+
+RawPixel::RawPixel(float raw_pixel)
+ : raw_pixel_(raw_pixel)
+{
+}
+
+float RawPixel::CP(EMConverter const& converter) const
+{
+ return converter.ConvertPixels(raw_pixel_);
+}
+
+RawPixel::operator float() const
+{
+ return raw_pixel_;
+}
+
+} // namesapce unity
diff --git a/unity-shared/RawPixel.h b/unity-shared/RawPixel.h
new file mode 100644
index 000000000..77de270f8
--- /dev/null
+++ b/unity-shared/RawPixel.h
@@ -0,0 +1,48 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2014 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 RAW_PIXEL_H
+#define RAW_PIXEL_H
+
+#include "EMConverter.h"
+
+namespace unity
+{
+
+class RawPixel
+{
+public:
+ RawPixel(float raw_pixel);
+
+ float CP(EMConverter const& converter) const;
+
+ operator float() const;
+
+private:
+ float raw_pixel_;
+
+};
+
+// User-Defined Literals (ex: 10_em, 10.0_em)
+RawPixel operator"" _em(long double pixel);
+RawPixel operator"" _em(unsigned long long pixel);
+
+} // namespace unity
+
+#endif // RAW_PIXEL_H
diff --git a/unity-shared/UScreen.cpp b/unity-shared/UScreen.cpp
index 869383824..c93f290f1 100644
--- a/unity-shared/UScreen.cpp
+++ b/unity-shared/UScreen.cpp
@@ -96,6 +96,17 @@ nux::Geometry UScreen::GetScreenGeometry()
return nux::Geometry(0, 0, width, height);
}
+const std::string UScreen::GetMonitorName(int output_number) const
+{
+ auto const &output_name = glib::gchar_to_string(gdk_screen_get_monitor_plug_name(screen_, output_number));
+ if (output_name.empty())
+ {
+ LOG_ERROR(logger) << "Failed to get monitor name";
+ }
+
+ return output_name;
+}
+
void UScreen::Changed(GdkScreen* screen)
{
if (refresh_idle_)
diff --git a/unity-shared/UScreen.h b/unity-shared/UScreen.h
index ff33d8e0a..fa31f7656 100644
--- a/unity-shared/UScreen.h
+++ b/unity-shared/UScreen.h
@@ -52,6 +52,8 @@ public:
sigc::signal<void, int, std::vector<nux::Geometry>&> changed;
sigc::signal<void> resuming;
+ const std::string GetMonitorName(int output_number) const;
+
private:
void Changed(GdkScreen* screen);
void Refresh();