Files
test/intern/ghost/intern/GHOST_SystemSDL.hh
Jonas Holzman 733d65e514 GHOST: Remove GHOST_DisplayManager and its implementations
The GHOST_DisplayManager and its implementations are for the most part
unmaintained and almost completely unused in all backends. To clean
things up, and avoid any confusion about how displays are handled in
each respective GHOST backend, this PR completely removes the GHOST
Display Manager, and move the few remaining logic it still held directly
to the corresponding backends.

The backends that were modified (apart from removing the display manager
initialization call from their init) are:

- Win32: `GHOST_SystemWin32::getNumDisplays()` was calling
  `m_displayManager->getNumDisplays`, the underlying system metric call
  (`GetSystemMetrics(SM_CMONITORS)`) was substituted in place.

- SDL: `GHOST_SystemSDL::createWindow` was calling
  `GHOST_DisplayManagerSDL::getCurrentDisplayModeSDL` which returned its
  `m_mode` data member by reference. Since none of the
  `GHOST_DisplayManagerSDL` member function that modified this data member
  were ever called, the variable `memset` initialization call was
  substituted in place from the `DisplayManagerSDL` constructor

Pull Request: https://projects.blender.org/blender/blender/pulls/138066
2025-04-28 14:26:39 +02:00

92 lines
2.5 KiB
C++

/* SPDX-FileCopyrightText: 2011-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup GHOST
* Declaration of GHOST_SystemSDL class.
*/
#pragma once
#include "../GHOST_Types.h"
#include "GHOST_Event.hh"
#include "GHOST_System.hh"
#include "GHOST_TimerManager.hh"
#include "GHOST_WindowSDL.hh"
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(2, 0, 0)
# error "SDL 2.0 or newer is needed to build with Ghost"
#endif
class GHOST_WindowSDL;
class GHOST_SystemSDL : public GHOST_System {
public:
void addDirtyWindow(GHOST_WindowSDL *bad_wind);
GHOST_SystemSDL();
~GHOST_SystemSDL();
bool processEvents(bool waitForEvent) override;
bool setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) override
{
return false;
}
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override;
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
GHOST_TCapabilityFlag getCapabilities() const override;
char *getClipboard(bool selection) const override;
void putClipboard(const char *buffer, bool selection) const override;
uint64_t getMilliSeconds() const override;
uint8_t getNumDisplays() const override;
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override;
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override;
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) override;
GHOST_TSuccess disposeContext(GHOST_IContext *context) override;
private:
GHOST_TSuccess init() override;
GHOST_IWindow *createWindow(const char *title,
int32_t left,
int32_t top,
uint32_t width,
uint32_t height,
GHOST_TWindowState state,
GHOST_GPUSettings gpuSettings,
const bool exclusive = false,
const bool is_dialog = false,
const GHOST_IWindow *parentWindow = nullptr) override;
/* SDL specific */
GHOST_WindowSDL *findGhostWindow(SDL_Window *sdl_win);
bool generateWindowExposeEvents();
void processEvent(SDL_Event *sdl_event);
/** The vector of windows that need to be updated. */
std::vector<GHOST_WindowSDL *> m_dirty_windows;
};