Rev 1647 | Rev 1660 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1647 | Rev 1652 | ||
|---|---|---|---|
| Line 18... | Line 18... | ||
| 18 | * |
18 | * |
| 19 | */ |
19 | */ |
| 20 | 20 | ||
| 21 | #include "Xorg.h" |
21 | #include "Xorg.h" |
| 22 | 22 | ||
| - | 23 | #ifdef USE_PLUGIN_XORG |
|
| - | 24 | ||
| 23 | #include <boost/lexical_cast.hpp> |
25 | #include <boost/lexical_cast.hpp> |
| 24 | 26 | ||
| 25 | #include <X11/Xlib.h> |
27 | #include <X11/Xlib.h> |
| 26 | 28 | ||
| 27 | #include "vm/Manager.h" |
29 | #include "vm/Manager.h" |
| 28 | 30 | ||
| 29 | namespace atom { |
31 | namespace atom { |
| 30 | namespace vm { |
32 | namespace vm { |
| 31 | namespace plugin { |
33 | namespace plugin { |
| 32 | 34 | ||
| 33 | logging::Logger Xorg::LOG("vm::plugin::xorg"); |
35 | logging::Logger Xorg::LOG("vm::plugin::xorg"); |
| 34 | 36 | ||
| 35 | Xorg::Xorg(boost::asio::io_service& io_service) : Plugin(io_service) |
37 | Xorg::Xorg(boost::asio::io_service& io_service) : Plugin(io_service) |
| 36 | { |
38 | { |
| 37 | this->name_ = "xorg"; |
39 | this->name_ = "xorg"; |
| 38 | 40 | ||
| 39 | this->ExportFunction("XorgExport_SendKey", Xorg::Export_SendKey); |
41 | this->ExportFunction("XorgExport_SendKey", Xorg::Export_SendKey); |
| Line 52... | Line 54... | ||
| 52 | { |
54 | { |
| 53 | LOG.Info(output); |
55 | LOG.Info(output); |
| 54 | } |
56 | } |
| 55 | 57 | ||
| 56 | Value Xorg::Export_SendKey(const v8::Arguments& args) |
58 | Value Xorg::Export_SendKey(const v8::Arguments& args) |
| 57 | { |
59 | { |
| 58 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
60 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 59 | 61 | ||
| 60 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
62 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 61 | 63 | ||
| 62 | if (args.Length() < 1) |
64 | if (args.Length() < 1) |
| 63 | { |
65 | { |
| 64 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
66 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 65 | return v8::Boolean::New(false); |
67 | return v8::Boolean::New(false); |
| 66 | } |
68 | } |
| 67 | 69 | ||
| 68 | Display* display = XOpenDisplay(":0"); |
70 | Display* display = XOpenDisplay(":0"); |
| 69 | 71 | ||
| 70 | if (display == NULL) |
72 | if (display == NULL) |
| 71 | { |
73 | { |
| 72 | LOG.Warning("Could not locate display :0"); |
74 | LOG.Warning("Could not locate display :0"); |
| 73 | return v8::Boolean::New(false); |
75 | return v8::Boolean::New(false); |
| 74 | } |
76 | } |
| Line 99... | Line 101... | ||
| 99 | 101 | ||
| 100 | LOG.Debug("Sent code " + boost::lexical_cast<std::string>(args[0]->Int32Value())); |
102 | LOG.Debug("Sent code " + boost::lexical_cast<std::string>(args[0]->Int32Value())); |
| 101 | 103 | ||
| 102 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
104 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
| 103 | 105 | ||
| 104 | event.type = KeyRelease; |
106 | event.type = KeyRelease; |
| 105 | 107 | ||
| 106 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
108 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
| 107 | 109 | ||
| 108 | XCloseDisplay(display); |
110 | XCloseDisplay(display); |
| 109 | 111 | ||
| 110 | return v8::Boolean::New(true); |
112 | return v8::Boolean::New(true); |
| 111 | } |
113 | } |
| 112 | 114 | ||
| 113 | }; // namespace plugin |
115 | }; // namespace plugin |
| 114 | }; // namespace vm |
116 | }; // namespace vm |
| 115 | }; // namespace atom |
117 | }; // namespace atom |
| - | 118 | ||
| - | 119 | #endif // USE_PLUGIN_XORG |
|