Skip to content
Browse files

Implement window.frame.focus to bring window to front

  • Loading branch information...
1 parent 5511e8a commit 12f407f62ce65e58775cae24fc80504fb1d07473 @milani committed Aug 22, 2012
View
1 lib/window.js
@@ -120,6 +120,7 @@ decorate(Frame.prototype, true, [
function restore(){ _(this).restore(); return this; },
function fullscreen(){ _(this).fullscreen(); return this; },
function show(){ _(this).show(); return this; },
+ function focus(){ _(this).focus(); return this; },
function hide(){ _(this).hide(); return this; },
function resize(width, height){ _(this).resize(width, height); return this; },
function move(left, top, width, height){
View
2 src/appjs_window.cpp
@@ -25,6 +25,7 @@ void Window::Init() {
DECLARE_PROTOTYPE_METHOD("fullscreen", Fullscreen);
DECLARE_PROTOTYPE_METHOD("drag", Drag);
DECLARE_PROTOTYPE_METHOD("show", Show);
+ DECLARE_PROTOTYPE_METHOD("focus", Focus);
DECLARE_PROTOTYPE_METHOD("hide", Hide);
DECLARE_PROTOTYPE_METHOD("destroy", Destroy);
DECLARE_PROTOTYPE_METHOD("runInBrowser", RunInBrowser);
@@ -90,6 +91,7 @@ CREATE_PROTOTYPE_INVOKER(Window, Minimize)
CREATE_PROTOTYPE_INVOKER(Window, Maximize)
CREATE_PROTOTYPE_INVOKER(Window, Fullscreen)
CREATE_PROTOTYPE_INVOKER(Window, Show)
+CREATE_PROTOTYPE_INVOKER(Window, Focus)
CREATE_PROTOTYPE_INVOKER(Window, Hide)
CREATE_PROTOTYPE_INVOKER(Window, Destroy)
View
1 src/appjs_window.h
@@ -20,6 +20,7 @@ class Window : public node::ObjectWrap {
DEFINE_PROTOTYPE_METHOD(Drag);
DEFINE_PROTOTYPE_METHOD(Drop);
DEFINE_PROTOTYPE_METHOD(Show);
+ DEFINE_PROTOTYPE_METHOD(Focus);
DEFINE_PROTOTYPE_METHOD(Hide);
DEFINE_PROTOTYPE_METHOD(Destroy);
DEFINE_PROTOTYPE_METHOD(RunInBrowser);
View
1 src/native_window/native_window.h
@@ -61,6 +61,7 @@ class NativeWindow {
void Maximize();
void Fullscreen();
void Show();
+ void Focus();
void Hide();
void Destroy();
View
4 src/native_window/native_window_linux.cpp
@@ -207,6 +207,10 @@ void NativeWindow::Show() {
gtk_widget_show_all(handle_);
}
+void NativeWindow::Focus() {
+ gtk_window_present((GtkWindow*)handle_);
+}
+
void NativeWindow::Hide() {
gtk_widget_hide(handle_);
}
View
4 src/native_window/native_window_mac.mm
@@ -303,6 +303,10 @@ void AddWebView(CefWindowHandle parent, char* url, Settings* settings) {
[[handle_ window] makeKeyAndOrderFront: nil];
}
+void NativeWindow::Focus() {
+ [[handle_ window] makeKeyAndOrderFront: nil];
+}
+
void NativeWindow::Hide() {
[[handle_ window] orderOut: nil];
}
View
4 src/native_window/native_window_win.cpp
@@ -263,6 +263,10 @@ void NativeWindow::Show() {
ForceForegroundWindow(handle_);
}
+void NativeWindow::Focus() {
+ SetActiveWindow(handle_);
+}
+
void NativeWindow::Hide() {
ShowWindow(handle_, SW_HIDE);
}

0 comments on commit 12f407f

Please sign in to comment.
Something went wrong with that request. Please try again.