#include #include #include #include #include #include #include class Fl_Embed_Window:public Fl_Window { public: Window xid_; Fl_Embed_Window(int ix,int iy,Window xid):Fl_Window(ix,iy,0,0) { xid_ = xid; } void show(void) { XWindowAttributes attribs; XGetWindowAttributes(fl_display, xid_, &attribs); if (shown()) { Fl_Window::show(); return; } Fl_X::set_xid(this, xid_); size(attribs.width,attribs.height); XReparentWindow (fl_display, xid_, fl_xid(window()), 0, 0); } }; void embed(Fl_Widget* widget,void* ptr) { Fl_Input* input = (Fl_Input*) widget; Fl_Window* window = widget->window(); Fl_Window* embedded; char tmp[256]; int xid; strncpy(tmp,input->value(),255); sscanf(tmp,"%x",&xid); window->add(embedded = new Fl_Embed_Window(0,0,xid)); embedded->show(); // cause the reparent } main() { Fl_Window window(400,400); Fl_Input input(0,380,400,20); input.when(FL_WHEN_ENTER_KEY); input.callback(embed); window.end(); window.resizable(window); window.show(); Fl::run(); }