Subversion Repositories HomeAutomation

Rev

Rev 1740 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1740 Rev 1741
Line 55... Line 55...
55
 
55
 
56
Value Xorg::Export_SendKey(const v8::Arguments& args)
56
Value Xorg::Export_SendKey(const v8::Arguments& args)
57
{
57
{
58
    v8::Locker lock;
58
    v8::Locker lock;
59
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
59
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
60
    v8::HandleScope handle_scope;
60
   
61
   
61
    LOG.Debug(std::string(__FUNCTION__) + " called!");
62
    LOG.Debug(std::string(__FUNCTION__) + " called!");
62
   
63
   
63
    if (args.Length() < 1)
64
    if (args.Length() < 1)
64
    {
65
    {
65
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
66
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
66
        return v8::Boolean::New(false);
67
        return handle_scope.Close(v8::Boolean::New(false));
67
    }
68
    }
68
   
69
   
69
    Display* display = XOpenDisplay(":0");
70
    Display* display = XOpenDisplay(":0");
70
   
71
   
71
    if (display == NULL)
72
    if (display == NULL)
72
    {
73
    {
73
        LOG.Warning("Could not locate display :0");
74
        LOG.Warning("Could not locate display :0");
74
        return v8::Boolean::New(false);
75
        return handle_scope.Close(v8::Boolean::New(false));
75
    }
76
    }
76
   
77
   
77
    // Get the root window for the current display.
78
    // Get the root window for the current display.
78
    Window winRoot = XDefaultRootWindow(display);
79
    Window winRoot = XDefaultRootWindow(display);
79
   
80
   
Line 106... Line 107...
106
   
107
   
107
    XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
108
    XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
108
   
109
   
109
    XCloseDisplay(display);
110
    XCloseDisplay(display);
110
   
111
   
111
    return v8::Boolean::New(true);
112
    return handle_scope.Close(v8::Boolean::New(true));
112
}
113
}
113
   
114
   
114
}; // namespace plugin
115
}; // namespace plugin
115
}; // namespace vm
116
}; // namespace vm
116
}; // namespace atom
117
}; // namespace atom