Skip to content

DevStory | Native Monitor Aware fullscreen #29

@AnnaSasDev

Description

@AnnaSasDev

📝 Task Description

Instread of doing the monitor aware fullscreen switching, we should do it natively in the c++ library

🛠 Technical Details

void Photino::SetFullScreen(const bool fullScreen)
{
	LONG_PTR style = GetWindowLongPtr(_hWnd, GWL_STYLE);
    
	if (fullScreen)
	{
		style &= ~WS_OVERLAPPEDWINDOW;
		style |= WS_POPUP;

	    SetWindowLongPtr(_hWnd, GWL_STYLE, style);

		const HMONITOR monitor = MonitorFromWindow(_hWnd, MONITOR_DEFAULTTONEAREST);
		MONITORINFO monitor_info = { sizeof(monitor_info) };

		if (GetMonitorInfoW(monitor, &monitor_info)) 
		{
			auto [left, top, right, bottom] = monitor_info.rcMonitor;
		    SetWindowPos(
                _hWnd, HWND_TOP,
                left,
                top,
                right - left,
                bottom - top,
                SWP_FRAMECHANGED | SWP_NOOWNERZORDER
            );
		}
	}
	else
	{
		style &= ~WS_POPUP;
		style |= WS_OVERLAPPEDWINDOW;

	    SetWindowLongPtr(_hWnd, GWL_STYLE, style);

	    SetWindowPos(
            _hWnd, HWND_TOP,
            0, 0,
            GetSystemMetrics(SM_CXSCREEN),
            GetSystemMetrics(SM_CYSCREEN),
            SWP_FRAMECHANGED | SWP_NOOWNERZORDER
        );
	}
}

This still needs a good way of resetting it to a previous size and location as in its current form it only goes to the main monitor (0,0) and some arbitrary size.
Look into a struct or something to store this info in.

🔧 Dev-Side Criteria

  • Windows implementation (the above example is this already)
  • Linux implementation
  • MacOs implementation

🔬 Testing Requirements

No response

📐 Application Section

🔗 API

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions