Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: chromeos/ime/ime_keyboard_x11.h

Issue 693733002: Adds ozone support for ime keyboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/ime/ime_keyboard_ozone.cc ('k') | chromeos/ime/ime_keyboard_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_IME_IME_KEYBOARD_X11_H_
6 #define CHROMEOS_IME_IME_KEYBOARD_X11_H_
5 7
6 #include "chromeos/ime/ime_keyboard.h" 8 #include "chromeos/ime/ime_keyboard.h"
7 9
8 #include <cstdlib> 10 #include <cstdlib>
9 #include <cstring> 11 #include <cstring>
10 #include <queue> 12 #include <queue>
11 #include <set> 13 #include <set>
12 #include <utility> 14 #include <utility>
13 15
14 #include "base/bind.h" 16 #include "base/bind.h"
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
18 #include "base/process/kill.h" 20 #include "base/process/kill.h"
19 #include "base/process/launch.h" 21 #include "base/process/launch.h"
20 #include "base/process/process_handle.h" 22 #include "base/process/process_handle.h"
21 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
23 #include "base/sys_info.h" 25 #include "base/sys_info.h"
24 #include "base/threading/thread_checker.h" 26 #include "base/threading/thread_checker.h"
25 #include "ui/gfx/x/x11_types.h" 27 #include "ui/gfx/x/x11_types.h"
26 28
27 // These includes conflict with base/tracked_objects.h so must come last. 29 // These includes conflict with base/tracked_objects.h so must come last.
28 #include <X11/XKBlib.h> 30 #include <X11/XKBlib.h>
29 #include <X11/Xlib.h> 31 #include <X11/Xlib.h>
30 32
31 33
32 namespace chromeos { 34 namespace chromeos {
33 namespace input_method { 35 namespace input_method {
34 namespace {
35 36
36 class ImeKeyboardX11 : public ImeKeyboard { 37 class CHROMEOS_EXPORT ImeKeyboardX11 : public ImeKeyboard {
37 public: 38 public:
38 ImeKeyboardX11(); 39 ImeKeyboardX11();
39 virtual ~ImeKeyboardX11(); 40 virtual ~ImeKeyboardX11();
40 41
41 // Adds/removes observer.
42 virtual void AddObserver(Observer* observer) override;
43 virtual void RemoveObserver(Observer* observer) override;
44
45 // ImeKeyboard: 42 // ImeKeyboard:
46 virtual bool SetCurrentKeyboardLayoutByName( 43 virtual bool SetCurrentKeyboardLayoutByName(
47 const std::string& layout_name) override; 44 const std::string& layout_name) override;
48 virtual bool ReapplyCurrentKeyboardLayout() override; 45 virtual bool ReapplyCurrentKeyboardLayout() override;
49 virtual void ReapplyCurrentModifierLockStatus() override; 46 virtual void ReapplyCurrentModifierLockStatus() override;
50 virtual void DisableNumLock() override; 47 virtual void DisableNumLock() override;
51 virtual void SetCapsLockEnabled(bool enable_caps_lock) override; 48 virtual void SetCapsLockEnabled(bool enable_caps_lock) override;
52 virtual bool CapsLockIsEnabled() override; 49 virtual bool CapsLockIsEnabled() override;
53 virtual bool IsISOLevel5ShiftAvailable() const override;
54 virtual bool IsAltGrAvailable() const override;
55 virtual bool SetAutoRepeatEnabled(bool enabled) override; 50 virtual bool SetAutoRepeatEnabled(bool enabled) override;
56 virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) override; 51 virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) override;
57 52
58 private: 53 private:
59 // Returns a mask for Num Lock (e.g. 1U << 4). Returns 0 on error. 54 // Returns a mask for Num Lock (e.g. 1U << 4). Returns 0 on error.
60 unsigned int GetNumLockMask(); 55 unsigned int GetNumLockMask();
61 56
62 // Sets the caps-lock status. Note that calling this function always disables 57 // Sets the caps-lock status. Note that calling this function always disables
63 // the num-lock. 58 // the num-lock.
64 void SetLockedModifiers(bool caps_lock_enabled); 59 void SetLockedModifiers();
65 60
66 // This function is used by SetLayout() and RemapModifierKeys(). Calls 61 // This function is used by SetLayout() and RemapModifierKeys(). Calls
67 // setxkbmap command if needed, and updates the last_full_layout_name_ cache. 62 // setxkbmap command if needed, and updates the last_full_layout_name_ cache.
68 bool SetLayoutInternal(const std::string& layout_name, bool force); 63 bool SetLayoutInternal(const std::string& layout_name, bool force);
69 64
70 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name 65 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name
71 // in the |execute_queue_|. Do nothing if the queue is empty. 66 // in the |execute_queue_|. Do nothing if the queue is empty.
72 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) 67 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105)
73 void MaybeExecuteSetLayoutCommand(); 68 void MaybeExecuteSetLayoutCommand();
74 69
75 // Polls to see setxkbmap process exits. 70 // Polls to see setxkbmap process exits.
76 void PollUntilChildFinish(const base::ProcessHandle handle); 71 void PollUntilChildFinish(const base::ProcessHandle handle);
77 72
78 // Called when execve'd setxkbmap process exits. 73 // Called when execve'd setxkbmap process exits.
79 void OnSetLayoutFinish(); 74 void OnSetLayoutFinish();
80 75
81 const bool is_running_on_chrome_os_; 76 const bool is_running_on_chrome_os_;
82 unsigned int num_lock_mask_; 77 unsigned int num_lock_mask_;
83 78
84 // The current Caps Lock status. If true, enabled.
85 bool current_caps_lock_status_;
86
87 // The XKB layout name which we set last time like "us" and "us(dvorak)".
88 std::string current_layout_name_;
89
90 // A queue for executing setxkbmap one by one. 79 // A queue for executing setxkbmap one by one.
91 std::queue<std::string> execute_queue_; 80 std::queue<std::string> execute_queue_;
92 81
93 base::ThreadChecker thread_checker_; 82 base::ThreadChecker thread_checker_;
94 83
95 base::WeakPtrFactory<ImeKeyboardX11> weak_factory_; 84 base::WeakPtrFactory<ImeKeyboardX11> weak_factory_;
96 85
97 ObserverList<Observer> observers_;
98
99 DISALLOW_COPY_AND_ASSIGN(ImeKeyboardX11); 86 DISALLOW_COPY_AND_ASSIGN(ImeKeyboardX11);
100 }; 87 };
101 88
102 89
103 } // namespace
104
105 } // namespace input_method 90 } // namespace input_method
106 } // namespace chromeos 91 } // namespace chromeos
107 92
93 #endif // CHROMEOS_IME_IME_KEYBOARD_X11_H_
OLDNEW
« no previous file with comments | « chromeos/ime/ime_keyboard_ozone.cc ('k') | chromeos/ime/ime_keyboard_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698