bool WrapWindow::QuitRequested() { app->Lock(); app->Quit(); app->Unlock(); return true; }
status_t DWindowHWInterface::SetMode(const display_mode& mode) { AutoWriteLocker _(this); status_t ret = B_OK; // prevent from doing the unnecessary if (fFrontBuffer && fDisplayMode.virtual_width == mode.virtual_width && fDisplayMode.virtual_height == mode.virtual_height && fDisplayMode.space == mode.space) return ret; // check if we support the mode display_mode *modes; uint32 modeCount, i; if (GetModeList(&modes, &modeCount) != B_OK) return B_NO_MEMORY; for (i = 0; i < modeCount; i++) { // we only care for the bare minimum if (modes[i].virtual_width == mode.virtual_width && modes[i].virtual_height == mode.virtual_height && modes[i].space == mode.space) { // take over settings fDisplayMode = modes[i]; break; } } delete[] modes; if (i == modeCount) return B_BAD_VALUE; BRect frame(0.0, 0.0, fDisplayMode.virtual_width - 1, fDisplayMode.virtual_height - 1); // create the window if we don't have one already if (!fWindow) { // if the window has not been created yet, the BApplication // has not been created either, but we need one to display // a real BWindow in the test environment. // be_app->Run() needs to be called in another thread BApplication* app = new BApplication("application/x-vnd.antares-app-server"); app->Unlock(); thread_id appThread = spawn_thread(run_app_thread, "app thread", B_NORMAL_PRIORITY, app); if (appThread >= B_OK) ret = resume_thread(appThread); else ret = appThread; if (ret < B_OK) return ret; fWindow = new DWindow(frame.OffsetByCopy(fXOffset, fYOffset), this, fFrontBuffer); // fire up the window thread but don't show it on screen yet fWindow->Hide(); fWindow->Show(); } if (fWindow->Lock()) { // free and reallocate the bitmaps while the window is locked, // so that the view does not accidentally draw a freed bitmap if (ret >= B_OK) { // change the window size and update the bitmap used for drawing fWindow->ResizeTo(frame.Width(), frame.Height()); } // window is hidden when this function is called the first time if (fWindow->IsHidden()) fWindow->Show(); fWindow->Unlock(); } else { ret = B_ERROR; } _UpdateFrameBufferConfig(); _NotifyFrameBufferChanged(); return ret; }