mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:57:34 +00:00
Keymap+WindowServer: Add context menu to keymap applet
Adding a context menu which lists configured keymaps and allows setting the active keymap
This commit is contained in:
parent
db11cfa2c5
commit
9906f41e01
11 changed files with 126 additions and 27 deletions
|
@ -53,7 +53,7 @@ void KeymapSwitcher::refresh()
|
|||
on_keymap_change(current_keymap);
|
||||
|
||||
if (m_keymaps.find(current_keymap).is_end()) {
|
||||
setkeymap(m_keymaps.first());
|
||||
set_keymap(m_keymaps.first());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ void KeymapSwitcher::next_keymap()
|
|||
if (it.is_end()) {
|
||||
auto first_keymap = m_keymaps.first();
|
||||
dbgln("Cannot find current keymap in the keymap list - setting first available ({})", first_keymap);
|
||||
setkeymap(first_keymap);
|
||||
set_keymap(first_keymap);
|
||||
} else {
|
||||
it++;
|
||||
|
||||
|
@ -84,7 +84,7 @@ void KeymapSwitcher::next_keymap()
|
|||
}
|
||||
|
||||
dbgln("Setting system keymap to: {}", *it);
|
||||
setkeymap(*it);
|
||||
set_keymap(*it);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ String KeymapSwitcher::get_current_keymap() const
|
|||
return keymap_object.get("keymap"sv).to_string();
|
||||
}
|
||||
|
||||
void KeymapSwitcher::setkeymap(const AK::String& keymap)
|
||||
void KeymapSwitcher::set_keymap(const AK::String& keymap)
|
||||
{
|
||||
if (Core::Process::spawn("/bin/keymap"sv, Array { "-m", keymap.characters() }).is_error())
|
||||
dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno));
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
|
||||
String get_current_keymap() const;
|
||||
|
||||
void set_keymap(AK::String const&);
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
|
@ -34,8 +36,6 @@ private:
|
|||
|
||||
Vector<AK::String> m_keymaps;
|
||||
|
||||
void setkeymap(AK::String const&);
|
||||
|
||||
RefPtr<Core::FileWatcher> m_file_watcher;
|
||||
|
||||
char const* m_keyboard_config = "/etc/Keyboard.ini";
|
||||
|
|
|
@ -183,4 +183,9 @@ void WMConnectionFromClient::set_window_taskbar_rect(i32 client_id, i32 window_i
|
|||
window.set_taskbar_rect(rect);
|
||||
}
|
||||
|
||||
void WMConnectionFromClient::set_keymap(String const& keymap)
|
||||
{
|
||||
WindowManager::the().keymap_switcher()->set_keymap(keymap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
virtual void set_event_mask(u32) override;
|
||||
virtual void set_manager_window(i32) override;
|
||||
virtual void set_workspace(u32, u32) override;
|
||||
virtual void set_keymap(String const&) override;
|
||||
|
||||
unsigned event_mask() const { return m_event_mask; }
|
||||
int window_id() const { return m_window_id; }
|
||||
|
|
|
@ -336,6 +336,8 @@ public:
|
|||
|
||||
bool is_cursor_highlight_enabled() const { return m_cursor_highlight_radius > 0 && m_cursor_highlight_enabled; }
|
||||
|
||||
RefPtr<KeymapSwitcher> keymap_switcher() { return m_keymap_switcher; }
|
||||
|
||||
private:
|
||||
explicit WindowManager(Gfx::PaletteImpl const&);
|
||||
|
||||
|
|
|
@ -13,4 +13,5 @@ endpoint WindowManagerServer
|
|||
set_window_taskbar_rect(i32 client_id, i32 window_id, Gfx::IntRect rect) =|
|
||||
set_applet_area_position(Gfx::IntPoint position) =|
|
||||
set_workspace(u32 row, u32 column) =|
|
||||
set_keymap([UTF8] String keymap) =|
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue