mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Update GPU flag correctly on all display when it's changed
This commit is contained in:
parent
533fb778f3
commit
2c7fc767bf
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 26994fe6c1210e0989eaddd4b2bdc00422e1ac8a
|
||||
Subproject commit 968f0e4b935c77ec3701307ec963f5e058254424
|
@ -396,19 +396,20 @@ int App::initialize(const AppOptions& options)
|
||||
m_mainWindow->openWindow();
|
||||
|
||||
#if LAF_LINUX // TODO check why this is required and we cannot call
|
||||
// updateAllDisplaysWithNewScale() on Linux/X11
|
||||
// updateAllDisplays() on Linux/X11
|
||||
// Redraw the whole screen.
|
||||
manager->invalidate();
|
||||
#else
|
||||
// To know the initial manager size we call to
|
||||
// Manager::updateAllDisplaysWithNewScale(...) so we receive a
|
||||
// Manager::updateAllDisplays(...) so we receive a
|
||||
// Manager::onNewDisplayConfiguration() (which will update the
|
||||
// bounds of the manager for first time). This is required so if
|
||||
// the OpenFileCommand (called when we're processing the CLI with
|
||||
// OpenBatchOfFiles) shows a dialog to open a sequence of files,
|
||||
// the dialog is centered correctly to the manager bounds.
|
||||
const int scale = Preferences::instance().general.screenScale();
|
||||
manager->updateAllDisplaysWithNewScale(scale);
|
||||
const bool gpu = Preferences::instance().general.gpuAcceleration();
|
||||
manager->updateAllDisplays(scale, gpu);
|
||||
#endif
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
@ -868,13 +868,13 @@ public:
|
||||
ui::set_mouse_cursor_scale(m_pref.cursor.cursorScale());
|
||||
|
||||
bool reset_screen = false;
|
||||
int newScreenScale = base::convert_to<int>(screenScale()->getValue());
|
||||
const int newScreenScale = base::convert_to<int>(screenScale()->getValue());
|
||||
if (newScreenScale != m_pref.general.screenScale()) {
|
||||
m_pref.general.screenScale(newScreenScale);
|
||||
reset_screen = true;
|
||||
}
|
||||
|
||||
int newUIScale = base::convert_to<int>(uiScale()->getValue());
|
||||
const int newUIScale = base::convert_to<int>(uiScale()->getValue());
|
||||
if (newUIScale != m_pref.general.uiScale()) {
|
||||
m_pref.general.uiScale(newUIScale);
|
||||
ui::set_theme(ui::get_theme(),
|
||||
@ -882,7 +882,7 @@ public:
|
||||
reset_screen = true;
|
||||
}
|
||||
|
||||
bool newGpuAccel = gpuAcceleration()->isSelected();
|
||||
const bool newGpuAccel = gpuAcceleration()->isSelected();
|
||||
if (newGpuAccel != m_pref.general.gpuAcceleration()) {
|
||||
m_pref.general.gpuAcceleration(newGpuAccel);
|
||||
reset_screen = true;
|
||||
@ -1018,8 +1018,8 @@ private:
|
||||
|
||||
void updateScreenScaling() {
|
||||
ui::Manager* manager = ui::Manager::getDefault();
|
||||
os::instance()->setGpuAcceleration(m_pref.general.gpuAcceleration());
|
||||
manager->updateAllDisplaysWithNewScale(m_pref.general.screenScale());
|
||||
manager->updateAllDisplays(m_pref.general.screenScale(),
|
||||
m_pref.general.gpuAcceleration());
|
||||
}
|
||||
|
||||
void onApply() {
|
||||
|
@ -127,8 +127,6 @@ static bool create_main_window(bool gpuAccel,
|
||||
// executed.
|
||||
int scale = Preferences::instance().general.screenScale();
|
||||
|
||||
os::instance()->setGpuAcceleration(gpuAccel);
|
||||
|
||||
try {
|
||||
if (!spec.frame().isEmpty() ||
|
||||
!spec.contentRect().isEmpty()) {
|
||||
@ -164,6 +162,8 @@ static bool create_main_window(bool gpuAccel,
|
||||
if (scale == 0)
|
||||
Preferences::instance().general.screenScale(main_window->scale());
|
||||
|
||||
main_window->setGpuAcceleration(gpuAccel);
|
||||
|
||||
if (main_window->isMinimized())
|
||||
main_window->maximize();
|
||||
}
|
||||
@ -655,7 +655,7 @@ bool CustomizedGuiManager::onProcessDevModeKeyDown(KeyMessage* msg)
|
||||
ui::set_theme(ui::get_theme(), uiScale);
|
||||
}
|
||||
if (screenScale != window->scale()) {
|
||||
updateAllDisplaysWithNewScale(screenScale);
|
||||
updateAllDisplays(screenScale, window->gpuAcceleration());
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
|
@ -77,7 +77,8 @@ public:
|
||||
ui::set_theme(ui::get_theme(), newUIScale);
|
||||
|
||||
Manager::getDefault()
|
||||
->updateAllDisplaysWithNewScale(newScreenScale);
|
||||
->updateAllDisplays(newScreenScale,
|
||||
pref.general.gpuAcceleration());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -311,10 +311,11 @@ void Manager::flipAllDisplays()
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::updateAllDisplaysWithNewScale(int scale)
|
||||
void Manager::updateAllDisplays(int scale, bool gpu)
|
||||
{
|
||||
os::Window* nativeWindow = m_display.nativeWindow();
|
||||
nativeWindow->setScale(scale);
|
||||
nativeWindow->setGpuAcceleration(gpu);
|
||||
|
||||
if (get_multiple_displays()) {
|
||||
for (auto child : children()) {
|
||||
@ -322,6 +323,7 @@ void Manager::updateAllDisplaysWithNewScale(int scale)
|
||||
if (window->ownDisplay()) {
|
||||
Display* display = static_cast<Window*>(child)->display();
|
||||
display->nativeWindow()->setScale(scale);
|
||||
display->nativeWindow()->setGpuAcceleration(gpu);
|
||||
onNewDisplayConfiguration(display);
|
||||
}
|
||||
}
|
||||
@ -1390,6 +1392,7 @@ void Manager::_openWindow(Window* window, bool center)
|
||||
if (get_multiple_displays()
|
||||
&& window->shouldCreateNativeWindow()) {
|
||||
const int scale = parentDisplay->nativeWindow()->scale();
|
||||
const int gpu = parentDisplay->nativeWindow()->gpuAcceleration();
|
||||
|
||||
os::WindowSpec spec;
|
||||
gfx::Rect frame;
|
||||
@ -1437,6 +1440,9 @@ void Manager::_openWindow(Window* window, bool center)
|
||||
// Set native title bar text
|
||||
newNativeWindow->setTitle(window->text());
|
||||
|
||||
// Same GPU acceleration flag that the parent display
|
||||
newNativeWindow->setGpuAcceleration(gpu);
|
||||
|
||||
// Activate only non-floating windows
|
||||
if (!spec.floating())
|
||||
newNativeWindow->activate();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -46,7 +46,9 @@ namespace ui {
|
||||
// Refreshes all real displays with the UI content.
|
||||
void flipAllDisplays();
|
||||
|
||||
void updateAllDisplaysWithNewScale(int scale);
|
||||
// Updates the scale and GPU acceleration flag of all native
|
||||
// windows.
|
||||
void updateAllDisplays(int scale, bool gpu);
|
||||
|
||||
// Adds the given "msg" message to the queue of messages to be
|
||||
// dispached. "msg" cannot be used after this function, it'll be
|
||||
|
Loading…
x
Reference in New Issue
Block a user