File tree Expand file tree Collapse file tree 4 files changed +17
-31
lines changed
Expand file tree Collapse file tree 4 files changed +17
-31
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,7 @@ setTimeout(() => {
1717
1818console . log ( "Windows list" ) ;
1919windowManager . getWindows ( ) . forEach ( window => {
20- if ( window . isVisible ( ) ) {
21- console . log ( window . getInfo ( ) ) ;
22- console . log ( window . getMonitor ( ) . getInfo ( ) ) ;
23- }
20+ console . log ( window . getInfo ( ) ) ;
2421} ) ;
2522
2623console . log ( "Monitors list" ) ;
Original file line number Diff line number Diff line change @@ -48,14 +48,21 @@ AXUIElementRef getAXWindow(int pid, int handle) {
4848 std::vector<Napi::Number> vec;
4949
5050 for (NSDictionary *info in (NSArray *)windowList) {
51+ NSNumber *ownerPid = info[(id )kCGWindowOwnerPID ];
5152 NSNumber *windowNumber = info[(id )kCGWindowNumber ];
52- vec.push_back (Napi::Number::New (env, [windowNumber intValue ]));
53+
54+ auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue ]];
55+ auto path = app ? [app.bundleURL.path UTF8String ] : " " ;
56+
57+ if (app && path != " " ) {
58+ vec.push_back (Napi::Number::New (env, [windowNumber intValue ]));
59+ }
5360 }
5461
5562 auto arr = Napi::Array::New (env, vec.size ());
5663
5764 for (int i = 0 ; i < vec.size (); i++) {
58- arr. Set (i, vec[i]) ;
65+ arr[i] = vec[i];
5966 }
6067
6168 return arr;
Original file line number Diff line number Diff line change 11import { platform } from "os" ;
2- import { windowManager , addon } from ".." ;
2+ import { addon } from ".." ;
33import extractFileIcon from 'extract-file-icon' ;
44import { Monitor } from "./monitor" ;
5-
6- interface Rectangle {
7- x ?: number ;
8- y ?: number ;
9- width ?: number ;
10- height ?: number ;
11- }
12-
13- interface WindowInfo {
14- id : number ;
15- path : string ;
16- processId : number ;
17- title ?: string ;
18- bounds ?: Rectangle ;
19- opacity ?: number ;
20- owner ?: number ;
21- }
5+ import { IRectangle , IWindowInfo } from "../interfaces" ;
226
237export class Window {
248 public id : number ;
@@ -35,7 +19,7 @@ export class Window {
3519 this . path = path ;
3620 }
3721
38- getBounds ( ) : Rectangle {
22+ getBounds ( ) : IRectangle {
3923 if ( ! addon ) return ;
4024
4125 const { bounds } = this . getInfo ( ) ;
@@ -52,7 +36,7 @@ export class Window {
5236 return bounds ;
5337 }
5438
55- setBounds ( bounds : Rectangle ) {
39+ setBounds ( bounds : IRectangle ) {
5640 if ( ! addon ) return ;
5741
5842 const newBounds = { ...this . getBounds ( ) , ...bounds } ;
@@ -184,11 +168,9 @@ export class Window {
184168 return new Window ( this . getInfo ( ) . owner ) ;
185169 }
186170
187- getInfo ( ) : WindowInfo {
171+ getInfo ( ) : IWindowInfo {
188172 if ( ! addon ) return ;
189-
190173 const info = addon . getWindowInfo ( this . id ) ;
191-
192174 return info ;
193175 }
194176}
Original file line number Diff line number Diff line change @@ -63,12 +63,12 @@ class WindowManager extends EventEmitter {
6363 } ;
6464
6565 getWindows = ( ) : Window [ ] => {
66- if ( ! addon || ! addon . getWindows ) return ;
66+ if ( ! addon || ! addon . getWindows ) return [ ] ;
6767 return addon . getWindows ( ) . map ( ( win : any ) => new Window ( win ) ) . filter ( ( x : Window ) => x . isWindow ( ) ) ;
6868 } ;
6969
7070 getMonitors = ( ) : Monitor [ ] => {
71- if ( ! addon || ! addon . getMonitors ) return ;
71+ if ( ! addon || ! addon . getMonitors ) return [ ] ;
7272 return addon . getMonitors ( ) . map ( ( mon : any ) => new Monitor ( mon ) ) ;
7373 } ;
7474
You can’t perform that action at this time.
0 commit comments