@@ -64,16 +64,46 @@ function Inner() {
6464 } ) ;
6565 onCleanup ( ( ) => unsubTargetUnderCursor . then ( ( unsub ) => unsub ( ) ) ) ;
6666
67+ const selectedWindow = createQuery ( ( ) => ( {
68+ queryKey : [ "selectedWindow" , rawOptions . captureTarget ] ,
69+ queryFn : async ( ) => {
70+ if ( rawOptions . captureTarget . variant !== "window" ) return null ;
71+ const windowId = rawOptions . captureTarget . id ;
72+
73+ const windows = await commands . listCaptureWindows ( ) ;
74+ const window = windows . find ( w => w . id === windowId ) ;
75+
76+ if ( ! window ) return null ;
77+
78+ return {
79+ id : window . id ,
80+ app_name : window . owner_name || window . name || "Unknown" ,
81+ bounds : window . bounds ,
82+ } ;
83+ } ,
84+ enabled : rawOptions . captureTarget . variant === "window" && rawOptions . targetMode === "window" ,
85+ staleTime : 5 * 1000 ,
86+ } ) ) ;
87+
88+ const windowToShow = ( ) => {
89+ if ( rawOptions . captureTarget . variant === "window" && selectedWindow . data ) {
90+ return selectedWindow . data ;
91+ }
92+ // Otherwise use what's under the cursor
93+ return targetUnderCursor . window ;
94+ } ;
95+
6796 const windowIcon = createQuery ( ( ) => ( {
68- queryKey : [ "windowIcon" , targetUnderCursor . window ?. id ] ,
97+ queryKey : [ "windowIcon" , windowToShow ( ) ?. id ] ,
6998 queryFn : async ( ) => {
70- if ( ! targetUnderCursor . window ?. id ) return null ;
99+ const window = windowToShow ( ) ;
100+ if ( ! window ?. id ) return null ;
71101 return await commands . getWindowIcon (
72- targetUnderCursor . window . id . toString ( ) ,
102+ window . id . toString ( ) ,
73103 ) ;
74104 } ,
75- enabled : ! ! targetUnderCursor . window ?. id ,
76- staleTime : 5 * 60 * 1000 , // Cache for 5 minutes
105+ enabled : ! ! windowToShow ( ) ?. id ,
106+ staleTime : 5 * 60 * 1000 ,
77107 } ) ) ;
78108
79109 const displayInformation = createQuery ( ( ) => ( {
@@ -184,10 +214,11 @@ function Inner() {
184214 < Match
185215 when = {
186216 rawOptions . targetMode === "window" &&
187- targetUnderCursor . display_id === params . displayId
217+ ( targetUnderCursor . display_id === params . displayId ||
218+ ( rawOptions . captureTarget . variant === "window" && selectedWindow . data ) )
188219 }
189220 >
190- < Show when = { targetUnderCursor . window } keyed >
221+ < Show when = { windowToShow ( ) } keyed >
191222 { ( windowUnderCursor ) => (
192223 < div
193224 data-over = { targetUnderCursor . display_id === params . displayId }
0 commit comments