void myWindow::OnKeyUp(int nKey, char cAscii)
{
	if (cAscii == 'f')
	{
		SetFullscreen(true);
	}
	else if (cAscii == 'w')
	{
		SetFullscreen(false);
	}
};
// Key up event handler.
void myWindow::OnKeyUp(int nKey, char cAscii)
{
	if (cAscii == 'o')
	{
		SetFullscreen(true);
	}
	else if (cAscii == 'l')
	{
		SetFullscreen(false);
	}

	// Disparamos evento de tecla liberada
	this->scene.onKeyUp(nKey, cAscii);
}
Пример #3
0
void CMyWindow::OnDestroy()
{
	SetFullscreen(false);
	PostQuitMessage(0);

	MSG_FORWARD_WM_DESTROY(CIdleOpenGLWnd);
}
Пример #4
0
void
Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
                            SDL_VideoDisplay * _display, SDL_bool fullscreen)
{
    struct wl_output *output = (struct wl_output *) _display->driverdata;
    SetFullscreen(_this, window, fullscreen ? output : NULL);
}
Пример #5
0
void CMyWindow::Create()
{
	const DWORD style = WS_POPUP | COpenGLWnd::WS_STYLE;

	int width = GetSystemMetrics(SM_CXSCREEN);
	int height = GetSystemMetrics(SM_CYSCREEN);

	CWindow::CreateEx(
		WS_EX_APPWINDOW,
		CWndClass(nullptr, COpenGLWnd::CS_STYLE | CS_DBLCLKS),
		L"OpenGL IWL", style,
		0, 0, width, height
		);
	SetFullscreen();
}
Пример #6
0
void 
MWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_KEY_DOWN:
		{
			uint32 code = message->FindInt32("key");
			uint32 raw_char = message->FindInt32("raw_char");

			switch (raw_char) {
				case B_ESCAPE:
					if(vo_fs==1) {
						vo_fs = !vo_fs;
	     	 			SetFullscreen(vo_fs);
					} else {
		     	 		mplayer_put_key(KEY_ESC);
					}
					break;
				case B_LEFT_ARROW:
					mplayer_put_key(KEY_LEFT);
					break;
				case B_RIGHT_ARROW:
					mplayer_put_key(KEY_RIGHT);
					break;
				case B_UP_ARROW:
					mplayer_put_key(KEY_UP);
					break;					
				case B_DOWN_ARROW:
					mplayer_put_key(KEY_DOWN);
					break;
				case B_FUNCTION_KEY:
					mplayer_put_key(KEY_F+code-1);
					break;
				case B_ENTER:
					mplayer_put_key(KEY_ENTER);
					break;					
				default:
					mplayer_put_key(raw_char);
					break;
					
			}     	 	
			break;
		}	
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Пример #7
0
RenderWindow2D::RenderWindow2D(unsigned int width, unsigned int height, bool fullscreen, const CString& scaler, unsigned int requestedScaleFactor)
   :scaleFactor(1),
   unscaledWidth(width),
   unscaledHeight(height),
   scalerFunc(nullptr)
{
   LoadScaler(scaler, requestedScaleFactor);

   scaleFactor = requestedScaleFactor;

   if (!CreateWindowAndRenderer(width, height))
      throw std::runtime_error("couldn't create window");

   SetFullscreen(fullscreen);

   SDL_SetRenderDrawColor(renderer.get(), 0, 0, 0, 255); // black
   SDL_RenderClear(renderer.get());
   SDL_RenderPresent(renderer.get());
}
Пример #8
0
        Win32Window::Win32Window(int width, int height, const Xli::String& title, int flags)
        {
            this->ownsHwnd = true;
            this->closed = false;
            this->fullscreen = false;
            this->eventHandler = eventHandler;

            if (flags & WindowFlagsFullscreen)
            {
                flags &= ~WindowFlagsFullscreen;
                fullscreen = true;
            }

            rect.top = 0;
            rect.left = 0;
            rect.bottom = height;
            rect.right = width;

            dwStyle = StyleFromXliWindowFlags(flags);
            AdjustWindowRect(&rect, dwStyle, 0);

            Utf16String titleW = Unicode::Utf8To16(title);
            hWnd = CreateWindowW(WindowClassName, titleW.Ptr(), dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, 0, 0, HInstance, 0);

            if (!hWnd)
                XLI_THROW("Failed to create window: " + Win32::GetLastErrorString());

            if (!MainWindow)
                MainWindow = this;

            SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));

            ShowWindow(hWnd, SW_NORMAL);
            SetForegroundWindow(hWnd);
            SetFocus(hWnd);

            if (fullscreen)
            {
                fullscreen = false;
                SetFullscreen(true);
            }
        }
Пример #9
0
void MyWindow::OnKeyboard(int key, bool down) {
	if (!down) return;
	switch( tolower(key) ) {
	case 'a': 
		_cameraAngle += 5.0;
		break;
	case 'z':
		_cameraAngle -= 5.0;
		break;
	case 'f':
		_fullscreen = !_fullscreen;
		SetFullscreen(_fullscreen);
		break;
	case 'q':
		Close();
		break;
	default:
		break;
	}
}	
Пример #10
0
	void Application::SetContentSize(const Vec2I& size)
	{
		Vec2I clientRectSize = size;

		RECT clientRect;
		GetClientRect(mHWnd, &clientRect);
		clientRect.right = clientRect.left + size.x;
		clientRect.bottom = clientRect.top + size.y;

		AdjustWindowRect(&clientRect, mWndStyle, false);

		mWindowedPos = Vec2I(clientRect.left, clientRect.top);
		mWindowedSize = Vec2I(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);

		mLog->Out("Set Content Size: %ix%i", size.x, size.y);

		SetFullscreen(!mWindowed);

		mRender->OnFrameResized();
		onResizing();
	}
Пример #11
0
bool MythDialogBox::Create(void)
{
    if (!CopyWindowFromBase("MythDialogBox", this))
        return false;

    SetFullscreen(false);

    MythUIText *textarea = dynamic_cast<MythUIText *>(GetChild("messagearea"));
    buttonList = dynamic_cast<MythListButton *>(GetChild("list"));

    if (!textarea || !buttonList)
        return false;

    textarea->SetText(m_text);
    buttonList->SetActive(true);

    connect(buttonList, SIGNAL(itemClicked(MythListButtonItem*)),
            this, SLOT(Select(MythListButtonItem*)));

    return true;
}
Пример #12
0
void Game::ToggleFullscreen()
{
  this->fullscreen_ = !this->fullscreen_;
  SetFullscreen(this->fullscreen_, false);
}
Пример #13
0
void 
MWindow::Zoom(BPoint origin, float width,float height)
{
 	vo_fs = !vo_fs;
 	SetFullscreen(vo_fs);	
}
Пример #14
0
	void Application::SetWindowPosition(const Vec2I& position)
	{
		mWindowedPos = position;
		mLog->Out("Set window position: %i, %i", mWindowedPos.x, mWindowedPos.y);
		SetFullscreen(!mWindowed);
	}
Пример #15
0
	void Application::SetWindowSize(const Vec2I& size)
	{
		mWindowedSize = size;
		mLog->Out("Set sindow size: %ix%i", mWindowedSize.x, mWindowedSize.y);
		SetFullscreen(!mWindowed);
	}
Пример #16
0
void CMainFrame::OnViewFullscreen() 
{
	SetFullscreen();
}
Пример #17
0
	inline Window& Window::ToggleFullscreen(void) {
		SetFullscreen(!m_fullscreen);
		return *this;
	}
Пример #18
0
HRESULT PlayMedia(LPTSTR lpszMovie, HINSTANCE hInstance)
{
    HRESULT hr = S_OK;
    BOOL bSleep=TRUE;

    if (!lpszMovie)
        return E_POINTER;

    // Allow DirectShow to create the FilterGraph for this media file
    hr = pGB->RenderFile(lpszMovie, NULL);
    if (FAILED(hr)) {
        Msg(TEXT("Failed(0x%08lx) in RenderFile(%s)!\r\n"), hr, lpszMovie);
        return hr;
    }

    // Set the message drain of the video window to point to our hidden
    // application window.  This allows keyboard input to be transferred
    // to our main window for processing.
    //
    // If this is an audio-only or MIDI file, then put_MessageDrain will fail.
    //
    hr = pVW->put_MessageDrain((OAHWND) g_hwndMain);
    if (FAILED(hr))
    {
        Msg(TEXT("Failed(0x%08lx) to set message drain for %s.\r\n\r\n")
            TEXT("This sample is designed to play videos, but the file selected ")
            TEXT("has no video component."), hr, lpszMovie);
        return hr;
    }

    // Set fullscreen
    hr = SetFullscreen();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) to set fullscreen!\r\n"), hr);
        return hr;
    }

    // Display first frame of the movie
    hr = pMC->Pause();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) in Pause()!\r\n"), hr);
        return hr;
    }

    // Start playback
    hr = pMC->Run();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) in Run()!\r\n"), hr);
        return hr;
    }

    // Update state variables
    g_bContinue = TRUE;

    // Enter a loop of checking for events and sampling keyboard input
    while (g_bContinue)
    {
        MSG msg;
        long lEventCode;
        LONG_PTR lpParam1, lpParam2;

        // Reset sleep flag
        bSleep = TRUE;

        // Has there been a media event?  Look for end of stream condition.
        if(E_ABORT != pME->GetEvent(&lEventCode, &lpParam1, 
                                    &lpParam2, 0))
        {
            // Is this the end of the movie?
            if (lEventCode == EC_COMPLETE)
            {
                g_bContinue = FALSE;
                bSleep = FALSE;
            }

            // Free the media event resources
            hr = pME->FreeEventParams(lEventCode, lpParam1, lpParam2);
            if (FAILED(hr))
            {
                Msg(TEXT("Failed(%08lx) to free event params (%s)!\r\n"),
                    hr, lpszMovie);
            }
        }

        // Give system threads time to run (and don't sample user input madly)
        if (bSleep)
            Sleep(KEYBOARD_SAMPLE_FREQ);

        // Check and process window messages (like our keystrokes)
        while (PeekMessage (&msg, g_hwndMain, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return hr;
}
Пример #19
0
void FizzyWindow::OnKeyboard(i32 key, bool down)
{
	gameTime.Update();

	if(key == VK_ESCAPE && down)
	{
		Close();
	}

	float2 camPos = scn.get_cam_pos();
	f32 dt = (f32)gameTime.GetDeltaTime();
	dt = 0.016f;
	f32 camSpeed = scn.get_cam_speed();
	f32 zoomSpeed = scn.zoomSpeed;

	switch(tolower(key))
	{
	case 'f':
		{
			if(down) break;

			static bool fullscreen=false;

			fullscreen = !fullscreen;
			SetFullscreen(fullscreen);

			break;
		}

	case 'o':
		{
			if(down) break;

			if(!(scn.netController->mode & NetworkController::Connected)) // only change iff not connected
			{
				scn.doOwnershipUpdates = !scn.doOwnershipUpdates;
			}

		} break;
	case 'p':
		{
			if(down) break;

			if(scn.alive)
			{
				printf("Pausing application . . .\n");

				scn.alive=false;
				scn.primaryTaskPool_physThread->Join();

				for(int i=0;i<scn.netController->peers.size();++i)
				{
					RunningStatePacket rsp; rsp.runningState=RunningStatePacket::Paused;
					send(scn.netController->peers[i].socket, (char*)(&rsp), sizeof(rsp), 0);
				}
			}
			else
			{
				printf("Unpausing application . . .\n");

				for(int i=0;i<scn.netController->peers.size();++i)
				{
					RunningStatePacket rsp; rsp.runningState=RunningStatePacket::Unpaused;
					send(scn.netController->peers[i].socket, (char*)(&rsp), sizeof(rsp), 0);
				}
				scn.alive=true;
				scn.primaryTaskPool_physThread->AddTask(Task(physthread, &scn));
			}
		} break;

	case 'c':
		{
			if(!down)
			{
				scn.netController->cs.Lock();
				scn.netController->netAlive = false;
				scn.netController->cs.Unlock();

				scn.netController->Close();

				scn.primaryTaskPool_netThread->SigKill();
				scn.primaryTaskPool_netThread->InitPool(1);

				scn.netController->writeOffset = 0;
				memset(scn.netController->buff, 0, sizeof(scn.netController->buff));
				
				scn.netController->Close();
				//if(scn.netController->Connect("127.0.0.1", 80))
				//if(scn.netController->Connect(
				//	scn.conf.Read("ConnectionAddress","127.0.0.1").c_str(),
				//	scn.conf.Read("Port", (unsigned short)9171U)))
				//if(scn.netController->Connect(
				//	scn.conf.Read("ConnectionAddress","127.0.0.1").c_str(),
				//	9171))

				string caddr = scn.conf.Read("ConnectionAddress", "127.0.0.1");
				const char *c = caddr.c_str();

				unsigned short _port = scn.conf.Read("Port", (unsigned short)9171U);

				if(scn.netController->Connect(c, _port))
				{
					scn.netController->connectionType = NetworkController::ClientConnection;

					scn.netController->peers.clear();

					Peer p; p.socket = scn.netController->sock;
					scn.netController->peers.push_back(p);
				}
				else
				{
					scn.netController->Close();
					//if(scn.netController->StartListening(scn.conf.Read("Port", (unsigned short)9171U)))
					if(scn.netController->StartListening(_port))
					{
						cout << "started listening again" << endl;
					}
				}

				scn.netController->cs.Lock();
				scn.netController->netAlive = true;
				scn.netController->cs.Unlock();
				
				scn.primaryTaskPool_netThread->AddTask(Task(netthread, scn.netController));

				//scn.netController->netAlive = false;
				//scn.primaryTaskPool_netThread->Join();
				//scn.netController->netAlive = true;
				//scn.netController->Close();
				//scn.netController->connectionType = NetworkController::ClientConnection;
				//scn.netController->Connect("127.0.0.1", 80);
				//scn.primaryTaskPool_netThread->AddTask(Task(netthread, scn.netController));
			}
		} break;
	case 187: // +
		scn.set_zoom(scn.get_zoom() + dt * zoomSpeed);

		{
			glViewport(0,0,windowResolution.x,windowResolution.y);
			float scale = max(1,scn.zoom)*min((float)windowResolution.x/640.0f, (float)windowResolution.y/480.0f);
			float w = windowResolution.x;
			float h = windowResolution.y;
			float hw = w*(0.5/scale);
			float hh = h*(0.5/scale);
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			glOrtho(-hw,hw,-hh,hh,-1,1);
			glTranslatef(0.5,0.5,0);
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
		}

		break;
	case 189: // -
		scn.set_zoom(scn.get_zoom() - dt * zoomSpeed);

		{
			glViewport(0,0,windowResolution.x,windowResolution.y);
			float scale = max(1,scn.zoom)*min((float)windowResolution.x/640.0f, (float)windowResolution.y/480.0f);
			float w = windowResolution.x;
			float h = windowResolution.y;
			float hw = w*(0.5/scale);
			float hh = h*(0.5/scale);
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			glOrtho(-hw,hw,-hh,hh,-1,1);
			glTranslatef(0.5,0.5,0);
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
		}

		break;
	case 'w':
		//camPos.y( camPos.y() - dt * camSpeed);
		camPos.y -= dt * camSpeed;
		break;
	case 's':
		//camPos.y( camPos.y() + dt * camSpeed);
		camPos.y += dt * camSpeed;
		break;
	case 'a':
		//camPos.x( camPos.x() + dt * camSpeed);
		camPos.x += dt * camSpeed;
		break;
	case 'd':
		//camPos.x( camPos.x() - dt * camSpeed);
		camPos.x -= dt * camSpeed;
		break;
	/*case 'r':
		scn.alive = false;
		scn.primaryTaskPool->Join();
		scn.Load();
		return;
		break;*/
	/*case 'f':
		if(!down) break;
		scn.set_global_fill_mode(scn.get_global_fill_mode() == GL_LINE ? GL_FILL : GL_LINE);
		break;*/
	}

	scn.set_cam_pos(camPos);
};
Пример #20
0
void Wayland_ShowWindow(_THIS, SDL_Window *window)
{
    struct wl_output *output = (struct wl_output *) window->fullscreen_mode.driverdata;
    SetFullscreen(_this, window, (window->flags & SDL_WINDOW_FULLSCREEN) ? output : NULL);
}
Пример #21
0
void Renderer::ToggleFullscreen()
{
	SetFullscreen( !isFullscreen );
}
Пример #22
0
/**
*  @brief
*    Called when a key is pressed down
*/
void WindowConnection::OnKeyDown(uint32 nKey, uint32 nModifiers)
{
    // Fullscreen mode toggle allowed and ALT+ENTER pressed?
    if (m_bToggleFullscreenMode && nKey == PLGUIKEY_RETURN && (nModifiers & PLGUIMOD_ALT) != 0)
        SetFullscreen(!IsFullscreen());
}
Пример #23
0
static LRESULT CALLBACK 
MainWindowProc(HWND MainWindow, UINT Message, WPARAM wParam, LPARAM lParam)
{
	LRESULT Result = 0;
	switch(Message) {
		case WM_CREATE:
			InitWindowComponents(MainWindow, &Controls);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		case WM_ERASEBKGND:
			// NOTE: Return a non-zero value. Literally.
			Result = !0;
			break;
		case WM_PAINT:
		{
			PAINTSTRUCT PaintStruct;
			HDC DC = BeginPaint(MainWindow, &PaintStruct);
			RECT FillRegion;
			GetClientRect(MainWindow, &FillRegion);
			COLORREF Top = RGB(239, 241, 245);
			COLORREF Bottom = RGB(218, 223, 233);
			DrawGradient(DC, FillRegion, Top, Top, Bottom, Bottom);
			EndPaint(MainWindow, &PaintStruct);
			ReleaseDC(MainWindow, DC);
		} break;
		case WM_COMMAND:
		{
			HWND Ctrl = (HWND)lParam;
			if(HIWORD(wParam) == CBN_SELCHANGE && Ctrl == Controls.ComboBox) {
				DWORD Pos = SendMessageA((HWND)lParam, CB_GETCURSEL, 0, 0);
				window_data *WndData = (window_data*)SendMessageA((HWND)lParam, CB_GETITEMDATA, Pos, 0);
				if(WndData) {
					Controls.CurSelection = WndData;
					HWND Window = WndData->Window;
					WINDOWINFO WindowInfo = {};
					WindowInfo.cbSize = sizeof(WindowInfo);
					if(GetWindowInfo(Window, &WindowInfo)) {
						RECT Rect = WindowInfo.rcWindow;
						LONG Width = Rect.right - Rect.left;
						LONG Height = Rect.bottom - Rect.top;

						// TODO: Display usefull data
						char Buffer[256];
						StringCbPrintfA(Buffer, sizeof(Buffer), "%dx%d starting at (%d,%d)", Width, Height, Rect.left, Rect.top);
						SetWindowTextA(Controls.StaticText, Buffer);
						ShowWindow(Controls.StaticText, TRUE);
					}
					else {
						PRINT_ERR("Could not get window info.\n");
					}
				}
			}
			else if(HIWORD(wParam) == BN_CLICKED) {
				if(Ctrl == Controls.ButtonOK) {
					if(Controls.CurSelection) {
						int UseConfig = SendMessageA(Controls.CheckBox, BM_GETCHECK, 0, 0);
						if(UseConfig == BST_CHECKED) {
							load_file_result LoadResult = LoadWindowSizeFromConfig();
							if(LoadResult.Valid) {
								SetWindowMode(*Controls.CurSelection, LoadResult.Width, LoadResult.Height);
							}
							else {
								int SetToFullscreen = MessageBoxA(MainWindow, "Error loading config.ini.\nSet to fullscreen instead?", 0, MB_YESNO | MB_TASKMODAL);
								if(SetToFullscreen == IDYES) {
									SetFullscreen(*Controls.CurSelection);
								}
							}
						}
						else {
							SetFullscreen(*Controls.CurSelection);
						}
					}
					PostQuitMessage(0);
				}
				else if(Ctrl == Controls.ButtonCancel) {
					PostQuitMessage(0);
				}
				else {
					Result = DefWindowProcA(MainWindow, Message, wParam, lParam);
				}
			}
		} break;
		default:
			Result = DefWindowProcA(MainWindow, Message, wParam, lParam);
	}

	return Result;
}
Пример #24
0
bool CVideoMode::ToggleFullscreen()
{
	return SetFullscreen(!m_IsFullscreen);
}
Пример #25
0
void ToggleFullscreen()
{
    SetFullscreen(!context->is_fullscreen);
}