4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
15 static WThingFuntab window_funtab
={
20 IMPLOBJ(WWindow
, WThing
, &window_funtab
)
26 bool init_window(WWindow
*p
, Window win
, WRectangle geom
)
35 XSaveContext(wglobal
.dpy
, win
, wglobal
.win_context
, (XPointer
)p
);
41 void deinit_window(WWindow
*wwin
)
44 XDestroyIC(wwin
->xic
);
46 if(wglobal
.current_wswindow
==wwin
)
47 wglobal
.current_wswindow
=NULL
;
49 XDeleteContext(wglobal
.dpy
, wwin
->win
, wglobal
.win_context
);
50 XDestroyWindow(wglobal
.dpy
, wwin
->win
);
57 /*{{{ Find, X Window -> thing */
60 WThing
*find_window(Window win
)
64 if(XFindContext(wglobal
.dpy
, win
, wglobal
.win_context
,
65 (XPointer
*)&thing
)!=0)
72 WThing
*find_window_t(Window win
, const WObjDescr
*descr
)
74 WThing
*thing
=find_window(win
);
79 if(!wobj_is((WObj
*)thing
, descr
))
86 WFrame
*find_frame_of(Window win
)
88 WWindow
*window
=find_window_of(win
);
90 if(window
==NULL
|| !WTHING_IS(window
, WFrame
))
93 return (WFrame
*)window
;
97 WWindow
*find_window_of(Window win
)
99 WThing
*thing
=FIND_WINDOW_T(win
, WThing
);
104 return window_of(thing
);
108 WWindow
*window_of(WThing
*thing
)
111 if(thing
->t_parent
==NULL
)
114 if(WTHING_IS(thing
->t_parent
, WWorkspace
))
117 thing
=thing
->t_parent
;
120 if(WTHING_IS(thing
, WWindow
))
121 return (WWindow
*)thing
;
133 void do_map_window(WWindow
*wwin
)
135 XMapWindow(wglobal
.dpy
, wwin
->win
);
137 wwin
->flags
|=WWINDOW_MAPPED
;
141 void do_unmap_window(WWindow
*wwin
)
145 if(!(wwin
->flags
&WWINDOW_MAPPED
))
148 XUnmapWindow(wglobal
.dpy
, wwin
->win
);
150 wwin
->flags
&=~WWINDOW_MAPPED
;
152 /*if(wglobal.current_wswindow==wwin)
153 wglobal.current_wswindow=NULL;*/
157 void map_window(WWindow
*wwin
)
159 if(wwin
->flags
&WWINDOW_UNMAPPABLE
)
166 void unmap_window(WWindow
*wwin
)
168 do_unmap_window(wwin
);
178 void focus_window(WWindow
*wwin
)
180 set_input_focus(wwin
->win
);