mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 23:34:57 -04:00
windisplay: Fix issues switching fullscreen while maximized
Fixes #1469
This commit is contained in:
parent
68927cad0b
commit
389b24e695
@ -283,15 +283,34 @@ process_events() {
|
||||
*/
|
||||
void WinGraphicsWindow::
|
||||
set_properties_now(WindowProperties &properties) {
|
||||
if (properties.has_fullscreen() && !properties.get_fullscreen() &&
|
||||
is_fullscreen()) {
|
||||
if (do_windowed_switch()) {
|
||||
_properties.set_fullscreen(false);
|
||||
properties.clear_fullscreen();
|
||||
} else {
|
||||
windisplay_cat.warning()
|
||||
<< "Switching to windowed mode failed!\n";
|
||||
if (properties.has_fullscreen()) {
|
||||
if (!properties.get_fullscreen() && is_fullscreen()) {
|
||||
if (do_windowed_switch()) {
|
||||
_properties.set_fullscreen(false);
|
||||
} else {
|
||||
windisplay_cat.warning()
|
||||
<< "Switching to windowed mode failed!\n";
|
||||
}
|
||||
}
|
||||
else if (properties.get_fullscreen() && !is_fullscreen()) {
|
||||
int x_size;
|
||||
int y_size;
|
||||
if (properties.has_size()) {
|
||||
x_size = properties.get_x_size();
|
||||
y_size = properties.get_y_size();
|
||||
} else {
|
||||
x_size = _properties.get_x_size();
|
||||
y_size = _properties.get_y_size();
|
||||
}
|
||||
if (do_fullscreen_switch(x_size, y_size)) {
|
||||
_properties.set_fullscreen(true);
|
||||
properties.clear_size();
|
||||
} else {
|
||||
windisplay_cat.warning()
|
||||
<< "Switching to fullscreen mode failed!\n";
|
||||
}
|
||||
}
|
||||
properties.clear_fullscreen();
|
||||
}
|
||||
|
||||
GraphicsWindow::set_properties_now(properties);
|
||||
@ -917,8 +936,8 @@ do_fullscreen_resize(int x_size, int y_size) {
|
||||
* Called in the set_properties_now function to switch to fullscreen.
|
||||
*/
|
||||
bool WinGraphicsWindow::
|
||||
do_fullscreen_switch() {
|
||||
if (!do_fullscreen_enable()) {
|
||||
do_fullscreen_switch(int x_size, int y_size) {
|
||||
if (!do_fullscreen_enable(x_size, y_size)) {
|
||||
// Couldn't get fullscreen.
|
||||
return false;
|
||||
}
|
||||
@ -928,17 +947,21 @@ do_fullscreen_switch() {
|
||||
DWORD window_style = make_style(props);
|
||||
SetWindowLong(_hWnd, GWL_STYLE, window_style);
|
||||
|
||||
WINDOW_METRICS metrics;
|
||||
bool has_origin;
|
||||
if (!calculate_metrics(true, window_style, metrics, has_origin)){
|
||||
return false;
|
||||
}
|
||||
|
||||
SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, metrics.width, metrics.height,
|
||||
SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, x_size, y_size,
|
||||
SWP_FRAMECHANGED | SWP_SHOWWINDOW);
|
||||
|
||||
handle_reshape();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in the set_properties_now function to switch to fullscreen.
|
||||
*/
|
||||
bool WinGraphicsWindow::
|
||||
do_fullscreen_switch() {
|
||||
return do_fullscreen_switch(_properties.get_x_size(), _properties.get_y_size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in the set_properties_now function to switch to windowed mode.
|
||||
*/
|
||||
@ -1188,8 +1211,8 @@ open_graphic_window() {
|
||||
// somehow, but I need the window's black background to cover up the desktop
|
||||
// during the mode change.
|
||||
|
||||
if (fullscreen){
|
||||
if (!do_fullscreen_enable()){
|
||||
if (fullscreen) {
|
||||
if (!do_fullscreen_enable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1202,7 +1225,7 @@ open_graphic_window() {
|
||||
* Not to confuse with do_fullscreen_switch().
|
||||
*/
|
||||
bool WinGraphicsWindow::
|
||||
do_fullscreen_enable() {
|
||||
do_fullscreen_enable(int x_size, int y_size) {
|
||||
|
||||
HWND hDesktopWindow = GetDesktopWindow();
|
||||
HDC scrnDC = GetDC(hDesktopWindow);
|
||||
@ -1212,8 +1235,8 @@ do_fullscreen_enable() {
|
||||
// GetDeviceCaps(scrnDC, VERTRES);
|
||||
ReleaseDC(hDesktopWindow, scrnDC);
|
||||
|
||||
DWORD dwWidth = _properties.get_x_size();
|
||||
DWORD dwHeight = _properties.get_y_size();
|
||||
DWORD dwWidth = x_size;
|
||||
DWORD dwHeight = y_size;
|
||||
DWORD dwFullScreenBitDepth = cur_bitdepth;
|
||||
|
||||
DEVMODE dm;
|
||||
@ -1241,12 +1264,16 @@ do_fullscreen_enable() {
|
||||
}
|
||||
|
||||
_fullscreen_display_mode = dm;
|
||||
|
||||
_properties.set_origin(0, 0);
|
||||
_properties.set_size(dwWidth, dwHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a low-level function that just puts Windows in fullscreen mode.
|
||||
* Not to confuse with do_fullscreen_switch().
|
||||
*/
|
||||
bool WinGraphicsWindow::
|
||||
do_fullscreen_enable() {
|
||||
return do_fullscreen_enable(_properties.get_x_size(), _properties.get_y_size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,8 +111,10 @@ protected:
|
||||
virtual void handle_reshape();
|
||||
virtual bool do_fullscreen_resize(int x_size, int y_size);
|
||||
|
||||
bool do_fullscreen_switch(int x_size, int y_size);
|
||||
virtual bool do_fullscreen_switch();
|
||||
virtual bool do_windowed_switch();
|
||||
bool do_fullscreen_enable(int x_size, int y_size);
|
||||
virtual bool do_fullscreen_enable();
|
||||
virtual bool do_fullscreen_disable();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user