Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
commita5b4b0f21c1ae8c96e4fea9abdcfac2fab1cf300 (patch)
tree0658d8bdfb8ec03652aa04f82ee8a4d243ec6370 /intern/ghost/intern
parentd68f698cf0321477c0734474150eb4bc43c4e85f (diff)
parentabcda06934aba054de8540b66b13c2bbc5f8f515 (diff)
Merge branch '28' into custom-manipulatorscustom-manipulators
Diffstat (limited to 'intern/ghost/intern')
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp2
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h2
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp117
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h14
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp10
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm93
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp3
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp33
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm140
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp121
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp6
13 files changed, 215 insertions, 333 deletions
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 0a9dc900aed..061ac29945b 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -57,7 +57,6 @@ GHOST_ContextGLX::GHOST_ContextGLX(
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
- XVisualInfo *visualInfo,
GLXFBConfig fbconfig,
int contextProfileMask,
int contextMajorVersion,
@@ -66,7 +65,6 @@ GHOST_ContextGLX::GHOST_ContextGLX(
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_display(display),
- m_visualInfo(visualInfo),
m_fbconfig(fbconfig),
m_window(window),
m_contextProfileMask(contextProfileMask),
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index 6547a0bd00a..51fb1dd57dc 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -57,7 +57,6 @@ public:
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
- XVisualInfo *visualInfo,
GLXFBConfig fbconfig,
int contextProfileMask,
int contextMajorVersion,
@@ -113,7 +112,6 @@ private:
void initContextGLXEW();
Display *m_display;
- XVisualInfo *m_visualInfo;
GLXFBConfig m_fbconfig;
Window m_window;
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 8cf311b9e84..d2dd38878f7 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -914,29 +914,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
reportContextString("Version", m_dummyVersion, version);
#endif
- if ((strcmp(vendor, "Microsoft Corporation") == 0 ||
- strcmp(renderer, "GDI Generic") == 0) && version[0] == '1' && version[2] == '1')
- {
- MessageBox(m_hWnd, "Your system does not use 3D hardware acceleration.\n"
- "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
- "This may be caused by:\n"
- "* A missing or faulty graphics driver installation.\n"
- " Blender needs a graphics card driver to work correctly.\n"
- "* Accessing Blender through a remote connection.\n"
- "* Using Blender through a virtual machine.\n\n"
- "The program will now close.",
- "Blender - Can't detect 3D hardware accelerated Driver!",
- MB_OK | MB_ICONERROR);
- exit(0);
- }
- else if (version[0] < '3' || (version[0] == '3' && version[2] < '3')) {
- MessageBox(m_hWnd, "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
- "The program will now close.",
- "Blender - Unsupported Graphics Driver!",
- MB_OK | MB_ICONERROR);
- exit(0);
- }
-
return GHOST_kSuccess;
}
@@ -950,3 +927,97 @@ GHOST_TSuccess GHOST_ContextWGL::releaseNativeHandles()
return success;
}
+
+/**
+ * For any given HDC you may call SetPixelFormat once
+ *
+ * So we better try to get the correct OpenGL version in a new window altogether, in case it fails.
+ * (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd369049(v=vs.85).aspx)
+ */
+static bool TryOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ int major, int minor)
+{
+ HWND dummyHWND = clone_window(hwnd, NULL);
+ if (dummyHWND == NULL) {
+ return false;
+ }
+
+ HDC dummyHDC = GetDC(dummyHWND);
+ if (dummyHDC == NULL) {
+ return false;
+ }
+
+ GHOST_ContextWGL * context = new GHOST_ContextWGL(
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ dummyHWND,
+ dummyHDC,
+ contextProfileMask,
+ major, minor,
+ (debugContext ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+ GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
+
+ bool result = context->initializeDrawingContext();
+ delete context;
+
+ ReleaseDC(dummyHWND, dummyHDC);
+ DestroyWindow(dummyHWND);
+
+ return result;
+}
+
+GHOST_TSuccess GHOST_ContextWGL::getMaximumSupportedOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ GHOST_TUns8 *r_major_version,
+ GHOST_TUns8 *r_minor_version)
+{
+ /* - AMD and Intel give us exactly this version
+ * - NVIDIA gives at least this version <-- desired behavior
+ * So we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system. */
+ for (int minor = 5; minor >= 0; --minor) {
+ if (TryOpenGLVersion(
+ hwnd,
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ contextProfileMask,
+ debugContext,
+ 4, minor))
+ {
+ *r_major_version = 4;
+ *r_minor_version = minor;
+ return GHOST_kSuccess;
+ }
+ }
+
+ /* Fallback to OpenGL 3.3 */
+ if (TryOpenGLVersion(
+ hwnd,
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ contextProfileMask,
+ debugContext,
+ 3, 3))
+ {
+ *r_major_version = 3;
+ *r_minor_version = 3;
+ return GHOST_kSuccess;
+ }
+
+ *r_major_version = 0;
+ *r_minor_version = 0;
+ return GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index a07cc1b6301..0d9986a0802 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -105,6 +105,20 @@ public:
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
+ /**
+ * Gets the maximum supported OpenGL context for the user hardware
+ * \return Whether major_version and minor_version resulted in a valid context.
+ */
+ static GHOST_TSuccess getMaximumSupportedOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ GHOST_TUns8 *r_major_version,
+ GHOST_TUns8 *r_minor_version);
+
private:
int choose_pixel_format(
bool stereoVisual,
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index f25f6637cb1..a6adba12152 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -193,16 +193,6 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const
}
else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) {
sprintf(str, "Numpad %d", (key - GHOST_kKeyNumpad0));
-#if defined(__sun__) || defined(__sun)
- }
- else if (key == 268828432) { /* solaris keyboards are messed up */
- /* This should really test XK_F11 but that doesn't work */
- strcpy(str, "F11");
- }
- else if (key == 268828433) { /* solaris keyboards are messed up */
- /* This should really test XK_F12 but that doesn't work */
- strcpy(str, "F12");
-#endif
}
else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) {
sprintf(str, "F%d", key - GHOST_kKeyF1 + 1);
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index b142c2f7194..6802ad42c7b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -292,11 +292,6 @@ protected:
/** Ignores window size messages (when window is dragged). */
bool m_ignoreWindowSizedMessages;
- /** Stores the mouse cursor delta due to setting a new cursor position
- * Needed because cocoa event delta cursor move takes setCursorPosition changes too.
- */
- GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
-
/** Temporarily ignore momentum scroll events */
bool m_ignoreMomentumScroll;
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 173f59c9c8f..42ccfb06fd9 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -366,8 +366,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
char *rstring = NULL;
m_modifierMask =0;
- m_cursorDelta_x=0;
- m_cursorDelta_y=0;
m_outsideLoopEventProcessed = false;
m_needDelayedApplicationBecomeActiveEventProcessing = false;
m_displayManager = new GHOST_DisplayManagerCocoa ();
@@ -644,6 +642,13 @@ GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_T
CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf));
+ // See https://stackoverflow.com/a/17559012. By default, hardware events
+ // will be suppressed for 500ms after a synthetic mouse event. For unknown
+ // reasons CGEventSourceSetLocalEventsSuppressionInterval does not work,
+ // however calling CGAssociateMouseAndMouseCursorPosition also removes the
+ // delay, even if this is undocumented.
+ CGAssociateMouseAndMouseCursorPosition(true);
+
[pool drain];
return GHOST_kSuccess;
}
@@ -1249,27 +1254,6 @@ bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
}
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-enum {
- NSEventPhaseNone = 0,
- NSEventPhaseBegan = 0x1 << 0,
- NSEventPhaseStationary = 0x1 << 1,
- NSEventPhaseChanged = 0x1 << 2,
- NSEventPhaseEnded = 0x1 << 3,
- NSEventPhaseCancelled = 0x1 << 4,
-};
-typedef NSUInteger NSEventPhase;
-
-@interface NSEvent (AvailableOn1070AndLater)
-- (BOOL)hasPreciseScrollingDeltas;
-- (CGFloat)scrollingDeltaX;
-- (CGFloat)scrollingDeltaY;
-- (NSEventPhase)momentumPhase;
-- (BOOL)isDirectionInvertedFromDevice;
-- (NSEventPhase)phase;
-@end
-#endif
-
GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
{
NSEvent *event = (NSEvent *)eventPtr;
@@ -1354,9 +1338,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries
{
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
- GHOST_TInt32 x_mouse= mousePos.x;
- GHOST_TInt32 y_mouse= mousePos.y;
- GHOST_TInt32 x_accum, y_accum, x_cur, y_cur, x, y;
+ GHOST_TInt32 x_mouse = mousePos.x;
+ GHOST_TInt32 y_mouse = mousePos.y;
GHOST_Rect bounds, windowBounds, correctedBounds;
/* fallback to window bounds */
@@ -1370,29 +1353,26 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
correctedBounds.m_b = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_b;
correctedBounds.m_t = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_t;
- //Update accumulation counts
+ //Get accumulation from previous mouse warps
+ GHOST_TInt32 x_accum, y_accum;
window->getCursorGrabAccum(x_accum, y_accum);
- x_accum += [event deltaX]-m_cursorDelta_x;
- y_accum += -[event deltaY]-m_cursorDelta_y; //Strange Apple implementation (inverted coordinates for the deltaY) ...
- window->setCursorGrabAccum(x_accum, y_accum);
//Warp mouse cursor if needed
- x_mouse += [event deltaX]-m_cursorDelta_x;
- y_mouse += -[event deltaY]-m_cursorDelta_y;
- correctedBounds.wrapPoint(x_mouse, y_mouse, 2);
-
- //Compensate for mouse moved event taking cursor position set into account
- m_cursorDelta_x = x_mouse-mousePos.x;
- m_cursorDelta_y = y_mouse-mousePos.y;
+ GHOST_TInt32 warped_x_mouse = x_mouse;
+ GHOST_TInt32 warped_y_mouse = y_mouse;
+ correctedBounds.wrapPoint(warped_x_mouse, warped_y_mouse, 4);
//Set new cursor position
- window->clientToScreenIntern(x_mouse, y_mouse, x_cur, y_cur);
- setMouseCursorPosition(x_cur, y_cur); /* wrap */
+ if (x_mouse != warped_x_mouse || y_mouse != warped_y_mouse) {
+ GHOST_TInt32 warped_x, warped_y;
+ window->clientToScreenIntern(warped_x_mouse, warped_y_mouse, warped_x, warped_y);
+ setMouseCursorPosition(warped_x, warped_y); /* wrap */
+ window->setCursorGrabAccum(x_accum + (x_mouse - warped_x_mouse), y_accum + (y_mouse - warped_y_mouse));
+ }
- //Post event
- window->getCursorGrabInitPos(x_cur, y_cur);
- window->screenToClientIntern(x_cur, y_cur, x_cur, y_cur);
- window->clientToScreenIntern(x_cur + x_accum, y_cur + y_accum, x, y);
+ //Generate event
+ GHOST_TInt32 x, y;
+ window->clientToScreenIntern(x_mouse + x_accum, y_mouse + y_accum, x, y);
pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
break;
}
@@ -1404,9 +1384,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
-
- m_cursorDelta_x=0;
- m_cursorDelta_y=0; //Mouse motion occurred between two cursor warps, so we can reset the delta counter
break;
}
}
@@ -1461,7 +1438,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
double dx;
double dy;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
/* with 10.7 nice scrolling deltas are supported */
dx = [event scrollingDeltaX];
dy = [event scrollingDeltaY];
@@ -1471,29 +1447,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
dx = [event deltaX];
dy = [event deltaY];
}
-#else
- /* trying to pretend you have nice scrolls... */
- dx = [event deltaX];
- dy = -[event deltaY];
- const double deltaMax = 50.0;
-
- if ((dx == 0) && (dy == 0)) break;
-
- /* Quadratic acceleration */
- dx = dx*(fabs(dx) + 0.5);
- if (dx < 0.0) dx -= 0.5;
- else dx += 0.5;
- if (dx < -deltaMax) dx = -deltaMax;
- else if (dx > deltaMax) dx = deltaMax;
-
- dy = dy*(fabs(dy) + 0.5);
- if (dy < 0.0) dy -= 0.5;
- else dy += 0.5;
- if (dy < -deltaMax) dy= -deltaMax;
- else if (dy > deltaMax) dy= deltaMax;
-
- dy = -dy;
-#endif
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventScroll, x, y, dx, dy));
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 9f03b5e9537..b0dae432643 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -941,6 +941,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized");
if (hwnd) {
+#if 0
+ // Disabled due to bug in Intel drivers, see T51959
if(msg == WM_NCCREATE) {
// Tell Windows to automatically handle scaling of non-client areas
// such as the caption bar. EnableNonClientDpiScaling was introduced in Windows 10
@@ -954,6 +956,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
}
}
+#endif
GHOST_WindowWin32 *window = (GHOST_WindowWin32 *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (window) {
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 30cfac08153..8fff565338f 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1601,26 +1601,6 @@ convertXKey(KeySym key)
}
else if ((key >= XK_F1) && (key <= XK_F24)) {
type = GHOST_TKey(key - XK_F1 + int(GHOST_kKeyF1));
-#if defined(__sun) || defined(__sun__)
- /* This is a bit of a hack, but it looks like sun
- * Used F11 and friends for its special keys Stop,again etc..
- * So this little patch enables F11 and F12 to work as expected
- * following link has documentation on it:
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4734408
- * also from /usr/include/X11/Sunkeysym.h
- * #define SunXK_F36 0x1005FF10 // Labeled F11
- * #define SunXK_F37 0x1005FF11 // Labeled F12
- *
- * mein@cs.umn.edu
- */
-
- }
- else if (key == 268828432) {
- type = GHOST_kKeyF11;
- }
- else if (key == 268828433) {
- type = GHOST_kKeyF12;
-#endif
}
else {
switch (key) {
@@ -1714,19 +1694,6 @@ convertXKey(KeySym key)
GXMAP(type, XF86XK_AudioForward, GHOST_kKeyMediaLast);
#endif
#endif
-
- /* some extra sun cruft (NICE KEYBOARD!) */
-#ifdef __sun__
- GXMAP(type, 0xffde, GHOST_kKeyNumpad1);
- GXMAP(type, 0xffe0, GHOST_kKeyNumpad3);
- GXMAP(type, 0xffdc, GHOST_kKeyNumpad5);
- GXMAP(type, 0xffd8, GHOST_kKeyNumpad7);
- GXMAP(type, 0xffda, GHOST_kKeyNumpad9);
-
- GXMAP(type, 0xffd6, GHOST_kKeyNumpadSlash);
- GXMAP(type, 0xffd7, GHOST_kKeyNumpadAsterisk);
-#endif
-
default:
type = GHOST_kKeyUnknown;
break;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 5168c48ca2f..9dbc85d91e2 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -303,8 +303,6 @@ protected:
GHOST_TabletData m_tablet;
- bool m_lionStyleFullScreen;
-
bool m_immediateDraw;
bool m_debug_context; // for debug messages during context setup
};
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index b0feb11a6af..309c19f92af 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -43,14 +43,6 @@
#include <sys/sysctl.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-/* Lion style fullscreen support when building with the 10.6 SDK */
-enum {
- NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
- NSFullScreenWindowMask = 1 << 14
-};
-#endif
-
#pragma mark Cocoa window delegate object
@interface CocoaWindowDelegate : NSObject
@@ -511,14 +503,6 @@ enum {
#pragma mark initialization / finalization
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-@interface NSView (NSOpenGLSurfaceResolution)
-- (BOOL)wantsBestResolutionOpenGLSurface;
-- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag;
-- (NSRect)convertRectToBacking:(NSRect)bounds;
-@end
-#endif
-
GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_SystemCocoa *systemCocoa,
const STR_String& title,
@@ -537,7 +521,6 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
m_systemCocoa = systemCocoa;
m_fullScreen = false;
m_immediateDraw = false;
- m_lionStyleFullScreen = false;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -613,16 +596,6 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
if (state == GHOST_kWindowStateFullScreen)
setState(GHOST_kWindowStateFullScreen);
- // Starting with 10.9 (darwin 13.x.x), we can use Lion fullscreen,
- // since it now has better multi-monitor support
- // if the screens are spawned, additional screens get useless,
- // so we only use lionStyleFullScreen when screens have separate spaces
-
- if ([NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && [NSScreen screensHaveSeparateSpaces]) {
- // implies we are on >= OSX 10.9
- m_lionStyleFullScreen = true;
- }
-
[pool drain];
}
@@ -760,28 +733,18 @@ void GHOST_WindowCocoa::getClientBounds(GHOST_Rect& bounds) const
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (!m_fullScreen) {
- NSRect screenSize = [[m_window screen] visibleFrame];
+ NSRect screenSize = [[m_window screen] visibleFrame];
- //Max window contents as screen size (excluding title bar...)
- NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
+ //Max window contents as screen size (excluding title bar...)
+ NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
- rect = [m_window contentRectForFrameRect:[m_window frame]];
-
- bounds.m_b = contentRect.size.height - (rect.origin.y -contentRect.origin.y);
- bounds.m_l = rect.origin.x -contentRect.origin.x;
- bounds.m_r = rect.origin.x-contentRect.origin.x + rect.size.width;
- bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height -contentRect.origin.y);
- }
- else {
- NSRect screenSize = [[m_window screen] frame];
-
- bounds.m_b = screenSize.origin.y + screenSize.size.height;
- bounds.m_l = screenSize.origin.x;
- bounds.m_r = screenSize.origin.x + screenSize.size.width;
- bounds.m_t = screenSize.origin.y;
- }
+ rect = [m_window contentRectForFrameRect:[m_window frame]];
+
+ bounds.m_b = contentRect.size.height - (rect.origin.y -contentRect.origin.y);
+ bounds.m_l = rect.origin.x -contentRect.origin.x;
+ bounds.m_r = rect.origin.x-contentRect.origin.x + rect.size.width;
+ bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height -contentRect.origin.y);
[pool drain];
}
@@ -856,9 +819,6 @@ GHOST_TWindowState GHOST_WindowCocoa::getState() const
state = GHOST_kWindowStateNormal;
}
}
- else if (m_fullScreen) {
- state = GHOST_kWindowStateFullScreen;
- }
else if ([m_window isMiniaturized]) {
state = GHOST_kWindowStateMinimized;
}
@@ -940,15 +900,12 @@ NSScreen* GHOST_WindowCocoa::getScreen()
/* called for event, when window leaves monitor to another */
void GHOST_WindowCocoa::setNativePixelSize(void)
{
- /* make sure 10.6 keeps running */
- if ([m_openGLView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
- NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
-
- GHOST_Rect rect;
- getClientBounds(rect);
+ NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
+
+ GHOST_Rect rect;
+ getClientBounds(rect);
- m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
- }
+ m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
}
/**
@@ -973,35 +930,8 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
{
NSUInteger masks = [m_window styleMask];
- if (!m_fullScreen && !(masks & NSFullScreenWindowMask)) {
- if (m_lionStyleFullScreen) {
- [m_window toggleFullScreen:nil];
- break;
- }
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- /* This status change needs to be done before Cocoa call to enter fullscreen mode
- * to give window delegate hint not to forward its deactivation to ghost wm that
- * doesn't know view/window difference. */
- m_fullScreen = true;
-
- /* Disable toggle for Lion style fullscreen */
- [m_window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
-
- //10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
- //Hide menu & dock if on primary screen. else only menu
- if ([[m_window screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
- [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
- }
- //Make window borderless and enlarge it
- [m_window setStyleMask:NSBorderlessWindowMask];
- [m_window setFrame:[[m_window screen] frame] display:YES];
- [m_window makeFirstResponder:m_openGLView];
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
-
- [pool drain];
+ if (!(masks & NSFullScreenWindowMask)) {
+ [m_window toggleFullScreen:nil];
}
break;
}
@@ -1014,26 +944,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
// Lion style fullscreen
[m_window toggleFullScreen:nil];
}
- else if (m_fullScreen) {
- m_fullScreen = false;
-
- /* Enable toggle for into Lion style fullscreen */
- [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
-
- //Exit fullscreen
- //Show again menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]]) {
- [NSApp setPresentationOptions:NSApplicationPresentationDefault];
- }
- //Make window normal and resize it
- [m_window setStyleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
- [m_window setFrame:[[m_window screen] visibleFrame] display:YES];
- //TODO for 10.6 only : window title is forgotten after the style change
- [m_window makeFirstResponder:m_openGLView];
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
- }
else if ([m_window isMiniaturized])
[m_window deminiaturize:nil];
else if ([m_window isZoomed])
@@ -1164,7 +1074,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress)
return GHOST_kSuccess;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
static void postNotification()
{
NSUserNotification *notification = [[NSUserNotification alloc] init];
@@ -1174,7 +1083,6 @@ static void postNotification()
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
[notification release];
}
-#endif
GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
{
@@ -1189,15 +1097,13 @@ GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
[dockIcon unlockFocus];
[NSApp setApplicationIconImage:dockIcon];
-
- // With OSX 10.8 and later, we can use notifications to inform the user when the progress reached 100%
- // Atm. just fire this when the progressbar ends, the behavior is controlled in the NotificationCenter
- // If Blender is not frontmost window, a message pops up with sound, in any case an entry in notifications
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+ // We use notifications to inform the user when the progress reached 100%
+ // Atm. just fire this when the progressbar ends, the behavior is controlled
+ // in the NotificationCenter If Blender is not frontmost window, a message
+ // pops up with sound, in any case an entry in notifications
if ([NSUserNotificationCenter respondsToSelector:@selector(defaultUserNotificationCenter)]) {
postNotification();
}
-#endif
[dockIcon release];
@@ -1311,9 +1217,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
//Make window key if it wasn't to get the mouse move events
[m_window makeKeyWindow];
- //Dissociate cursor position even for warp mode, to allow mouse acceleration to work even when warping the cursor
- err = CGAssociateMouseAndMouseCursorPosition(false) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
-
[pool drain];
}
}
@@ -1323,7 +1226,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
setWindowCursorVisibility(true);
}
- err = CGAssociateMouseAndMouseCursorPosition(true) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
/* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 2a141f8770c..ee0d7ef460c 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -402,21 +402,29 @@ void GHOST_WindowWin32::getClientBounds(GHOST_Rect &bounds) const
{
RECT rect;
POINT coord;
- ::GetClientRect(m_hWnd, &rect);
+ if (!IsIconic(m_hWnd)) {
+ ::GetClientRect(m_hWnd, &rect);
- coord.x = rect.left;
- coord.y = rect.top;
- ::ClientToScreen(m_hWnd, &coord);
+ coord.x = rect.left;
+ coord.y = rect.top;
+ ::ClientToScreen(m_hWnd, &coord);
- bounds.m_l = coord.x;
- bounds.m_t = coord.y;
+ bounds.m_l = coord.x;
+ bounds.m_t = coord.y;
- coord.x = rect.right;
- coord.y = rect.bottom;
- ::ClientToScreen(m_hWnd, &coord);
+ coord.x = rect.right;
+ coord.y = rect.bottom;
+ ::ClientToScreen(m_hWnd, &coord);
- bounds.m_r = coord.x;
- bounds.m_b = coord.y;
+ bounds.m_r = coord.x;
+ bounds.m_b = coord.y;
+ }
+ else {
+ bounds.m_b = 0;
+ bounds.m_l = 0;
+ bounds.m_r = 0;
+ bounds.m_t = 0;
+ }
}
@@ -611,54 +619,48 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
-
- // During development:
- // ask for 2.1 context, driver gives latest compatibility profile
- // (we check later to ensure it's >= 3.3 on Windows)
- //
- // Final Blender 2.8:
- // try 4.x core profile
- // try 3.3 core profile
- // no fallbacks
-
- // TODO(merwin): query version of initial dummy context, request that + profile + debug
-
GHOST_Context *context;
#if defined(WITH_GL_PROFILE_CORE)
- // our minimum requirement is 3.3 core profile
- // when we request a specific GL version:
- // - AMD and Intel give us exactly this version
- // - NVIDIA gives at least this version <-- desired behavior
- // so we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system
- for (int minor = 5; minor >= 0; --minor) {
+ GHOST_TUns8 major, minor;
+
+ if (GHOST_ContextWGL::getMaximumSupportedOpenGLVersion(
+ m_hWnd,
+ m_wantStereoVisual,
+ m_wantAlphaBackground,
+ m_wantNumOfAASamples,
+ WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ m_debug_context,
+ &major, &minor))
+ {
context = new GHOST_ContextWGL(
- m_wantStereoVisual,
- m_wantAlphaBackground,
- m_wantNumOfAASamples,
- m_hWnd,
- m_hDC,
- WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- 4, minor,
- (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
- GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
-
- if (context->initializeDrawingContext())
+ m_wantStereoVisual,
+ m_wantAlphaBackground,
+ m_wantNumOfAASamples,
+ m_hWnd,
+ m_hDC,
+ WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ major, minor,
+ (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+ GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
+
+ if (context->initializeDrawingContext()) {
return context;
- else
+ }
+ else {
delete context;
+ }
+ }
+ else {
+ MessageBox(
+ m_hWnd,
+ "Blender requires a graphics driver with at least OpenGL 3.3 support.\n\n"
+ "The program will now close.",
+ "Blender - Unsupported Graphics Driver!",
+ MB_OK | MB_ICONERROR);
+ exit(0);
+ return NULL;
}
-
- context = new GHOST_ContextWGL(
- m_wantStereoVisual,
- m_wantAlphaBackground,
- m_wantNumOfAASamples,
- m_hWnd,
- m_hDC,
- WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- 3, 3,
- (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
- GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
// ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
@@ -677,10 +679,12 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
# error // must specify either core or compat at build time
#endif
- if (context->initializeDrawingContext())
+ if (context->initializeDrawingContext()) {
return context;
- else
+ }
+ else {
delete context;
+ }
}
return NULL;
@@ -865,19 +869,14 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam)
if (fpWTPacket) {
if (fpWTPacket((HCTX)lParam, wParam, &pkt)) {
if (m_tabletData) {
- switch (pkt.pkCursor) {
- case 0: /* first device */
- case 3: /* second device */
+ switch (pkt.pkCursor % 3) { /* % 3 for multiple devices ("DualTrack") */
+ case 0:
m_tabletData->Active = GHOST_kTabletModeNone; /* puck - not yet supported */
break;
case 1:
- case 4:
- case 7:
m_tabletData->Active = GHOST_kTabletModeStylus; /* stylus */
break;
case 2:
- case 5:
- case 8:
m_tabletData->Active = GHOST_kTabletModeEraser; /* eraser */
break;
}
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 450fe568814..c48e969baf3 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -59,10 +59,6 @@
//For DPI value
#include <X11/Xresource.h>
-#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX)
-# include <strings.h>
-#endif
-
#include <cstring>
#include <cstdio>
@@ -1356,7 +1352,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
m_wantNumOfAASamples,
m_window,
m_display,
- m_visualInfo,
(GLXFBConfig)m_fbconfig,
profile_mask,
4, minor,
@@ -1374,7 +1369,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
m_wantNumOfAASamples,
m_window,
m_display,
- m_visualInfo,
(GLXFBConfig)m_fbconfig,
profile_mask,
3, 3,