Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement window.frame.focus to bring window to front

  • Loading branch information...
commit 12f407f62ce65e58775cae24fc80504fb1d07473 1 parent 5511e8a
Morteza Milani authored
1  lib/window.js
@@ -120,6 +120,7 @@ decorate(Frame.prototype, true, [
120 120 function restore(){ _(this).restore(); return this; },
121 121 function fullscreen(){ _(this).fullscreen(); return this; },
122 122 function show(){ _(this).show(); return this; },
  123 + function focus(){ _(this).focus(); return this; },
123 124 function hide(){ _(this).hide(); return this; },
124 125 function resize(width, height){ _(this).resize(width, height); return this; },
125 126 function move(left, top, width, height){
2  src/appjs_window.cpp
@@ -25,6 +25,7 @@ void Window::Init() {
25 25 DECLARE_PROTOTYPE_METHOD("fullscreen", Fullscreen);
26 26 DECLARE_PROTOTYPE_METHOD("drag", Drag);
27 27 DECLARE_PROTOTYPE_METHOD("show", Show);
  28 + DECLARE_PROTOTYPE_METHOD("focus", Focus);
28 29 DECLARE_PROTOTYPE_METHOD("hide", Hide);
29 30 DECLARE_PROTOTYPE_METHOD("destroy", Destroy);
30 31 DECLARE_PROTOTYPE_METHOD("runInBrowser", RunInBrowser);
@@ -90,6 +91,7 @@ CREATE_PROTOTYPE_INVOKER(Window, Minimize)
90 91 CREATE_PROTOTYPE_INVOKER(Window, Maximize)
91 92 CREATE_PROTOTYPE_INVOKER(Window, Fullscreen)
92 93 CREATE_PROTOTYPE_INVOKER(Window, Show)
  94 +CREATE_PROTOTYPE_INVOKER(Window, Focus)
93 95 CREATE_PROTOTYPE_INVOKER(Window, Hide)
94 96 CREATE_PROTOTYPE_INVOKER(Window, Destroy)
95 97
1  src/appjs_window.h
@@ -20,6 +20,7 @@ class Window : public node::ObjectWrap {
20 20 DEFINE_PROTOTYPE_METHOD(Drag);
21 21 DEFINE_PROTOTYPE_METHOD(Drop);
22 22 DEFINE_PROTOTYPE_METHOD(Show);
  23 + DEFINE_PROTOTYPE_METHOD(Focus);
23 24 DEFINE_PROTOTYPE_METHOD(Hide);
24 25 DEFINE_PROTOTYPE_METHOD(Destroy);
25 26 DEFINE_PROTOTYPE_METHOD(RunInBrowser);
1  src/native_window/native_window.h
@@ -61,6 +61,7 @@ class NativeWindow {
61 61 void Maximize();
62 62 void Fullscreen();
63 63 void Show();
  64 + void Focus();
64 65 void Hide();
65 66 void Destroy();
66 67
4 src/native_window/native_window_linux.cpp
@@ -207,6 +207,10 @@ void NativeWindow::Show() {
207 207 gtk_widget_show_all(handle_);
208 208 }
209 209
  210 +void NativeWindow::Focus() {
  211 + gtk_window_present((GtkWindow*)handle_);
  212 +}
  213 +
210 214 void NativeWindow::Hide() {
211 215 gtk_widget_hide(handle_);
212 216 }
4 src/native_window/native_window_mac.mm
@@ -303,6 +303,10 @@ void AddWebView(CefWindowHandle parent, char* url, Settings* settings) {
303 303 [[handle_ window] makeKeyAndOrderFront: nil];
304 304 }
305 305
  306 +void NativeWindow::Focus() {
  307 + [[handle_ window] makeKeyAndOrderFront: nil];
  308 +}
  309 +
306 310 void NativeWindow::Hide() {
307 311 [[handle_ window] orderOut: nil];
308 312 }
4 src/native_window/native_window_win.cpp
@@ -263,6 +263,10 @@ void NativeWindow::Show() {
263 263 ForceForegroundWindow(handle_);
264 264 }
265 265
  266 +void NativeWindow::Focus() {
  267 + SetActiveWindow(handle_);
  268 +}
  269 +
266 270 void NativeWindow::Hide() {
267 271 ShowWindow(handle_, SW_HIDE);
268 272 }

0 comments on commit 12f407f

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