Correctly set tray window sizes so tray app can draw icon(s) on correct place.

This commit is contained in:
Sanel Zukan 2012-04-19 10:08:41 +00:00
parent 7d884242bd
commit 403f4be39d
2 changed files with 26 additions and 2 deletions

View File

@ -47,6 +47,9 @@ static int handle_xevent(int e) {
XDestroyWindowEvent xev = fl_xevent->xdestroywindow; XDestroyWindowEvent xev = fl_xevent->xdestroywindow;
curr_tray->unembed_window(xev.window); curr_tray->unembed_window(xev.window);
return false; return false;
} else if(fl_xevent->type == ConfigureNotify) {
curr_tray->configure_notify(fl_xevent->xconfigure.window);
return false;
} }
return false; return false;
@ -148,10 +151,13 @@ void Tray::embed_window(Window id) {
add_to_tray(win); add_to_tray(win);
win->show(); win->show();
/* do real magic */ /* do real magic
* Some apps require we explicitly resize tray window, but some ignores it. So after window was shown, ConfigureNotify
* will be fired up and we will handle those windows who are not resized.
*/
XResizeWindow(fl_display, id, win->w(), win->h()); XResizeWindow(fl_display, id, win->w(), win->h());
XReparentWindow(fl_display, id, fl_xid(win), 0, 0); XReparentWindow(fl_display, id, fl_xid(win), 0, 0);
XMapWindow(fl_display, id); XMapRaised(fl_display, id);
/* need to know when child dies */ /* need to know when child dies */
XSelectInput(fl_display, fl_xid(win), SubstructureNotifyMask); XSelectInput(fl_display, fl_xid(win), SubstructureNotifyMask);
@ -175,6 +181,23 @@ void Tray::unembed_window(Window id) {
} }
} }
void Tray::configure_notify(Window id) {
WinListIt it = win_list.begin(), ite = win_list.end();
for(; it != ite; ++it) {
if(it->id == id) {
XWindowChanges c;
c.width = TRAY_ICON_W;
c.height = TRAY_ICON_H;
c.x = 0;
c.y = 0;
XConfigureWindow(fl_display, id, CWWidth | CWHeight | CWX | CWY, &c);
return;
}
}
}
void Tray::add_to_tray(Fl_Widget *win) { void Tray::add_to_tray(Fl_Widget *win) {
insert(*win, 0); insert(*win, 0);
w(w() + win->w() + TRAY_ICONS_SPACE); w(w() + win->w() + TRAY_ICONS_SPACE);

View File

@ -27,6 +27,7 @@ public:
Atom get_opcode(void) const { return opcode; } Atom get_opcode(void) const { return opcode; }
void embed_window(Window id); void embed_window(Window id);
void unembed_window(Window id); void unembed_window(Window id);
void configure_notify(Window id);
void add_to_tray(Fl_Widget *w); void add_to_tray(Fl_Widget *w);
void remove_from_tray(Fl_Widget *w); void remove_from_tray(Fl_Widget *w);