X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwindow.cpp;h=5395a00535c3aa2c4ee41797b0d71b6513aaacf1;hb=d39a783c839c08be8ac36a040f4f8b2ee0da8d56;hp=b977f6bc97ac89cbd7af1e81d02f125593f3de02;hpb=935c50bdcc95fe95d39931182461a2b25ac30b9d;p=libs%2Fgui.git diff --git a/source/window.cpp b/source/window.cpp index b977f6b..5395a00 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -90,14 +90,15 @@ void Window::prepare() wm_delete_window=XInternAtom(display, "WM_DELETE_WINDOW", true); + /* Throwing from the error handler doesn't work too well and I don't know + how to dig up all the information that Xlib gives by default, so disable + custom error handling for now. */ //XSetErrorHandler(x_error_handler); } -void Window::create() +void Window::set_window(Handle wnd) { - window=XCreateWindow(display, DefaultRootWindow(display), 0, 0, options.width, options.height, 0, CopyFromParent, InputOutput, CopyFromParent, 0, 0); - if(!window) - throw Exception("Couldn't create a window"); + window=wnd; XSelectInput(display, window, ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask); @@ -107,7 +108,9 @@ void Window::create() void Window::init() { prepare(); - create(); + + Handle wnd=XCreateWindow(display, DefaultRootWindow(display), 0, 0, options.width, options.height, 0, CopyFromParent, InputOutput, CopyFromParent, 0, 0); + set_window(wnd); } void Window::process_event(const XEvent &event) @@ -137,7 +140,6 @@ void Window::process_event(const XEvent &event) case ConfigureNotify: options.width=event.xconfigure.width; options.height=event.xconfigure.height; - on_resize(); signal_resize.emit(options.width, options.height); break; case ClientMessage: @@ -146,6 +148,8 @@ void Window::process_event(const XEvent &event) break; default:; } + + on_event(event); } int Window::x_error_handler(Display *display, XErrorEvent *error)