4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
16 /*{{{ Previous active thing */
19 static WThing
*current_client_or_frame()
21 WWindow
*cw
=wglobal
.current_wswindow
;
23 if(cw
!=NULL
&& WTHING_IS(cw
, WFrame
) &&
24 ((WFrame
*)cw
)->current_client
!=NULL
){
25 return (WThing
*)((WFrame
*)cw
)->current_client
;
31 static WThing
*get_next_previous(WThing
*next
)
33 WThing
*current
=current_client_or_frame();
35 if(current
==next
|| current
==NULL
)
38 if((WThing
*)FIND_PARENT(current
, WWindow
)==next
)
45 void set_previous(WThing
*thing
)
49 if(wglobal
.previous_protect
!=0)
52 previous
=get_next_previous(thing
);
55 wglobal
.previous
=previous
;
59 void protect_previous()
61 wglobal
.previous_protect
++;
65 void unprotect_previous()
67 assert(wglobal
.previous_protect
>0);
68 wglobal
.previous_protect
--;
75 /*{{{ set_focus, warp */
77 void set_input_focus(Window win
)
79 XSetInputFocus(wglobal
.dpy
, win
, RevertToParent
, CurrentTime
);
82 void do_set_focus(WThing
*thing
)
85 thing
=(WThing
*)wglobal
.current_screen
;
88 }else if(!on_visible_workspace(thing
)){
92 query_set_function_thing(thing
);
94 if(WTHING_IS(thing
, WFrame
))
95 focus_frame((WFrame
*)thing
);
96 else if(WTHING_IS(thing
, WWindow
))
97 focus_window((WWindow
*)thing
);
98 else if(WTHING_IS(thing
, WClient
))
99 focus_client((WClient
*)thing
);
100 else if(WTHING_IS(thing
, WClientWin
))
101 focus_clientwin((WClientWin
*)thing
);
103 if(wglobal
.current_screen
!=NULL
){
104 XSetInputFocus(wglobal
.dpy
, wglobal
.current_screen
->root
.win
,
105 RevertToNone
, CurrentTime
);
111 void set_focus(WThing
*thing
)
113 wglobal
.focus_next
=thing
;
114 query_set_function_thing(thing
);
118 void warp(WWindow
*wwin
)
121 XWarpPointer(wglobal
.dpy
, None
, wwin
->win
, 0, 0, 0, 0,
124 set_focus((WThing
*)wwin
);
125 query_set_function_thing((WThing
*)wwin
);