Revert "Cleanup: Cleanup: style, use braces for GHOST (X11/SDL)"
This reverts commit 935c9ab0de.
Clang-tidy was making unrelated *fixes*.
This commit is contained in:
@@ -181,12 +181,10 @@ GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
|
||||
GHOST_IWindow *window = NULL;
|
||||
bool bstereoVisual;
|
||||
|
||||
if (stereoVisual) {
|
||||
if (stereoVisual)
|
||||
bstereoVisual = true;
|
||||
}
|
||||
else {
|
||||
else
|
||||
bstereoVisual = false;
|
||||
}
|
||||
|
||||
system->beginFullScreen(*setting, &window, bstereoVisual);
|
||||
|
||||
@@ -697,9 +695,8 @@ 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;
|
||||
}
|
||||
@@ -708,9 +705,8 @@ 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;
|
||||
}
|
||||
@@ -739,9 +735,8 @@ GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
|
||||
{
|
||||
GHOST_TSuccess result = GHOST_kFailure;
|
||||
|
||||
if (((GHOST_Rect *)rectanglehandle)->isInside(x, y)) {
|
||||
if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
|
||||
result = GHOST_kSuccess;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -777,9 +772,8 @@ 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;
|
||||
}
|
||||
@@ -817,9 +811,8 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,9 +129,8 @@ bool win32_chk(bool result, const char *file, int line, const char *text)
|
||||
|
||||
SetLastError(NO_ERROR);
|
||||
|
||||
if (count != 0) {
|
||||
if (count != 0)
|
||||
LocalFree(formattedMsg);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -236,26 +236,23 @@ 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));
|
||||
}
|
||||
|
||||
EGL_CHK(::eglTerminate(m_display));
|
||||
}
|
||||
@@ -320,9 +317,8 @@ GHOST_TSuccess GHOST_ContextEGL::releaseDrawingContext()
|
||||
|
||||
void GHOST_ContextEGL::initContextEGLEW()
|
||||
{
|
||||
if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK) {
|
||||
if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK)
|
||||
fprintf(stderr, "Warning! EGLEW failed to initialize properly.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static const std::string &api_string(EGLenum api)
|
||||
@@ -340,9 +336,8 @@ 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.
|
||||
|
||||
@@ -367,27 +362,23 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
||||
|
||||
m_display = ::eglGetDisplay(m_nativeDisplay);
|
||||
|
||||
if (!EGL_CHK(m_display != EGL_NO_DISPLAY)) {
|
||||
if (!EGL_CHK(m_display != EGL_NO_DISPLAY))
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
fprintf(stderr, "EGL Version %d.%d\n", egl_major, egl_minor);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
initContextEGLEW();
|
||||
|
||||
if (!bindAPI(m_api)) {
|
||||
if (!bindAPI(m_api))
|
||||
goto error;
|
||||
}
|
||||
|
||||
// build attribute list
|
||||
|
||||
@@ -447,20 +438,17 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
||||
|
||||
EGLConfig config;
|
||||
|
||||
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config))) {
|
||||
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &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;
|
||||
}
|
||||
|
||||
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
|
||||
|
||||
if (!EGL_CHK(m_surface != EGL_NO_SURFACE)) {
|
||||
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
|
||||
goto error;
|
||||
}
|
||||
|
||||
attrib_list.clear();
|
||||
|
||||
@@ -500,10 +488,9 @@ 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) {
|
||||
@@ -560,19 +547,16 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
|
||||
|
||||
m_context = ::eglCreateContext(m_display, 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();
|
||||
|
||||
@@ -582,9 +566,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -70,18 +70,16 @@ GHOST_ContextGLX::~GHOST_ContextGLX()
|
||||
{
|
||||
if (m_display != NULL) {
|
||||
if (m_context != None) {
|
||||
if (m_window != 0 && m_context == ::glXGetCurrentContext()) {
|
||||
if (m_window != 0 && m_context == ::glXGetCurrentContext())
|
||||
::glXMakeCurrent(m_display, None, NULL);
|
||||
}
|
||||
|
||||
if (m_context != s_sharedContext || s_sharedCount == 1) {
|
||||
assert(s_sharedCount > 0);
|
||||
|
||||
s_sharedCount--;
|
||||
|
||||
if (s_sharedCount == 0) {
|
||||
if (s_sharedCount == 0)
|
||||
s_sharedContext = NULL;
|
||||
}
|
||||
|
||||
::glXDestroyContext(m_display, m_context);
|
||||
}
|
||||
@@ -179,43 +177,35 @@ 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) {
|
||||
if (!GLXEW_EXT_create_context_es_profile && profileBitES && m_contextMajorVersion == 1)
|
||||
fprintf(stderr, "Warning! OpenGL ES profile not available.\n");
|
||||
}
|
||||
|
||||
if (!GLXEW_EXT_create_context_es2_profile && profileBitES && m_contextMajorVersion == 2) {
|
||||
if (!GLXEW_EXT_create_context_es2_profile && profileBitES && m_contextMajorVersion == 2)
|
||||
fprintf(stderr, "Warning! OpenGL ES2 profile not available.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
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) {
|
||||
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];
|
||||
@@ -297,9 +287,8 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
||||
if (m_context != NULL) {
|
||||
const unsigned char *version;
|
||||
|
||||
if (!s_sharedContext) {
|
||||
if (!s_sharedContext)
|
||||
s_sharedContext = m_context;
|
||||
}
|
||||
|
||||
s_sharedCount++;
|
||||
|
||||
@@ -432,36 +421,30 @@ int GHOST_X11_GL_GetAttributes(
|
||||
static GLuint _glewStrLen(const GLubyte *s)
|
||||
{
|
||||
GLuint i = 0;
|
||||
if (s == NULL) {
|
||||
if (s == NULL)
|
||||
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 == NULL)
|
||||
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) {
|
||||
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]) {
|
||||
while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i])
|
||||
i++;
|
||||
}
|
||||
return i == n ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -472,9 +455,8 @@ 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;
|
||||
|
||||
@@ -57,25 +57,22 @@ GHOST_ContextSDL::GHOST_ContextSDL(bool stereoVisual,
|
||||
GHOST_ContextSDL::~GHOST_ContextSDL()
|
||||
{
|
||||
if (m_context != NULL) {
|
||||
if (m_window != NULL && m_context == SDL_GL_GetCurrentContext()) {
|
||||
if (m_window != NULL && m_context == SDL_GL_GetCurrentContext())
|
||||
SDL_GL_MakeCurrent(m_window, NULL);
|
||||
}
|
||||
|
||||
if (m_context != s_sharedContext || s_sharedCount == 1) {
|
||||
assert(s_sharedCount > 0);
|
||||
|
||||
s_sharedCount--;
|
||||
|
||||
if (s_sharedCount == 0) {
|
||||
if (s_sharedCount == 0)
|
||||
s_sharedContext = NULL;
|
||||
}
|
||||
|
||||
SDL_GL_DeleteContext(m_context);
|
||||
}
|
||||
|
||||
if (m_hidden_window != NULL) {
|
||||
if (m_hidden_window != NULL)
|
||||
SDL_DestroyWindow(m_hidden_window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,9 +148,8 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
|
||||
GHOST_TSuccess success;
|
||||
|
||||
if (m_context != NULL) {
|
||||
if (!s_sharedContext) {
|
||||
if (!s_sharedContext)
|
||||
s_sharedContext = m_context;
|
||||
}
|
||||
|
||||
s_sharedCount++;
|
||||
|
||||
|
||||
@@ -137,9 +137,8 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
|
||||
}
|
||||
}
|
||||
|
||||
if (best_fit == -1) {
|
||||
if (best_fit == -1)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
SDL_GetDisplayMode(display, best_fit, &mode);
|
||||
}
|
||||
|
||||
@@ -56,9 +56,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::getNumDisplaySettings(GHOST_TUns8 displa
|
||||
|
||||
GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
|
||||
|
||||
if (dpy == NULL) {
|
||||
if (dpy == NULL)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
majorVersion = minorVersion = 0;
|
||||
if (!XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion)) {
|
||||
@@ -95,9 +94,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::getDisplaySetting(GHOST_TUns8 display,
|
||||
{
|
||||
Display *dpy = m_system->getXDisplay();
|
||||
|
||||
if (dpy == NULL) {
|
||||
if (dpy == NULL)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
(void)display;
|
||||
|
||||
@@ -162,9 +160,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting(
|
||||
Display *dpy = m_system->getXDisplay();
|
||||
int scrnum, num_vidmodes;
|
||||
|
||||
if (dpy == NULL) {
|
||||
if (dpy == NULL)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
scrnum = DefaultScreen(dpy);
|
||||
|
||||
|
||||
@@ -160,14 +160,12 @@ void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char
|
||||
/* Ensure both characters are hexadecimal */
|
||||
|
||||
for (j = 0; j < 2; ++j) {
|
||||
if (!isxdigit(tempNumBuf[j])) {
|
||||
if (!isxdigit(tempNumBuf[j]))
|
||||
bothDigits = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bothDigits) {
|
||||
if (!bothDigits)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert two hexadecimal characters into one character */
|
||||
sscanf(tempNumBuf, "%x", &asciiCharacter);
|
||||
@@ -213,9 +211,8 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
|
||||
curLength = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
curLength++;
|
||||
}
|
||||
}
|
||||
|
||||
strArray = (GHOST_TStringArray *)malloc(sizeof(GHOST_TStringArray));
|
||||
@@ -242,9 +239,8 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
|
||||
curLength = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
curLength++;
|
||||
}
|
||||
}
|
||||
|
||||
return strArray;
|
||||
@@ -284,9 +280,8 @@ void *GHOST_DropTargetX11::getGhostData(Atom dropType,
|
||||
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
|
||||
}
|
||||
|
||||
if (needsFree) {
|
||||
if (needsFree)
|
||||
free(tmpBuffer);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -308,10 +303,9 @@ 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);
|
||||
|
||||
|
||||
@@ -92,9 +92,8 @@ class GHOST_EventDragnDrop : public GHOST_Event {
|
||||
~GHOST_EventDragnDrop()
|
||||
{
|
||||
// Free the dropped object data
|
||||
if (m_dragnDropEventData.data == NULL) {
|
||||
if (m_dragnDropEventData.data == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_dragnDropEventData.dataType) {
|
||||
case GHOST_kDragnDropTypeBitmap:
|
||||
@@ -104,9 +103,8 @@ class GHOST_EventDragnDrop : public GHOST_Event {
|
||||
GHOST_TStringArray *strArray = (GHOST_TStringArray *)m_dragnDropEventData.data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < strArray->count; i++) {
|
||||
for (i = 0; i < strArray->count; i++)
|
||||
free(strArray->strings[i]);
|
||||
}
|
||||
|
||||
free(strArray->strings);
|
||||
free(strArray);
|
||||
|
||||
@@ -64,12 +64,10 @@ class GHOST_EventKey : public GHOST_Event {
|
||||
{
|
||||
m_keyEventData.key = key;
|
||||
m_keyEventData.ascii = ascii;
|
||||
if (utf8_buf) {
|
||||
if (utf8_buf)
|
||||
memcpy(m_keyEventData.utf8_buf, utf8_buf, sizeof(m_keyEventData.utf8_buf));
|
||||
}
|
||||
else {
|
||||
else
|
||||
m_keyEventData.utf8_buf[0] = '\0';
|
||||
}
|
||||
m_data = &m_keyEventData;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,8 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
|
||||
|
||||
GHOST_ASSERT(event, "event==0");
|
||||
|
||||
if (event->getType() == GHOST_kEventWindowUpdate) {
|
||||
if (event->getType() == GHOST_kEventWindowUpdate)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "\nGHOST_EventPrinter::processEvent, time: " << (GHOST_TInt32)event->getTime()
|
||||
<< ", type: ";
|
||||
@@ -123,9 +122,8 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
|
||||
std::cout << " type : GHOST_kDragnDropTypeFilenames,";
|
||||
std::cout << "\n Received " << strArray->count << " filename"
|
||||
<< (strArray->count > 1 ? "s:" : ":");
|
||||
for (i = 0; i < strArray->count; i++) {
|
||||
for (i = 0; i < strArray->count; i++)
|
||||
std::cout << "\n File[" << i << "] : " << strArray->strings[i];
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
@@ -135,12 +133,10 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
|
||||
case GHOST_kEventOpenMainFile: {
|
||||
GHOST_TEventDataPtr eventData = ((GHOST_IEvent *)event)->getData();
|
||||
|
||||
if (eventData) {
|
||||
if (eventData)
|
||||
std::cout << "GHOST_kEventOpenMainFile for path : " << (char *)eventData;
|
||||
}
|
||||
else {
|
||||
else
|
||||
std::cout << "GHOST_kEventOpenMainFile with no path specified!!";
|
||||
}
|
||||
} break;
|
||||
|
||||
case GHOST_kEventQuitRequest:
|
||||
|
||||
@@ -50,9 +50,8 @@ class GHOST_EventString : public GHOST_Event {
|
||||
|
||||
~GHOST_EventString()
|
||||
{
|
||||
if (m_data) {
|
||||
if (m_data)
|
||||
free(m_data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -267,9 +267,8 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
|
||||
printf("ndof: unknown device %04hx:%04hx\n", vendor_id, product_id);
|
||||
}
|
||||
|
||||
if (m_buttonMask == 0) {
|
||||
if (m_buttonMask == 0)
|
||||
m_buttonMask = (int)~(UINT_MAX << m_buttonCount);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_NDOF_BUTTONS
|
||||
printf("ndof: %d buttons -> hex:%X\n", m_buttonCount, m_buttonMask);
|
||||
@@ -422,9 +421,8 @@ static bool nearHomePosition(GHOST_TEventNDOFMotionData *ndof, float threshold)
|
||||
|
||||
bool GHOST_NDOFManager::sendMotionEvent()
|
||||
{
|
||||
if (!m_motionEventPending) {
|
||||
if (!m_motionEventPending)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_motionEventPending = false; // any pending motion is handled right now
|
||||
|
||||
|
||||
@@ -46,11 +46,10 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys)
|
||||
char line[MAX_LINE_LENGTH] = {0};
|
||||
while (fgets(line, MAX_LINE_LENGTH, command_output)) {
|
||||
unsigned short vendor_id = 0, product_id = 0;
|
||||
if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) {
|
||||
if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2)
|
||||
if (setDevice(vendor_id, product_id)) {
|
||||
break; /* stop looking once the first 3D mouse is found */
|
||||
}
|
||||
}
|
||||
}
|
||||
pclose(command_output);
|
||||
}
|
||||
@@ -59,9 +58,8 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys)
|
||||
|
||||
GHOST_NDOFManagerUnix::~GHOST_NDOFManagerUnix()
|
||||
{
|
||||
if (m_available) {
|
||||
if (m_available)
|
||||
spnav_close();
|
||||
}
|
||||
}
|
||||
|
||||
bool GHOST_NDOFManagerUnix::available()
|
||||
|
||||
@@ -356,12 +356,10 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
|
||||
if (stereoVisual) {
|
||||
if (stereoVisual)
|
||||
glSettings.flags |= GHOST_glStereoVisual;
|
||||
}
|
||||
if (alphaBackground) {
|
||||
if (alphaBackground)
|
||||
glSettings.flags |= GHOST_glAlphaBackground;
|
||||
}
|
||||
|
||||
/* note: don't use getCurrentDisplaySetting() because on X11 we may
|
||||
* be zoomed in and the desktop may be bigger then the viewport. */
|
||||
|
||||
@@ -96,7 +96,7 @@ class GHOST_SystemNULL : public GHOST_System {
|
||||
GHOST_TSuccess success = GHOST_System::init();
|
||||
|
||||
if (success) {
|
||||
m_displayManager = new GHOST_DisplayManager(this);
|
||||
m_displayManager = new GHOST_DisplayManagerNULL(this);
|
||||
|
||||
if (m_displayManager) {
|
||||
return GHOST_kSuccess;
|
||||
|
||||
@@ -97,9 +97,8 @@ const GHOST_TUns8 *GHOST_SystemPathsUnix::getUserDir(int version, const char *ve
|
||||
else {
|
||||
home = getenv("HOME");
|
||||
|
||||
if (home == NULL) {
|
||||
if (home == NULL)
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
}
|
||||
|
||||
user_path = string(home) + "/.config/blender/" + versionstr;
|
||||
}
|
||||
|
||||
@@ -148,12 +148,10 @@ GHOST_IContext *GHOST_SystemSDL::createOffscreenContext()
|
||||
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -421,25 +419,19 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
||||
assert(window != NULL);
|
||||
|
||||
/* 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) {
|
||||
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);
|
||||
break;
|
||||
@@ -700,9 +692,8 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent)
|
||||
|
||||
GHOST_WindowSDL *GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
|
||||
{
|
||||
if (sdl_win == NULL) {
|
||||
if (sdl_win == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// It is not entirely safe to do this as the backptr may point
|
||||
// to a window that has recently been removed.
|
||||
|
||||
@@ -340,9 +340,8 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const STR_String &title,
|
||||
{
|
||||
GHOST_WindowX11 *window = NULL;
|
||||
|
||||
if (!m_display) {
|
||||
if (!m_display)
|
||||
return 0;
|
||||
}
|
||||
|
||||
window = new GHOST_WindowX11(this,
|
||||
m_display,
|
||||
@@ -427,12 +426,10 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
|
||||
(false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
}
|
||||
|
||||
context = new GHOST_ContextGLX(false,
|
||||
@@ -446,12 +443,10 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
|
||||
(false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -473,24 +468,21 @@ static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/)
|
||||
{
|
||||
GHOST_PRINT("XIM server died\n");
|
||||
|
||||
if (ptr) {
|
||||
if (ptr)
|
||||
*(XIM *)ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool GHOST_SystemX11::openX11_IM()
|
||||
{
|
||||
if (!m_display) {
|
||||
if (!m_display)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (!m_xim) {
|
||||
if (!m_xim)
|
||||
return false;
|
||||
}
|
||||
|
||||
XIMCallback destroy;
|
||||
destroy.callback = (XIMProc)destroyIMCallback;
|
||||
@@ -503,9 +495,8 @@ bool GHOST_SystemX11::openX11_IM()
|
||||
GHOST_WindowX11 *GHOST_SystemX11::findGhostWindow(Window xwind) const
|
||||
{
|
||||
|
||||
if (xwind == 0) {
|
||||
if (xwind == 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* It is not entirely safe to do this as the backptr may point
|
||||
* to a window that has recently been removed.
|
||||
@@ -615,9 +606,8 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
||||
else {
|
||||
GHOST_TInt64 maxSleep = next - getMilliSeconds();
|
||||
|
||||
if (maxSleep >= 0) {
|
||||
if (maxSleep >= 0)
|
||||
SleepTillEvent(m_display, next - getMilliSeconds());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,12 +632,11 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
||||
GHOST_WindowX11 *window = findGhostWindow(xevent.xany.window);
|
||||
if (window && !window->getX11_XIC() && window->createX11_XIC()) {
|
||||
GHOST_PRINT("XIM input context created\n");
|
||||
if (xevent.type == KeyPress) {
|
||||
if (xevent.type == KeyPress)
|
||||
/* we can assume the window has input focus
|
||||
* here, because key events are received only
|
||||
* when the window is focused. */
|
||||
XSetICFocus(window->getX11_XIC());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,9 +655,8 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
||||
}
|
||||
else if (xevent.type == KeyPress) {
|
||||
if ((xevent.xkey.keycode == m_last_release_keycode) &&
|
||||
((xevent.xkey.time <= m_last_release_time))) {
|
||||
((xevent.xkey.time <= m_last_release_time)))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
processEvent(&xevent);
|
||||
@@ -877,9 +865,8 @@ 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 atm.
|
||||
* Use offset of 8 in case the window is at screen bounds. */
|
||||
@@ -1112,15 +1099,13 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
if ((unsigned char)utf8_buf[i++] > 0x7f) {
|
||||
for (; i < len; ++i) {
|
||||
c = utf8_buf[i];
|
||||
if (c < 0x80 || c > 0xbf) {
|
||||
if (c < 0x80 || c > 0xbf)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= len) {
|
||||
if (i >= len)
|
||||
break;
|
||||
}
|
||||
|
||||
/* enqueue previous character */
|
||||
pushEvent(g_event);
|
||||
@@ -1129,9 +1114,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
}
|
||||
}
|
||||
|
||||
if (utf8_buf != utf8_array) {
|
||||
if (utf8_buf != utf8_array)
|
||||
free(utf8_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
@@ -1146,47 +1130,37 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
|
||||
/* process wheel mouse events and break, only pass on press events */
|
||||
if (xbe.button == Button4) {
|
||||
if (xbe.type == ButtonPress) {
|
||||
if (xbe.type == ButtonPress)
|
||||
g_event = new GHOST_EventWheel(getMilliSeconds(), window, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (xbe.button == Button5) {
|
||||
if (xbe.type == ButtonPress) {
|
||||
if (xbe.type == ButtonPress)
|
||||
g_event = new GHOST_EventWheel(getMilliSeconds(), window, -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* process rest of normal mouse buttons */
|
||||
if (xbe.button == Button1) {
|
||||
if (xbe.button == Button1)
|
||||
gbmask = GHOST_kButtonMaskLeft;
|
||||
}
|
||||
else if (xbe.button == Button2) {
|
||||
else if (xbe.button == Button2)
|
||||
gbmask = GHOST_kButtonMaskMiddle;
|
||||
}
|
||||
else if (xbe.button == Button3) {
|
||||
else if (xbe.button == Button3)
|
||||
gbmask = GHOST_kButtonMaskRight;
|
||||
/* It seems events 6 and 7 are for horizontal scrolling.
|
||||
* you can re-order button mapping like this... (swaps 6,7 with 8,9)
|
||||
* xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"
|
||||
*/
|
||||
}
|
||||
else if (xbe.button == 6) {
|
||||
/* It seems events 6 and 7 are for horizontal scrolling.
|
||||
* you can re-order button mapping like this... (swaps 6,7 with 8,9)
|
||||
* xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"
|
||||
*/
|
||||
else if (xbe.button == 6)
|
||||
gbmask = GHOST_kButtonMaskButton6;
|
||||
}
|
||||
else if (xbe.button == 7) {
|
||||
else if (xbe.button == 7)
|
||||
gbmask = GHOST_kButtonMaskButton7;
|
||||
}
|
||||
else if (xbe.button == 8) {
|
||||
else if (xbe.button == 8)
|
||||
gbmask = GHOST_kButtonMaskButton4;
|
||||
}
|
||||
else if (xbe.button == 9) {
|
||||
else if (xbe.button == 9)
|
||||
gbmask = GHOST_kButtonMaskButton5;
|
||||
}
|
||||
else {
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
g_event = new GHOST_EventButton(getMilliSeconds(), type, window, gbmask);
|
||||
break;
|
||||
@@ -1216,12 +1190,10 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
|
||||
XIC xic = window->getX11_XIC();
|
||||
if (xic) {
|
||||
if (xe->type == FocusIn) {
|
||||
if (xe->type == FocusIn)
|
||||
XSetICFocus(xic);
|
||||
}
|
||||
else {
|
||||
else
|
||||
XUnsetICFocus(xic);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1252,9 +1224,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
if (XGetWindowAttributes(m_display, xcme.window, &attr) == True) {
|
||||
if (XGetInputFocus(m_display, &fwin, &revert_to) == True) {
|
||||
if (attr.map_state == IsViewable) {
|
||||
if (fwin != xcme.window) {
|
||||
if (fwin != xcme.window)
|
||||
XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1299,12 +1270,10 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
// printf("X: %s window %d\n",
|
||||
// xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window);
|
||||
|
||||
if (xce.type == EnterNotify) {
|
||||
if (xce.type == EnterNotify)
|
||||
m_windowManager->setActiveWindow(window);
|
||||
}
|
||||
else {
|
||||
else
|
||||
m_windowManager->setWindowInactive(window);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1878,9 +1847,8 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
|
||||
return;
|
||||
|
||||
case XCLIB_XCOUT_SENTCONVSEL:
|
||||
if (evt->type != SelectionNotify) {
|
||||
if (evt->type != SelectionNotify)
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == m_atom.UTF8_STRING && evt->xselection.property == None) {
|
||||
*context = XCLIB_XCOUT_FALLBACK_UTF8;
|
||||
@@ -1966,14 +1934,12 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
|
||||
* then read it, delete it, etc. */
|
||||
|
||||
/* make sure that the event is relevant */
|
||||
if (evt->type != PropertyNotify) {
|
||||
if (evt->type != PropertyNotify)
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip unless the property has a new value */
|
||||
if (evt->xproperty.state != PropertyNewValue) {
|
||||
if (evt->xproperty.state != PropertyNewValue)
|
||||
return;
|
||||
}
|
||||
|
||||
/* check size and format of the property */
|
||||
XGetWindowProperty(m_display,
|
||||
@@ -2062,12 +2028,10 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
|
||||
XEvent evt;
|
||||
unsigned int context = XCLIB_XCOUT_NONE;
|
||||
|
||||
if (selection == True) {
|
||||
if (selection == True)
|
||||
sseln = m_atom.PRIMARY;
|
||||
}
|
||||
else {
|
||||
else
|
||||
sseln = m_atom.CLIPBOARD;
|
||||
}
|
||||
|
||||
vector<GHOST_IWindow *> &win_vec = m_windowManager->getWindows();
|
||||
vector<GHOST_IWindow *>::iterator win_it = win_vec.begin();
|
||||
@@ -2088,15 +2052,13 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
|
||||
return sel_buf;
|
||||
}
|
||||
}
|
||||
else if (owner == None) {
|
||||
else if (owner == None)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* only get an event if xcout() is doing something */
|
||||
if (context != XCLIB_XCOUT_NONE) {
|
||||
if (context != XCLIB_XCOUT_NONE)
|
||||
XNextEvent(m_display, &evt);
|
||||
}
|
||||
|
||||
/* fetch the selection, or part of it */
|
||||
getClipboard_xcout(&evt, sseln, target, &sel_buf, &sel_len, &context);
|
||||
@@ -2125,9 +2087,8 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
|
||||
}
|
||||
|
||||
/* only continue if xcout() is doing something */
|
||||
if (context == XCLIB_XCOUT_NONE) {
|
||||
if (context == XCLIB_XCOUT_NONE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sel_len) {
|
||||
@@ -2138,12 +2099,10 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
|
||||
memcpy((char *)tmp_data, (char *)sel_buf, sel_len);
|
||||
tmp_data[sel_len] = '\0';
|
||||
|
||||
if (sseln == m_atom.STRING) {
|
||||
if (sseln == m_atom.STRING)
|
||||
XFree(sel_buf);
|
||||
}
|
||||
else {
|
||||
else
|
||||
free(sel_buf);
|
||||
}
|
||||
|
||||
return tmp_data;
|
||||
}
|
||||
@@ -2163,9 +2122,8 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
|
||||
if (selection == False) {
|
||||
XSetSelectionOwner(m_display, m_atom.CLIPBOARD, m_window, CurrentTime);
|
||||
owner = XGetSelectionOwner(m_display, m_atom.CLIPBOARD);
|
||||
if (txt_cut_buffer) {
|
||||
if (txt_cut_buffer)
|
||||
free((void *)txt_cut_buffer);
|
||||
}
|
||||
|
||||
txt_cut_buffer = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(txt_cut_buffer, buffer);
|
||||
@@ -2173,17 +2131,15 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
|
||||
else {
|
||||
XSetSelectionOwner(m_display, m_atom.PRIMARY, m_window, CurrentTime);
|
||||
owner = XGetSelectionOwner(m_display, m_atom.PRIMARY);
|
||||
if (txt_select_buffer) {
|
||||
if (txt_select_buffer)
|
||||
free((void *)txt_select_buffer);
|
||||
}
|
||||
|
||||
txt_select_buffer = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(txt_select_buffer, buffer);
|
||||
}
|
||||
|
||||
if (owner != m_window) {
|
||||
if (owner != m_window)
|
||||
fprintf(stderr, "failed to own primary\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2243,23 +2199,18 @@ static bool match_token(const char *haystack, const char *needle)
|
||||
{
|
||||
const char *p, *q;
|
||||
for (p = haystack; *p;) {
|
||||
while (*p && isspace(*p)) {
|
||||
while (*p && isspace(*p))
|
||||
p++;
|
||||
}
|
||||
if (!*p) {
|
||||
if (!*p)
|
||||
break;
|
||||
}
|
||||
|
||||
for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++) {
|
||||
for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++)
|
||||
p++;
|
||||
}
|
||||
if (!*q && (isspace(*p) || !*p)) {
|
||||
if (!*q && (isspace(*p) || !*p))
|
||||
return true;
|
||||
}
|
||||
|
||||
while (*p && !isspace(*p)) {
|
||||
while (*p && !isspace(*p))
|
||||
p++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2383,9 +2334,8 @@ void GHOST_SystemX11::refreshXInputDevices()
|
||||
void GHOST_SystemX11::clearXInputDevices()
|
||||
{
|
||||
for (GHOST_TabletX11 &xtablet : m_xtablets) {
|
||||
if (xtablet.Device) {
|
||||
if (xtablet.Device)
|
||||
XCloseDevice(m_display, xtablet.Device);
|
||||
}
|
||||
}
|
||||
|
||||
m_xtablets.clear();
|
||||
|
||||
@@ -89,9 +89,8 @@ GHOST_TUns64 GHOST_TimerManager::nextFireTime()
|
||||
for (iter = m_timers.begin(); iter != m_timers.end(); ++iter) {
|
||||
GHOST_TUns64 next = (*iter)->getNext();
|
||||
|
||||
if (next < smallest) {
|
||||
if (next < smallest)
|
||||
smallest = next;
|
||||
}
|
||||
}
|
||||
|
||||
return smallest;
|
||||
@@ -103,9 +102,8 @@ bool GHOST_TimerManager::fireTimers(GHOST_TUns64 time)
|
||||
bool anyProcessed = false;
|
||||
|
||||
for (iter = m_timers.begin(); iter != m_timers.end(); ++iter) {
|
||||
if (fireTimer(time, *iter)) {
|
||||
if (fireTimer(time, *iter))
|
||||
anyProcessed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return anyProcessed;
|
||||
|
||||
@@ -76,9 +76,8 @@ GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType typ
|
||||
delete m_context;
|
||||
m_context = NULL;
|
||||
|
||||
if (type != GHOST_kDrawingContextTypeNone) {
|
||||
if (type != GHOST_kDrawingContextTypeNone)
|
||||
m_context = newDrawingContext(type);
|
||||
}
|
||||
|
||||
if (m_context != NULL) {
|
||||
m_drawingContextType = type;
|
||||
@@ -146,9 +145,8 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode,
|
||||
GHOST_Rect *bounds,
|
||||
GHOST_TInt32 mouse_ungrab_xy[2])
|
||||
{
|
||||
if (m_cursorGrab == mode) {
|
||||
if (m_cursorGrab == mode)
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
/* override with new location */
|
||||
if (mouse_ungrab_xy) {
|
||||
|
||||
@@ -287,9 +287,8 @@ class GHOST_Window : public GHOST_IWindow {
|
||||
|
||||
float getNativePixelSize(void)
|
||||
{
|
||||
if (m_nativePixelSize > 0.0f) {
|
||||
if (m_nativePixelSize > 0.0f)
|
||||
return m_nativePixelSize;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,9 +172,8 @@ 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;
|
||||
@@ -186,9 +185,8 @@ 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;
|
||||
|
||||
@@ -87,12 +87,10 @@ 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 {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -136,15 +134,12 @@ 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) {
|
||||
else if (flags & SDL_WINDOW_MAXIMIZED)
|
||||
return GHOST_kWindowStateMaximized;
|
||||
}
|
||||
else if (flags & SDL_WINDOW_MINIMIZED) {
|
||||
else if (flags & SDL_WINDOW_MINIMIZED)
|
||||
return GHOST_kWindowStateMinimized;
|
||||
}
|
||||
return GHOST_kWindowStateNormal;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,19 +137,16 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
|
||||
/* take a frame buffer config that has alpha cap */
|
||||
for (int i = 0; i < nbfbconfig; i++) {
|
||||
XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
|
||||
if (!visual) {
|
||||
if (!visual)
|
||||
continue;
|
||||
}
|
||||
/* if we don't need a alpha background, the first config will do, otherwise
|
||||
* test the alphaMask as it won't necessarily be present */
|
||||
if (needAlpha) {
|
||||
XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
|
||||
if (!pict_format) {
|
||||
if (!pict_format)
|
||||
continue;
|
||||
}
|
||||
if (pict_format->direct.alphaMask <= 0) {
|
||||
if (pict_format->direct.alphaMask <= 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*fbconfig = fbconfigs[i];
|
||||
@@ -506,9 +503,8 @@ static Bool destroyICCallback(XIC /*xic*/, XPointer ptr, XPointer /*data*/)
|
||||
bool GHOST_WindowX11::createX11_XIC()
|
||||
{
|
||||
XIM xim = m_system->getX11_XIM();
|
||||
if (!xim) {
|
||||
if (!xim)
|
||||
return false;
|
||||
}
|
||||
|
||||
XICCallback destroy;
|
||||
destroy.callback = (XICProc)destroyICCallback;
|
||||
@@ -527,9 +523,8 @@ bool GHOST_WindowX11::createX11_XIC()
|
||||
XNDestroyCallback,
|
||||
&destroy,
|
||||
NULL);
|
||||
if (!m_xic) {
|
||||
if (!m_xic)
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long fevent;
|
||||
XGetICValues(m_xic, XNFilterEvents, &fevent, NULL);
|
||||
@@ -557,21 +552,17 @@ void GHOST_WindowX11::refreshXInputDevices()
|
||||
XEventClass ev;
|
||||
|
||||
DeviceMotionNotify(xtablet.Device, xtablet.MotionEvent, ev);
|
||||
if (ev) {
|
||||
if (ev)
|
||||
xevents.push_back(ev);
|
||||
}
|
||||
DeviceButtonPress(xtablet.Device, xtablet.PressEvent, ev);
|
||||
if (ev) {
|
||||
if (ev)
|
||||
xevents.push_back(ev);
|
||||
}
|
||||
ProximityIn(xtablet.Device, xtablet.ProxInEvent, ev);
|
||||
if (ev) {
|
||||
if (ev)
|
||||
xevents.push_back(ev);
|
||||
}
|
||||
ProximityOut(xtablet.Device, xtablet.ProxOutEvent, ev);
|
||||
if (ev) {
|
||||
if (ev)
|
||||
xevents.push_back(ev);
|
||||
}
|
||||
}
|
||||
|
||||
XSelectExtensionEvent(m_display, m_window, xevents.data(), (int)xevents.size());
|
||||
@@ -714,9 +705,8 @@ void GHOST_WindowX11::icccmSetState(int state)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
if (state != IconicState) {
|
||||
if (state != IconicState)
|
||||
return;
|
||||
}
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
@@ -782,12 +772,10 @@ 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;
|
||||
@@ -838,9 +826,8 @@ bool GHOST_WindowX11::netwmIsMaximized(void) const
|
||||
}
|
||||
}
|
||||
|
||||
if (prop_ret) {
|
||||
if (prop_ret)
|
||||
XFree(prop_ret);
|
||||
}
|
||||
return (st);
|
||||
}
|
||||
|
||||
@@ -855,12 +842,10 @@ 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;
|
||||
@@ -904,9 +889,8 @@ bool GHOST_WindowX11::netwmIsFullScreen(void) const
|
||||
}
|
||||
}
|
||||
|
||||
if (prop_ret) {
|
||||
if (prop_ret)
|
||||
XFree(prop_ret);
|
||||
}
|
||||
return (st);
|
||||
}
|
||||
|
||||
@@ -915,12 +899,10 @@ 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,
|
||||
@@ -956,15 +938,13 @@ 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);
|
||||
}
|
||||
|
||||
@@ -979,18 +959,14 @@ GHOST_TWindowState GHOST_WindowX11::getState() const
|
||||
* In the Iconic and Withdrawn state, the window
|
||||
* is unmaped, 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);
|
||||
}
|
||||
|
||||
@@ -1000,9 +976,8 @@ 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) {
|
||||
/*
|
||||
@@ -1019,20 +994,16 @@ 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);
|
||||
}
|
||||
@@ -1042,21 +1013,17 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1065,19 +1032,15 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1134,9 +1097,8 @@ GHOST_TSuccess GHOST_WindowX11::setOrder(GHOST_TWindowOrder order)
|
||||
XGetWindowAttributes(m_display, m_window, &attr);
|
||||
|
||||
/* iconized 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) {
|
||||
@@ -1288,12 +1250,10 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
||||
(m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
}
|
||||
|
||||
context = new GHOST_ContextGLX(m_wantStereoVisual,
|
||||
@@ -1307,12 +1267,10 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
||||
(m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
|
||||
/* Ugly, but we get crashes unless a whole bunch of systems are patched. */
|
||||
fprintf(stderr, "Error! Unsupported graphics card or driver.\n");
|
||||
@@ -1422,12 +1380,10 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCursorVisibility(bool visible)
|
||||
Cursor xcursor;
|
||||
|
||||
if (visible) {
|
||||
if (m_visible_cursor) {
|
||||
if (m_visible_cursor)
|
||||
xcursor = m_visible_cursor;
|
||||
}
|
||||
else {
|
||||
else
|
||||
xcursor = getStandardCursor(getCursorShape());
|
||||
}
|
||||
}
|
||||
else {
|
||||
xcursor = getEmptyCursor();
|
||||
@@ -1446,9 +1402,8 @@ 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,
|
||||
@@ -1540,12 +1495,10 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCustomCursorShape(GHOST_TUns8 *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);
|
||||
@@ -1593,9 +1546,8 @@ 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,
|
||||
@@ -1606,9 +1558,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -412,9 +412,8 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate: {
|
||||
GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent);
|
||||
if (!GHOST_ValidWindow(shSystem, window2)) {
|
||||
if (!GHOST_ValidWindow(shSystem, window2))
|
||||
break;
|
||||
}
|
||||
setViewPortGL(window2);
|
||||
drawGL();
|
||||
GHOST_SwapWindowBuffers(window2);
|
||||
|
||||
@@ -578,12 +578,10 @@ bool Application::processEvent(GHOST_IEvent *event)
|
||||
break;
|
||||
|
||||
case GHOST_kKeyS: // toggle mono and stereo
|
||||
if (stereo) {
|
||||
if (stereo)
|
||||
stereo = false;
|
||||
}
|
||||
else {
|
||||
else
|
||||
stereo = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kKeyT:
|
||||
@@ -632,9 +630,8 @@ bool Application::processEvent(GHOST_IEvent *event)
|
||||
|
||||
case GHOST_kEventWindowUpdate: {
|
||||
GHOST_IWindow *window2 = event->getWindow();
|
||||
if (!m_system->validWindow(window2)) {
|
||||
if (!m_system->validWindow(window2))
|
||||
break;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -691,24 +688,20 @@ int main(int /*argc*/, char ** /*argv*/)
|
||||
"SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
|
||||
KEY_ALL_ACCESS);
|
||||
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
if (lresult == ERROR_SUCCESS)
|
||||
printf("Successfully opened key\n");
|
||||
}
|
||||
# if 0
|
||||
lresult = regkey.QueryValue(&keyValue, "StereoEnable");
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
if (lresult == ERROR_SUCCESS)
|
||||
printf("Successfully queried key\n");
|
||||
}
|
||||
# endif
|
||||
lresult = regkey.SetValue(
|
||||
HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable", "1");
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
if (lresult == ERROR_SUCCESS)
|
||||
printf("Successfully set value for key\n");
|
||||
}
|
||||
regkey.Close();
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
if (lresult == ERROR_SUCCESS)
|
||||
printf("Successfully closed key\n");
|
||||
}
|
||||
// regkey.Write("2");
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
@@ -234,9 +234,8 @@ void event_to_buf(GHOST_EventHandle evt, char buf[128])
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd = data;
|
||||
pos += sprintf(pos, " - key: %s (%d)", keytype_to_string(kd->key), kd->key);
|
||||
if (kd->ascii) {
|
||||
if (kd->ascii)
|
||||
pos += sprintf(pos, " ascii: '%c' (%d)", kd->ascii, kd->ascii);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +84,10 @@ void rect_bevel_side(int rect[2][2], int side, float *lt, float *dk, const float
|
||||
int x = (corner == 0 || corner == 1) ? (rect[0][0] + i) : (rect[1][0] - i - 1);
|
||||
int y = (corner == 0 || corner == 3) ? (rect[0][1] + i) : (rect[1][1] - i - 1);
|
||||
|
||||
if (ltidx == corner) {
|
||||
if (ltidx == corner)
|
||||
glColor3f(col[0] * ltf, col[1] * ltf, col[2] * ltf);
|
||||
}
|
||||
if (dkidx == corner) {
|
||||
if (dkidx == corner)
|
||||
glColor3f(col[0] * dkf, col[1] * dkf, col[2] * dkf);
|
||||
}
|
||||
|
||||
glVertex2i(lx, ly);
|
||||
glVertex2i(lx = x, ly = y);
|
||||
@@ -185,44 +183,37 @@ static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press)
|
||||
{
|
||||
switch (key) {
|
||||
case GHOST_kKeyC:
|
||||
if (press) {
|
||||
if (press)
|
||||
GHOST_SetCursorShape(mw->win,
|
||||
(GHOST_TStandardCursor)(rand() % (GHOST_kStandardCursorNumCursors)));
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyLeftBracket:
|
||||
if (press) {
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 0);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyRightBracket:
|
||||
if (press) {
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 1);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyE:
|
||||
if (press) {
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(mw->app);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyQ:
|
||||
if (press) {
|
||||
if (press)
|
||||
multitestapp_exit(mw->app);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyT:
|
||||
if (press) {
|
||||
if (press)
|
||||
mainwindow_log(mw, "TextTest~|`hello`\"world\",<>/");
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyR:
|
||||
if (press) {
|
||||
int i;
|
||||
|
||||
mainwindow_log(mw, "Invalidating window 10 times");
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (i = 0; i < 10; i++)
|
||||
GHOST_InvalidateWindow(mw->win);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyF11:
|
||||
@@ -538,9 +529,8 @@ static void loggerwindow_do_key(LoggerWindow *lw, GHOST_TKey key, int press)
|
||||
{
|
||||
switch (key) {
|
||||
case GHOST_kKeyQ:
|
||||
if (press) {
|
||||
if (press)
|
||||
multitestapp_exit(lw->app);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -710,9 +700,8 @@ static void extrawindow_do_key(ExtraWindow *ew, GHOST_TKey key, int press)
|
||||
{
|
||||
switch (key) {
|
||||
case GHOST_kKeyE:
|
||||
if (press) {
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(ew->app);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -882,23 +871,19 @@ MultiTestApp *multitestapp_new(void)
|
||||
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(multitest_event_handler, app);
|
||||
|
||||
app->sys = GHOST_CreateSystem();
|
||||
if (!app->sys) {
|
||||
if (!app->sys)
|
||||
fatal("Unable to create ghost system");
|
||||
}
|
||||
|
||||
if (!GHOST_AddEventConsumer(app->sys, consumer)) {
|
||||
if (!GHOST_AddEventConsumer(app->sys, consumer))
|
||||
fatal("Unable to add multitest event consumer ");
|
||||
}
|
||||
|
||||
app->main = mainwindow_new(app);
|
||||
if (!app->main) {
|
||||
if (!app->main)
|
||||
fatal("Unable to create main window");
|
||||
}
|
||||
|
||||
app->logger = loggerwindow_new(app);
|
||||
if (!app->logger) {
|
||||
if (!app->logger)
|
||||
fatal("Unable to create logger window");
|
||||
}
|
||||
|
||||
app->extra = NULL;
|
||||
app->exit = 0;
|
||||
|
||||
Reference in New Issue
Block a user