void changeFullscreenMode() override {
			if(fullscreenMode() == FullScreenMode::FULLSCREEN_EXCLUSIVE) {
				nonfs_width_ = width();
				nonfs_height_ = height();
				if(SDL_SetWindowFullscreen(window_.get(), SDL_WINDOW_FULLSCREEN) != 0) {
					LOG_WARN("Unable to set fullscreen mode at " << width() << " x " << height());
					return;
				}
			} else if(fullscreenMode() == FullScreenMode::FULLSCREEN_WINDOWED) {
				nonfs_width_ = width();
				nonfs_height_ = height();

				if(SDL_SetWindowFullscreen(window_.get(), SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
					LOG_WARN("Unable to set windowed fullscreen mode at " << width() << " x " << height());
					return;
				}
				SDL_SetWindowSize(window_.get(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED);
				SDL_SetWindowPosition(window_.get(), 0, 0);

			} else {
				if(SDL_SetWindowFullscreen(window_.get(), 0) != 0) {
					LOG_WARN("Unable to set windowed mode at " << width() << " x " << height());
					return;
				}
				SDL_SetWindowSize(window_.get(), nonfs_width_, nonfs_height_);
				SDL_SetWindowPosition(window_.get(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
			}
			int w, h;
			SDL_GetWindowSize(window_.get(), &w, &h);
			// update viewport
			setViewPort(0, 0, w, h);
			// update width_ and height_ and notify observers
			updateDimensions(w, h);
		}
/*
 * Shuffles the window around in a circle
 * PARAMS:
 *		iters: number of times to move in a full circle
 *		offset: pixel distance moved at each step
 *		delay: time between steps (not full circles)
 */
void CycleAround(int iters, int offset, int delay) {
	int x, y;
	SDL_GetWindowPosition(window, &x, &y);

	int cnt;
	for(cnt=0; cnt < iters; cnt++) {
		SDL_SetWindowPosition(window, x+offset, y); 	   SDL_Delay(delay);
		SDL_SetWindowPosition(window, x+offset, y+offset); SDL_Delay(delay);
		SDL_SetWindowPosition(window, x,        y+offset); SDL_Delay(delay);
		SDL_SetWindowPosition(window, x,        y);        SDL_Delay(delay);
	}
	EndDemo();
}
int
X11_ResizeWindowShape(SDL_Window* window) {
    SDL_ShapeData* data = window->shaper->driverdata;
    SDL_assert(data != NULL);
    
    unsigned int bitmapsize = window->w / 8;
    if(window->w % 8 > 0)
        bitmapsize += 1;
    bitmapsize *= window->h;
    if(data->bitmapsize != bitmapsize || data->bitmap == NULL) {
        data->bitmapsize = bitmapsize;
        if(data->bitmap != NULL)
            free(data->bitmap);
        data->bitmap = malloc(data->bitmapsize);
        if(data->bitmap == NULL) {
            SDL_SetError("Could not allocate memory for shaped-window bitmap.");
            return -1;
        }
    }
    memset(data->bitmap,0,data->bitmapsize);
    
    window->shaper->userx = window->x;
    window->shaper->usery = window->y;
    SDL_SetWindowPosition(window,-1000,-1000);
    
    return 0;
}
void Window_UpdateVideo(void)
{
	if (Video.msaa_samples != cv_video_msaasamples.iValue)
	{
		// TODO: Destroy window etc.

		Video.msaa_samples = cv_video_msaasamples.iValue;
	}

	SDL_SetWindowSize(sMainWindow, Video.iWidth, Video.iHeight);

	if (Video.vertical_sync != cv_video_verticlesync.bValue)
	{
		SDL_GL_SetSwapInterval(cv_video_verticlesync.iValue);

		Video.vertical_sync = cv_video_verticlesync.bValue;
	}

	if (Video.fullscreen != cv_video_fullscreen.bValue)
	{
		if (SDL_SetWindowFullscreen(sMainWindow, (SDL_bool)cv_video_fullscreen.bValue) == -1)
		{
			Con_Warning("Failed to set window mode!\n%s", SDL_GetError());

			// Reset the variable to the current value.
			Cvar_SetValue(cv_video_fullscreen.name, Video.fullscreen);
		}
		else
			Video.fullscreen = cv_video_fullscreen.bValue;
	}

	if (!cv_video_fullscreen.value)
		// Center the window, to ensure it's not off screen.
		SDL_SetWindowPosition(sMainWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
Beispiel #5
0
void Graphics::SetWindowPosition(const IntVector2& position)
{
    if (window_)
        SDL_SetWindowPosition(window_, position.x_, position.y_);
    else
        position_ = position; // Sets as initial position for OpenWindow()
}
Beispiel #6
0
    void KGLWindow::setPosition(const KVector2I32 &Pos){
		if (_kwindow) {
			DSDL_CALL(SDL_SetWindowPosition(_kwindow, Pos.x, Pos.y));
			_kwinstate.xpos = Pos.x;
			_kwinstate.ypos = Pos.y;
		}
    }
Beispiel #7
0
void video_set_position( const struct point *position )
{
	video_options.position = *position;
	if ( video_window != NULL ) {
		SDL_SetWindowPosition( video_window, position->x, position->y );
	}
}
 void SDL2WindowBackend::setPosition(int32_t x, int32_t y)
 {
     if(isOpen())
     {
         SDL_SetWindowPosition(mWindow, x, y);
     }
 }
Beispiel #9
0
void VR::orient_window(Game &game) const
{
    SDL_SetWindowSize(game.window(), m_hmd->Resolution.w, m_hmd->Resolution.h);
    SDL_SetWindowPosition(game.window(),
                          m_hmd->WindowsPos.x, m_hmd->WindowsPos.y);
    SDL_SetWindowFullscreen(game.window(), SDL_WINDOW_FULLSCREEN_DESKTOP);
}
/** Native windows should implement MoveWindowTo by relocating the platform-specific window to (X,Y). */
void FLinuxWindow::MoveWindowTo( int32 X, int32 Y )
{
	// we are passed coordinates of a client area, so account for decorations
	checkf(bValidNativePropertiesCache, TEXT("Attempted to use border sizes too early, native properties aren't yet cached. Review the flow"));

	SDL_SetWindowPosition( HWnd, X - LeftBorderWidth, Y - TopBorderHeight );
}
bool GraphicsWindowSDL2::setWindowRectangleImplementation(int x, int y, int width, int height)
{
    if(!mWindow) return false;

    SDL_SetWindowPosition(mWindow, x, y);
    SDL_SetWindowSize(mWindow, width, height);
    return true;
}
Beispiel #12
0
void Window::setPosition( int x, int y ) noexcept
{
    WindowInfo winfo;
    getInfo( winfo );

    if ( !winfo.wflags.fullscreen )
        SDL_SetWindowPosition( m_wimpl->window, x, y );

}
Beispiel #13
0
void SDLManager::setWindowPos(int x, int y){
	if(x != -1){	
		_windowSettings.windowPosX = x;
	}
	if(y != -1){
		_windowSettings.windowPosY = y;	
	}
	SDL_SetWindowPosition(_window,_windowSettings.windowPosX,_windowSettings.windowPosY);
}
Beispiel #14
0
bool gutCenterWindow(void) {
	chkwin;
	SDL_SetWindowPosition(
		gut.core->window.handle,
		SDL_WINDOWPOS_CENTERED,
		SDL_WINDOWPOS_CENTERED
	);
	return true;
}
Beispiel #15
0
void UIInterface::setWindowPosition(int x, int y)
{
    SDL_SetWindowPosition(this->m_Win, (x == NIDIUM_WINDOWPOS_UNDEFINED_MASK)
                                           ? SDL_WINDOWPOS_UNDEFINED_MASK
                                           : x,
                          (y == NIDIUM_WINDOWPOS_UNDEFINED_MASK)
                              ? SDL_WINDOWPOS_UNDEFINED_MASK
                              : y);
}
Beispiel #16
0
	void BaseManager::setWindowCoord(const MyGUI::IntCoord& _value)
	{
		if (_value.empty())
			return;

		MyGUI::IntCoord coord = _value;

		SDL_SetWindowPosition(mWindow, coord.left, coord.top);
	}
Beispiel #17
0
        void WindowSDL2::set_position(int x, int y) {

            if(closed) {
                return;
            }

            SDL_SetWindowPosition(window, x, y);

        } //set_position
Beispiel #18
0
void toggleFullscreen(SDL_Window* window, SDL_Renderer* renderer, bool &isFullscreen, int &width, int &height)
{
	SDL_SetWindowFullscreen(window, isFullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
	if (!isFullscreen)
		SDL_SetWindowSize(window, 800, 600); //or 1024x768

	isFullscreen = !isFullscreen; //toggle isFullscreen
	SDL_GetRendererOutputSize(renderer, &width, &height);
	SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
Beispiel #19
0
	inline Window& Window::SetPosition(int32 X, int32 Y) {
		x = X;
		y = Y;
		
		if (m_window == NULL) {
			return *this;
		}
		SDL_SetWindowPosition(m_window, X, Y);
		return *this;
	}
void Window::resizeWindow(int x, int y, int w, int h)
{
    SDL_SetWindowSize(window, w, h);
    SDL_SetWindowPosition(window, x, y);

    dimensions.x = x;
    dimensions.y = y;
    dimensions.w = w;
    dimensions.h = h;
}
Beispiel #21
0
bool Client::SetFullScreen (const bool want_fullscreen)
{
    if (want_fullscreen == fullscreen)
        return true;

    if (want_fullscreen)
    {
        SDL_SetWindowPosition (mainWindow, 0, 0);

        int x, y, w, h;
        SDL_GetWindowSize (mainWindow, &w, &h);
        SDL_GetMouseState (&x, &y);

        // Clamp mouse position
        x = std::max (0, std::min (x, w));
        y = std::max (0, std::min (y, h));
        SDL_WarpMouseInWindow (mainWindow, x, y);
    }

    Uint32 flags = want_fullscreen? SDL_WINDOW_FULLSCREEN : 0;

    if (SDL_SetWindowFullscreen (mainWindow, flags) < 0)
    {
        SetError ("Cannot set fullscreen to %d: %s", want_fullscreen, SDL_GetError ());
        return false;
    }

    fullscreen = want_fullscreen;
    SaveSetting (settingsPath.c_str (), FULLSCREEN_SETTING, fullscreen);

    // Some final adjustments
    if (fullscreen)
    {
        SDL_SetWindowGrab (mainWindow, SDL_TRUE);
    }
    else
    {
        SDL_SetWindowGrab (mainWindow, SDL_FALSE);
        SDL_SetWindowPosition (mainWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
    }

    return true;
}
Beispiel #22
0
void GraphicsEngine::setWindowSize(const int &w, const int &h) {
	SDL_SetWindowSize(window, w, h);
	SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
#ifdef __DEBUG
	debug("Set Window W", w);
	debug("Set Window H", h);
#endif
	Camera::instance->cameraPerspective.width = (float)w;
	Camera::instance->cameraPerspective.height = (float)h;
	glViewport(0, 0, w, h);	// Core in version 	4.4
}
void Window::forceFullscreenMode(int w, int h)
{
    if (!isFullscreen())
    {
        fullscreen = true;
        setSize(w, h);

        SDL_SetWindowPosition(window, 0, 0);
        SDL_SetWindowSize(window, w, h);
        SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
    }
}
void Window::forceWindowedMode()
{
    if (isFullscreen())
    {
        fullscreen = false;
        setSize(1280, 720);

        SDL_SetWindowSize(window, 1280, 720);
        SDL_SetWindowFullscreen(window, NULL);
        SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
    }
}
Beispiel #25
0
	int Window::setWindowPosition(State & state, SDL_Window  * window){
		Stack * stack = state.stack;
		if (stack->is<LUA_TTABLE>(1)){
			stack->getField("x", 1);
			stack->getField("y", 1);

			if (stack->is<LUA_TNUMBER>(-2) && stack->is<LUA_TNUMBER>(-1)){
				SDL_SetWindowPosition(window, stack->to<int>(-2), stack->to<int>(-1));
			}
			stack->pop(2);
		}
		return 0;
	}
/*
 * Vibrates the window randomly
 * PARAMS:
 *		iters: number of times to vibrate the window
 *		pos_variance: pixel area size the window may move around
 *		delay: time between vibrations
 */
void Shake(int iters, int pos_variance, int delay) {
	int half_variance = pos_variance / 2;

	int x, y;
	SDL_GetWindowPosition(window, &x, &y);

	int x_offset, y_offset;
	int cnt;
	for(cnt=0; cnt < iters; cnt++) {
		x_offset = rand() % pos_variance - half_variance;
		y_offset = rand() % pos_variance - half_variance;

		SDL_SetWindowPosition(window,
			x + x_offset,
			y + y_offset
		);
		SDL_Delay(delay);
	}

	SDL_SetWindowPosition(window, x, y);
	EndDemo();
}
Beispiel #27
0
int
DirectFB_ResizeWindowShape(SDL_Window* window) {
    SDL_ShapeData* data = window->shaper->driverdata;
    SDL_assert(data != NULL);
        
    if (window->x != -1000) 
    {
		window->shaper->userx = window->x;
		window->shaper->usery = window->y;
    }
    SDL_SetWindowPosition(window,-1000,-1000);
    
    return 0;
}
void windowToggleFullscreen() {
	SDL_SetWindowFullscreen(sdl_window,
		windowIsFullscreen() ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);

	app->video.fullscreen = windowIsFullscreen();

#ifdef _WIN32
	// hack for when the title bar is off screen after restoring from fullscreen
	if (!app->video.fullscreen) {
		int x, y;
		SDL_GetWindowPosition(sdl_window, &x, &y);
		if (y < 32) SDL_SetWindowPosition(sdl_window, x, 32);
	}
#endif
}
Beispiel #29
0
static void GLimp_CreateWindow( int x, int y, int width, int height )
{
	glw_state.sdl_window = SDL_CreateWindow( glw_state.applicationName, 
		SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL );

	if( !glw_state.sdl_window )
		Sys_Error( "Couldn't create window: \"%s\"", SDL_GetError() );

	if( glw_state.wndproc ) {
		glw_state.wndproc( glw_state.sdl_window, 0, 0, 0 );
	}

	SDL_SetWindowPosition( glw_state.sdl_window, x, y );

	GLimp_SetWindowIcon();
}
static bool SetScreenParmsWindowed( glimpParms_t parms )
{
	SDL_SetWindowSize( window, parms.width, parms.height );
	SDL_SetWindowPosition( window, parms.x, parms.y );
	
	// if we're currently in fullscreen mode, we need to disable that
	if( SDL_GetWindowFlags( window ) & SDL_WINDOW_FULLSCREEN )
	{
		if( SDL_SetWindowFullscreen( window, SDL_FALSE ) < 0 )
		{
			common->Warning( "Couldn't switch to windowed mode, reason: %s!", SDL_GetError() );
			return false;
		}
	}
	return true;
}