示例#1
0
bool WebEmberX11::initSDL(FB::PluginWindow *pluginwindow)
{
	assert(!mPluginWindow);
	mPluginWindow = static_cast<FB::PluginWindowX11*>(pluginwindow);

	GtkWidget* widget = mPluginWindow->getWidget();

	// Fixes BadWindow error in SDL_SetVideoMode
	gdk_display_flush(gtk_widget_get_display(widget));

	char tmp[64];
	sprintf(tmp, "SDL_WINDOWID=%lu", (unsigned long)mPluginWindow->getWindow());
	putenv(tmp);
	//putenv("SDL_DEBUG=1");

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		FBLOG_FATAL("WebEmberX11::initSDL", "Couldn't initialize SDL: " << SDL_GetError());
		return true;
	}

	if (!SDL_SetVideoMode(800, 600, 0, 0)) {
		FBLOG_FATAL("WebEmberX11::initSDL", "Couldn't create SDL window: " << SDL_GetError());
		return true;
	}

	SDL_SysWMinfo info;
	XSetWindowAttributes attributes;

	SDL_VERSION(&info.version); // this is important!
	SDL_GetWMInfo(&info);
	mDisplaySDL = info.info.x11.display;
	mWindow = info.info.x11.window;
	// Select the events, what SDL should receive.
	// SDL will not receive any messages when SDL_WINDOWID is set.
	{
		attributes.event_mask =
			//KeyPressMask | KeyReleaseMask | //ButtonPressMask | //ButtonReleaseMask |
			PropertyChangeMask// | StructureNotifyMask | //KeymapStateMask |
			//EnterWindowMask  | LeaveWindowMask | ExposureMask | PointerMotionMask |
			//VisibilityChangeMask// | PointerMotionHintMask |
			//FocusChangeMask
			;

		//select events, what SDL should receive.
		XSelectInput(mDisplaySDL, mWindow, attributes.event_mask);

		// Get the atom.
		//Atom WM_DELETE_WINDOW = XInternAtom(mDisplaySDL, "WM_DELETE_WINDOW", False);

		// Send window destory event to SDL to shut down properly.
		//XSetWMProtocols(mDisplaySDL, mWindow, &WM_DELETE_WINDOW, 1);
	}
	return false;
}
示例#2
0
void FB::BrowserHost::assertMainThread() const
{
#ifdef _DEBUG
    if (!isMainThread()) {
        FBLOG_FATAL("BrowserHost", "Trying to call something from the wrong thread!");
    }
    assert(isMainThread());
#endif
}