Exemple #1
0
    void EGLWindow::setFullscreen(bool fullscreen, uint width, uint height)
    {
        short frequency = 0;

        if (mClosed || !mIsTopLevel)
        {
            return;
        }

        if (fullscreen == mIsFullScreen && width == mWidth && height == mHeight)
        {
            return;
        }
		if (fullscreen)
        {
            mGLSupport->switchMode(width, height, frequency);
        }
        else
        {
            mGLSupport->switchMode();
        }

        if (mIsFullScreen != fullscreen)
        {
            switchFullScreen(fullscreen);
        }

        if (!mIsFullScreen)
        {
            resize(width, height);
            reposition(mLeft, mTop);
        }
    }
Exemple #2
0
// virtual
void VideoContainer::keyPressEvent(QKeyEvent *event)
{
    // Exit fullscreen with Esc key
    if (event->key() == Qt::Key_Escape && isFullScreen()) {
        switchFullScreen();
        event->setAccepted(true);
    } else event->setAccepted(false);
}
Exemple #3
0
    void EGLWindow::destroy(void)
    {
        if (mClosed)
        {
            return;
        }

        mClosed = true;
        mActive = false;

        if (mIsFullScreen)
        {
            mGLSupport->switchMode();
            switchFullScreen(false);
        }
    }
void CApplication::setSize(unsigned int width, unsigned int height)
{
    T_ASSERT(m_window != nullptr);

    m_videoMode.width = width;
    m_videoMode.height = height;

    if (m_fullscreen)
    {
        // Création du nouveau contexte
        switchFullScreen(true);
    }
    else
    {
        m_window->setSize(sf::Vector2u(width, height));
    }
}
	//-------------------------------------------------------------------------------------------------//
	void GLXWindow::destroy(void)
	{
		if (mClosed)
			return;
		
		mClosed = true;
		mActive = false;
		
		if (! mIsExternal)
			WindowEventUtilities::_removeRenderWindow(this);
		
		if (mIsFullScreen) 
		{
			mGLSupport->switchMode();
			switchFullScreen(false);
		}
	}
	//-------------------------------------------------------------------------------------------------//
	void GLXWindow::setHidden(bool hidden)
	{
		mHidden = hidden;
		// ignore for external windows as these should handle
		// this externally
		if (mIsExternal)
			return;

		if (hidden)
		{
			XUnmapWindow(mGLSupport->getXDisplay(), mWindow);
		}
		else
		{
			XMapWindow(mGLSupport->getXDisplay(), mWindow);
			if (mIsFullScreen)
			{
				switchFullScreen(true);
			}
		}
	}
	//-------------------------------------------------------------------------------------------------//
	void GLXWindow::setFullscreen(bool fullscreen, uint width, uint height)
	{
		short frequency = 0;
		
		if (mClosed || ! mIsTopLevel)
			return;
		
		if (fullscreen == mIsFullScreen && width == mWidth && height == mHeight)
			return;
		
		if (mIsFullScreen != fullscreen && &mGLSupport->mAtomFullScreen == None)
		{
			// Without WM support it is best to give up.
			LogManager::getSingleton().logMessage("GLXWindow::switchFullScreen: Your WM has no fullscreen support");
			return;
		}
		else if (fullscreen)
		{
			mGLSupport->switchMode(width, height, frequency);
		}
		else
		{
			mGLSupport->switchMode();
		}
		
		if (mIsFullScreen != fullscreen)
		{
			switchFullScreen(fullscreen);
		}
		
		if (! mIsFullScreen)
		{
			resize(width, height);
			reposition(mLeft, mTop);
		}
	}
void NGLScene::keyPressEvent(QKeyEvent *_event)
{
  // this method is called every time the main window recives a key event.
  // we then switch on the key value and set the camera in the GLWindow
  switch (_event->key())
  {
  // escape key to quite
  case Qt::Key_Escape : QGuiApplication::exit(EXIT_SUCCESS); break;
  case Qt::Key_Space : makerBirds.Produce(); break;
  case Qt::Key_W : cam.moveCamera(0.05f, 0.0f);  break;
  case Qt::Key_S : cam.moveCamera(-0.05f, 0.0f); break;
  case Qt::Key_A : cam.moveCamera(0.0f, -0.1f); break;
  case Qt::Key_D : cam.moveCamera(0.0f, 0.1f);  break;
  case Qt::Key_F : m_fullScreen += 1; switchFullScreen(); break;
  case Qt::Key_L : lockFollow = true; break;
  case Qt::Key_P : lockFollow = false; break;
  default : break;
  }
  // finally update the GLWindow and re-draw

  loadToShader();

  update();
}
    void X11EGLWindow::createNativeWindow( int &left, int &top, uint &width, uint &height, String &title )
    {
        mEglDisplay = mGLSupport->getGLDisplay();//todo
        XSetWindowAttributes attr;
        ulong mask;
        XVisualInfo *visualInfo = mGLSupport->getVisualFromFBConfig(mEglConfig);

        attr.background_pixel = 0;
        attr.border_pixel = 0;
        attr.colormap = XCreateColormap((Display*)mNativeDisplay,
            DefaultRootWindow((Display*)mNativeDisplay),
            visualInfo->visual,
            AllocNone);
        attr.event_mask = StructureNotifyMask | VisibilityChangeMask | FocusChangeMask;
        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

        if(mIsFullScreen && mGLSupport->mAtomFullScreen == None) 
        {
            LogManager::getSingleton().logMessage("EGLWindow::switchFullScreen: Your WM has no fullscreen support");

            // A second best approach for outdated window managers
            attr.backing_store = NotUseful;
            attr.save_under = False;
            attr.override_redirect = True;
            mask |= CWSaveUnder | CWBackingStore | CWOverrideRedirect;
            left = top = 0;
        }

        // Create window on server
        mWindow = (NativeWindowType)XCreateWindow((Display*)mNativeDisplay,
            mParentWindow,
            left, top, width, height,
            0, visualInfo->depth,
            InputOutput,
            visualInfo->visual, mask, &attr);
        XFree(visualInfo);

        if(!mWindow)
        {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                "Unable to create an X NativeWindowType",
                "EGLWindow::create");
        }

        if (mIsTopLevel)
        {
            XWMHints *wmHints;
            XSizeHints *sizeHints;

            // Is this really necessary ? Which broken WM might need it?
            if ((wmHints = XAllocWMHints()) != NULL)
            {
                wmHints->initial_state = NormalState;
                wmHints->input = True;
                wmHints->flags = StateHint | InputHint;
            }

            // Is this really necessary ? Which broken WM might need it?
            if ((sizeHints = XAllocSizeHints()) != NULL)
            {
                sizeHints->flags = USPosition;
            }

            XTextProperty titleprop;
            char *lst = (char*)title.c_str();
            XStringListToTextProperty((char **)&lst, 1, &titleprop);
            XSetWMProperties((Display*)mNativeDisplay, (Window)mWindow, &titleprop,
                NULL, NULL, 0, sizeHints, wmHints, NULL);

            XFree(titleprop.value);
            XFree(wmHints);
            XFree(sizeHints);

            XSetWMProtocols((Display*)mNativeDisplay, (Window)mWindow, &mGLSupport->mAtomDeleteWindow, 1);

            XWindowAttributes windowAttrib;

            XGetWindowAttributes((Display*)mNativeDisplay, (Window)mWindow, &windowAttrib);

            left = windowAttrib.x;
            top = windowAttrib.y;
            width = windowAttrib.width;
            height = windowAttrib.height;
        }

        mEglSurface = createSurfaceFromWindow(mGLSupport->getGLDisplay(), mWindow);

        XMapWindow((Display*)mNativeDisplay, (Window)mWindow);

        if (mIsFullScreen)
        {
            switchFullScreen(true);
        }

        XFlush((Display*)mNativeDisplay);

        WindowEventUtilities::_addRenderWindow(this);
    }
Exemple #10
0
void VideoContainer::mouseDoubleClickEvent(QMouseEvent * event)
{
    if (!KdenliveSettings::openglmonitors())
        switchFullScreen();
    event->accept();
}
bool VideoOutputEventFilter::eventFilter(QObject *watched, QEvent *event)
{
    // a widget shown means it's available and not deleted
    if (event->type() == QEvent::Show || event->type() == QEvent::ShowToParent) {
        mRendererIsQObj = !!mpRenderer->widget();
        return false;
    }
    if (!mRendererIsQObj)
        return false;
    /*
     * deleted renderer (after destroyed()) can not access it's member, so we must mark it as invalid.
     * hide event is sent when close. what about QEvent::Close?
     */
    if (event->type() == QEvent::Close || event->type() == QEvent::Hide) {
        mRendererIsQObj = false;
        return true;
    }
    if (!mpRenderer)
        return false;
    if (!mpRenderer->isDefaultEventFilterEnabled())
        return false;
    if (watched != mpRenderer->widget()
            /* && watched != mpRenderer->graphicsWidget()*/ //no showFullScreen() etc.
            )
        return false;
    switch (event->type()) {
    case QEvent::KeyPress: {
        QKeyEvent *key_event = static_cast<QKeyEvent*>(event);
        int key = key_event->key();
        //Qt::KeyboardModifiers modifiers = key_event->modifiers();
        switch (key) {
        case Qt::Key_F:
            switchFullScreen();
            break;
        case Qt::Key_I:
            mpRenderer->setQuality(VideoRenderer::Quality(((int)mpRenderer->quality()+1)%3));
            break;
        case Qt::Key_T: {
            QWidget *w = mpRenderer->widget()->window();
            Qt::WindowFlags wf = w->windowFlags();
            if (wf & Qt::WindowStaysOnTopHint) {
                qDebug("Window not stays on top");
                w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
            } else {
                qDebug("Window stays on top");
                w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
            }
            //call setParent() when changing the flags, causing the widget to be hidden
            w->show();
        }
            break;
        }
    }
        break;
    case QEvent::MouseButtonDblClick:
        switchFullScreen();
        break;
    case QEvent::MouseButtonPress: {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt == Qt::LeftButton) {
            gMousePos = me->globalPos();
            iMousePos = me->pos();
        }
    }
        break;
    case QEvent::MouseButtonRelease: {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt != Qt::LeftButton)
            return false;
        iMousePos = QPoint();
        gMousePos = QPoint();
    }
        break;
    case QEvent::MouseMove: {
        if (iMousePos.isNull() || gMousePos.isNull())
            return false;
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        QWidget *window = mpRenderer->widget()->window();
        int x = window->pos().x();
        int y = window->pos().y();
        int dx = me->globalPos().x() - gMousePos.x();
        int dy = me->globalPos().y() - gMousePos.y();
        gMousePos = me->globalPos();
        window->move(x + dx, y + dy);
    }
        break;
    default:
        break;
    }
    return false;
}
Exemple #12
0
VideoPlayer::VideoPlayer(QString programPath, QWidget *parent) :
    QWidget(parent)
  ,programDir(programPath)
  ,WIDTH(600)
  ,HEIGHT(380)
  ,videoNameWidth(300)
  ,videoListWidth(200)
  ,hideButtonsTime(2000)
  ,forwardStep(5)
  ,retreatStep(5)
  ,volumnChangeStep(5)
  ,hideCursor(false)
  ,keepAwakeTimes(0)
{
    //设置窗口无边框
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
    this->installEventFilter(this);

    //初始化窗口位置、大小
    QDesktopWidget desktop;
    setGeometry((desktop.width()-WIDTH)/2, (desktop.height()-HEIGHT)/2, WIDTH, HEIGHT);
    setObjectName("videoPlayer");

    //背景label
    lab_background = new QLabel(this);
    lab_background->setGeometry(0, 0, WIDTH, HEIGHT);
    lab_background->setObjectName("lab_background");

//    videoList = new VideoList(0, 25, videoListWidth, this->height()-50, false, this);
//    videoList->show();

    //设置鼠标跟踪,响应鼠标移动事件
    this->setMouseTracking(true);
    lab_background->setMouseTracking(true);

    //
    videoWidget = new VideoWidget;
    videoWidget->hide();
    videoWidget->installEventFilter(this);
    videoWidget->setMouseTracking(true);

    //保持视频屏幕常亮
    helpKeepAwake = new HelpKeepAwake;

    //布局
    layout_top = new QGridLayout;
    layout_top->addWidget(lab_background, 0, 0, 1, 1);
    layout_top->addWidget(videoWidget, 0, 0, 1, 1);
    layout_top->setSpacing(0);
    layout_top->setMargin(0);
    this->setLayout(layout_top);

    //
    videoContral = new VideoContral(this);
    videoContral->setGeometry(this->x(), this->y(), this->width(), this->height());

    tbn_openVideoFile = new QToolButton(this);
    tbn_openVideoFile->setText("放入视频");
    tbn_openVideoFile->setGeometry((this->width()-126-32)/2+35, (this->height()-41)/2+95, 80, 30);
    tbn_openVideoFile->setObjectName("tbn_openVideoFile");

    //初始化多媒体播放器
    player = new QMediaPlayer(this);
    QMediaPlaylist *playlist = new QMediaPlaylist;
    QMediaPlaylist *playlistHistory = new QMediaPlaylist;

    playlist_list.append(playlistHistory);
    playlist_list.append(playlist);

    player->setVideoOutput(videoWidget);
    player->setPlaylist(playlist);
    player->setVolume(60);

    connect(tbn_openVideoFile,SIGNAL(clicked()), this, SLOT(openVideoFile()));
    connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
/*    connect(this, SIGNAL(moveWindow(QPoint)), videoList, SLOT(toMoveWindow(QPoint)));*/

    //设置样式表
    setStyleSheet(
                "#videoPlayer{"
//                    "border-radius: 3px;"
                "}"
                "#lab_background{"
//                    "border-radius: 3px;"
                    "border-image: url(:/Images/videoPlayerBg.png);"
                "}"
                "#tbn_openVideoFile{"
                    "background: rgba(0, 0, 0, 30);"
                    "color: rgba(200, 255, 255, 255);"
                "}"
                );

    //创建定时器(1.5秒无鼠标动作按钮自动隐藏)
    timerHideWidgets = new QTimer(this);
    timerHideWidgets->start(hideButtonsTime);
    connect(timerHideWidgets, SIGNAL(timeout()), this, SLOT(hideWidgets_timeout()));


    //操作控制
    connect(videoWidget, SIGNAL(clicked()), this, SLOT(videoPlayPause()));
    connect(videoWidget, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen()));
//    connect(videoWidget, SIGNAL(goForward()), this, SLOT(videoGoForward()));
//    connect(videoWidget, SIGNAL(retreat()), this, SLOT(videoRetreat()));
    connect(videoWidget, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int)));
    connect(videoWidget, SIGNAL(volumnAdd()), this, SLOT(volumnAdd()));
    connect(videoWidget, SIGNAL(volumnReduce()), this, SLOT(volumnReduce()));

    connect(videoContral, SIGNAL(isHideWidget(bool)), this, SLOT(isHideWidget(bool)));
    connect(videoContral, SIGNAL(playerStop()), player, SLOT(stop()));
    connect(videoContral, SIGNAL(playPause()), this, SLOT(videoPlayPause()));
    connect(videoContral, SIGNAL(playNext()), player->playlist(), SLOT(next()));
    connect(videoContral, SIGNAL(currentMediaEnd()), this, SLOT(currentMediaEnd()));
//    connect(videoContral, SIGNAL(goForward()), this, SLOT(videoGoForward()));
//    connect(videoContral, SIGNAL(retreat()), this, SLOT(videoRetreat()));
    connect(videoContral, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int)));
    connect(videoContral, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen()));

    connect(player, SIGNAL(durationChanged(qint64)), videoContral, SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(setVideoTitle()));
    connect(player, SIGNAL(positionChanged(qint64)), videoContral, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playStateChanged(QMediaPlayer::State)));

    //
    connect(videoContral, SIGNAL(itemDoubleClicked(int, int)), this, SLOT(itemDoubleClicked(int, int)));

//    videoWidget->setFocus();
    timerKeepAwake = new QTimer(this);
    connect(timerKeepAwake, SIGNAL(timeout()), this, SLOT(timeoutKeepAwake()));
}
	//-------------------------------------------------------------------------------------------------//
	void GLXWindow::create(const String& name, uint width, uint height,
			   bool fullScreen, const NameValuePairList *miscParams)
	{
		Display *xDisplay = mGLSupport->getXDisplay();
		String title = name;
		uint samples = 0;
		short frequency = 0;
		bool vsync = false;
		unsigned int vsyncInterval = 1;
		int gamma = 0;
		::GLXContext glxContext = 0;
		::GLXDrawable glxDrawable = 0;
		Window externalWindow = 0;
		Window parentWindow = DefaultRootWindow(xDisplay);
		int left = DisplayWidth(xDisplay, DefaultScreen(xDisplay))/2 - width/2;
		int top  = DisplayHeight(xDisplay, DefaultScreen(xDisplay))/2 - height/2;
		
		mIsFullScreen = fullScreen;
		
		if(miscParams)
		{
			NameValuePairList::const_iterator opt;
			NameValuePairList::const_iterator end = miscParams->end();
			
			// NB: Do not try to implement the externalGLContext option.
			//
			//	 Accepting a non-current context would expose us to the 
			//	 risk of segfaults when we made it current. Since the
			//	 application programmers would be responsible for these
			//	 segfaults, they are better discovering them in their code.
		
			if ((opt = miscParams->find("currentGLContext")) != end &&
				StringConverter::parseBool(opt->second))
			{
				if (! glXGetCurrentContext())
				{
					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "currentGLContext was specified with no current GL context", "GLXWindow::create");
				}
				
				glxContext = glXGetCurrentContext();
				glxDrawable = glXGetCurrentDrawable();
			}
			
			// Note: Some platforms support AA inside ordinary windows
			if((opt = miscParams->find("FSAA")) != end) 
				samples = StringConverter::parseUnsignedInt(opt->second);
			
			if((opt = miscParams->find("displayFrequency")) != end) 
				frequency = (short)StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("vsync")) != end) 
				vsync = StringConverter::parseBool(opt->second);

			if((opt = miscParams->find("vsyncInterval")) != end) 
				vsyncInterval = StringConverter::parseUnsignedInt(opt->second);

			if ((opt = miscParams->find("gamma")) != end)
				gamma = StringConverter::parseBool(opt->second);

			if((opt = miscParams->find("left")) != end) 
				left = StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("top")) != end) 
				top = StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("title")) != end) 
				title = opt->second;
			
			if ((opt = miscParams->find("externalGLControl")) != end)
				mIsExternalGLControl = StringConverter::parseBool(opt->second);
			
			if((opt = miscParams->find("parentWindowHandle")) != end) 
			{
				vector<String>::type tokens = StringUtil::split(opt->second, " :");
				
				if (tokens.size() == 3)
				{
					// deprecated display:screen:xid format
					parentWindow = StringConverter::parseUnsignedLong(tokens[2]);
				}
				else
				{
					// xid format
					parentWindow = StringConverter::parseUnsignedLong(tokens[0]);
				}
			}
			else if((opt = miscParams->find("externalWindowHandle")) != end) 
			{
				vector<String>::type tokens = StringUtil::split(opt->second, " :");
				
				LogManager::getSingleton().logMessage(
													  "GLXWindow::create: The externalWindowHandle parameter is deprecated.\n"
													  "Use the parentWindowHandle or currentGLContext parameter instead.");
				
				if (tokens.size() == 3)
				{
					// Old display:screen:xid format
					// The old GLX code always created a "parent" window in this case:
					parentWindow = StringConverter::parseUnsignedLong(tokens[2]);
				}
				else if (tokens.size() == 4)
				{
					// Old display:screen:xid:visualinfo format
					externalWindow = StringConverter::parseUnsignedLong(tokens[2]);
				}
				else
				{
					// xid format
					externalWindow = StringConverter::parseUnsignedLong(tokens[0]);
				}
			}
		}
		
		// Ignore fatal XErrorEvents during parameter validation:
		oldXErrorHandler = XSetErrorHandler(safeXErrorHandler);
		// Validate parentWindowHandle
		
		if (parentWindow != DefaultRootWindow(xDisplay))
		{
			XWindowAttributes windowAttrib;
			
			if (! XGetWindowAttributes(xDisplay, parentWindow, &windowAttrib) ||
				windowAttrib.root != DefaultRootWindow(xDisplay))
			{
				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Invalid parentWindowHandle (wrong server or screen)", "GLXWindow::create");
			}
		}
		
		// Validate externalWindowHandle
		
		if (externalWindow != 0)
		{
			XWindowAttributes windowAttrib;
			
			if (! XGetWindowAttributes(xDisplay, externalWindow, &windowAttrib) ||
				windowAttrib.root != DefaultRootWindow(xDisplay))
			{
				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Invalid externalWindowHandle (wrong server or screen)", "GLXWindow::create");
			}
			glxDrawable = externalWindow;
		}

		// Derive fbConfig
		
		::GLXFBConfig fbConfig = 0;
		
		if (glxDrawable)
		{
			fbConfig = mGLSupport->getFBConfigFromDrawable (glxDrawable, &width, &height);
		}

		if (! fbConfig && glxContext)
		{
			fbConfig = mGLSupport->getFBConfigFromContext (glxContext);
		}
			
		mIsExternal = (glxDrawable != 0);
		
		XSetErrorHandler(oldXErrorHandler);
		
		if (! fbConfig)
		{
			int minAttribs[] = {
				GLX_DRAWABLE_TYPE,  GLX_WINDOW_BIT,
				GLX_RENDER_TYPE,	GLX_RGBA_BIT,
				GLX_RED_SIZE,	   1,
				GLX_BLUE_SIZE,	  1,
				GLX_GREEN_SIZE,	 1,
				None
			};
			
			int maxAttribs[] = {
				GLX_SAMPLES,		samples,
				GLX_DOUBLEBUFFER,   1,
				GLX_STENCIL_SIZE,   INT_MAX,
				GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, 1,
				None
			};

			fbConfig = mGLSupport->selectFBConfig(minAttribs, maxAttribs);

			if (gamma != 0)
			{
				mGLSupport->getFBConfigAttrib(fbConfig, GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &gamma);
			}

			mHwGamma = (gamma != 0);
		}
		
    if (! fbConfig)
    {
      // This should never happen.
      OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unexpected failure to determine a GLXFBConfig","GLXWindow::create");
    }
		
		mIsTopLevel = (! mIsExternal && parentWindow == DefaultRootWindow(xDisplay));
		
		if (! mIsTopLevel)
		{
			mIsFullScreen = false;
			left = top = 0;
		}
		
		if (mIsFullScreen) 
		{
			mGLSupport->switchMode (width, height, frequency);
		}
		
		if (! mIsExternal)
		{
			XSetWindowAttributes attr;
			ulong mask;
			XVisualInfo *visualInfo = mGLSupport->getVisualFromFBConfig (fbConfig);
			
			attr.background_pixel = 0;
			attr.border_pixel = 0;
			attr.colormap = XCreateColormap(xDisplay, DefaultRootWindow(xDisplay), visualInfo->visual, AllocNone);
			attr.event_mask = StructureNotifyMask | VisibilityChangeMask | FocusChangeMask;
			mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
			
			if(mIsFullScreen && mGLSupport->mAtomFullScreen == None) 
			{
				LogManager::getSingleton().logMessage("GLXWindow::switchFullScreen: Your WM has no fullscreen support");
				
				// A second best approach for outdated window managers
				attr.backing_store = NotUseful;
				attr.save_under = False;
				attr.override_redirect = True;
				mask |= CWSaveUnder | CWBackingStore | CWOverrideRedirect;
				left = top = 0;
			} 
			
			// Create window on server
			mWindow = XCreateWindow(xDisplay, parentWindow, left, top, width, height, 0, visualInfo->depth, InputOutput, visualInfo->visual, mask, &attr);
			
			XFree(visualInfo);
			
			if(!mWindow) 
			{
				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to create an X Window", "GLXWindow::create");
			}
			
			if (mIsTopLevel)
			{
				XWMHints *wmHints;
				XSizeHints *sizeHints;
				
				if ((wmHints = XAllocWMHints()) != NULL) 
				{
					wmHints->initial_state = NormalState;
					wmHints->input = True;
					wmHints->flags = StateHint | InputHint;
					
					int depth = DisplayPlanes(xDisplay, DefaultScreen(xDisplay));
					
					// Check if we can give it an icon
					if(depth == 24 || depth == 32) 
					{
						if(mGLSupport->loadIcon("GLX_icon.png", &wmHints->icon_pixmap, &wmHints->icon_mask))
						{
							wmHints->flags |= IconPixmapHint | IconMaskHint;
						}
					}
				}
				
				// Is this really necessary ? Which broken WM might need it?
				if ((sizeHints = XAllocSizeHints()) != NULL)
				{
					sizeHints->flags = USPosition;
				}
				
				XTextProperty titleprop;
				char *lst = (char*)title.c_str();
				XStringListToTextProperty((char **)&lst, 1, &titleprop);
				XSetWMProperties(xDisplay, mWindow, &titleprop, NULL, NULL, 0, sizeHints, wmHints, NULL);
				
				XFree(titleprop.value);
				XFree(wmHints);
				XFree(sizeHints);
				
				XSetWMProtocols(xDisplay, mWindow, &mGLSupport->mAtomDeleteWindow, 1);
				
				XWindowAttributes windowAttrib;
				
				XGetWindowAttributes(xDisplay, mWindow, &windowAttrib);
				
				left = windowAttrib.x;
				top = windowAttrib.y;
				width = windowAttrib.width;
				height = windowAttrib.height;
			}
			
			glxDrawable = mWindow;
			
			XMapWindow(xDisplay, mWindow);
			
			if (mIsFullScreen)
			{
				switchFullScreen (true);
			}
			XFlush(xDisplay);
			
			WindowEventUtilities::_addRenderWindow(this);
		}
		
    mContext = new GLXContext(mGLSupport, fbConfig, glxDrawable, glxContext);
		
		::GLXDrawable oldDrawable = glXGetCurrentDrawable();
		::GLXContext  oldContext  = glXGetCurrentContext();
		
		mContext->setCurrent();
		
		if (! mIsExternalGLControl && GLXEW_SGI_swap_control)
		{
			glXSwapIntervalSGI (vsync ? vsyncInterval : 0);
		}
		
		mContext->endCurrent();
		
		glXMakeCurrent (mGLSupport->getGLDisplay(), oldDrawable, oldContext);
		
		int fbConfigID;
		
		mGLSupport->getFBConfigAttrib(fbConfig, GLX_FBCONFIG_ID, &fbConfigID);
		
		LogManager::getSingleton().logMessage("GLXWindow::create used FBConfigID = " + StringConverter::toString(fbConfigID));
		
		mName = name;
		mWidth = width;
		mHeight = height;
		mLeft = left;
		mTop = top;
		mActive = true;
		mClosed = false;
	}
Exemple #14
0
// Distributes task for the "key" kind of events 
// For example : std::cout when b key is pressed
void Application::handleKeyDownEvents(SDL_keysym* keysym)
{
	switch(keysym->sym)
    	{
    		case SDLK_ESCAPE:
      			_done=true;
      			break;
      	
		// W : wireframe
    		case SDLK_w :
      			switchWireframe();
      			break;
      	
		// F : fullscreen
     		case SDLK_f :
      			switchFullScreen();
      			break;     	
	
		//@TO_REMOVE
		// E : explose everything
		case SDLK_e :
			for(unsigned int i=0; i<m_figures.size(); ++i)
				m_figures[i] = new Explosion(m_figures[i]);
			break;

		//@TO_REMOVE
		// B : make everything as Boids
		case SDLK_b :
			for(unsigned int i=0; i<m_figures.size(); ++i)
				m_figures[i] = new Boids(m_figures[i]);
			break;

		// Space : launch play mode
		// It is easier to keep the camera mode 
		// as the global play mode for the Application
		case SDLK_SPACE :
			m_camera->startPlayMode();
			break;
		
		// Render : launch the renderman rendermode
		// Like a play mode but with the render option enabled
		case SDLK_r :
			m_renderFlag = true;
			m_camera->startPlayMode();
			break;

		// FPS management
		// classic : Z,Q,S,D
		case SDLK_z :	
			m_goingForward = true;
		      	break;
		case SDLK_s :
			m_goingBackward = true;
			break;
		case SDLK_q :
			m_goingLeft = true;
			break;
		case SDLK_d :
			m_goingRight = true;			
			break;

    		default:
      			break;
  	}
}