Cleanup: clang-tidy for GHOST X11/SDL/Wayland/NULL backends
Also early exit in some functions.
This commit is contained in:
parent
13373a6ccd
commit
93e4b15767
Notes:
blender-bot
2024-03-22 15:57:27 +01:00
Referenced by commit 99f88281df
, Fix T101776: wrong logic for GLX setSwapInterval
Referenced by issue #101776, Wrong logic inside GHOST_ContextGLX::setSwapInterval method
|
@ -414,7 +414,7 @@ extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
|
|||
*/
|
||||
extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
|
||||
GHOST_TGrabCursorMode mode,
|
||||
GHOST_TAxisFlag warp_axis,
|
||||
GHOST_TAxisFlag wrap_axis,
|
||||
int bounds[4],
|
||||
const int mouse_ungrab_xy[2]);
|
||||
|
||||
|
@ -727,7 +727,7 @@ extern unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle
|
|||
/**
|
||||
* Get the OpenGL frame-buffer handle that serves as a default frame-buffer.
|
||||
*/
|
||||
extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHandle);
|
||||
extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle);
|
||||
|
||||
/**
|
||||
* Set which tablet API to use. Only affects Windows, other platforms have a single API.
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* C Api for GHOST
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "GHOST_C-api.h"
|
||||
#include "GHOST_IEvent.h"
|
||||
|
@ -206,13 +206,15 @@ GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
|
|||
const int stereoVisual)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
GHOST_IWindow *window = NULL;
|
||||
GHOST_IWindow *window = nullptr;
|
||||
bool bstereoVisual;
|
||||
|
||||
if (stereoVisual)
|
||||
if (stereoVisual) {
|
||||
bstereoVisual = true;
|
||||
else
|
||||
}
|
||||
else {
|
||||
bstereoVisual = false;
|
||||
}
|
||||
|
||||
system->beginFullScreen(*setting, &window, bstereoVisual);
|
||||
|
||||
|
@ -371,7 +373,7 @@ GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
|
|||
}
|
||||
|
||||
return window->setCursorGrab(
|
||||
mode, wrap_axis, bounds ? &bounds_rect : NULL, mouse_ungrab_xy ? mouse_xy : NULL);
|
||||
mode, wrap_axis, bounds ? &bounds_rect : nullptr, mouse_ungrab_xy ? mouse_xy : nullptr);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
|
||||
|
@ -509,8 +511,8 @@ char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
|
|||
|
||||
char *ctitle = (char *)malloc(title.size() + 1);
|
||||
|
||||
if (ctitle == NULL) {
|
||||
return NULL;
|
||||
if (ctitle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
strcpy(ctitle, title.c_str());
|
||||
|
@ -521,7 +523,7 @@ char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
|
|||
GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
|
||||
{
|
||||
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
|
||||
GHOST_Rect *rectangle = NULL;
|
||||
GHOST_Rect *rectangle = nullptr;
|
||||
|
||||
rectangle = new GHOST_Rect();
|
||||
window->getWindowBounds(*rectangle);
|
||||
|
@ -532,7 +534,7 @@ GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
|
|||
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
|
||||
{
|
||||
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
|
||||
GHOST_Rect *rectangle = NULL;
|
||||
GHOST_Rect *rectangle = nullptr;
|
||||
|
||||
rectangle = new GHOST_Rect();
|
||||
window->getClientBounds(*rectangle);
|
||||
|
@ -646,10 +648,8 @@ GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle)
|
|||
if (context) {
|
||||
return context->activateDrawingContext();
|
||||
}
|
||||
else {
|
||||
GHOST_PRINTF("%s: Context not valid\n", __func__);
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
GHOST_PRINTF("%s: Context not valid\n", __func__);
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle)
|
||||
|
@ -717,9 +717,9 @@ GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
|
|||
{
|
||||
GHOST_TSuccess result = GHOST_kFailure;
|
||||
|
||||
if (((GHOST_Rect *)rectanglehandle)->isEmpty())
|
||||
if (((GHOST_Rect *)rectanglehandle)->isEmpty()) {
|
||||
result = GHOST_kSuccess;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -727,9 +727,9 @@ GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
|
|||
{
|
||||
GHOST_TSuccess result = GHOST_kFailure;
|
||||
|
||||
if (((GHOST_Rect *)rectanglehandle)->isValid())
|
||||
if (((GHOST_Rect *)rectanglehandle)->isValid()) {
|
||||
result = GHOST_kSuccess;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -753,9 +753,9 @@ GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle, in
|
|||
{
|
||||
GHOST_TSuccess result = GHOST_kFailure;
|
||||
|
||||
if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
|
||||
if (((GHOST_Rect *)rectanglehandle)->isInside(x, y)) {
|
||||
result = GHOST_kSuccess;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -785,9 +785,9 @@ GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
|
|||
{
|
||||
GHOST_TSuccess result = GHOST_kFailure;
|
||||
|
||||
if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle))
|
||||
if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle)) {
|
||||
result = GHOST_kSuccess;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -824,8 +824,9 @@ void GHOST_UseWindowFocus(int use_focus)
|
|||
float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
|
||||
{
|
||||
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
|
||||
if (window)
|
||||
if (window) {
|
||||
return window->getNativePixelSize();
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static const char *get_egl_error_enum_string(EGLint error)
|
|||
CASE_CODE_RETURN_STR(EGL_BAD_NATIVE_WINDOW)
|
||||
CASE_CODE_RETURN_STR(EGL_CONTEXT_LOST)
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,11 +106,14 @@ static const char *get_egl_error_message_string(EGLint error)
|
|||
"and objects to continue rendering.");
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static bool egl_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL)
|
||||
static bool egl_chk(bool result,
|
||||
const char *file = nullptr,
|
||||
int line = 0,
|
||||
const char *text = nullptr)
|
||||
{
|
||||
if (!result) {
|
||||
const EGLint error = eglGetError();
|
||||
|
@ -158,7 +161,7 @@ static inline bool bindAPI(EGLenum api)
|
|||
}
|
||||
|
||||
#ifdef WITH_GL_ANGLE
|
||||
HMODULE GHOST_ContextEGL::s_d3dcompiler = NULL;
|
||||
HMODULE GHOST_ContextEGL::s_d3dcompiler = nullptr;
|
||||
#endif
|
||||
|
||||
EGLContext GHOST_ContextEGL::s_gl_sharedContext = EGL_NO_CONTEXT;
|
||||
|
@ -170,7 +173,9 @@ EGLint GHOST_ContextEGL::s_gles_sharedCount = 0;
|
|||
EGLContext GHOST_ContextEGL::s_vg_sharedContext = EGL_NO_CONTEXT;
|
||||
EGLint GHOST_ContextEGL::s_vg_sharedCount = 0;
|
||||
|
||||
#pragma warning(disable : 4715)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4715)
|
||||
#endif
|
||||
|
||||
template<typename T> T &choose_api(EGLenum api, T &a, T &b, T &c)
|
||||
{
|
||||
|
@ -223,23 +228,24 @@ GHOST_ContextEGL::~GHOST_ContextEGL()
|
|||
bindAPI(m_api);
|
||||
|
||||
if (m_context != EGL_NO_CONTEXT) {
|
||||
if (m_context == ::eglGetCurrentContext())
|
||||
if (m_context == ::eglGetCurrentContext()) {
|
||||
EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
|
||||
|
||||
}
|
||||
if (m_context != m_sharedContext || m_sharedCount == 1) {
|
||||
assert(m_sharedCount > 0);
|
||||
|
||||
m_sharedCount--;
|
||||
|
||||
if (m_sharedCount == 0)
|
||||
if (m_sharedCount == 0) {
|
||||
m_sharedContext = EGL_NO_CONTEXT;
|
||||
|
||||
}
|
||||
EGL_CHK(::eglDestroyContext(m_display, m_context));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_surface != EGL_NO_SURFACE)
|
||||
if (m_surface != EGL_NO_SURFACE) {
|
||||
EGL_CHK(::eglDestroySurface(m_display, m_surface));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,13 +262,9 @@ GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int interval)
|
|||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut)
|
||||
|
@ -293,13 +295,10 @@ GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
|
|||
{
|
||||
if (m_display) {
|
||||
bindAPI(m_api);
|
||||
|
||||
return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess :
|
||||
GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextEGL::releaseDrawingContext()
|
||||
|
@ -311,9 +310,7 @@ GHOST_TSuccess GHOST_ContextEGL::releaseDrawingContext()
|
|||
GHOST_kSuccess :
|
||||
GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
bool GHOST_ContextEGL::initContextEGLEW()
|
||||
|
@ -322,7 +319,7 @@ bool GHOST_ContextEGL::initContextEGLEW()
|
|||
* it requires a display argument. glewInit() does the same, but we only want
|
||||
* to initialize EGLEW here. */
|
||||
eglGetDisplay = (PFNEGLGETDISPLAYPROC)eglGetProcAddress("eglGetDisplay");
|
||||
if (eglGetDisplay == NULL) {
|
||||
if (eglGetDisplay == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -353,9 +350,9 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
std::vector<EGLint> attrib_list;
|
||||
EGLint num_config = 0;
|
||||
|
||||
if (m_stereoVisual)
|
||||
if (m_stereoVisual) {
|
||||
fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
|
||||
|
||||
}
|
||||
m_stereoVisual = false; /* It doesn't matter what the Window wants. */
|
||||
|
||||
if (!initContextEGLEW()) {
|
||||
|
@ -364,12 +361,12 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
|
||||
#ifdef WITH_GL_ANGLE
|
||||
/* `d3dcompiler_XX.dll` needs to be loaded before ANGLE will work. */
|
||||
if (s_d3dcompiler == NULL) {
|
||||
if (s_d3dcompiler == nullptr) {
|
||||
s_d3dcompiler = LoadLibrary(D3DCOMPILER);
|
||||
|
||||
WIN32_CHK(s_d3dcompiler != NULL);
|
||||
WIN32_CHK(s_d3dcompiler != nullptr);
|
||||
|
||||
if (s_d3dcompiler == NULL) {
|
||||
if (s_d3dcompiler == nullptr) {
|
||||
fprintf(stderr, "LoadLibrary(\"" D3DCOMPILER "\") failed!\n");
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
@ -383,18 +380,19 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
|
||||
EGLint egl_major, egl_minor;
|
||||
|
||||
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)))
|
||||
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor))) {
|
||||
goto error;
|
||||
|
||||
}
|
||||
#ifdef WITH_GHOST_DEBUG
|
||||
fprintf(stderr, "EGL Version %d.%d\n", egl_major, egl_minor);
|
||||
#endif
|
||||
|
||||
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
|
||||
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT))) {
|
||||
goto error;
|
||||
|
||||
if (!bindAPI(m_api))
|
||||
}
|
||||
if (!bindAPI(m_api)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Build attribute list. */
|
||||
|
||||
|
@ -462,15 +460,17 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
|
||||
attrib_list.push_back(EGL_NONE);
|
||||
|
||||
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config)))
|
||||
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config))) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* A common error is to assume that ChooseConfig worked because it returned EGL_TRUE. */
|
||||
if (num_config != 1) /* `num_config` should be exactly 1. */
|
||||
if (num_config != 1) { /* `num_config` should be exactly 1. */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (m_nativeWindow != 0) {
|
||||
m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, NULL);
|
||||
m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, nullptr);
|
||||
}
|
||||
else {
|
||||
static const EGLint pb_attrib_list[] = {
|
||||
|
@ -483,9 +483,9 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
m_surface = ::eglCreatePbufferSurface(m_display, m_config, pb_attrib_list);
|
||||
}
|
||||
|
||||
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
|
||||
if (!EGL_CHK(m_surface != EGL_NO_SURFACE)) {
|
||||
goto error;
|
||||
|
||||
}
|
||||
attrib_list.clear();
|
||||
|
||||
if (EGLEW_VERSION_1_5 || EGLEW_KHR_create_context) {
|
||||
|
@ -524,9 +524,10 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (m_contextProfileMask != 0)
|
||||
if (m_contextProfileMask != 0) {
|
||||
fprintf(
|
||||
stderr, "Warning! Cannot select profile for %s contexts.", api_string(m_api).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_api == EGL_OPENGL_API || EGLEW_VERSION_1_5) {
|
||||
|
@ -583,16 +584,19 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
|
||||
m_context = ::eglCreateContext(m_display, m_config, m_sharedContext, &(attrib_list[0]));
|
||||
|
||||
if (!EGL_CHK(m_context != EGL_NO_CONTEXT))
|
||||
if (!EGL_CHK(m_context != EGL_NO_CONTEXT)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (m_sharedContext == EGL_NO_CONTEXT)
|
||||
if (m_sharedContext == EGL_NO_CONTEXT) {
|
||||
m_sharedContext = m_context;
|
||||
}
|
||||
|
||||
m_sharedCount++;
|
||||
|
||||
if (!EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)))
|
||||
if (!EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context))) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
initContextGLEW();
|
||||
|
||||
|
@ -602,16 +606,16 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
|||
return GHOST_kSuccess;
|
||||
|
||||
error:
|
||||
if (prev_display != EGL_NO_DISPLAY)
|
||||
if (prev_display != EGL_NO_DISPLAY) {
|
||||
EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
|
||||
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextEGL::releaseNativeHandles()
|
||||
{
|
||||
m_nativeWindow = 0;
|
||||
m_nativeDisplay = NULL;
|
||||
m_nativeDisplay = nullptr;
|
||||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
|
|
@ -47,23 +47,24 @@ GHOST_ContextGLX::GHOST_ContextGLX(bool stereoVisual,
|
|||
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
|
||||
m_context(None)
|
||||
{
|
||||
assert(m_display != NULL);
|
||||
assert(m_display != nullptr);
|
||||
}
|
||||
|
||||
GHOST_ContextGLX::~GHOST_ContextGLX()
|
||||
{
|
||||
if (m_display != NULL) {
|
||||
if (m_display != nullptr) {
|
||||
if (m_context != None) {
|
||||
if (m_window != 0 && m_context == ::glXGetCurrentContext())
|
||||
::glXMakeCurrent(m_display, None, NULL);
|
||||
|
||||
if (m_window != 0 && m_context == ::glXGetCurrentContext()) {
|
||||
::glXMakeCurrent(m_display, None, nullptr);
|
||||
}
|
||||
if (m_context != s_sharedContext || s_sharedCount == 1) {
|
||||
assert(s_sharedCount > 0);
|
||||
|
||||
s_sharedCount--;
|
||||
|
||||
if (s_sharedCount == 0)
|
||||
s_sharedContext = NULL;
|
||||
if (s_sharedCount == 0) {
|
||||
s_sharedContext = nullptr;
|
||||
}
|
||||
|
||||
::glXDestroyContext(m_display, m_context);
|
||||
}
|
||||
|
@ -80,22 +81,18 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers()
|
|||
|
||||
GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext()
|
||||
{
|
||||
if (m_display) {
|
||||
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
if (m_display == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextGLX::releaseDrawingContext()
|
||||
{
|
||||
if (m_display) {
|
||||
return ::glXMakeCurrent(m_display, None, NULL) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
if (m_display == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return ::glXMakeCurrent(m_display, None, nullptr) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
|
||||
void GHOST_ContextGLX::initContextGLXEW()
|
||||
|
@ -113,15 +110,15 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||
#ifdef USE_GLXEW_INIT_WORKAROUND
|
||||
const GLubyte *extStart = (GLubyte *)"";
|
||||
const GLubyte *extEnd;
|
||||
if (glXQueryExtension(m_display, NULL, NULL)) {
|
||||
if (glXQueryExtension(m_display, nullptr, nullptr)) {
|
||||
extStart = (const GLubyte *)glXGetClientString(m_display, GLX_EXTENSIONS);
|
||||
if ((extStart == NULL) ||
|
||||
if ((extStart == nullptr) ||
|
||||
(glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB(
|
||||
(const GLubyte *)"glXChooseFBConfig")) == NULL ||
|
||||
(const GLubyte *)"glXChooseFBConfig")) == nullptr ||
|
||||
(glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB(
|
||||
(const GLubyte *)"glXCreateContextAttribsARB")) == NULL ||
|
||||
(const GLubyte *)"glXCreateContextAttribsARB")) == nullptr ||
|
||||
(glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glXGetProcAddressARB(
|
||||
(const GLubyte *)"glXCreatePbuffer")) == NULL) {
|
||||
(const GLubyte *)"glXCreatePbuffer")) == nullptr) {
|
||||
extStart = (GLubyte *)"";
|
||||
}
|
||||
}
|
||||
|
@ -161,11 +158,12 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||
int profileBitES = m_contextProfileMask & GLX_CONTEXT_ES_PROFILE_BIT_EXT;
|
||||
#endif
|
||||
|
||||
if (!GLXEW_ARB_create_context_profile && profileBitCore)
|
||||
if (!GLXEW_ARB_create_context_profile && profileBitCore) {
|
||||
fprintf(stderr, "Warning! OpenGL core profile not available.\n");
|
||||
|
||||
if (!GLXEW_ARB_create_context_profile && profileBitCompat)
|
||||
}
|
||||
if (!GLXEW_ARB_create_context_profile && profileBitCompat) {
|
||||
fprintf(stderr, "Warning! OpenGL compatibility profile not available.\n");
|
||||
}
|
||||
|
||||
#ifdef WITH_GLEW_ES
|
||||
if (!GLXEW_EXT_create_context_es_profile && profileBitES && m_contextMajorVersion == 1)
|
||||
|
@ -177,20 +175,21 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||
|
||||
int profileMask = 0;
|
||||
|
||||
if (GLXEW_ARB_create_context_profile && profileBitCore)
|
||||
if (GLXEW_ARB_create_context_profile && profileBitCore) {
|
||||
profileMask |= profileBitCore;
|
||||
|
||||
if (GLXEW_ARB_create_context_profile && profileBitCompat)
|
||||
}
|
||||
if (GLXEW_ARB_create_context_profile && profileBitCompat) {
|
||||
profileMask |= profileBitCompat;
|
||||
}
|
||||
|
||||
#ifdef WITH_GLEW_ES
|
||||
if (GLXEW_EXT_create_context_es_profile && profileBitES)
|
||||
profileMask |= profileBitES;
|
||||
#endif
|
||||
|
||||
if (profileMask != m_contextProfileMask)
|
||||
if (profileMask != m_contextProfileMask) {
|
||||
fprintf(stderr, "Warning! Ignoring untested OpenGL context profile mask bits.");
|
||||
|
||||
}
|
||||
/* max 10 attributes plus terminator */
|
||||
int attribs[11];
|
||||
int i = 0;
|
||||
|
@ -238,7 +237,7 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||
}
|
||||
}
|
||||
else {
|
||||
GLXFBConfig *framebuffer_config = NULL;
|
||||
GLXFBConfig *framebuffer_config = nullptr;
|
||||
{
|
||||
int glx_attribs[64];
|
||||
int fbcount = 0;
|
||||
|
@ -269,12 +268,12 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||
|
||||
GHOST_TSuccess success;
|
||||
|
||||
if (m_context != NULL) {
|
||||
if (m_context != nullptr) {
|
||||
const unsigned char *version;
|
||||
|
||||
if (!s_sharedContext)
|
||||
if (!s_sharedContext) {
|
||||
s_sharedContext = m_context;
|
||||
|
||||
}
|
||||
s_sharedCount++;
|
||||
|
||||
glXMakeCurrent(m_display, m_window, m_context);
|
||||
|
@ -319,14 +318,11 @@ GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
|
|||
|
||||
GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval)
|
||||
{
|
||||
if (GLXEW_EXT_swap_control) {
|
||||
if (!GLXEW_EXT_swap_control) {
|
||||
::glXSwapIntervalEXT(m_display, m_window, interval);
|
||||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
|
||||
|
@ -340,9 +336,7 @@ GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
|
|||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,30 +400,36 @@ int GHOST_X11_GL_GetAttributes(
|
|||
static GLuint _glewStrLen(const GLubyte *s)
|
||||
{
|
||||
GLuint i = 0;
|
||||
if (s == NULL)
|
||||
if (s == nullptr) {
|
||||
return 0;
|
||||
while (s[i] != '\0')
|
||||
}
|
||||
while (s[i] != '\0') {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static GLuint _glewStrCLen(const GLubyte *s, GLubyte c)
|
||||
{
|
||||
GLuint i = 0;
|
||||
if (s == NULL)
|
||||
if (s == nullptr) {
|
||||
return 0;
|
||||
while (s[i] != '\0' && s[i] != c)
|
||||
}
|
||||
while (s[i] != '\0' && s[i] != c) {
|
||||
i++;
|
||||
}
|
||||
return (s[i] == '\0' || s[i] == c) ? i : 0;
|
||||
}
|
||||
|
||||
static GLboolean _glewStrSame(const GLubyte *a, const GLubyte *b, GLuint n)
|
||||
{
|
||||
GLuint i = 0;
|
||||
if (a == NULL || b == NULL)
|
||||
return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE;
|
||||
while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i])
|
||||
if (a == nullptr || b == nullptr) {
|
||||
return (a == nullptr && b == nullptr && n == 0) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) {
|
||||
i++;
|
||||
}
|
||||
return i == n ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -440,8 +440,9 @@ static GLboolean _glewSearchExtension(const char *name, const GLubyte *start, co
|
|||
p = start;
|
||||
while (p < end) {
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte *)name, p, n))
|
||||
if (len == n && _glewStrSame((const GLubyte *)name, p, n)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
p += n + 1;
|
||||
}
|
||||
return GL_FALSE;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
SDL_GLContext GHOST_ContextSDL::s_sharedContext = NULL;
|
||||
SDL_GLContext GHOST_ContextSDL::s_sharedContext = nullptr;
|
||||
int GHOST_ContextSDL::s_sharedCount = 0;
|
||||
|
||||
GHOST_ContextSDL::GHOST_ContextSDL(bool stereoVisual,
|
||||
|
@ -27,36 +27,39 @@ GHOST_ContextSDL::GHOST_ContextSDL(bool stereoVisual,
|
|||
int contextResetNotificationStrategy)
|
||||
: GHOST_Context(stereoVisual),
|
||||
m_window(window),
|
||||
m_hidden_window(NULL),
|
||||
m_hidden_window(nullptr),
|
||||
m_contextProfileMask(contextProfileMask),
|
||||
m_contextMajorVersion(contextMajorVersion),
|
||||
m_contextMinorVersion(contextMinorVersion),
|
||||
m_contextFlags(contextFlags),
|
||||
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
|
||||
m_context(NULL)
|
||||
m_context(nullptr)
|
||||
{
|
||||
// assert(m_window != NULL);
|
||||
// assert(m_window != nullptr);
|
||||
}
|
||||
|
||||
GHOST_ContextSDL::~GHOST_ContextSDL()
|
||||
{
|
||||
if (m_context != NULL) {
|
||||
if (m_window != NULL && m_context == SDL_GL_GetCurrentContext())
|
||||
SDL_GL_MakeCurrent(m_window, NULL);
|
||||
if (m_context == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_context != s_sharedContext || s_sharedCount == 1) {
|
||||
assert(s_sharedCount > 0);
|
||||
if (m_window != nullptr && m_context == SDL_GL_GetCurrentContext()) {
|
||||
SDL_GL_MakeCurrent(m_window, nullptr);
|
||||
}
|
||||
if (m_context != s_sharedContext || s_sharedCount == 1) {
|
||||
assert(s_sharedCount > 0);
|
||||
|
||||
s_sharedCount--;
|
||||
s_sharedCount--;
|
||||
|
||||
if (s_sharedCount == 0)
|
||||
s_sharedContext = NULL;
|
||||
|
||||
SDL_GL_DeleteContext(m_context);
|
||||
if (s_sharedCount == 0) {
|
||||
s_sharedContext = nullptr;
|
||||
}
|
||||
SDL_GL_DeleteContext(m_context);
|
||||
}
|
||||
|
||||
if (m_hidden_window != NULL)
|
||||
SDL_DestroyWindow(m_hidden_window);
|
||||
if (m_hidden_window != nullptr) {
|
||||
SDL_DestroyWindow(m_hidden_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,23 +72,19 @@ GHOST_TSuccess GHOST_ContextSDL::swapBuffers()
|
|||
|
||||
GHOST_TSuccess GHOST_ContextSDL::activateDrawingContext()
|
||||
{
|
||||
if (m_context) {
|
||||
return SDL_GL_MakeCurrent(m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
if (m_context == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return SDL_GL_MakeCurrent(m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextSDL::releaseDrawingContext()
|
||||
{
|
||||
if (m_context) {
|
||||
/* Untested, may not work */
|
||||
return SDL_GL_MakeCurrent(NULL, NULL) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
if (m_context == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
/* Untested, may not work. */
|
||||
return SDL_GL_MakeCurrent(nullptr, nullptr) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
|
||||
|
@ -115,7 +114,7 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
|
|||
SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
|
||||
}
|
||||
|
||||
if (m_window == NULL) {
|
||||
if (m_window == nullptr) {
|
||||
m_hidden_window = SDL_CreateWindow("Offscreen Context Windows",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
|
@ -131,10 +130,10 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
|
|||
|
||||
GHOST_TSuccess success;
|
||||
|
||||
if (m_context != NULL) {
|
||||
if (!s_sharedContext)
|
||||
if (m_context != nullptr) {
|
||||
if (!s_sharedContext) {
|
||||
s_sharedContext = m_context;
|
||||
|
||||
}
|
||||
s_sharedCount++;
|
||||
|
||||
success = (SDL_GL_MakeCurrent(m_window, m_context) < 0) ? GHOST_kFailure : GHOST_kSuccess;
|
||||
|
@ -155,19 +154,17 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
|
|||
|
||||
GHOST_TSuccess GHOST_ContextSDL::releaseNativeHandles()
|
||||
{
|
||||
m_window = NULL;
|
||||
m_window = nullptr;
|
||||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextSDL::setSwapInterval(int interval)
|
||||
{
|
||||
if (SDL_GL_SetSwapInterval(interval) != -1) {
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
if (SDL_GL_SetSwapInterval(interval) == -1) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextSDL::getSwapInterval(int &intervalOut)
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
#include "GHOST_DisplayManager.h"
|
||||
#include "GHOST_Debug.h"
|
||||
|
||||
GHOST_DisplayManager::GHOST_DisplayManager(void) : m_settingsInitialized(false)
|
||||
GHOST_DisplayManager::GHOST_DisplayManager() : m_settingsInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
GHOST_DisplayManager::~GHOST_DisplayManager(void)
|
||||
GHOST_DisplayManager::~GHOST_DisplayManager()
|
||||
{
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_DisplayManager::initialize(void)
|
||||
GHOST_TSuccess GHOST_DisplayManager::initialize()
|
||||
{
|
||||
GHOST_TSuccess success;
|
||||
if (!m_settingsInitialized) {
|
||||
|
@ -139,7 +139,7 @@ GHOST_TSuccess GHOST_DisplayManager::findMatch(uint8_t display,
|
|||
return success;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_DisplayManager::initializeSettings(void)
|
||||
GHOST_TSuccess GHOST_DisplayManager::initializeSettings()
|
||||
{
|
||||
uint8_t numDisplays;
|
||||
GHOST_TSuccess success = getNumDisplays(numDisplays);
|
||||
|
|
|
@ -109,7 +109,7 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
|
|||
|
||||
SDL_GetDisplayMode(display, i, &mode);
|
||||
|
||||
if (setting.xPixels > mode.w || setting.yPixels > mode.h) {
|
||||
if ((int)setting.xPixels > mode.w || (int)setting.yPixels > mode.h) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -122,9 +122,9 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
|
|||
}
|
||||
}
|
||||
|
||||
if (best_fit == -1)
|
||||
if (best_fit == -1) {
|
||||
return GHOST_kFailure;
|
||||
|
||||
}
|
||||
SDL_GetDisplayMode(display, best_fit, &mode);
|
||||
}
|
||||
|
||||
|
@ -142,12 +142,10 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
|
|||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
/* this is a problem for the BGE player :S, perhaps SDL2 will resolve at some point.
|
||||
* we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */
|
||||
printf("no windows available, can't fullscreen\n");
|
||||
/* This is a problem for the BGE player :S, perhaps SDL2 will resolve at some point.
|
||||
* we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell. */
|
||||
printf("no windows available, can't fullscreen\n");
|
||||
|
||||
/* do not fail, we will try again later when the window is created - wander */
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
/* do not fail, we will try again later when the window is created - wander */
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,9 @@ GHOST_TSuccess GHOST_DisplayManagerX11::getNumDisplaySettings(uint8_t display,
|
|||
|
||||
GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
|
||||
|
||||
if (dpy == NULL)
|
||||
if (dpy == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
majorVersion = minorVersion = 0;
|
||||
if (!XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion)) {
|
||||
|
@ -77,8 +78,9 @@ GHOST_TSuccess GHOST_DisplayManagerX11::getDisplaySetting(uint8_t display,
|
|||
{
|
||||
Display *dpy = m_system->getXDisplay();
|
||||
|
||||
if (dpy == NULL)
|
||||
if (dpy == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
(void)display;
|
||||
|
||||
|
@ -143,8 +145,9 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting(
|
|||
Display *dpy = m_system->getXDisplay();
|
||||
int scrnum, num_vidmodes;
|
||||
|
||||
if (dpy == NULL)
|
||||
if (dpy == nullptr) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
scrnum = DefaultScreen(dpy);
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#include "GHOST_DropTargetX11.h"
|
||||
#include "GHOST_Debug.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cassert>.
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
bool GHOST_DropTargetX11::m_xdndInitialized = false;
|
||||
DndClass GHOST_DropTargetX11::m_dndClass;
|
||||
Atom *GHOST_DropTargetX11::m_dndTypes = NULL;
|
||||
Atom *GHOST_DropTargetX11::m_dndActions = NULL;
|
||||
Atom *GHOST_DropTargetX11::m_dndTypes = nullptr;
|
||||
Atom *GHOST_DropTargetX11::m_dndActions = nullptr;
|
||||
const char *GHOST_DropTargetX11::m_dndMimeTypes[] = {
|
||||
"url/url", "text/uri-list", "text/plain", "application/octet-stream"};
|
||||
int GHOST_DropTargetX11::m_refCounter = 0;
|
||||
|
@ -180,12 +180,12 @@ char *GHOST_DropTargetX11::FileUrlDecode(char *fileUrl)
|
|||
return decodedPath;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dropBufferSize)
|
||||
{
|
||||
GHOST_TStringArray *strArray = NULL;
|
||||
GHOST_TStringArray *strArray = nullptr;
|
||||
int totPaths = 0, curLength = 0;
|
||||
|
||||
/* Count total number of file paths in buffer. */
|
||||
|
@ -196,8 +196,9 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
|
|||
curLength = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
curLength++;
|
||||
}
|
||||
}
|
||||
|
||||
strArray = (GHOST_TStringArray *)malloc(sizeof(GHOST_TStringArray));
|
||||
|
@ -224,8 +225,9 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
|
|||
curLength = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
curLength++;
|
||||
}
|
||||
}
|
||||
|
||||
return strArray;
|
||||
|
@ -235,11 +237,11 @@ void *GHOST_DropTargetX11::getGhostData(Atom dropType,
|
|||
unsigned char *dropBuffer,
|
||||
int dropBufferSize)
|
||||
{
|
||||
void *data = NULL;
|
||||
void *data = nullptr;
|
||||
unsigned char *tmpBuffer = (unsigned char *)malloc(dropBufferSize + 1);
|
||||
bool needsFree = true;
|
||||
|
||||
/* ensure NULL-terminator */
|
||||
/* Ensure nil-terminator. */
|
||||
memcpy(tmpBuffer, dropBuffer, dropBufferSize);
|
||||
tmpBuffer[dropBufferSize] = 0;
|
||||
|
||||
|
@ -265,8 +267,9 @@ void *GHOST_DropTargetX11::getGhostData(Atom dropType,
|
|||
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
|
||||
}
|
||||
|
||||
if (needsFree)
|
||||
if (needsFree) {
|
||||
free(tmpBuffer);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -288,9 +291,10 @@ bool GHOST_DropTargetX11::GHOST_HandleClientMessage(XEvent *event)
|
|||
&dropY)) {
|
||||
void *data = getGhostData(dropType, dropBuffer, dropBufferSize);
|
||||
|
||||
if (data)
|
||||
if (data) {
|
||||
m_system->pushDragDropEvent(
|
||||
GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, dropX, dropY, data);
|
||||
}
|
||||
|
||||
free(dropBuffer);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# include "GHOST_SystemCocoa.h"
|
||||
#endif
|
||||
|
||||
GHOST_ISystem *GHOST_ISystem::m_system = NULL;
|
||||
GHOST_ISystem *GHOST_ISystem::m_system = nullptr;
|
||||
|
||||
GHOST_TSuccess GHOST_ISystem::createSystem()
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
|
|||
#elif defined(__APPLE__)
|
||||
m_system = new GHOST_SystemCocoa();
|
||||
#endif
|
||||
success = m_system != NULL ? GHOST_kSuccess : GHOST_kFailure;
|
||||
success = m_system != nullptr ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
success = GHOST_kFailure;
|
||||
|
@ -77,7 +77,7 @@ GHOST_TSuccess GHOST_ISystem::disposeSystem()
|
|||
GHOST_TSuccess success = GHOST_kSuccess;
|
||||
if (m_system) {
|
||||
delete m_system;
|
||||
m_system = NULL;
|
||||
m_system = nullptr;
|
||||
}
|
||||
else {
|
||||
success = GHOST_kFailure;
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* just for NULL */
|
||||
|
||||
#include "GHOST_ISystemPaths.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -23,7 +21,7 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = NULL;
|
||||
GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = nullptr;
|
||||
|
||||
GHOST_TSuccess GHOST_ISystemPaths::create()
|
||||
{
|
||||
|
@ -38,7 +36,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create()
|
|||
m_systemPaths = new GHOST_SystemPathsUnix();
|
||||
# endif
|
||||
#endif
|
||||
success = m_systemPaths != NULL ? GHOST_kSuccess : GHOST_kFailure;
|
||||
success = m_systemPaths != nullptr ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
success = GHOST_kFailure;
|
||||
|
@ -51,7 +49,7 @@ GHOST_TSuccess GHOST_ISystemPaths::dispose()
|
|||
GHOST_TSuccess success = GHOST_kSuccess;
|
||||
if (m_systemPaths) {
|
||||
delete m_systemPaths;
|
||||
m_systemPaths = NULL;
|
||||
m_systemPaths = nullptr;
|
||||
}
|
||||
else {
|
||||
success = GHOST_kFailure;
|
||||
|
|
|
@ -25,25 +25,28 @@ GHOST_TSuccess GHOST_DisposeSystemPaths(void)
|
|||
const char *GHOST_getSystemDir(int version, const char *versionstr)
|
||||
{
|
||||
GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get();
|
||||
return systemPaths ? systemPaths->getSystemDir(version, versionstr) : NULL;
|
||||
return systemPaths ? systemPaths->getSystemDir(version, versionstr) : nullptr;
|
||||
}
|
||||
|
||||
const char *GHOST_getUserDir(int version, const char *versionstr)
|
||||
{
|
||||
GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get();
|
||||
return systemPaths ? systemPaths->getUserDir(version, versionstr) : NULL; /* shouldn't be NULL */
|
||||
/* Shouldn't be `nullptr`. */
|
||||
return systemPaths ? systemPaths->getUserDir(version, versionstr) : nullptr;
|
||||
}
|
||||
|
||||
const char *GHOST_getUserSpecialDir(GHOST_TUserSpecialDirTypes type)
|
||||
{
|
||||
GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get();
|
||||
return systemPaths ? systemPaths->getUserSpecialDir(type) : NULL; /* shouldn't be NULL */
|
||||
/* Shouldn't be `nullptr`. */
|
||||
return systemPaths ? systemPaths->getUserSpecialDir(type) : nullptr;
|
||||
}
|
||||
|
||||
const char *GHOST_getBinaryDir()
|
||||
{
|
||||
GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get();
|
||||
return systemPaths ? systemPaths->getBinaryDir() : NULL; /* shouldn't be NULL */
|
||||
/* Shouldn't be `nullptr`. */
|
||||
return systemPaths ? systemPaths->getBinaryDir() : nullptr;
|
||||
}
|
||||
|
||||
void GHOST_addToSystemRecentFiles(const char *filename)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "GHOST_System.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <stdio.h> /* just for printf */
|
||||
#include <cstdio> /* just for printf */
|
||||
|
||||
#include "GHOST_DisplayManager.h"
|
||||
#include "GHOST_EventManager.h"
|
||||
|
@ -23,10 +23,10 @@
|
|||
GHOST_System::GHOST_System()
|
||||
: m_nativePixel(false),
|
||||
m_windowFocus(true),
|
||||
m_displayManager(NULL),
|
||||
m_timerManager(NULL),
|
||||
m_windowManager(NULL),
|
||||
m_eventManager(NULL),
|
||||
m_displayManager(nullptr),
|
||||
m_timerManager(nullptr),
|
||||
m_windowManager(nullptr),
|
||||
m_eventManager(nullptr),
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
m_ndofManager(0),
|
||||
#endif
|
||||
|
@ -61,7 +61,7 @@ GHOST_ITimerTask *GHOST_System::installTimer(uint64_t delay,
|
|||
}
|
||||
else {
|
||||
delete timer;
|
||||
timer = NULL;
|
||||
timer = nullptr;
|
||||
}
|
||||
}
|
||||
return timer;
|
||||
|
@ -205,7 +205,7 @@ GHOST_IWindow *GHOST_System::getWindowUnderCursor(int32_t x, int32_t y)
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GHOST_System::dispatchEvents()
|
||||
|
@ -331,20 +331,20 @@ GHOST_TSuccess GHOST_System::exit()
|
|||
}
|
||||
|
||||
delete m_displayManager;
|
||||
m_displayManager = NULL;
|
||||
m_displayManager = nullptr;
|
||||
|
||||
delete m_windowManager;
|
||||
m_windowManager = NULL;
|
||||
m_windowManager = nullptr;
|
||||
|
||||
delete m_timerManager;
|
||||
m_timerManager = NULL;
|
||||
m_timerManager = nullptr;
|
||||
|
||||
delete m_eventManager;
|
||||
m_eventManager = NULL;
|
||||
m_eventManager = nullptr;
|
||||
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
delete m_ndofManager;
|
||||
m_ndofManager = NULL;
|
||||
m_ndofManager = nullptr;
|
||||
#endif
|
||||
|
||||
return GHOST_kSuccess;
|
||||
|
@ -376,13 +376,13 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
|
|||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings,
|
||||
true /* exclusive */);
|
||||
return (*window == NULL) ? GHOST_kFailure : GHOST_kSuccess;
|
||||
return (*window == nullptr) ? GHOST_kFailure : GHOST_kSuccess;
|
||||
}
|
||||
|
||||
bool GHOST_System::useNativePixel(void)
|
||||
bool GHOST_System::useNativePixel()
|
||||
{
|
||||
m_nativePixel = true;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GHOST_System::useWindowFocus(const bool use_focus)
|
||||
|
|
|
@ -40,7 +40,7 @@ class GHOST_SystemNULL : public GHOST_System {
|
|||
}
|
||||
char *getClipboard(bool selection) const
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
void putClipboard(const char *buffer, bool selection) const
|
||||
{ /* nop */
|
||||
|
@ -69,7 +69,7 @@ class GHOST_SystemNULL : public GHOST_System {
|
|||
}
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GHOST_TSuccess disposeContext(GHOST_IContext *context)
|
||||
{
|
||||
|
@ -117,6 +117,6 @@ class GHOST_SystemNULL : public GHOST_System {
|
|||
|
||||
GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstdio> /* for fprintf only */
|
||||
#include <cstdlib> /* for exit */
|
||||
#include <stdio.h> /* for fprintf only */
|
||||
|
||||
#include <pwd.h> /* for get home without use getenv() */
|
||||
#include <string>
|
||||
|
@ -28,7 +28,7 @@ using std::string;
|
|||
#ifdef PREFIX
|
||||
static const char *static_path = PREFIX "/share";
|
||||
#else
|
||||
static const char *static_path = NULL;
|
||||
static const char *static_path = nullptr;
|
||||
#endif
|
||||
|
||||
GHOST_SystemPathsUnix::GHOST_SystemPathsUnix()
|
||||
|
@ -39,7 +39,7 @@ GHOST_SystemPathsUnix::~GHOST_SystemPathsUnix()
|
|||
{
|
||||
}
|
||||
|
||||
const char *GHOST_SystemPathsUnix::getSystemDir(int, const char *versionstr) const
|
||||
const char *GHOST_SystemPathsUnix::getSystemDir(int /*version*/, const char *versionstr) const
|
||||
{
|
||||
/* no prefix assumes a portable build which only uses bundled scripts */
|
||||
if (static_path) {
|
||||
|
@ -47,7 +47,7 @@ const char *GHOST_SystemPathsUnix::getSystemDir(int, const char *versionstr) con
|
|||
return system_path.c_str();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *GHOST_SystemPathsUnix::getUserDir(int version, const char *versionstr) const
|
||||
|
@ -67,32 +67,29 @@ const char *GHOST_SystemPathsUnix::getUserDir(int version, const char *versionst
|
|||
user_path = string(home) + "/.blender/" + versionstr;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return user_path.c_str();
|
||||
}
|
||||
else {
|
||||
if (user_path.empty() || last_version != version) {
|
||||
const char *home = getenv("XDG_CONFIG_HOME");
|
||||
if (user_path.empty() || last_version != version) {
|
||||
const char *home = getenv("XDG_CONFIG_HOME");
|
||||
|
||||
last_version = version;
|
||||
last_version = version;
|
||||
|
||||
if (home) {
|
||||
user_path = string(home) + "/blender/" + versionstr;
|
||||
}
|
||||
else {
|
||||
home = getenv("HOME");
|
||||
|
||||
if (home == NULL)
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
|
||||
user_path = string(home) + "/.config/blender/" + versionstr;
|
||||
}
|
||||
if (home) {
|
||||
user_path = string(home) + "/blender/" + versionstr;
|
||||
}
|
||||
else {
|
||||
home = getenv("HOME");
|
||||
if (home == nullptr) {
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
}
|
||||
user_path = string(home) + "/.config/blender/" + versionstr;
|
||||
}
|
||||
|
||||
return user_path.c_str();
|
||||
}
|
||||
|
||||
return user_path.c_str();
|
||||
}
|
||||
|
||||
const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const
|
||||
|
@ -135,7 +132,7 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
|
|||
GHOST_ASSERT(
|
||||
false,
|
||||
"GHOST_SystemPathsUnix::getUserSpecialDir(): Invalid enum value for type parameter");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static string path = "";
|
||||
|
@ -143,8 +140,8 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
|
|||
string command = string("xdg-user-dir ") + type_str + " 2> /dev/null";
|
||||
|
||||
FILE *fstream = popen(command.c_str(), "r");
|
||||
if (fstream == NULL) {
|
||||
return NULL;
|
||||
if (fstream == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
std::stringstream path_stream;
|
||||
while (!feof(fstream)) {
|
||||
|
@ -157,7 +154,7 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
|
|||
}
|
||||
if (pclose(fstream) == -1) {
|
||||
perror("GHOST_SystemPathsUnix::getUserSpecialDir failed at pclose()");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!add_path.empty()) {
|
||||
|
@ -165,12 +162,12 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
|
|||
}
|
||||
|
||||
path = path_stream.str();
|
||||
return path[0] ? path.c_str() : NULL;
|
||||
return path[0] ? path.c_str() : nullptr;
|
||||
}
|
||||
|
||||
const char *GHOST_SystemPathsUnix::getBinaryDir() const
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GHOST_SystemPathsUnix::addToSystemRecentFiles(const char * /*filename*/) const
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* \ingroup GHOST
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "GHOST_ContextSDL.h"
|
||||
#include "GHOST_SystemSDL.h"
|
||||
|
@ -47,7 +47,7 @@ GHOST_IWindow *GHOST_SystemSDL::createWindow(const char *title,
|
|||
const bool /* is_dialog */,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
{
|
||||
GHOST_WindowSDL *window = NULL;
|
||||
GHOST_WindowSDL *window = nullptr;
|
||||
|
||||
window = new GHOST_WindowSDL(this,
|
||||
title,
|
||||
|
@ -79,7 +79,7 @@ GHOST_IWindow *GHOST_SystemSDL::createWindow(const char *title,
|
|||
}
|
||||
else {
|
||||
delete window;
|
||||
window = NULL;
|
||||
window = nullptr;
|
||||
}
|
||||
}
|
||||
return window;
|
||||
|
@ -127,20 +127,20 @@ uint8_t GHOST_SystemSDL::getNumDisplays() const
|
|||
|
||||
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings /*glSettings*/)
|
||||
{
|
||||
GHOST_Context *context = new GHOST_ContextSDL(0,
|
||||
NULL,
|
||||
GHOST_Context *context = new GHOST_ContextSDL(false,
|
||||
nullptr,
|
||||
0, /* Profile bit. */
|
||||
3,
|
||||
3,
|
||||
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemSDL::disposeContext(GHOST_IContext *context)
|
||||
|
@ -286,7 +286,7 @@ static GHOST_TKey convertSDLKey(SDL_Scancode key)
|
|||
static SDL_Window *SDL_GetWindowFromID_fallback(Uint32 id)
|
||||
{
|
||||
SDL_Window *sdl_win = SDL_GetWindowFromID(id);
|
||||
if (sdl_win == NULL) {
|
||||
if (sdl_win == nullptr) {
|
||||
sdl_win = SDL_GL_GetCurrentWindow();
|
||||
}
|
||||
return sdl_win;
|
||||
|
@ -294,16 +294,16 @@ static SDL_Window *SDL_GetWindowFromID_fallback(Uint32 id)
|
|||
|
||||
void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
||||
{
|
||||
GHOST_Event *g_event = NULL;
|
||||
GHOST_Event *g_event = nullptr;
|
||||
|
||||
switch (sdl_event->type) {
|
||||
case SDL_WINDOWEVENT: {
|
||||
SDL_WindowEvent &sdl_sub_evt = sdl_event->window;
|
||||
GHOST_WindowSDL *window = findGhostWindow(
|
||||
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
|
||||
/* Can be NULL on close window. */
|
||||
/* Can be nullptr on close window. */
|
||||
#if 0
|
||||
assert(window != NULL);
|
||||
assert(window != nullptr);
|
||||
#endif
|
||||
|
||||
switch (sdl_sub_evt.event) {
|
||||
|
@ -340,7 +340,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
SDL_MouseMotionEvent &sdl_sub_evt = sdl_event->motion;
|
||||
SDL_Window *sdl_win = SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID);
|
||||
GHOST_WindowSDL *window = findGhostWindow(sdl_win);
|
||||
assert(window != NULL);
|
||||
assert(window != nullptr);
|
||||
|
||||
int x_win, y_win;
|
||||
SDL_GetWindowPosition(sdl_win, &x_win, &y_win);
|
||||
|
@ -416,22 +416,28 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
|
||||
GHOST_WindowSDL *window = findGhostWindow(
|
||||
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
|
||||
assert(window != NULL);
|
||||
assert(window != nullptr);
|
||||
|
||||
/* process rest of normal mouse buttons */
|
||||
if (sdl_sub_evt.button == SDL_BUTTON_LEFT)
|
||||
if (sdl_sub_evt.button == SDL_BUTTON_LEFT) {
|
||||
gbmask = GHOST_kButtonMaskLeft;
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_MIDDLE)
|
||||
}
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_MIDDLE) {
|
||||
gbmask = GHOST_kButtonMaskMiddle;
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_RIGHT)
|
||||
}
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_RIGHT) {
|
||||
gbmask = GHOST_kButtonMaskRight;
|
||||
/* these buttons are untested! */
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_X1)
|
||||
/* these buttons are untested! */
|
||||
}
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_X1) {
|
||||
gbmask = GHOST_kButtonMaskButton4;
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_X2)
|
||||
}
|
||||
else if (sdl_sub_evt.button == SDL_BUTTON_X2) {
|
||||
gbmask = GHOST_kButtonMaskButton5;
|
||||
else
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
g_event = new GHOST_EventButton(
|
||||
getMilliSeconds(), type, window, gbmask, GHOST_TABLET_DATA_NONE);
|
||||
|
@ -441,7 +447,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
SDL_MouseWheelEvent &sdl_sub_evt = sdl_event->wheel;
|
||||
GHOST_WindowSDL *window = findGhostWindow(
|
||||
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
|
||||
assert(window != NULL);
|
||||
assert(window != nullptr);
|
||||
g_event = new GHOST_EventWheel(getMilliSeconds(), window, sdl_sub_evt.y);
|
||||
break;
|
||||
}
|
||||
|
@ -454,7 +460,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
|
||||
GHOST_WindowSDL *window = findGhostWindow(
|
||||
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
|
||||
assert(window != NULL);
|
||||
assert(window != nullptr);
|
||||
|
||||
GHOST_TKey gkey = convertSDLKey(sdl_sub_evt.keysym.scancode);
|
||||
/* NOTE: the `sdl_sub_evt.keysym.sym` is truncated,
|
||||
|
@ -590,7 +596,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
}
|
||||
}
|
||||
|
||||
g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym, NULL, false);
|
||||
g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym, nullptr, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -660,14 +666,14 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent)
|
|||
uint64_t next = timerMgr->nextFireTime();
|
||||
|
||||
if (next == GHOST_kFireTimeNever) {
|
||||
SDL_WaitEventTimeout(NULL, -1);
|
||||
SDL_WaitEventTimeout(nullptr, -1);
|
||||
// SleepTillEvent(m_display, -1);
|
||||
}
|
||||
else {
|
||||
int64_t maxSleep = next - getMilliSeconds();
|
||||
|
||||
if (maxSleep >= 0) {
|
||||
SDL_WaitEventTimeout(NULL, next - getMilliSeconds());
|
||||
SDL_WaitEventTimeout(nullptr, next - getMilliSeconds());
|
||||
// SleepTillEvent(m_display, next - getMilliSeconds()); /* X11. */
|
||||
}
|
||||
}
|
||||
|
@ -693,9 +699,9 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent)
|
|||
|
||||
GHOST_WindowSDL *GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
|
||||
{
|
||||
if (sdl_win == NULL)
|
||||
return NULL;
|
||||
|
||||
if (sdl_win == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
/* It is not entirely safe to do this as the backptr may point
|
||||
* to a window that has recently been removed.
|
||||
* We should always check the window manager's list of windows
|
||||
|
@ -712,19 +718,19 @@ GHOST_WindowSDL *GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
|
|||
return window;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GHOST_SystemSDL::addDirtyWindow(GHOST_WindowSDL *bad_wind)
|
||||
{
|
||||
GHOST_ASSERT((bad_wind != NULL), "addDirtyWindow() NULL ptr trapped (window)");
|
||||
GHOST_ASSERT((bad_wind != nullptr), "addDirtyWindow() nullptr ptr trapped (window)");
|
||||
|
||||
m_dirty_windows.push_back(bad_wind);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemSDL::getButtons(GHOST_Buttons &buttons) const
|
||||
{
|
||||
Uint8 state = SDL_GetMouseState(NULL, NULL);
|
||||
Uint8 state = SDL_GetMouseState(nullptr, nullptr);
|
||||
buttons.set(GHOST_kButtonMaskLeft, (state & SDL_BUTTON_LMASK) != 0);
|
||||
buttons.set(GHOST_kButtonMaskMiddle, (state & SDL_BUTTON_MMASK) != 0);
|
||||
buttons.set(GHOST_kButtonMaskRight, (state & SDL_BUTTON_RMASK) != 0);
|
||||
|
|
|
@ -507,7 +507,7 @@ static std::string read_pipe(data_offer_t *data_offer, const std::string mime_re
|
|||
* A target accepts an offered mime type.
|
||||
*
|
||||
* Sent when a target accepts pointer_focus or motion events. If
|
||||
* a target does not accept any of the offered types, type is NULL.
|
||||
* a target does not accept any of the offered types, type is nullptr.
|
||||
*/
|
||||
static void data_source_target(void * /*data*/,
|
||||
struct wl_data_source * /*wl_data_source*/,
|
||||
|
@ -828,8 +828,9 @@ static bool update_cursor_scale(cursor_t &cursor, wl_shm *shm)
|
|||
{
|
||||
int scale = 0;
|
||||
for (const output_t *output : cursor.outputs) {
|
||||
if (output->scale > scale)
|
||||
if (output->scale > scale) {
|
||||
scale = output->scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (scale > 0 && cursor.scale != scale) {
|
||||
|
@ -1538,8 +1539,9 @@ void GHOST_SystemWayland::putClipboard(const char *buffer, bool /*selection*/) c
|
|||
data_source_t *data_source = d->inputs[0]->data_source;
|
||||
|
||||
/* Copy buffer. */
|
||||
data_source->buffer_out = static_cast<char *>(malloc(strlen(buffer) + 1));
|
||||
std::strcpy(data_source->buffer_out, buffer);
|
||||
const size_t buffer_size = strlen(buffer) + 1;
|
||||
data_source->buffer_out = static_cast<char *>(malloc(buffer_size));
|
||||
std::memcpy(data_source->buffer_out, buffer, buffer_size);
|
||||
|
||||
data_source->data_source = wl_data_device_manager_create_data_source(d->data_device_manager);
|
||||
|
||||
|
@ -1563,14 +1565,13 @@ uint8_t GHOST_SystemWayland::getNumDisplays() const
|
|||
|
||||
GHOST_TSuccess GHOST_SystemWayland::getCursorPosition(int32_t &x, int32_t &y) const
|
||||
{
|
||||
if (!d->inputs.empty() && (d->inputs[0]->focus_pointer != nullptr)) {
|
||||
x = d->inputs[0]->x;
|
||||
y = d->inputs[0]->y;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
if (d->inputs.empty() || (d->inputs[0]->focus_pointer == nullptr)) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
x = d->inputs[0]->x;
|
||||
y = d->inputs[0]->y;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemWayland::setCursorPosition(int32_t /*x*/, int32_t /*y*/)
|
||||
|
@ -1615,10 +1616,10 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
|
|||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
|
||||
context = new GHOST_ContextEGL(this,
|
||||
|
@ -1635,9 +1636,7 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
|
|||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
|
||||
GHOST_PRINT("Cannot create off-screen EGL context" << std::endl);
|
||||
|
||||
|
@ -1806,7 +1805,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap,
|
|||
cursor_t *cursor = &d->inputs[0]->cursor;
|
||||
|
||||
static const int32_t stride = sizex * 4; /* ARGB */
|
||||
cursor->file_buffer->size = size_t(stride * sizey);
|
||||
cursor->file_buffer->size = (size_t)stride * sizey;
|
||||
|
||||
#ifdef HAVE_MEMFD_CREATE
|
||||
const int fd = memfd_create("blender-cursor-custom", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||
|
|
|
@ -23,8 +23,8 @@ struct display_t;
|
|||
|
||||
struct output_t {
|
||||
struct wl_output *output;
|
||||
int32_t width_pxl, height_pxl; // dimensions in pixel
|
||||
int32_t width_mm, height_mm; // dimensions in millimeter
|
||||
int32_t width_pxl, height_pxl; /* Dimensions in pixel. */
|
||||
int32_t width_mm, height_mm; /* Dimensions in millimeter. */
|
||||
int transform;
|
||||
int scale;
|
||||
std::string make;
|
||||
|
|
|
@ -58,9 +58,9 @@
|
|||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstdio> /* for fprintf only */
|
||||
#include <cstdlib> /* for exit */
|
||||
#include <iostream>
|
||||
#include <stdio.h> /* for fprintf only */
|
||||
#include <vector>
|
||||
|
||||
/* For debugging, so we can break-point X11 errors. */
|
||||
|
@ -89,8 +89,8 @@ static GHOST_TKey ghost_key_from_keysym_or_keycode(const KeySym key,
|
|||
const KeyCode keycode);
|
||||
|
||||
/* these are for copy and select copy */
|
||||
static char *txt_cut_buffer = NULL;
|
||||
static char *txt_select_buffer = NULL;
|
||||
static char *txt_cut_buffer = nullptr;
|
||||
static char *txt_select_buffer = nullptr;
|
||||
|
||||
#ifdef WITH_XWAYLAND_HACK
|
||||
static bool use_xwayland_hack = false;
|
||||
|
@ -98,10 +98,10 @@ static bool use_xwayland_hack = false;
|
|||
|
||||
using namespace std;
|
||||
|
||||
GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_time(0)
|
||||
GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(nullptr), m_start_time(0)
|
||||
{
|
||||
XInitThreads();
|
||||
m_display = XOpenDisplay(NULL);
|
||||
m_display = XOpenDisplay(nullptr);
|
||||
|
||||
if (!m_display) {
|
||||
std::cerr << "Unable to open a display" << std::endl;
|
||||
|
@ -117,7 +117,7 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_
|
|||
/* NOTE: Don't open connection to XIM server here, because the locale has to be
|
||||
* set before opening the connection but `setlocale()` has not been called yet.
|
||||
* the connection will be opened after entering the event loop. */
|
||||
m_xim = NULL;
|
||||
m_xim = nullptr;
|
||||
#endif
|
||||
|
||||
#define GHOST_INTERN_ATOM_IF_EXISTS(atom) \
|
||||
|
@ -165,7 +165,7 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_
|
|||
|
||||
/* compute the initial time */
|
||||
timeval tv;
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
if (gettimeofday(&tv, nullptr) == -1) {
|
||||
GHOST_ASSERT(false, "Could not instantiate timer!");
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_
|
|||
use_xkb = XkbQueryExtension(
|
||||
m_display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_major, &xkb_minor);
|
||||
if (use_xkb) {
|
||||
XkbSetDetectableAutoRepeat(m_display, true, NULL);
|
||||
XkbSetDetectableAutoRepeat(m_display, true, nullptr);
|
||||
|
||||
m_xkb_descr = XkbGetMap(m_display, 0, XkbUseCoreKbd);
|
||||
if (m_xkb_descr) {
|
||||
|
@ -190,7 +190,7 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_
|
|||
}
|
||||
|
||||
#ifdef WITH_XWAYLAND_HACK
|
||||
use_xwayland_hack = getenv("WAYLAND_DISPLAY") != NULL;
|
||||
use_xwayland_hack = getenv("WAYLAND_DISPLAY") != nullptr;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_X11_XINPUT
|
||||
|
@ -266,7 +266,7 @@ GHOST_TSuccess GHOST_SystemX11::init()
|
|||
uint64_t GHOST_SystemX11::getMilliSeconds() const
|
||||
{
|
||||
timeval tv;
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
if (gettimeofday(&tv, nullptr) == -1) {
|
||||
GHOST_ASSERT(false, "Could not compute time!");
|
||||
}
|
||||
|
||||
|
@ -334,10 +334,11 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title,
|
|||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
{
|
||||
GHOST_WindowX11 *window = NULL;
|
||||
GHOST_WindowX11 *window = nullptr;
|
||||
|
||||
if (!m_display)
|
||||
return 0;
|
||||
if (!m_display) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
window = new GHOST_WindowX11(this,
|
||||
m_display,
|
||||
|
@ -367,7 +368,7 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title,
|
|||
}
|
||||
else {
|
||||
delete window;
|
||||
window = NULL;
|
||||
window = nullptr;
|
||||
}
|
||||
}
|
||||
return window;
|
||||
|
@ -395,7 +396,7 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
|||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
{
|
||||
const char *version_major = (char *)glewGetString(GLEW_VERSION_MAJOR);
|
||||
if (version_major != NULL && version_major[0] == '1') {
|
||||
if (version_major != nullptr && version_major[0] == '1') {
|
||||
fprintf(stderr, "Error: GLEW version 2.0 and above is required.\n");
|
||||
abort();
|
||||
}
|
||||
|
@ -438,9 +439,9 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
|||
EGL_OPENGL_API);
|
||||
#else
|
||||
context = new GHOST_ContextGLX(false,
|
||||
(Window)NULL,
|
||||
(Window) nullptr,
|
||||
m_display,
|
||||
(GLXFBConfig)NULL,
|
||||
(GLXFBConfig) nullptr,
|
||||
profile_mask,
|
||||
4,
|
||||
minor,
|
||||
|
@ -449,10 +450,10 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
|||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
|
||||
#if defined(WITH_GL_EGL)
|
||||
|
@ -469,9 +470,9 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
|||
EGL_OPENGL_API);
|
||||
#else
|
||||
context = new GHOST_ContextGLX(false,
|
||||
(Window)NULL,
|
||||
(Window) nullptr,
|
||||
m_display,
|
||||
(GLXFBConfig)NULL,
|
||||
(GLXFBConfig) nullptr,
|
||||
profile_mask,
|
||||
3,
|
||||
3,
|
||||
|
@ -480,12 +481,12 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
|||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -506,7 +507,7 @@ static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/)
|
|||
GHOST_PRINT("XIM server died\n");
|
||||
|
||||
if (ptr)
|
||||
*(XIM *)ptr = NULL;
|
||||
*(XIM *)ptr = nullptr;
|
||||
}
|
||||
|
||||
bool GHOST_SystemX11::openX11_IM()
|
||||
|
@ -517,14 +518,14 @@ bool GHOST_SystemX11::openX11_IM()
|
|||
/* set locale modifiers such as `@im=ibus` specified by XMODIFIERS. */
|
||||
XSetLocaleModifiers("");
|
||||
|
||||
m_xim = XOpenIM(m_display, NULL, (char *)GHOST_X11_RES_NAME, (char *)GHOST_X11_RES_CLASS);
|
||||
m_xim = XOpenIM(m_display, nullptr, (char *)GHOST_X11_RES_NAME, (char *)GHOST_X11_RES_CLASS);
|
||||
if (!m_xim)
|
||||
return false;
|
||||
|
||||
XIMCallback destroy;
|
||||
destroy.callback = (XIMProc)destroyIMCallback;
|
||||
destroy.client_data = (XPointer)&m_xim;
|
||||
XSetIMValues(m_xim, XNDestroyCallback, &destroy, NULL);
|
||||
XSetIMValues(m_xim, XNDestroyCallback, &destroy, nullptr);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -532,8 +533,9 @@ bool GHOST_SystemX11::openX11_IM()
|
|||
GHOST_WindowX11 *GHOST_SystemX11::findGhostWindow(Window xwind) const
|
||||
{
|
||||
|
||||
if (xwind == 0)
|
||||
return NULL;
|
||||
if (xwind == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* It is not entirely safe to do this as the backptr may point
|
||||
* to a window that has recently been removed.
|
||||
|
@ -551,7 +553,7 @@ GHOST_WindowX11 *GHOST_SystemX11::findGhostWindow(Window xwind) const
|
|||
return window;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void SleepTillEvent(Display *display, int64_t maxSleep)
|
||||
|
@ -563,7 +565,7 @@ static void SleepTillEvent(Display *display, int64_t maxSleep)
|
|||
FD_SET(fd, &fds);
|
||||
|
||||
if (maxSleep == -1) {
|
||||
select(fd + 1, &fds, NULL, NULL, NULL);
|
||||
select(fd + 1, &fds, nullptr, nullptr, nullptr);
|
||||
}
|
||||
else {
|
||||
timeval tv;
|
||||
|
@ -571,7 +573,7 @@ static void SleepTillEvent(Display *display, int64_t maxSleep)
|
|||
tv.tv_sec = maxSleep / 1000;
|
||||
tv.tv_usec = (maxSleep - tv.tv_sec * 1000) * 1000;
|
||||
|
||||
select(fd + 1, &fds, NULL, NULL, &tv);
|
||||
select(fd + 1, &fds, nullptr, nullptr, &tv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,7 +679,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
|||
}
|
||||
|
||||
/* dispatch event to XIM server */
|
||||
if ((XFilterEvent(&xevent, (Window)NULL) == True)) {
|
||||
if ((XFilterEvent(&xevent, (Window) nullptr) == True)) {
|
||||
/* do nothing now, the event is consumed by XIM. */
|
||||
continue;
|
||||
}
|
||||
|
@ -739,7 +741,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
|||
window,
|
||||
ghost_key_from_keysym(modifiers[i]),
|
||||
'\0',
|
||||
NULL,
|
||||
nullptr,
|
||||
false));
|
||||
}
|
||||
}
|
||||
|
@ -773,7 +775,7 @@ static bool checkTabletProximity(Display *display, XDevice *device)
|
|||
/* see: state.c from xinput, to get more data out of the device */
|
||||
XDeviceState *state;
|
||||
|
||||
if (device == NULL) {
|
||||
if (device == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -812,7 +814,7 @@ static bool checkTabletProximity(Display *display, XDevice *device)
|
|||
void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
{
|
||||
GHOST_WindowX11 *window = findGhostWindow(xe->xany.window);
|
||||
GHOST_Event *g_event = NULL;
|
||||
GHOST_Event *g_event = nullptr;
|
||||
|
||||
/* Detect auto-repeat. */
|
||||
bool is_repeat = false;
|
||||
|
@ -822,7 +824,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
/* Set to true if this key will repeat. */
|
||||
bool is_repeat_keycode = false;
|
||||
|
||||
if (m_xkb_descr != NULL) {
|
||||
if (m_xkb_descr != nullptr) {
|
||||
/* Use XKB support. */
|
||||
is_repeat_keycode = (
|
||||
/* Should always be true, check just in case. */
|
||||
|
@ -954,8 +956,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
GHOST_Rect bounds;
|
||||
|
||||
/* fallback to window bounds */
|
||||
if (window->getCursorGrabBounds(bounds) == GHOST_kFailure)
|
||||
if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
|
||||
window->getClientBounds(bounds);
|
||||
}
|
||||
|
||||
/* Could also clamp to screen bounds wrap with a window outside the view will
|
||||
* fail at the moment. Use offset of 8 in case the window is at screen bounds. */
|
||||
|
@ -1019,7 +1022,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
char *utf8_buf = utf8_array;
|
||||
int len = 1; /* at least one null character will be stored */
|
||||
#else
|
||||
char *utf8_buf = NULL;
|
||||
char *utf8_buf = nullptr;
|
||||
#endif
|
||||
|
||||
GHOST_TEventType type = (xke->type == KeyPress) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp;
|
||||
|
@ -1065,7 +1068,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
key_sym = XLookupKeysym(xke, 0);
|
||||
}
|
||||
|
||||
if (!XLookupString(xke, &ascii, 1, &key_sym_str, NULL)) {
|
||||
if (!XLookupString(xke, &ascii, 1, &key_sym_str, nullptr)) {
|
||||
ascii = '\0';
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1138,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
|
||||
gkey = ghost_key_from_keysym_or_keycode(key_sym, m_xkb_descr, xke->keycode);
|
||||
|
||||
if (!XLookupString(xke, &ascii, 1, NULL, NULL)) {
|
||||
if (!XLookupString(xke, &ascii, 1, nullptr, nullptr)) {
|
||||
ascii = '\0';
|
||||
}
|
||||
#endif
|
||||
|
@ -1715,7 +1718,7 @@ GHOST_TSuccess GHOST_SystemX11::setCursorPosition(int32_t x, int32_t y)
|
|||
|
||||
void GHOST_SystemX11::addDirtyWindow(GHOST_WindowX11 *bad_wind)
|
||||
{
|
||||
GHOST_ASSERT((bad_wind != NULL), "addDirtyWindow() NULL ptr trapped (window)");
|
||||
GHOST_ASSERT((bad_wind != nullptr), "addDirtyWindow() nullptr ptr trapped (window)");
|
||||
|
||||
m_dirty_windows.push_back(bad_wind);
|
||||
}
|
||||
|
@ -2157,8 +2160,9 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
|
|||
return sel_buf;
|
||||
}
|
||||
}
|
||||
else if (owner == None)
|
||||
return NULL;
|
||||
else if (owner == None) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Restore events so copy doesn't swallow other event types (keyboard/mouse). */
|
||||
vector<XEvent> restore_events;
|
||||
|
@ -2224,7 +2228,7 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
|
|||
|
||||
return tmp_data;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const
|
||||
|
@ -2352,14 +2356,16 @@ static void split(const char *text, const char *seps, char ***str, int *count)
|
|||
*count = 0;
|
||||
|
||||
data = strdup(text);
|
||||
for (tok = strtok(data, seps); tok != NULL; tok = strtok(NULL, seps))
|
||||
for (tok = strtok(data, seps); tok != nullptr; tok = strtok(nullptr, seps)) {
|
||||
(*count)++;
|
||||
}
|
||||
free(data);
|
||||
|
||||
data = strdup(text);
|
||||
*str = (char **)malloc((size_t)(*count) * sizeof(char *));
|
||||
for (i = 0, tok = strtok(data, seps); tok != NULL; tok = strtok(NULL, seps), i++)
|
||||
for (i = 0, tok = strtok(data, seps); tok != nullptr; tok = strtok(nullptr, seps), i++) {
|
||||
(*str)[i] = strdup(tok);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
@ -2370,7 +2376,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
|
|||
const char *link,
|
||||
GHOST_DialogOptions) const
|
||||
{
|
||||
char **text_splitted = NULL;
|
||||
char **text_splitted = nullptr;
|
||||
int textLines = 0;
|
||||
split(message, "\n", &text_splitted, &textLines);
|
||||
|
||||
|
@ -2433,7 +2439,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
|
|||
XSelectInput(m_display, window, ExposureMask | ButtonPressMask | ButtonReleaseMask);
|
||||
XMapWindow(m_display, window);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
XNextEvent(m_display, &e);
|
||||
if (e.type == Expose) {
|
||||
for (int i = 0; i < textLines; i++) {
|
||||
|
@ -2454,7 +2460,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
|
|||
if (dialog_data.isInsideButton(e, 1)) {
|
||||
break;
|
||||
}
|
||||
else if (dialog_data.isInsideButton(e, 2)) {
|
||||
if (dialog_data.isInsideButton(e, 2)) {
|
||||
if (strlen(link)) {
|
||||
string cmd = "xdg-open \"" + string(link) + "\"";
|
||||
if (system(cmd.c_str()) != 0) {
|
||||
|
@ -2580,19 +2586,19 @@ static bool match_token(const char *haystack, const char *needle)
|
|||
static GHOST_TTabletMode tablet_mode_from_name(const char *name, const char *type)
|
||||
{
|
||||
int i;
|
||||
static const char *tablet_stylus_whitelist[] = {"stylus", "wizardpen", "acecad", "pen", NULL};
|
||||
static const char *tablet_stylus_whitelist[] = {"stylus", "wizardpen", "acecad", "pen", nullptr};
|
||||
|
||||
static const char *type_blacklist[] = {"pad", "cursor", "touch", NULL};
|
||||
static const char *type_blacklist[] = {"pad", "cursor", "touch", nullptr};
|
||||
|
||||
/* Skip some known unsupported types. */
|
||||
for (i = 0; type_blacklist[i] != NULL; i++) {
|
||||
for (i = 0; type_blacklist[i] != nullptr; i++) {
|
||||
if (type && (strcasecmp(type, type_blacklist[i]) == 0)) {
|
||||
return GHOST_kTabletModeNone;
|
||||
}
|
||||
}
|
||||
|
||||
/* First check device type to avoid cases where name is "Pen and Eraser" and type is "ERASER" */
|
||||
for (i = 0; tablet_stylus_whitelist[i] != NULL; i++) {
|
||||
for (i = 0; tablet_stylus_whitelist[i] != nullptr; i++) {
|
||||
if (type && match_token(type, tablet_stylus_whitelist[i])) {
|
||||
return GHOST_kTabletModeStylus;
|
||||
}
|
||||
|
@ -2600,7 +2606,7 @@ static GHOST_TTabletMode tablet_mode_from_name(const char *name, const char *typ
|
|||
if (type && match_token(type, "eraser")) {
|
||||
return GHOST_kTabletModeEraser;
|
||||
}
|
||||
for (i = 0; tablet_stylus_whitelist[i] != NULL; i++) {
|
||||
for (i = 0; tablet_stylus_whitelist[i] != nullptr; i++) {
|
||||
if (name && match_token(name, tablet_stylus_whitelist[i])) {
|
||||
return GHOST_kTabletModeStylus;
|
||||
}
|
||||
|
@ -2629,7 +2635,7 @@ void GHOST_SystemX11::refreshXInputDevices()
|
|||
|
||||
for (int i = 0; i < device_count; ++i) {
|
||||
char *device_type = device_info[i].type ? XGetAtomName(m_display, device_info[i].type) :
|
||||
NULL;
|
||||
nullptr;
|
||||
GHOST_TTabletMode tablet_mode = tablet_mode_from_name(device_info[i].name, device_type);
|
||||
|
||||
// printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
|
||||
|
@ -2646,15 +2652,15 @@ void GHOST_SystemX11::refreshXInputDevices()
|
|||
xtablet.ID = device_info[i].id;
|
||||
xtablet.Device = XOpenDevice(m_display, xtablet.ID);
|
||||
|
||||
if (xtablet.Device != NULL) {
|
||||
if (xtablet.Device != nullptr) {
|
||||
/* Find how many pressure levels tablet has */
|
||||
XAnyClassPtr ici = device_info[i].inputclassinfo;
|
||||
|
||||
if (ici != NULL) {
|
||||
if (ici != nullptr) {
|
||||
for (int j = 0; j < device_info[i].num_classes; ++j) {
|
||||
if (ici->c_class == ValuatorClass) {
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)ici;
|
||||
if (xvi->axes != NULL) {
|
||||
if (xvi->axes != nullptr) {
|
||||
xtablet.PressureLevels = xvi->axes[2].max_value;
|
||||
|
||||
if (xvi->num_axes > 3) {
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#include <cstdlib>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef void *(*unity_get_entry_t)(const char *);
|
||||
typedef void (*unity_set_progress_t)(void *, double);
|
||||
typedef void (*unity_set_progress_visible_t)(void *, int);
|
||||
typedef int (*unity_event_loop_t)(void *, int);
|
||||
using unity_get_entry_t = void *(*)(const char *);
|
||||
using unity_set_progress_t = void (*)(void *, double);
|
||||
using unity_set_progress_visible_t = void (*)(void *, int);
|
||||
using unity_event_loop_t = int (*)(void *, int);
|
||||
|
||||
static unity_get_entry_t unity_get_entry;
|
||||
static unity_set_progress_t unity_set_progress;
|
||||
|
@ -23,13 +23,13 @@ static unity_event_loop_t unity_event_loop;
|
|||
|
||||
static bool libunity_initialized = false;
|
||||
static bool libunity_available = false;
|
||||
static void *libunity_handle = NULL;
|
||||
static void *libunity_handle = nullptr;
|
||||
|
||||
void GHOST_TaskBarX11::free()
|
||||
{
|
||||
if (libunity_handle) {
|
||||
dlclose(libunity_handle);
|
||||
libunity_handle = NULL;
|
||||
libunity_handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ bool GHOST_TaskBarX11::init()
|
|||
libunity_initialized = true;
|
||||
|
||||
const char *libunity_names[] = {
|
||||
"libunity.so.4", "libunity.so.6", "libunity.so.9", "libunity.so", NULL};
|
||||
"libunity.so.4", "libunity.so.6", "libunity.so.9", "libunity.so", nullptr};
|
||||
for (int i = 0; libunity_names[i]; i++) {
|
||||
libunity_handle = dlopen(libunity_names[i], RTLD_LAZY);
|
||||
if (libunity_handle) {
|
||||
|
@ -90,13 +90,13 @@ GHOST_TaskBarX11::GHOST_TaskBarX11(const char *name)
|
|||
handle = unity_get_entry(name);
|
||||
}
|
||||
else {
|
||||
handle = NULL;
|
||||
handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool GHOST_TaskBarX11::is_valid()
|
||||
{
|
||||
return (handle != NULL);
|
||||
return (handle != nullptr);
|
||||
}
|
||||
|
||||
void GHOST_TaskBarX11::set_progress(double progress)
|
||||
|
@ -109,5 +109,5 @@ void GHOST_TaskBarX11::set_progress_enabled(bool enabled)
|
|||
{
|
||||
assert(is_valid());
|
||||
unity_set_progress_visible(handle, enabled ? 1 : 0);
|
||||
unity_event_loop(NULL, 0);
|
||||
unity_event_loop(nullptr, 0);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class GHOST_TimerTask : public GHOST_ITimerTask {
|
|||
GHOST_TimerTask(uint64_t start,
|
||||
uint64_t interval,
|
||||
GHOST_TimerProcPtr timerProc,
|
||||
GHOST_TUserDataPtr userData = NULL)
|
||||
GHOST_TUserDataPtr userData = nullptr)
|
||||
: m_start(start),
|
||||
m_interval(interval),
|
||||
m_next(start),
|
||||
|
|
|
@ -28,7 +28,7 @@ static DBusMessage *get_setting_sync(DBusConnection *const connection,
|
|||
message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID);
|
||||
|
||||
if (!success) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
reply = dbus_connection_send_with_reply_and_block(
|
||||
|
@ -37,7 +37,7 @@ static DBusMessage *get_setting_sync(DBusConnection *const connection,
|
|||
dbus_message_unref(message);
|
||||
|
||||
if (dbus_error_is_set(&error)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reply;
|
||||
|
@ -76,7 +76,7 @@ static bool get_cursor_settings(std::string &theme, int &size)
|
|||
DBusError error;
|
||||
DBusConnection *connection;
|
||||
DBusMessage *reply;
|
||||
const char *value_theme = NULL;
|
||||
const char *value_theme = nullptr;
|
||||
|
||||
dbus_error_init(&error);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "GHOST_ContextNone.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
|
||||
GHOST_Window::GHOST_Window(uint32_t width,
|
||||
uint32_t height,
|
||||
|
@ -51,19 +51,19 @@ GHOST_Window::~GHOST_Window()
|
|||
|
||||
void *GHOST_Window::getOSWindow() const
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
|
||||
{
|
||||
if (type != m_drawingContextType) {
|
||||
delete m_context;
|
||||
m_context = NULL;
|
||||
m_context = nullptr;
|
||||
|
||||
if (type != GHOST_kDrawingContextTypeNone)
|
||||
if (type != GHOST_kDrawingContextTypeNone) {
|
||||
m_context = newDrawingContext(type);
|
||||
|
||||
if (m_context != NULL) {
|
||||
}
|
||||
if (m_context != nullptr) {
|
||||
m_drawingContextType = type;
|
||||
}
|
||||
else {
|
||||
|
@ -73,9 +73,7 @@ GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType typ
|
|||
|
||||
return (type == m_drawingContextType) ? GHOST_kSuccess : GHOST_kFailure;
|
||||
}
|
||||
else {
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::swapBuffers()
|
||||
|
@ -119,9 +117,7 @@ GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
|
|||
m_cursorVisible = visible;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode,
|
||||
|
@ -129,10 +125,10 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode,
|
|||
GHOST_Rect *bounds,
|
||||
int32_t mouse_ungrab_xy[2])
|
||||
{
|
||||
if (m_cursorGrab == mode)
|
||||
if (m_cursorGrab == mode) {
|
||||
return GHOST_kSuccess;
|
||||
|
||||
/* override with new location */
|
||||
}
|
||||
/* Override with new location. */
|
||||
if (mouse_ungrab_xy) {
|
||||
assert(mode == GHOST_kGrabDisable);
|
||||
m_cursorGrabInitPos[0] = mouse_ungrab_xy[0];
|
||||
|
@ -154,9 +150,7 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode,
|
|||
m_cursorGrabAxis = wrap_axis;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::getCursorGrabBounds(GHOST_Rect &bounds)
|
||||
|
@ -171,9 +165,7 @@ GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)
|
|||
m_cursorShape = cursorShape;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::setCustomCursorShape(
|
||||
|
@ -183,9 +175,7 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape(
|
|||
m_cursorShape = GHOST_kStandardCursorCustom;
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
else {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
void GHOST_Window::setAcceptDragOperation(bool canAccept)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
GHOST_WindowManager::GHOST_WindowManager()
|
||||
: m_fullScreenWindow(0), m_activeWindow(0), m_activeWindowBeforeFullScreen(0)
|
||||
: m_fullScreenWindow(nullptr), m_activeWindow(nullptr), m_activeWindowBeforeFullScreen(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,12 @@ bool GHOST_WindowManager::getWindowFound(const GHOST_IWindow *window) const
|
|||
return found;
|
||||
}
|
||||
|
||||
bool GHOST_WindowManager::getFullScreen(void) const
|
||||
bool GHOST_WindowManager::getFullScreen() const
|
||||
{
|
||||
return m_fullScreenWindow != NULL;
|
||||
return m_fullScreenWindow != nullptr;
|
||||
}
|
||||
|
||||
GHOST_IWindow *GHOST_WindowManager::getFullScreenWindow(void) const
|
||||
GHOST_IWindow *GHOST_WindowManager::getFullScreenWindow() const
|
||||
{
|
||||
return m_fullScreenWindow;
|
||||
}
|
||||
|
@ -100,17 +100,17 @@ GHOST_TSuccess GHOST_WindowManager::beginFullScreen(GHOST_IWindow *window, bool
|
|||
return success;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowManager::endFullScreen(void)
|
||||
GHOST_TSuccess GHOST_WindowManager::endFullScreen()
|
||||
{
|
||||
GHOST_TSuccess success = GHOST_kFailure;
|
||||
if (getFullScreen()) {
|
||||
if (m_fullScreenWindow != NULL) {
|
||||
if (m_fullScreenWindow != nullptr) {
|
||||
// GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
|
||||
setWindowInactive(m_fullScreenWindow);
|
||||
m_fullScreenWindow->endFullScreen();
|
||||
delete m_fullScreenWindow;
|
||||
// GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
|
||||
m_fullScreenWindow = NULL;
|
||||
m_fullScreenWindow = nullptr;
|
||||
if (m_activeWindowBeforeFullScreen) {
|
||||
setActiveWindow(m_activeWindowBeforeFullScreen);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ GHOST_TSuccess GHOST_WindowManager::setActiveWindow(GHOST_IWindow *window)
|
|||
return success;
|
||||
}
|
||||
|
||||
GHOST_IWindow *GHOST_WindowManager::getActiveWindow(void) const
|
||||
GHOST_IWindow *GHOST_WindowManager::getActiveWindow() const
|
||||
{
|
||||
return m_activeWindow;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ GHOST_IWindow *GHOST_WindowManager::getActiveWindow(void) const
|
|||
void GHOST_WindowManager::setWindowInactive(const GHOST_IWindow *window)
|
||||
{
|
||||
if (window == m_activeWindow) {
|
||||
m_activeWindow = NULL;
|
||||
m_activeWindow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,11 +156,11 @@ GHOST_IWindow *GHOST_WindowManager::getWindowAssociatedWithOSWindow(void *osWind
|
|||
std::vector<GHOST_IWindow *>::iterator iter;
|
||||
|
||||
for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
|
||||
if ((*iter)->getOSWindow() == osWindow)
|
||||
if ((*iter)->getOSWindow() == osWindow) {
|
||||
return *iter;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GHOST_WindowManager::getAnyModifiedState()
|
||||
|
@ -169,8 +169,9 @@ bool GHOST_WindowManager::getAnyModifiedState()
|
|||
std::vector<GHOST_IWindow *>::iterator iter;
|
||||
|
||||
for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
|
||||
if ((*iter)->getModifiedState())
|
||||
if ((*iter)->getModifiedState()) {
|
||||
isAnyModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isAnyModified;
|
||||
|
|
|
@ -153,6 +153,6 @@ class GHOST_WindowNULL : public GHOST_Window {
|
|||
*/
|
||||
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "GHOST_ContextSDL.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
|
||||
GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
|
||||
const char *title,
|
||||
|
@ -27,7 +27,7 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
|
|||
m_system(system),
|
||||
m_valid_setup(false),
|
||||
m_invalid_window(false),
|
||||
m_sdl_custom_cursor(NULL)
|
||||
m_sdl_custom_cursor(nullptr)
|
||||
{
|
||||
|
||||
/* creating the window _must_ come after setting attributes */
|
||||
|
@ -73,16 +73,16 @@ GHOST_Context *GHOST_WindowSDL::newDrawingContext(GHOST_TDrawingContextType type
|
|||
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowSDL::invalidate(void)
|
||||
GHOST_TSuccess GHOST_WindowSDL::invalidate()
|
||||
{
|
||||
if (m_invalid_window == false) {
|
||||
m_system->addDirtyWindow(this);
|
||||
|
@ -120,12 +120,15 @@ GHOST_TWindowState GHOST_WindowSDL::getState() const
|
|||
{
|
||||
Uint32 flags = SDL_GetWindowFlags(m_sdl_win);
|
||||
|
||||
if (flags & SDL_WINDOW_FULLSCREEN)
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
return GHOST_kWindowStateFullScreen;
|
||||
else if (flags & SDL_WINDOW_MAXIMIZED)
|
||||
}
|
||||
if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
return GHOST_kWindowStateMaximized;
|
||||
else if (flags & SDL_WINDOW_MINIMIZED)
|
||||
}
|
||||
if (flags & SDL_WINDOW_MINIMIZED) {
|
||||
return GHOST_kWindowStateMinimized;
|
||||
}
|
||||
return GHOST_kWindowStateNormal;
|
||||
}
|
||||
|
||||
|
@ -164,7 +167,7 @@ void GHOST_WindowSDL::getClientBounds(GHOST_Rect &bounds) const
|
|||
GHOST_TSuccess GHOST_WindowSDL::setClientWidth(uint32_t width)
|
||||
{
|
||||
int height;
|
||||
SDL_GetWindowSize(m_sdl_win, NULL, &height);
|
||||
SDL_GetWindowSize(m_sdl_win, nullptr, &height);
|
||||
SDL_SetWindowSize(m_sdl_win, width, height);
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
@ -172,7 +175,7 @@ GHOST_TSuccess GHOST_WindowSDL::setClientWidth(uint32_t width)
|
|||
GHOST_TSuccess GHOST_WindowSDL::setClientHeight(uint32_t height)
|
||||
{
|
||||
int width;
|
||||
SDL_GetWindowSize(m_sdl_win, &width, NULL);
|
||||
SDL_GetWindowSize(m_sdl_win, &width, nullptr);
|
||||
SDL_SetWindowSize(m_sdl_win, width, height);
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
@ -483,7 +486,7 @@ static unsigned char sdl_std_cursor_arrow[] = {
|
|||
#define sdl_std_cursor_HOT_Y_arrow -14
|
||||
/* end cursor data */
|
||||
|
||||
static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors] = {0};
|
||||
static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors] = {nullptr};
|
||||
|
||||
/* utility function mostly a copy of SDL_CreateCursor but allows us to change
|
||||
* color and supports blenders flipped bits */
|
||||
|
@ -505,7 +508,7 @@ static SDL_Cursor *sdl_ghost_CreateCursor(
|
|||
/* Create the surface from a bitmap */
|
||||
surface = SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
for (y = 0; y < h; ++y) {
|
||||
pixel = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch);
|
||||
|
@ -539,7 +542,7 @@ static SDL_Cursor *sdl_ghost_CreateCursor(
|
|||
/* TODO: this is currently never freed but it won't leak either. */
|
||||
static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
|
||||
{
|
||||
if (sdl_std_cursor_array[0] == NULL) {
|
||||
if (sdl_std_cursor_array[0] == nullptr) {
|
||||
#define DEF_CURSOR(name, ind) \
|
||||
{ \
|
||||
sdl_std_cursor_array[(int)ind] = sdl_ghost_CreateCursor( \
|
||||
|
@ -549,7 +552,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
|
|||
sdl_std_cursor_HEIGHT_##name, \
|
||||
(sdl_std_cursor_WIDTH_##name + (sdl_std_cursor_HOT_X_##name)) - 1, \
|
||||
(sdl_std_cursor_HEIGHT_##name + (sdl_std_cursor_HOT_Y_##name)) - 1); \
|
||||
assert(sdl_std_cursor_array[(int)ind] != NULL); \
|
||||
assert(sdl_std_cursor_array[(int)ind] != nullptr); \
|
||||
} \
|
||||
(void)0
|
||||
|
||||
|
@ -589,7 +592,7 @@ GHOST_TSuccess GHOST_WindowSDL::setWindowCursorGrab(GHOST_TGrabCursorMode /*mode
|
|||
GHOST_TSuccess GHOST_WindowSDL::setWindowCursorShape(GHOST_TStandardCursor shape)
|
||||
{
|
||||
SDL_Cursor *cursor = getStandardCursorShape(shape);
|
||||
if (cursor == NULL) {
|
||||
if (cursor == nullptr) {
|
||||
cursor = getStandardCursorShape(GHOST_kStandardCursorDefault);
|
||||
}
|
||||
|
||||
|
@ -635,7 +638,7 @@ uint16_t GHOST_WindowSDL::getDPIHint()
|
|||
}
|
||||
|
||||
float ddpi;
|
||||
if (SDL_GetDisplayDPI(displayIndex, &ddpi, NULL, NULL) != 0) {
|
||||
if (SDL_GetDisplayDPI(displayIndex, &ddpi, nullptr, nullptr) != 0) {
|
||||
return 96;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,8 +134,9 @@ static bool update_scale(GHOST_WindowWayland *window)
|
|||
{
|
||||
int scale = 0;
|
||||
for (const output_t *output : window->outputs_active()) {
|
||||
if (output->scale > scale)
|
||||
if (output->scale > scale) {
|
||||
scale = output->scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (scale > 0 && window->scale() != scale) {
|
||||
|
@ -453,12 +454,10 @@ GHOST_TWindowState GHOST_WindowWayland::getState() const
|
|||
if (w->is_fullscreen) {
|
||||
return GHOST_kWindowStateFullScreen;
|
||||
}
|
||||
else if (w->is_maximised) {
|
||||
if (w->is_maximised) {
|
||||
return GHOST_kWindowStateMaximized;
|
||||
}
|
||||
else {
|
||||
return GHOST_kWindowStateNormal;
|
||||
}
|
||||
return GHOST_kWindowStateNormal;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowWayland::invalidate()
|
||||
|
@ -525,10 +524,10 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
|
|||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
context = new GHOST_ContextEGL(this->m_system,
|
||||
m_wantStereoVisual,
|
||||
|
|
|
@ -44,19 +44,19 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
/* For obscure full screen mode stuff
|
||||
* lifted verbatim from blut. */
|
||||
|
||||
typedef struct {
|
||||
using MotifWmHints = struct {
|
||||
long flags;
|
||||
long functions;
|
||||
long decorations;
|
||||
long input_mode;
|
||||
} MotifWmHints;
|
||||
};
|
||||
|
||||
enum {
|
||||
MWM_HINTS_FUNCTIONS = (1L << 0),
|
||||
|
@ -107,7 +107,7 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
|||
int glx_major, glx_minor, glx_version; /* GLX version: major.minor */
|
||||
int glx_attribs[64];
|
||||
|
||||
*fbconfig = NULL;
|
||||
*fbconfig = nullptr;
|
||||
|
||||
/* Set up the minimum attributes that we require and see if
|
||||
* X can find us a visual matching those requirements. */
|
||||
|
@ -119,7 +119,7 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
|||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
glx_version = glx_major * 100 + glx_minor;
|
||||
# ifndef WITH_X11_ALPHA
|
||||
|
@ -129,10 +129,10 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
|||
# ifdef WITH_X11_ALPHA
|
||||
if (needAlpha && glx_version >= 103 &&
|
||||
(glXChooseFBConfig || (glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB(
|
||||
(const GLubyte *)"glXChooseFBConfig")) != NULL) &&
|
||||
(const GLubyte *)"glXChooseFBConfig")) != nullptr) &&
|
||||
(glXGetVisualFromFBConfig ||
|
||||
(glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddressARB(
|
||||
(const GLubyte *)"glXGetVisualFromFBConfig")) != NULL)) {
|
||||
(const GLubyte *)"glXGetVisualFromFBConfig")) != nullptr)) {
|
||||
|
||||
GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, true);
|
||||
|
||||
|
@ -177,7 +177,7 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
|||
|
||||
/* Any sample level or even zero, which means oversampling disabled, is good
|
||||
* but we need a valid visual to continue */
|
||||
if (visual != NULL) {
|
||||
if (visual != nullptr) {
|
||||
return visual;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
|||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // WITH_GL_EGL
|
||||
|
@ -211,8 +211,8 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
|
|||
const bool is_debug)
|
||||
: GHOST_Window(width, height, state, stereoVisual, exclusive),
|
||||
m_display(display),
|
||||
m_visualInfo(NULL),
|
||||
m_fbconfig(NULL),
|
||||
m_visualInfo(nullptr),
|
||||
m_fbconfig(nullptr),
|
||||
m_normal_state(GHOST_kWindowStateNormal),
|
||||
m_system(system),
|
||||
m_invalid_window(false),
|
||||
|
@ -221,11 +221,11 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
|
|||
m_visible_cursor(None),
|
||||
m_taskbar("blender.desktop"),
|
||||
#ifdef WITH_XDND
|
||||
m_dropTarget(NULL),
|
||||
m_dropTarget(nullptr),
|
||||
#endif
|
||||
m_tabletData(GHOST_TABLET_DATA_NONE),
|
||||
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
|
||||
m_xic(NULL),
|
||||
m_xic(nullptr),
|
||||
#endif
|
||||
m_valid_setup(false),
|
||||
m_is_debug_context(is_debug)
|
||||
|
@ -240,13 +240,13 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
|
|||
#endif
|
||||
}
|
||||
else {
|
||||
XVisualInfo tmp = {0};
|
||||
XVisualInfo tmp = {nullptr};
|
||||
int n;
|
||||
m_visualInfo = XGetVisualInfo(m_display, 0, &tmp, &n);
|
||||
}
|
||||
|
||||
/* caller needs to check 'getValid()' */
|
||||
if (m_visualInfo == NULL) {
|
||||
if (m_visualInfo == nullptr) {
|
||||
fprintf(stderr, "initial window could not find the GLX extension\n");
|
||||
return;
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ static Bool destroyICCallback(XIC /*xic*/, XPointer ptr, XPointer /*data*/)
|
|||
GHOST_PRINT("XIM input context destroyed\n");
|
||||
|
||||
if (ptr) {
|
||||
*(XIC *)ptr = NULL;
|
||||
*(XIC *)ptr = nullptr;
|
||||
}
|
||||
/* Ignored by X11. */
|
||||
return True;
|
||||
|
@ -505,12 +505,12 @@ bool GHOST_WindowX11::createX11_XIC()
|
|||
GHOST_X11_RES_CLASS,
|
||||
XNDestroyCallback,
|
||||
&destroy,
|
||||
NULL);
|
||||
nullptr);
|
||||
if (!m_xic)
|
||||
return false;
|
||||
|
||||
unsigned long fevent;
|
||||
XGetICValues(m_xic, XNFilterEvents, &fevent, NULL);
|
||||
XGetICValues(m_xic, XNFilterEvents, &fevent, nullptr);
|
||||
XSelectInput(m_display,
|
||||
m_window,
|
||||
ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
||||
|
@ -586,7 +586,7 @@ void GHOST_WindowX11::setTitle(const char *title)
|
|||
|
||||
std::string GHOST_WindowX11::getTitle() const
|
||||
{
|
||||
char *name = NULL;
|
||||
char *name = nullptr;
|
||||
|
||||
XFetchName(m_display, m_window, &name);
|
||||
std::string title = name ? name : "untitled";
|
||||
|
@ -719,8 +719,9 @@ void GHOST_WindowX11::icccmSetState(int state)
|
|||
{
|
||||
XEvent xev;
|
||||
|
||||
if (state != IconicState)
|
||||
if (state != IconicState) {
|
||||
return;
|
||||
}
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
|
@ -737,7 +738,7 @@ void GHOST_WindowX11::icccmSetState(int state)
|
|||
&xev);
|
||||
}
|
||||
|
||||
int GHOST_WindowX11::icccmGetState(void) const
|
||||
int GHOST_WindowX11::icccmGetState() const
|
||||
{
|
||||
struct {
|
||||
CARD32 state;
|
||||
|
@ -748,7 +749,7 @@ int GHOST_WindowX11::icccmGetState(void) const
|
|||
int ret, format_ret;
|
||||
CARD32 st;
|
||||
|
||||
prop_ret = NULL;
|
||||
prop_ret = nullptr;
|
||||
ret = XGetWindowProperty(m_display,
|
||||
m_window,
|
||||
m_system->m_atom.WM_STATE,
|
||||
|
@ -761,7 +762,7 @@ int GHOST_WindowX11::icccmGetState(void) const
|
|||
&num_ret,
|
||||
&bytes_after,
|
||||
((unsigned char **)&prop_ret));
|
||||
if ((ret == Success) && (prop_ret != NULL) && (num_ret == 2)) {
|
||||
if ((ret == Success) && (prop_ret != nullptr) && (num_ret == 2)) {
|
||||
st = prop_ret->state;
|
||||
}
|
||||
else {
|
||||
|
@ -786,10 +787,12 @@ void GHOST_WindowX11::netwmMaximized(bool set)
|
|||
xev.xclient.message_type = m_system->m_atom._NET_WM_STATE;
|
||||
xev.xclient.format = 32;
|
||||
|
||||
if (set == True)
|
||||
if (set == True) {
|
||||
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
|
||||
else
|
||||
}
|
||||
else {
|
||||
xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
|
||||
}
|
||||
|
||||
xev.xclient.data.l[1] = m_system->m_atom._NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
xev.xclient.data.l[2] = m_system->m_atom._NET_WM_STATE_MAXIMIZED_VERT;
|
||||
|
@ -802,7 +805,7 @@ void GHOST_WindowX11::netwmMaximized(bool set)
|
|||
&xev);
|
||||
}
|
||||
|
||||
bool GHOST_WindowX11::netwmIsMaximized(void) const
|
||||
bool GHOST_WindowX11::netwmIsMaximized() const
|
||||
{
|
||||
Atom *prop_ret;
|
||||
unsigned long bytes_after, num_ret, i;
|
||||
|
@ -810,7 +813,7 @@ bool GHOST_WindowX11::netwmIsMaximized(void) const
|
|||
bool st;
|
||||
int format_ret, ret, count;
|
||||
|
||||
prop_ret = NULL;
|
||||
prop_ret = nullptr;
|
||||
st = False;
|
||||
ret = XGetWindowProperty(m_display,
|
||||
m_window,
|
||||
|
@ -840,8 +843,9 @@ bool GHOST_WindowX11::netwmIsMaximized(void) const
|
|||
}
|
||||
}
|
||||
|
||||
if (prop_ret)
|
||||
if (prop_ret) {
|
||||
XFree(prop_ret);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
@ -856,10 +860,12 @@ void GHOST_WindowX11::netwmFullScreen(bool set)
|
|||
xev.xclient.message_type = m_system->m_atom._NET_WM_STATE;
|
||||
xev.xclient.format = 32;
|
||||
|
||||
if (set == True)
|
||||
if (set == True) {
|
||||
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
|
||||
else
|
||||
}
|
||||
else {
|
||||
xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
|
||||
}
|
||||
|
||||
xev.xclient.data.l[1] = m_system->m_atom._NET_WM_STATE_FULLSCREEN;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
@ -872,7 +878,7 @@ void GHOST_WindowX11::netwmFullScreen(bool set)
|
|||
&xev);
|
||||
}
|
||||
|
||||
bool GHOST_WindowX11::netwmIsFullScreen(void) const
|
||||
bool GHOST_WindowX11::netwmIsFullScreen() const
|
||||
{
|
||||
Atom *prop_ret;
|
||||
unsigned long bytes_after, num_ret, i;
|
||||
|
@ -880,7 +886,7 @@ bool GHOST_WindowX11::netwmIsFullScreen(void) const
|
|||
bool st;
|
||||
int format_ret, ret;
|
||||
|
||||
prop_ret = NULL;
|
||||
prop_ret = nullptr;
|
||||
st = False;
|
||||
ret = XGetWindowProperty(m_display,
|
||||
m_window,
|
||||
|
@ -903,8 +909,9 @@ bool GHOST_WindowX11::netwmIsFullScreen(void) const
|
|||
}
|
||||
}
|
||||
|
||||
if (prop_ret)
|
||||
if (prop_ret) {
|
||||
XFree(prop_ret);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
@ -913,10 +920,12 @@ void GHOST_WindowX11::motifFullScreen(bool set)
|
|||
MotifWmHints hints;
|
||||
|
||||
hints.flags = MWM_HINTS_DECORATIONS;
|
||||
if (set == True)
|
||||
if (set == True) {
|
||||
hints.decorations = 0;
|
||||
else
|
||||
}
|
||||
else {
|
||||
hints.decorations = 1;
|
||||
}
|
||||
|
||||
XChangeProperty(m_display,
|
||||
m_window,
|
||||
|
@ -928,7 +937,7 @@ void GHOST_WindowX11::motifFullScreen(bool set)
|
|||
4);
|
||||
}
|
||||
|
||||
bool GHOST_WindowX11::motifIsFullScreen(void) const
|
||||
bool GHOST_WindowX11::motifIsFullScreen() const
|
||||
{
|
||||
MotifWmHints *prop_ret;
|
||||
unsigned long bytes_after, num_ret;
|
||||
|
@ -936,7 +945,7 @@ bool GHOST_WindowX11::motifIsFullScreen(void) const
|
|||
bool state;
|
||||
int format_ret, st;
|
||||
|
||||
prop_ret = NULL;
|
||||
prop_ret = nullptr;
|
||||
state = False;
|
||||
st = XGetWindowProperty(m_display,
|
||||
m_window,
|
||||
|
@ -952,13 +961,15 @@ bool GHOST_WindowX11::motifIsFullScreen(void) const
|
|||
(unsigned char **)&prop_ret);
|
||||
if ((st == Success) && prop_ret) {
|
||||
if (prop_ret->flags & MWM_HINTS_DECORATIONS) {
|
||||
if (!prop_ret->decorations)
|
||||
if (!prop_ret->decorations) {
|
||||
state = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prop_ret)
|
||||
if (prop_ret) {
|
||||
XFree(prop_ret);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -973,14 +984,18 @@ GHOST_TWindowState GHOST_WindowX11::getState() const
|
|||
* In the Iconic and Withdrawn state, the window
|
||||
* is unmapped, so only need return a Minimized state.
|
||||
*/
|
||||
if ((state == IconicState) || (state == WithdrawnState))
|
||||
if ((state == IconicState) || (state == WithdrawnState)) {
|
||||
state_ret = GHOST_kWindowStateMinimized;
|
||||
else if (netwmIsFullScreen() == True)
|
||||
}
|
||||
else if (netwmIsFullScreen() == True) {
|
||||
state_ret = GHOST_kWindowStateFullScreen;
|
||||
else if (motifIsFullScreen() == True)
|
||||
}
|
||||
else if (motifIsFullScreen() == True) {
|
||||
state_ret = GHOST_kWindowStateFullScreen;
|
||||
else if (netwmIsMaximized() == True)
|
||||
}
|
||||
else if (netwmIsMaximized() == True) {
|
||||
state_ret = GHOST_kWindowStateMaximized;
|
||||
}
|
||||
return state_ret;
|
||||
}
|
||||
|
||||
|
@ -990,8 +1005,9 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
|
|||
bool is_max, is_full, is_motif_full;
|
||||
|
||||
cur_state = getState();
|
||||
if (state == (int)cur_state)
|
||||
if (state == (int)cur_state) {
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
if (cur_state != GHOST_kWindowStateMinimized) {
|
||||
/*
|
||||
|
@ -1008,16 +1024,20 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
|
|||
|
||||
is_motif_full = motifIsFullScreen();
|
||||
|
||||
if (state == GHOST_kWindowStateNormal)
|
||||
if (state == GHOST_kWindowStateNormal) {
|
||||
state = m_normal_state;
|
||||
}
|
||||
|
||||
if (state == GHOST_kWindowStateNormal) {
|
||||
if (is_max == True)
|
||||
if (is_max == True) {
|
||||
netwmMaximized(False);
|
||||
if (is_full == True)
|
||||
}
|
||||
if (is_full == True) {
|
||||
netwmFullScreen(False);
|
||||
if (is_motif_full == True)
|
||||
}
|
||||
if (is_motif_full == True) {
|
||||
motifFullScreen(False);
|
||||
}
|
||||
icccmSetState(NormalState);
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
@ -1027,17 +1047,21 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
|
|||
* We can't change to full screen if the window
|
||||
* isn't mapped.
|
||||
*/
|
||||
if (cur_state == GHOST_kWindowStateMinimized)
|
||||
if (cur_state == GHOST_kWindowStateMinimized) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
m_normal_state = cur_state;
|
||||
|
||||
if (is_max == True)
|
||||
if (is_max == True) {
|
||||
netwmMaximized(False);
|
||||
if (is_full == False)
|
||||
}
|
||||
if (is_full == False) {
|
||||
netwmFullScreen(True);
|
||||
if (is_motif_full == False)
|
||||
}
|
||||
if (is_motif_full == False) {
|
||||
motifFullScreen(True);
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
|
@ -1046,15 +1070,19 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
|
|||
* We can't change to Maximized if the window
|
||||
* isn't mapped.
|
||||
*/
|
||||
if (cur_state == GHOST_kWindowStateMinimized)
|
||||
if (cur_state == GHOST_kWindowStateMinimized) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
if (is_full == True)
|
||||
if (is_full == True) {
|
||||
netwmFullScreen(False);
|
||||
if (is_motif_full == True)
|
||||
}
|
||||
if (is_motif_full == True) {
|
||||
motifFullScreen(False);
|
||||
if (is_max == False)
|
||||
}
|
||||
if (is_max == False) {
|
||||
netwmMaximized(True);
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
|
@ -1111,8 +1139,9 @@ GHOST_TSuccess GHOST_WindowX11::setOrder(GHOST_TWindowOrder order)
|
|||
XGetWindowAttributes(m_display, m_window, &attr);
|
||||
|
||||
/* Minimized windows give bad match error. */
|
||||
if (attr.map_state == IsViewable)
|
||||
if (attr.map_state == IsViewable) {
|
||||
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
XFlush(m_display);
|
||||
}
|
||||
else if (order == GHOST_kWindowOrderBottom) {
|
||||
|
@ -1137,7 +1166,7 @@ bool GHOST_WindowX11::isDialog() const
|
|||
bool st;
|
||||
int format_ret, ret;
|
||||
|
||||
prop_ret = NULL;
|
||||
prop_ret = nullptr;
|
||||
st = False;
|
||||
ret = XGetWindowProperty(m_display,
|
||||
m_window,
|
||||
|
@ -1272,7 +1301,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
|||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
{
|
||||
const char *version_major = (char *)glewGetString(GLEW_VERSION_MAJOR);
|
||||
if (version_major != NULL && version_major[0] == '1') {
|
||||
if (version_major != nullptr && version_major[0] == '1') {
|
||||
fprintf(stderr, "Error: GLEW version 2.0 and above is required.\n");
|
||||
abort();
|
||||
}
|
||||
|
@ -1327,10 +1356,10 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
|||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
|
||||
#ifdef WITH_GL_EGL
|
||||
|
@ -1358,10 +1387,10 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
|||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
delete context;
|
||||
|
||||
/* Ugly, but we get crashes unless a whole bunch of systems are patched. */
|
||||
fprintf(stderr, "Error! Unsupported graphics card or driver.\n");
|
||||
|
@ -1372,7 +1401,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
|||
exit(1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowX11::getStandardCursor(GHOST_TStandardCursor g_cursor, Cursor &xcursor)
|
||||
|
@ -1488,8 +1517,9 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
|
|||
m_system->getCursorPosition(m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
|
||||
setCursorGrabAccum(0, 0);
|
||||
|
||||
if (mode == GHOST_kGrabHide)
|
||||
if (mode == GHOST_kGrabHide) {
|
||||
setWindowCursorVisibility(false);
|
||||
}
|
||||
}
|
||||
#ifdef GHOST_X11_GRAB
|
||||
XGrabPointer(m_display,
|
||||
|
@ -1580,10 +1610,12 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCustomCursorShape(uint8_t *bitmap,
|
|||
Pixmap bitmap_pix, mask_pix;
|
||||
XColor fg, bg;
|
||||
|
||||
if (XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0)
|
||||
if (XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0) {
|
||||
return GHOST_kFailure;
|
||||
if (XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0)
|
||||
}
|
||||
if (XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
if (m_custom_cursor) {
|
||||
XFreeCursor(m_display, m_custom_cursor);
|
||||
|
@ -1631,8 +1663,9 @@ GHOST_TSuccess GHOST_WindowX11::beginFullScreen() const
|
|||
int err;
|
||||
|
||||
err = XGrabKeyboard(m_display, m_window, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
if (err != GrabSuccess)
|
||||
if (err != GrabSuccess) {
|
||||
printf("XGrabKeyboard failed %d\n", err);
|
||||
}
|
||||
|
||||
err = XGrabPointer(m_display,
|
||||
m_window,
|
||||
|
@ -1643,8 +1676,9 @@ GHOST_TSuccess GHOST_WindowX11::beginFullScreen() const
|
|||
m_window,
|
||||
None,
|
||||
CurrentTime);
|
||||
if (err != GrabSuccess)
|
||||
if (err != GrabSuccess) {
|
||||
printf("XGrabPointer failed %d\n", err);
|
||||
}
|
||||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
@ -1664,7 +1698,7 @@ uint16_t GHOST_WindowX11::getDPIHint()
|
|||
if (resMan) {
|
||||
XrmDatabase xrdb = XrmGetStringDatabase(resMan);
|
||||
if (xrdb) {
|
||||
char *type = NULL;
|
||||
char *type = nullptr;
|
||||
XrmValue val;
|
||||
|
||||
int success = XrmGetResource(xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
|
||||
|
|
Loading…
Reference in New Issue