mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
~ Reorganized viewport detection for screens and added proper checks for XRandr extension
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
be68fe209f
commit
ce23ca53b1
57
main.cpp
57
main.cpp
@ -25,33 +25,26 @@ irr::SIrrlichtCreationParameters _irr_params;
|
||||
|
||||
irr::f32 g_Time = 0;
|
||||
|
||||
int init_irrlicht()
|
||||
void initialize_viewports ()
|
||||
{
|
||||
// prepare basic configuration for irrlicht
|
||||
_irr_params.AntiAlias = 8;
|
||||
_irr_params.Bits = 16;
|
||||
// _irr_params.DeviceType = irr::EIDT_X11;
|
||||
_irr_params.DriverType = irr::video::EDT_OPENGL;
|
||||
_irr_params.Doublebuffer = false;
|
||||
_irr_params.EventReceiver = nullptr;
|
||||
_irr_params.Fullscreen = false;
|
||||
_irr_params.HandleSRGB = false;
|
||||
_irr_params.IgnoreInput = true;
|
||||
_irr_params.Stencilbuffer = true;
|
||||
_irr_params.UsePerformanceTimer = false;
|
||||
_irr_params.Vsync = false;
|
||||
_irr_params.WithAlphaChannel = false;
|
||||
_irr_params.ZBufferBits = 24;
|
||||
_irr_params.LoggingLevel = irr::ELL_DEBUG;
|
||||
if (IsRootWindow == false || Screens.size () == 0)
|
||||
return;
|
||||
|
||||
if (IsRootWindow == true)
|
||||
{
|
||||
Display* display = XOpenDisplay (NULL);
|
||||
int xrandr_result, xrandr_error;
|
||||
|
||||
if (!XRRQueryExtension (display, &xrandr_result, &xrandr_error))
|
||||
{
|
||||
std::cerr << "XRandr is not present, cannot detect specified screens, running in window mode" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
XRRScreenResources* screenResources = XRRGetScreenResources (display, DefaultRootWindow (display));
|
||||
|
||||
// there are some situations where xrandr returns null (like screen not using the extension)
|
||||
if (screenResources != nullptr)
|
||||
{
|
||||
if (screenResources == nullptr)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < screenResources->noutput; i ++)
|
||||
{
|
||||
XRROutputInfo* info = XRRGetOutputInfo (display, screenResources, screenResources->outputs [i]);
|
||||
@ -88,11 +81,31 @@ int init_irrlicht()
|
||||
}
|
||||
|
||||
XRRFreeScreenResources (screenResources);
|
||||
}
|
||||
|
||||
_irr_params.WindowId = reinterpret_cast<void*> (DefaultRootWindow (display));
|
||||
}
|
||||
|
||||
int init_irrlicht()
|
||||
{
|
||||
// prepare basic configuration for irrlicht
|
||||
_irr_params.AntiAlias = 8;
|
||||
_irr_params.Bits = 16;
|
||||
// _irr_params.DeviceType = irr::EIDT_X11;
|
||||
_irr_params.DriverType = irr::video::EDT_OPENGL;
|
||||
_irr_params.Doublebuffer = false;
|
||||
_irr_params.EventReceiver = nullptr;
|
||||
_irr_params.Fullscreen = false;
|
||||
_irr_params.HandleSRGB = false;
|
||||
_irr_params.IgnoreInput = true;
|
||||
_irr_params.Stencilbuffer = true;
|
||||
_irr_params.UsePerformanceTimer = false;
|
||||
_irr_params.Vsync = false;
|
||||
_irr_params.WithAlphaChannel = false;
|
||||
_irr_params.ZBufferBits = 24;
|
||||
_irr_params.LoggingLevel = irr::ELL_DEBUG;
|
||||
|
||||
initialize_viewports ();
|
||||
|
||||
wp::irrlicht::device = irr::createDeviceEx (_irr_params);
|
||||
|
||||
if (wp::irrlicht::device == nullptr)
|
||||
|
Loading…
Reference in New Issue
Block a user