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);
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)
case ConfigureNotify:
options.width=event.xconfigure.width;
options.height=event.xconfigure.height;
- on_resize();
signal_resize.emit(options.width, options.height);
break;
case ClientMessage:
break;
default:;
}
+
+ on_event(event);
}
int Window::x_error_handler(Display *display, XErrorEvent *error)