summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2014-07-25 01:41:23 +0200
committerAndrea Azzarone <azzaronea@gmail.com>2014-07-25 01:41:23 +0200
commit25fd85b2e3f1e2c1dd91a5c2d75368150e312023 (patch)
tree23c4c3c421a893659fa96bf8e1a3884990dcaaa2 /unity-shared
parent306bc106319317664e11d6d85a0d54978708040b (diff)
Merge lp:~andyrock/unity/fix-lp-1347735.
(bzr r3844.3.1)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/TextInput.cpp32
-rw-r--r--unity-shared/TextInput.h1
2 files changed, 9 insertions, 24 deletions
diff --git a/unity-shared/TextInput.cpp b/unity-shared/TextInput.cpp
index 23a4e3196..0ae601c81 100644
--- a/unity-shared/TextInput.cpp
+++ b/unity-shared/TextInput.cpp
@@ -23,7 +23,7 @@
#include "unity-shared/RawPixel.h"
#include "unity-shared/PreviewStyle.h"
-#include <X11/XKBlib.h>
+//#include <X11/XKBlib.h>
namespace unity
{
@@ -42,9 +42,6 @@ const RawPixel TOOLTIP_Y_OFFSET = 3_em;
const RawPixel TOOLTIP_OFFSET = 10_em;
const RawPixel DEFAULT_ICON_SIZE = 22_em;
-// Caps is on 0x1, couldn't find any #define in /usr/include/X11
-const int CAPS_STATE_ON = 0x1;
-
std::string WARNING_ICON = "dialog-warning-symbolic";
// Fonts
const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu";
@@ -114,7 +111,7 @@ TextInput::TextInput(NUX_FILE_LINE_DECL)
pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE);
pango_entry_->cursor_moved.connect([this](int i) { QueueDraw(); });
pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown));
- pango_entry_->key_up.connect(sigc::mem_fun(this, &TextInput::OnKeyUp));
+ //pango_entry_->key_up.connect(sigc::mem_fun(this, &TextInput::OnKeyUp));
pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus));
pango_entry_->text_changed.connect([this](nux::TextEntry*) {
hint_->SetVisible(input_string().empty());
@@ -155,6 +152,11 @@ TextInput::TextInput(NUX_FILE_LINE_DECL)
"notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged));
OnFontChanged(gtk_settings_get_default());
+ sig_manager_.Add<void, GdkKeymap*, gpointer>(gdk_keymap_get_default(),
+ "state-changed", [this](GdkKeymap*, gpointer){
+ CheckIfCapsLockOn();
+ });
+
input_string.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_input_string));
input_string.SetSetterFunction(sigc::mem_fun(this, &TextInput::set_input_string));
im_active.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_active));
@@ -174,14 +176,8 @@ TextInput::TextInput(NUX_FILE_LINE_DECL)
void TextInput::CheckIfCapsLockOn()
{
- Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
- unsigned int state = 0;
- XkbGetIndicatorState(dpy, XkbUseCoreKbd, &state);
-
- if ((state & CAPS_STATE_ON) == 1)
- caps_lock_on = true;
- else
- caps_lock_on = false;
+ GdkKeymap* keymap = gdk_keymap_get_default();
+ caps_lock_on = gdk_keymap_get_caps_lock_state(keymap) == FALSE ? false : true;
}
void TextInput::SetSpinnerVisible(bool visible)
@@ -418,16 +414,6 @@ void TextInput::UpdateBackground(bool force)
texture2D->UnReference();
}
-void TextInput::OnKeyUp(unsigned keysym,
- unsigned long keycode,
- unsigned long state)
-{
- if (!caps_lock_on && keysym == NUX_VK_CAPITAL)
- caps_lock_on = true;
- else if (caps_lock_on && keysym == NUX_VK_CAPITAL)
- caps_lock_on = false;
-}
-
void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
{
hint_->SetVisible(false);
diff --git a/unity-shared/TextInput.h b/unity-shared/TextInput.h
index 1e708511e..a494997b9 100644
--- a/unity-shared/TextInput.h
+++ b/unity-shared/TextInput.h
@@ -99,7 +99,6 @@ private:
protected:
void OnInputHintChanged();
void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
- void OnKeyUp(unsigned keysym, unsigned long keycode, unsigned long state);
void OnEndKeyFocus();
// getters & setters