Merge lp:~azzar1/unity/fix-lp-1347735 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3849
Proposed branch: lp:~azzar1/unity/fix-lp-1347735
Merge into: lp:unity
Diff against target: 87 lines (+6/-25)
2 files modified
unity-shared/TextInput.cpp (+6/-24)
unity-shared/TextInput.h (+0/-1)
To merge this branch: bzr merge lp:~azzar1/unity/fix-lp-1347735
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+228219@code.launchpad.net

Commit message

== Problem ==
Lockscreen capslock detection doesn't work well with remapped capslocks

== Fix ==
Use gdk keymap to get the state of the caps lock.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Fine, just fix that small thing I diff-commented.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Fine, just fix that small thing I diff-commented.

Fixed!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/TextInput.cpp'
2--- unity-shared/TextInput.cpp 2014-04-23 16:49:25 +0000
3+++ unity-shared/TextInput.cpp 2014-07-28 17:57:07 +0000
4@@ -23,8 +23,6 @@
5 #include "unity-shared/RawPixel.h"
6 #include "unity-shared/PreviewStyle.h"
7
8-#include <X11/XKBlib.h>
9-
10 namespace unity
11 {
12
13@@ -42,9 +40,6 @@
14 const RawPixel TOOLTIP_OFFSET = 10_em;
15 const RawPixel DEFAULT_ICON_SIZE = 22_em;
16
17-// Caps is on 0x1, couldn't find any #define in /usr/include/X11
18-const int CAPS_STATE_ON = 0x1;
19-
20 std::string WARNING_ICON = "dialog-warning-symbolic";
21 // Fonts
22 const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu";
23@@ -114,7 +109,6 @@
24 pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE);
25 pango_entry_->cursor_moved.connect([this](int i) { QueueDraw(); });
26 pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown));
27- pango_entry_->key_up.connect(sigc::mem_fun(this, &TextInput::OnKeyUp));
28 pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus));
29 pango_entry_->text_changed.connect([this](nux::TextEntry*) {
30 hint_->SetVisible(input_string().empty());
31@@ -155,6 +149,10 @@
32 "notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged));
33 OnFontChanged(gtk_settings_get_default());
34
35+ sig_manager_.Add<void, GdkKeymap*>(gdk_keymap_get_default(), "state-changed", [this](GdkKeymap*) {
36+ CheckIfCapsLockOn();
37+ });
38+
39 input_string.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_input_string));
40 input_string.SetSetterFunction(sigc::mem_fun(this, &TextInput::set_input_string));
41 im_active.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_active));
42@@ -174,14 +172,8 @@
43
44 void TextInput::CheckIfCapsLockOn()
45 {
46- Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
47- unsigned int state = 0;
48- XkbGetIndicatorState(dpy, XkbUseCoreKbd, &state);
49-
50- if ((state & CAPS_STATE_ON) == 1)
51- caps_lock_on = true;
52- else
53- caps_lock_on = false;
54+ GdkKeymap* keymap = gdk_keymap_get_default();
55+ caps_lock_on = gdk_keymap_get_caps_lock_state(keymap) == FALSE ? false : true;
56 }
57
58 void TextInput::SetSpinnerVisible(bool visible)
59@@ -418,16 +410,6 @@
60 texture2D->UnReference();
61 }
62
63-void TextInput::OnKeyUp(unsigned keysym,
64- unsigned long keycode,
65- unsigned long state)
66-{
67- if (!caps_lock_on && keysym == NUX_VK_CAPITAL)
68- caps_lock_on = true;
69- else if (caps_lock_on && keysym == NUX_VK_CAPITAL)
70- caps_lock_on = false;
71-}
72-
73 void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
74 {
75 hint_->SetVisible(false);
76
77=== modified file 'unity-shared/TextInput.h'
78--- unity-shared/TextInput.h 2014-04-23 16:49:25 +0000
79+++ unity-shared/TextInput.h 2014-07-28 17:57:07 +0000
80@@ -99,7 +99,6 @@
81 protected:
82 void OnInputHintChanged();
83 void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
84- void OnKeyUp(unsigned keysym, unsigned long keycode, unsigned long state);
85 void OnEndKeyFocus();
86
87 // getters & setters