From 8574ceec3bd0b972c28cb4acf98ae560837f94aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 6 Jul 2012 00:41:26 +0200 Subject: KeyboardUtil: fix possible crash if XkbGetKeyboard returns null Also use initializer list (bzr r2470.13.1) --- unity-shared/KeyboardUtil.cpp | 17 +++++++++++------ unity-shared/KeyboardUtil.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/KeyboardUtil.cpp b/unity-shared/KeyboardUtil.cpp index b65fbc15a..97f1f6fce 100644 --- a/unity-shared/KeyboardUtil.cpp +++ b/unity-shared/KeyboardUtil.cpp @@ -25,17 +25,18 @@ namespace unity { namespace ui { +namespace { + const unsigned int FETCH_MAKS = XkbGBN_KeyNamesMask | XkbGBN_ClientSymbolsMask | XkbGBN_GeometryMask; +} KeyboardUtil::KeyboardUtil(Display *display) : display_(display) -{ - unsigned int fetch_mask = XkbGBN_KeyNamesMask | XkbGBN_ClientSymbolsMask | XkbGBN_GeometryMask; - keyboard_ = XkbGetKeyboard (display, fetch_mask, XkbUseCoreKbd); -} + , keyboard_(XkbGetKeyboard(display_, FETCH_MAKS, XkbUseCoreKbd)) +{} KeyboardUtil::~KeyboardUtil() { - XkbFreeKeyboard (keyboard_, 0, True); + XkbFreeKeyboard(keyboard_, 0, True); } bool KeyboardUtil::FindKeyInGeometry(XkbGeometryPtr geo, char *key_name, int& res_section, XkbBoundsRec& res_bounds) const @@ -86,6 +87,9 @@ bool KeyboardUtil::CompareOffsets(int current_x, int current_y, int best_x, int guint KeyboardUtil::ConvertKeyToKeycode(XkbKeyPtr key) const { + if (!keyboard_) + return; + int min_code = keyboard_->min_key_code; int max_code = keyboard_->max_key_code; @@ -94,6 +98,7 @@ guint KeyboardUtil::ConvertKeyToKeycode(XkbKeyPtr key) const if (!strncmp(key->name.name, keyboard_->names->keys[i].name, XkbKeyNameLength)) return i; } + return 0; } @@ -186,7 +191,7 @@ guint KeyboardUtil::GetKeycodeAboveKeySymbol(KeySym key_symbol) const int code = XKeysymToKeycode(display_, key_symbol); - if (!code) + if (!code || !keyboard_) return result; if (keyboard_->min_key_code > code || keyboard_->max_key_code < code) diff --git a/unity-shared/KeyboardUtil.h b/unity-shared/KeyboardUtil.h index 0df116299..b5ee98146 100644 --- a/unity-shared/KeyboardUtil.h +++ b/unity-shared/KeyboardUtil.h @@ -51,8 +51,8 @@ private: XkbBoundsRec GetAbsoluteKeyBounds (XkbKeyPtr key, XkbRowPtr row, XkbSectionPtr section, XkbGeometryPtr geo) const; - XkbDescPtr keyboard_; Display *display_; + XkbDescPtr keyboard_; }; } -- cgit v1.2.3 From 79f0aef3214a4197d7a01b41b16ba4518b7c516e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 6 Jul 2012 00:54:34 +0200 Subject: KeyboardUtil: oops fix return value. (bzr r2470.13.2) --- unity-shared/KeyboardUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/KeyboardUtil.cpp b/unity-shared/KeyboardUtil.cpp index 97f1f6fce..a3c791215 100644 --- a/unity-shared/KeyboardUtil.cpp +++ b/unity-shared/KeyboardUtil.cpp @@ -88,7 +88,7 @@ bool KeyboardUtil::CompareOffsets(int current_x, int current_y, int best_x, int guint KeyboardUtil::ConvertKeyToKeycode(XkbKeyPtr key) const { if (!keyboard_) - return; + return 0; int min_code = keyboard_->min_key_code; int max_code = keyboard_->max_key_code; -- cgit v1.2.3 From 5d99a3261cf3048b0fd3e660fa46d3430069b13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 6 Jul 2012 00:58:33 +0200 Subject: KeyboardUtil: fixed typo (bzr r2470.13.3) --- unity-shared/KeyboardUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/KeyboardUtil.cpp b/unity-shared/KeyboardUtil.cpp index a3c791215..90806d5e0 100644 --- a/unity-shared/KeyboardUtil.cpp +++ b/unity-shared/KeyboardUtil.cpp @@ -26,12 +26,12 @@ namespace unity { namespace ui { namespace { - const unsigned int FETCH_MAKS = XkbGBN_KeyNamesMask | XkbGBN_ClientSymbolsMask | XkbGBN_GeometryMask; + const unsigned int FETCH_MASK = XkbGBN_KeyNamesMask | XkbGBN_ClientSymbolsMask | XkbGBN_GeometryMask; } KeyboardUtil::KeyboardUtil(Display *display) : display_(display) - , keyboard_(XkbGetKeyboard(display_, FETCH_MAKS, XkbUseCoreKbd)) + , keyboard_(XkbGetKeyboard(display_, FETCH_MASK, XkbUseCoreKbd)) {} KeyboardUtil::~KeyboardUtil() -- cgit v1.2.3 From e8d50da9421c20d65b070891703bde69d043cd30 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Mon, 23 Jul 2012 11:09:02 +1200 Subject: Make sure that weight is always set. (bzr r2501.4.3) --- unity-shared/DashStyle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DashStyle.cpp b/unity-shared/DashStyle.cpp index 4fbb32ff2..789659139 100644 --- a/unity-shared/DashStyle.cpp +++ b/unity-shared/DashStyle.cpp @@ -1359,10 +1359,6 @@ void Style::Impl::Text(cairo_t* cr, PangoWeight weight; switch (regular_text_weight_) { - case FontWeight::REGULAR: - weight = PANGO_WEIGHT_NORMAL; - break; - case FontWeight::LIGHT: weight = PANGO_WEIGHT_LIGHT; break; @@ -1370,6 +1366,10 @@ void Style::Impl::Text(cairo_t* cr, case FontWeight::BOLD: weight = PANGO_WEIGHT_BOLD; break; + + case FontWeight::REGULAR: + default: + weight = PANGO_WEIGHT_NORMAL; } pango_font_description_set_weight(desc, weight); -- cgit v1.2.3 From 0eb705edcec2eb49d22bc06b5caf4efa538180be Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Mon, 23 Jul 2012 11:12:28 +1200 Subject: Initialize some colors. (bzr r2501.4.4) --- unity-shared/IconRenderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp index 7e87f9425..f8bbbba66 100644 --- a/unity-shared/IconRenderer.cpp +++ b/unity-shared/IconRenderer.cpp @@ -760,9 +760,9 @@ void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext, int TextureObjectLocation; int VertexLocation; int TextureCoord0Location; - int FragmentColor; - int ColorifyColor; - int DesatFactor; + int FragmentColor = 0; + int ColorifyColor = 0; + int DesatFactor = 0; if (nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath()) { -- cgit v1.2.3 From 206ab98e51910ced28ee2fbc8fc8032111afc75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 24 Jul 2012 03:07:58 +0200 Subject: UScreen: make the default screen a static member, so that we can mock it (bzr r2509.2.2) --- unity-shared/UScreen.cpp | 7 ++++--- unity-shared/UScreen.h | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/UScreen.cpp b/unity-shared/UScreen.cpp index e33508e30..3b643382d 100644 --- a/unity-shared/UScreen.cpp +++ b/unity-shared/UScreen.cpp @@ -24,17 +24,18 @@ namespace unity namespace { -static UScreen* default_screen_ = nullptr; nux::logging::Logger logger("unity.screen"); } +UScreen* UScreen::default_screen_ = nullptr; + UScreen::UScreen() - : screen_(gdk_screen_get_default(), glib::AddRef()) + : primary_(0) + , screen_(gdk_screen_get_default(), glib::AddRef()) , proxy_("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", G_BUS_TYPE_SYSTEM) - , primary_(0) { size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed)); monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed)); diff --git a/unity-shared/UScreen.h b/unity-shared/UScreen.h index 3e44dfeea..f66e07d7a 100644 --- a/unity-shared/UScreen.h +++ b/unity-shared/UScreen.h @@ -55,14 +55,17 @@ private: void Changed(GdkScreen* screen); void Refresh(); -private: +protected: + static UScreen* default_screen_; std::vector monitors_; + int primary_; + +private: glib::Object screen_; glib::DBusProxy proxy_; glib::Signal size_changed_signal_; glib::Signal monitors_changed_signal_; glib::Source::UniquePtr refresh_idle_; - int primary_; }; } // Namespace -- cgit v1.2.3