-}
-
-void Window::init()
-{
- priv=new Private;
-
-#ifdef WIN32
- static bool wndclass_created=false;
-
- if(!wndclass_created)
- {
- WNDCLASSEX wndcl;
-
- wndcl.cbSize=sizeof(WNDCLASSEX);
- wndcl.style=0;
- wndcl.lpfnWndProc=&wndproc_;
- wndcl.cbClsExtra=0;
- wndcl.cbWndExtra=sizeof(Window *);
- wndcl.hInstance=reinterpret_cast<HINSTANCE>(Application::get_data());
- wndcl.hIcon=0;
- wndcl.hCursor=LoadCursor(0, IDC_ARROW);
- wndcl.hbrBackground=0;
- wndcl.lpszMenuName=0;
- wndcl.lpszClassName="mspgbase";
- wndcl.hIconSm=0;
-
- if(!RegisterClassEx(&wndcl))
- throw Exception("Couldn't register window class");
-
- wndclass_created=true;
- }
-
- RECT rect;
- SetRect(&rect, 0, 0, options.width, options.height);
-
- int style=(options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
- if(!options.resizable)
- style&=~WS_THICKFRAME;
- int exstyle=(options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
- AdjustWindowRectEx(&rect, style, false, exstyle);
-
- priv->window=CreateWindowEx(exstyle,
- "mspgbase",
- "Window",
- style,
- CW_USEDEFAULT, CW_USEDEFAULT,
- rect.right-rect.left, rect.bottom-rect.top,
- 0,
- 0,
- reinterpret_cast<HINSTANCE>(Application::get_data()),
- this);
- if(!priv->window)
- throw Exception("CreateWindowEx failed");
-
- if(options.fullscreen)
- display.set_mode(VideoMode(options.width, options.height));
-
-#else
- ::Display *dpy=display.get_private().display;
-
- priv->wm_delete_window=XInternAtom(dpy, "WM_DELETE_WINDOW", true);
- priv->invisible_cursor=0;
-
- XSetWindowAttributes attr;
- attr.override_redirect=options.fullscreen;
- attr.event_mask=ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask;
-
- priv->window=XCreateWindow(dpy,
- DefaultRootWindow(dpy),
- 0, 0,
- options.width, options.height,
- 0,
- CopyFromParent,
- InputOutput,
- CopyFromParent,
- CWOverrideRedirect|CWEventMask, &attr);
-
- XSetWMProtocols(dpy, priv->window, &priv->wm_delete_window, 1);
-
- if(!options.resizable)
- {
- XSizeHints hints;
- hints.flags=PMinSize|PMaxSize;
- hints.min_width=hints.max_width=options.width;
- hints.min_height=hints.max_height=options.height;
- XSetWMNormalHints(dpy, priv->window, &hints);
- }