@@ -64,19 +64,60 @@ router.post('/hide', (req, res) => {
64
64
} )
65
65
66
66
router . get ( '/current' , ( req , res ) => {
67
- const currentWindow = Object . values ( state . windows ) . find ( window => window . id === BrowserWindow . getFocusedWindow ( ) . id )
68
- // Find object key with matching value
69
- const id = Object . keys ( state . windows ) . find ( key => state . windows [ key ] === currentWindow )
67
+ // Find the current window object
68
+ const currentWindow = Object . values ( state . windows ) . find ( window => window . id === BrowserWindow . getFocusedWindow ( ) . id ) ;
70
69
71
- res . json ( {
70
+ // Get the developer-assigned id for that window
71
+ const id = Object . keys ( state . windows ) . find ( key => state . windows [ key ] === currentWindow ) ;
72
+
73
+ res . json ( getWindowData ( id ) ) ;
74
+ } ) ;
75
+
76
+ router . get ( '/get/:id' , ( req , res ) => {
77
+ const { id} = req . params ;
78
+
79
+ if ( state . windows [ id ] === undefined ) {
80
+ res . sendStatus ( 404 ) ;
81
+ return ;
82
+ }
83
+
84
+ res . json ( getWindowData ( id ) ) ;
85
+ } ) ;
86
+
87
+ function getWindowData ( id ) {
88
+ const currentWindow = state . windows [ id ] ;
89
+
90
+ if ( state . windows [ id ] === undefined ) {
91
+ throw `Window [${ id } ] not found` ;
92
+ }
93
+
94
+ return {
72
95
id : id ,
73
96
x : currentWindow . getPosition ( ) [ 0 ] ,
74
97
y : currentWindow . getPosition ( ) [ 1 ] ,
75
98
width : currentWindow . getSize ( ) [ 0 ] ,
76
99
height : currentWindow . getSize ( ) [ 1 ] ,
77
100
title : currentWindow . getTitle ( ) ,
78
101
alwaysOnTop : currentWindow . isAlwaysOnTop ( ) ,
79
- } )
102
+ url : currentWindow . webContents . getURL ( ) ,
103
+ autoHideMenuBar : currentWindow . isMenuBarAutoHide ( ) ,
104
+ fullscreen : currentWindow . isFullScreen ( ) ,
105
+ fullscreenable : currentWindow . isFullScreenable ( ) ,
106
+ kiosk : currentWindow . isKiosk ( ) ,
107
+ showDevTools : currentWindow . webContents . isDevToolsOpened ( ) ,
108
+ resizable : currentWindow . isResizable ( ) ,
109
+ movable : currentWindow . isMovable ( ) ,
110
+ minimizable : currentWindow . isMinimizable ( ) ,
111
+ maximizable : currentWindow . isMaximizable ( ) ,
112
+ closable : currentWindow . isClosable ( ) ,
113
+ focusable : currentWindow . isFocusable ( ) ,
114
+ focused : currentWindow . isFocused ( ) ,
115
+ hasShadow : currentWindow . hasShadow ( ) ,
116
+ // frame: currentWindow.frame(),
117
+ // titleBarStyle: currentWindow.getTitleBarStyle(),
118
+ // trafficLightPosition: currentWindow.getTrafficLightPosition(),
119
+ } ;
120
+ }
80
121
} ) ;
81
122
82
123
router . post ( '/always-on-top' , ( req , res ) => {
0 commit comments