Merge lp:~robert-ancell/unity-system-compositor/vt-switch into lp:unity-system-compositor

Proposed by Robert Ancell
Status: Rejected
Rejected by: Robert Ancell
Proposed branch: lp:~robert-ancell/unity-system-compositor/vt-switch
Merge into: lp:unity-system-compositor
Diff against target: 152 lines (+88/-16)
2 files modified
debian/10-unity-system-compositor.conf (+1/-1)
src/system_compositor.cpp (+87/-15)
To merge this branch: bzr merge lp:~robert-ancell/unity-system-compositor/vt-switch
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+178072@code.launchpad.net

Commit message

Re-enable input and have global keys for VT switching

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
40. By Robert Ancell

Merge with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Unmerged revisions

40. By Robert Ancell

Merge with trunk

39. By Robert Ancell

Re-enable input and have global keys for VT switching

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/10-unity-system-compositor.conf'
2--- debian/10-unity-system-compositor.conf 2013-07-24 12:44:50 +0000
3+++ debian/10-unity-system-compositor.conf 2013-08-01 14:34:30 +0000
4@@ -1,3 +1,3 @@
5 [SeatDefaults]
6 type=unity
7-unity-compositor-command=unity-system-compositor.sleep --enable-input=false
8+unity-compositor-command=unity-system-compositor.sleep
9
10=== modified file 'src/system_compositor.cpp'
11--- src/system_compositor.cpp 2013-07-10 17:16:32 +0000
12+++ src/system_compositor.cpp 2013-08-01 14:34:30 +0000
13@@ -19,6 +19,7 @@
14 #include "system_compositor.h"
15
16 #include <mir/run_mir.h>
17+#include <mir/input/event_filter.h>
18 #include <mir/shell/session.h>
19 #include <mir/shell/session_container.h>
20 #include <mir/shell/focus_setter.h>
21@@ -26,25 +27,104 @@
22
23 #include <iostream>
24 #include <thread>
25+#include <linux/input.h>
26+#include <linux/vt.h>
27+#include <sys/ioctl.h>
28+#include <fcntl.h>
29
30+namespace mi = mir::input;
31 namespace msh = mir::shell;
32 namespace mi = mir::input;
33
34+struct VTFilter : public mi::EventFilter
35+{
36+ bool handle(MirEvent const& event) override
37+ {
38+ if (event.type == mir_event_type_key &&
39+ event.key.action == mir_key_action_down &&
40+ (event.key.modifiers & mir_key_modifier_alt) &&
41+ (event.key.modifiers & mir_key_modifier_ctrl))
42+ {
43+ switch (event.key.scan_code)
44+ {
45+ case KEY_F1:
46+ set_active_vt(1);
47+ return true;
48+ case KEY_F2:
49+ set_active_vt(2);
50+ return true;
51+ case KEY_F3:
52+ set_active_vt(3);
53+ return true;
54+ case KEY_F4:
55+ set_active_vt(4);
56+ return true;
57+ case KEY_F5:
58+ set_active_vt(5);
59+ return true;
60+ case KEY_F6:
61+ set_active_vt(6);
62+ return true;
63+ case KEY_F7:
64+ set_active_vt(7);
65+ return true;
66+ case KEY_F8:
67+ set_active_vt(8);
68+ return true;
69+ case KEY_F9:
70+ set_active_vt(9);
71+ return true;
72+ }
73+ }
74+
75+ return false;
76+ }
77+
78+private:
79+ void set_active_vt(int vt)
80+ {
81+ int console_fd;
82+
83+ console_fd = open("/dev/console", O_RDONLY | O_NDELAY);
84+ ioctl(console_fd, VT_ACTIVATE, vt);
85+ close(console_fd);
86+ }
87+};
88+
89+
90 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
91 {
92 public:
93 SystemCompositorServerConfiguration(int argc, char const** argv)
94- : mir::DefaultServerConfiguration(argc, argv)
95+ : mir::DefaultServerConfiguration(argc, argv),
96+ vt_filter(std::make_shared<VTFilter>())
97 {
98 namespace po = boost::program_options;
99
100 add_options()
101 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
102 ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]");
103- add_options()
104+ add_options()
105 ("version", "Show version of Unity System Compositor");
106 }
107
108+ std::shared_ptr<mi::CursorListener> the_cursor_listener() override
109+ {
110+ struct NullCursorListener : public mi::CursorListener
111+ {
112+ void cursor_moved_to(float, float) override
113+ {
114+ }
115+ };
116+ return std::make_shared<NullCursorListener>();
117+ }
118+
119+ std::initializer_list<std::shared_ptr<mi::EventFilter> const> the_event_filters() override
120+ {
121+ static std::initializer_list<std::shared_ptr<mi::EventFilter> const> filter_list = { vt_filter };
122+ return filter_list;
123+ }
124+
125 int from_dm_fd()
126 {
127 return the_options()->get("from-dm-fd", -1);
128@@ -57,19 +137,11 @@
129
130 bool show_version()
131 {
132- return the_options()->is_set ("version");
133- }
134-
135- std::shared_ptr<mi::CursorListener> the_cursor_listener() override
136- {
137- struct NullCursorListener : public mi::CursorListener
138- {
139- void cursor_moved_to(float, float) override
140- {
141- }
142- };
143- return std::make_shared<NullCursorListener>();
144- }
145+ return the_options()->is_set("version");
146+ }
147+
148+private:
149+ std::shared_ptr<VTFilter> const vt_filter;
150 };
151
152 void SystemCompositor::run(int argc, char const** argv)

Subscribers

People subscribed via source and target branches