diff options
Diffstat (limited to 'indra/llwindow')
| -rw-r--r-- | indra/llwindow/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | indra/llwindow/lldxhardware.cpp | 4 | ||||
| -rw-r--r-- | indra/llwindow/llopenglview-objc.h | 17 | ||||
| -rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 232 | ||||
| -rw-r--r-- | indra/llwindow/llwindow.h | 1 | ||||
| -rw-r--r-- | indra/llwindow/llwindowmacosx-objc.h | 7 | ||||
| -rw-r--r-- | indra/llwindow/llwindowmacosx-objc.mm | 81 | ||||
| -rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 29 | ||||
| -rw-r--r-- | indra/llwindow/llwindowmacosx.h | 3 | ||||
| -rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 44 | 
10 files changed, 169 insertions, 252 deletions
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 6debd54665..69f11991ea 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -108,7 +108,7 @@ if (DARWIN)        llkeyboardmacosx.cpp        llwindowmacosx.cpp        PROPERTIES -      COMPILE_FLAGS "-Wno-deprecated-declarations -fpascal-strings" +      COMPILE_FLAGS "-fpascal-strings"        )  endif (DARWIN) @@ -183,7 +183,6 @@ endif (SDL_FOUND)    target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})  if (DARWIN) -  find_library(CARBON_LIBRARY Carbon)    target_link_libraries(llwindow ${CARBON_LIBRARY})  endif (DARWIN) diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index 387982dfc2..ff85b2cb14 100644 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -312,7 +312,7 @@ std::string get_string(IDxDiagContainer *containerp, const WCHAR *wszPropName)      WCHAR wszPropValue[256];      get_wstring(containerp, wszPropName, wszPropValue, 256); -    return utf16str_to_utf8str(wszPropValue); +    return ll_convert<std::string>(std::wstring(wszPropValue));  }  LLDXHardware::LLDXHardware() @@ -440,7 +440,7 @@ LLSD LLDXHardware::getDisplayInfo()                      // print the value                      // windows doesn't guarantee to be null terminated                      release_version[RV_SIZE - 1] = NULL; -                    ret["DriverVersion"] = utf16str_to_utf8str(release_version); +                    ret["DriverVersion"] = ll_convert<std::string>(std::wstring(release_version));                  }                  RegCloseKey(hKey); diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 249c997340..a2c55a2dd9 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -42,7 +42,6 @@      unsigned int mMarkedTextLength;      bool mMarkedTextAllowed;      bool mSimulatedRightClick; -    bool mOldResize;      NSOpenGLPixelFormat *pixelFormat;      NSOpenGLContext *glContext; @@ -55,8 +54,6 @@  - (void)commitCurrentPreedit; -- (void) setOldResize:(bool)oldresize; -  // rebuildContext  // Destroys and recreates a context with the view's internal format set via setPixelFormat;  // Use this in event of needing to rebuild a context for whatever reason, without needing to assign a new pixel format. @@ -73,7 +70,6 @@  - (unsigned long) getVramSize;  - (void) allowMarkedTextInput:(bool)allowed; -- (void) viewDidEndLiveResize;  @end @@ -93,9 +89,6 @@  @interface LLNSWindow : NSWindow -- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view; -- (NSPoint)flipPoint:(NSPoint)aPoint; -  @end  @interface NSScreen (PointConversion) @@ -105,16 +98,6 @@   */  + (NSScreen *)currentScreenForMouseLocation; -/* - Allows you to convert a point from global coordinates to the current screen coordinates. - */ -- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint; - -/* - Allows to flip the point coordinates, so y is 0 at the top instead of the bottom. x remains the same - */ -- (NSPoint)flipPoint:(NSPoint)aPoint; -  @end  #endif diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 109c1d9b15..57b1252cf1 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -28,6 +28,8 @@  #import "llwindowmacosx-objc.h"  #import "llappdelegate-objc.h" +#import <Carbon/Carbon.h> +  extern BOOL gHiDPISupport;  extern BOOL gHDRDisplaySupport; @@ -65,16 +67,16 @@ attributedStringInfo getSegments(NSAttributedString *str)      segment_standouts seg_standouts;      NSRange effectiveRange;      NSRange limitRange = NSMakeRange(0, [str length]); -     +      while (limitRange.length > 0) {          NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];          limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange)); -         +          if (effectiveRange.length <= 0)          {              effectiveRange.length = 1;          } -         +          if ([attr integerValue] == 2)          {              seg_lengths.push_back(effectiveRange.length); @@ -97,27 +99,13 @@ attributedStringInfo getSegments(NSAttributedString *str)  + (NSScreen *)currentScreenForMouseLocation  {      NSPoint mouseLocation = [NSEvent mouseLocation]; -     +      NSEnumerator *screenEnumerator = [[NSScreen screens] objectEnumerator];      NSScreen *screen;      while ((screen = [screenEnumerator nextObject]) && !NSMouseInRect(mouseLocation, screen.frame, NO))          ; -     -    return screen; -} - - -- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint -{ -    float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x)); -    float normalizedY = aPoint.y - self.frame.origin.y; -     -    return NSMakePoint(normalizedX, normalizedY); -} -- (NSPoint)flipPoint:(NSPoint)aPoint -{ -    return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y); +    return screen;  }  @end @@ -134,16 +122,6 @@ attributedStringInfo getSegments(NSAttributedString *str)      return pixelFormat;  } -// Force a high quality update after live resizing -- (void) viewDidEndLiveResize -{ -    if (mOldResize)  //Maint-3135 -    { -        NSSize size = [self frame].size; -        callResize(size.width, size.height); -    } -} -  - (unsigned long)getVramSize  {      CGLRendererInfoObj info = 0; @@ -164,7 +142,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      {          vram_megabytes = 256;      } -     +  	return (unsigned long)vram_megabytes; // return value is in megabytes.  } @@ -189,15 +167,15 @@ attributedStringInfo getSegments(NSAttributedString *str)  	[[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowResized:) name:NSWindowDidResizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification  											   object:[self window]]; @@ -214,18 +192,10 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } -- (void)setOldResize:(bool)oldresize -{ -    mOldResize = oldresize; -} -  - (void)windowResized:(NSNotification *)notification;  { -    if (!mOldResize)  //Maint-3288 -    { -        NSSize dev_sz = gHiDPISupport ? [self convertSizeToBacking:[self frame].size] : [self frame].size; -        callResize(dev_sz.width, dev_sz.height); -    } +    NSSize dev_sz = [self convertSizeToBacking:[self frame].size]; +    callResize(dev_sz.width, dev_sz.height);  }  - (void)windowWillMiniaturize:(NSNotification *)notification; @@ -269,11 +239,17 @@ attributedStringInfo getSegments(NSAttributedString *str)  	return [self initWithFrame:[self bounds] withSamples:samples andVsync:vsync];  } +#if LL_DARWIN +// For setView and opengl deprecation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  - (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOOL)vsync  { -	[self registerForDraggedTypes:[NSArray arrayWithObject:NSURLPboardType]]; +    [self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeURL]];  	[self initWithFrame:frame]; -	 +  	// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.  	// Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat.  	// 10.7 and 10.8 don't really care if we're defining a profile or not.  If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons). @@ -291,8 +267,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  		NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,  		0      }; -	 -	 +      NSOpenGLPixelFormatAttribute HDRAttrs[] = {          NSOpenGLPFANoRecovery,          NSOpenGLPFADoubleBuffer, @@ -335,15 +310,15 @@ attributedStringInfo getSegments(NSAttributedString *str)  		NSLog(@"Failed to create pixel format!", nil);  		return nil;  	} -	 -	 +  	glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; +  	if (glContext == nil)  	{  		NSLog(@"Failed to create OpenGL context!", nil);  		return nil;  	} -	 +  	[self setPixelFormat:pixelFormat];      if(mHDRDisplay) @@ -363,28 +338,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  	[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];  	[self setOpenGLContext:glContext]; -	 +  	[glContext setView:self]; -	 +  	[glContext makeCurrentContext]; -	 +  	if (vsync)  	{  		GLint value = 1; -		[glContext setValues:&value forParameter:NSOpenGLCPSwapInterval]; +        [glContext setValues:&value forParameter:NSOpenGLContextParameterSwapInterval];  	} else {  		// supress this error after move to Xcode 7:  		// error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]  		// Tried using ObjC 'nonnull' keyword as per SO article but didn't build  		GLint swapInterval=0; -		[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; +        [glContext setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];  	} -	 +      GLint opacity = 1;      [glContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity]; -    mOldResize = false; -      	return self;  } @@ -396,22 +369,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (BOOL) rebuildContextWithFormat:(NSOpenGLPixelFormat *)format  {  	NSOpenGLContext *ctx = [self openGLContext]; -	 +  	[ctx clearDrawable];  	[ctx initWithFormat:format shareContext:nil]; -	 +  	if (ctx == nil)  	{  		NSLog(@"Failed to create OpenGL context!", nil);  		return false;  	} -	 +  	[self setOpenGLContext:ctx];  	[ctx setView:self];  	[ctx makeCurrentContext];  	return true;  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  - (CGLContextObj)getCGLContextObj  {  	NSOpenGLContext *ctx = [self openGLContext]; @@ -429,18 +406,14 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) mouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y; -      // Apparently people still use this? -    if ([theEvent modifierFlags] & NSCommandKeyMask && -        !([theEvent modifierFlags] & NSControlKeyMask) && -        !([theEvent modifierFlags] & NSShiftKeyMask) && -        !([theEvent modifierFlags] & NSAlternateKeyMask) && -        !([theEvent modifierFlags] & NSAlphaShiftKeyMask) && -        !([theEvent modifierFlags] & NSFunctionKeyMask) && -        !([theEvent modifierFlags] & NSHelpKeyMask)) +    if ([theEvent modifierFlags] & NSEventModifierFlagCommand && +        !([theEvent modifierFlags] & NSEventModifierFlagControl) && +        !([theEvent modifierFlags] & NSEventModifierFlagShift) && +        !([theEvent modifierFlags] & NSEventModifierFlagOption) && +        !([theEvent modifierFlags] & NSEventModifierFlagCapsLock) && +        !([theEvent modifierFlags] & NSEventModifierFlagFunction) && +        !([theEvent modifierFlags] & NSEventModifierFlagHelp))      {          callRightMouseDown(mMousePos, [theEvent modifierFlags]);          mSimulatedRightClick = true; @@ -461,7 +434,7 @@ attributedStringInfo getSegments(NSAttributedString *str)          callRightMouseUp(mMousePos, [theEvent modifierFlags]);          mSimulatedRightClick = false;      } else { -        NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; +        NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];          mMousePos[0] = mPoint.x;          mMousePos[1] = mPoint.y;          callLeftMouseUp(mMousePos, [theEvent modifierFlags]); @@ -470,32 +443,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) rightMouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;  	callRightMouseDown(mMousePos, [theEvent modifierFlags]);  }  - (void) rightMouseUp:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;  	callRightMouseUp(mMousePos, [theEvent modifierFlags]);  }  - (void)mouseMoved:(NSEvent *)theEvent  { -    NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); +    NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];  	float mouseDeltas[] = {  		float(dev_delta.x),  		float(dev_delta.y)  	}; -	 +  	callDeltaUpdate(mouseDeltas, 0); -	 -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; + +    NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];  	mMousePos[0] = mPoint.x;  	mMousePos[1] = mPoint.y;  	callMouseMoved(mMousePos, 0); @@ -510,16 +477,16 @@ attributedStringInfo getSegments(NSAttributedString *str)  	// The old CoreGraphics APIs we previously relied on are now flagged as obsolete.  	// NSEvent isn't obsolete, and provides us with the correct deltas. -    NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); +    NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];  	float mouseDeltas[] = {  		float(dev_delta.x),  		float(dev_delta.y)  	}; -	 +  	callDeltaUpdate(mouseDeltas, 0); -	 -	NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; + +	NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];  	mMousePos[0] = mPoint.x;  	mMousePos[1] = mPoint.y;  	callMouseDragged(mMousePos, 0); @@ -527,17 +494,11 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) otherMouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;      callOtherMouseDown(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);  }  - (void) otherMouseUp:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;      callOtherMouseUp(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);  } @@ -548,7 +509,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) otherMouseDragged:(NSEvent *)theEvent  { -	[self mouseDragged:theEvent];         +	[self mouseDragged:theEvent];  }  - (void) scrollWheel:(NSEvent *)theEvent @@ -572,7 +533,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  {      NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);      eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; -    +      uint keycode = [theEvent keyCode];      // We must not depend on flagsChange event to detect modifier flags changed,      // must depend on the modifire flags in the event parameter. @@ -590,7 +551,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      if (acceptsText &&          !mMarkedTextAllowed && -        !(mModifiers & (NSControlKeyMask | NSCommandKeyMask)) &&  // commands don't invoke InputWindow +        !(mModifiers & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) &&  // commands don't invoke InputWindow          ![(LLAppDelegate*)[NSApp delegate] romanScript] &&          ch > ' ' &&          ch != NSDeleteCharacter && @@ -606,26 +567,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void)flagsChanged:(NSEvent *)theEvent  {      NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent); -  +  	mModifiers = [theEvent modifierFlags];  	callModifier([theEvent modifierFlags]); -      +      NSInteger mask = 0;      switch([theEvent keyCode]) -    {         -        case 56: -            mask = NSShiftKeyMask; +    { +        case kVK_Shift: +            mask = NSEventModifierFlagShift;              break; -        case 58: -            mask = NSAlternateKeyMask; +        case kVK_Option: +            mask = NSEventModifierFlagOption;              break; -        case 59: -            mask = NSControlKeyMask; +        case kVK_Control: +            mask = NSEventModifierFlagControl;              break;          default: -            return;             +            return;      } -     +      if (mModifiers & mask)      {          eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; @@ -644,7 +605,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      {          eventData.mKeyEvent = NativeKeyEventData::KEYUP;          callKeyUp(&eventData, [theEvent keyCode], 0); -    }   +    }  }  - (BOOL) acceptsFirstResponder @@ -656,12 +617,12 @@ attributedStringInfo getSegments(NSAttributedString *str)  {  	NSPasteboard *pboard;      NSDragOperation sourceDragMask; -	 +  	sourceDragMask = [sender draggingSourceOperationMask]; -	 +  	pboard = [sender draggingPasteboard]; -	 -	if ([[pboard types] containsObject:NSURLPboardType]) + +    if ([[pboard types] containsObject:NSPasteboardTypeURL])  	{  		if (sourceDragMask & NSDragOperationLink) {  			NSURL *fileUrl = [[pboard readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]] options:[NSDictionary dictionary]] objectAtIndex:0]; @@ -675,7 +636,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender  {  	callHandleDragUpdated(mLastDraggedUrl); -	 +  	return NSDragOperationLink;  } @@ -729,12 +690,12 @@ attributedStringInfo getSegments(NSAttributedString *str)              unsigned(selectedRange.location),              unsigned(selectedRange.length)          }; -         +          unsigned int replacement[2] = {              unsigned(replacementRange.location),              unsigned(replacementRange.length)          }; -         +          int string_length = [aString length];          unichar *text = new unichar[string_length];          attributedStringInfo segments; @@ -774,6 +735,12 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } +#if LL_DARWIN +// For commitEditing deprecation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  - (void)commitCurrentPreedit  {      if (mHasMarkedText) @@ -785,6 +752,10 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  - (void)unmarkText  {  	[[self inputContext] discardMarkedText]; @@ -835,7 +806,7 @@ attributedStringInfo getSegments(NSAttributedString *str)              return;          }  	} -     +      @try      {          if (!mHasMarkedText) @@ -848,7 +819,7 @@ attributedStringInfo getSegments(NSAttributedString *str)              resetPreedit();              // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.              // But just in case... -             +              for (NSInteger i = 0; i < [aString length]; i++)              {                  handleUnicodeCharacter([aString characterAtIndex:i]); @@ -864,9 +835,9 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) insertNewline:(id)sender  { -	if (!(mModifiers & NSCommandKeyMask) && -		!(mModifiers & NSShiftKeyMask) && -		!(mModifiers & NSAlternateKeyMask)) +    if (!(mModifiers & NSEventModifierFlagCommand) && +        !(mModifiers & NSEventModifierFlagShift) && +        !(mModifiers & NSEventModifierFlagOption))  	{  		callUnicodeCallback(13, 0);  	} else { @@ -985,27 +956,6 @@ attributedStringInfo getSegments(NSAttributedString *str)  	return self;  } -- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view -{ -	NSScreen *currentScreen = [NSScreen currentScreenForMouseLocation]; -	if(currentScreen) -	{ -		NSPoint windowPoint = [view convertPoint:point toView:nil]; -		NSPoint screenPoint = [[view window] convertBaseToScreen:windowPoint]; -		NSPoint flippedScreenPoint = [currentScreen flipPoint:screenPoint]; -		flippedScreenPoint.y += [currentScreen frame].origin.y; -		 -		return flippedScreenPoint; -	} -	 -	return NSZeroPoint; -} - -- (NSPoint)flipPoint:(NSPoint)aPoint -{ -    return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y); -} -  - (BOOL) becomeFirstResponder  {  	callFocus(); diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 0514f63830..8f8ea7fdb6 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -147,7 +147,6 @@ public:      virtual void swapBuffers() = 0;      virtual void bringToFront() = 0;      virtual void focusClient() { };     // this may not have meaning or be required on other platforms, therefore, it's not abstract -    virtual void setOldResize(bool oldresize) { };      // handy coordinate space conversion routines      // NB: screen to window and vice verse won't work on width/height coordinate pairs,      // as the conversion must take into account left AND right border widths, etc. diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index d9d8bfce1f..b302a705da 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -100,7 +100,6 @@ bool isCGCursorVisible();  void hideNSCursorTillMove(bool hide);  void requestUserAttention();  long showAlert(std::string title, std::string text, int type); -void setResizeMode(bool oldresize, void* glview);  NSWindowRef createNSWindow(int x, int y, int width, int height); @@ -111,16 +110,14 @@ void glSwapBuffers(void* context);  CGLContextObj getCGLContextObj(GLViewRef view);  unsigned long getVramSize(GLViewRef view);  float getDeviceUnitSize(GLViewRef view); -CGPoint getContentViewBoundsPosition(NSWindowRef window); -CGSize getContentViewBoundsSize(NSWindowRef window); -CGSize getDeviceContentViewSize(NSWindowRef window, GLViewRef view); +CGRect getContentViewRect(NSWindowRef window); +CGRect getBackingViewRect(NSWindowRef window, GLViewRef view);  void getWindowSize(NSWindowRef window, float* size);  void setWindowSize(NSWindowRef window, int width, int height);  void getCursorPos(NSWindowRef window, float* pos);  void makeWindowOrderFront(NSWindowRef window);  void convertScreenToWindow(NSWindowRef window, float *coord);  void convertWindowToScreen(NSWindowRef window, float *coord); -void convertScreenToView(NSWindowRef window, float *coord);  void convertRectToScreen(NSWindowRef window, float *coord);  void convertRectFromScreen(NSWindowRef window, float *coord);  void setWindowPos(NSWindowRef window, float* pos); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 2e75d309ea..42cd95be5d 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -162,11 +162,21 @@ void showNSCursor()  	[NSCursor unhide];  } +#if LL_DARWIN +// For CGCursorIsVisible no replacement in modern API +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  bool isCGCursorVisible()  {      return CGCursorIsVisible();  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  void hideNSCursorTillMove(bool hide)  {  	[NSCursor setHiddenUntilMouseMoves:hide]; @@ -213,7 +223,8 @@ OSErr setImageCursor(CursorRef ref)  NSWindowRef createNSWindow(int x, int y, int width, int height)  {  	LLNSWindow *window = [[LLNSWindow alloc]initWithContentRect:NSMakeRect(x, y, width, height) -													  styleMask:NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTexturedBackgroundWindowMask backing:NSBackingStoreBuffered defer:NO]; +                                                      styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable +                                                        backing:NSBackingStoreBuffered defer:NO];  	[window makeKeyAndOrderFront:nil];  	[window setAcceptsMouseMovedEvents:TRUE];      [window setRestorable:FALSE]; // Viewer manages state from own settings @@ -227,11 +238,6 @@ GLViewRef createOpenGLView(NSWindowRef window, unsigned int samples, bool vsync)  	return glview;  } -void setResizeMode(bool oldresize, void* glview) -{ -    [(LLOpenGLView *)glview setOldResize:oldresize]; -} -  void glSwapBuffers(void* context)  {  	[(NSOpenGLContext*)context flushBuffer]; @@ -258,19 +264,14 @@ float getDeviceUnitSize(GLViewRef view)  	return [(LLOpenGLView*)view convertSizeToBacking:NSMakeSize(1, 1)].width;  } -CGPoint getContentViewBoundsPosition(NSWindowRef window) +CGRect getContentViewRect(NSWindowRef window)  { -	return [[(LLNSWindow*)window contentView] bounds].origin; +    return [[(LLNSWindow*)window contentView] bounds];  } -CGSize getContentViewBoundsSize(NSWindowRef window) +CGRect getBackingViewRect(NSWindowRef window, GLViewRef view)  { -	return [[(LLNSWindow*)window contentView] bounds].size; -} - -CGSize getDeviceContentViewSize(NSWindowRef window, GLViewRef view) -{ -    return [(NSOpenGLView*)view convertRectToBacking:[[(LLNSWindow*)window contentView] bounds]].size; +    return [(NSOpenGLView*)view convertRectToBacking:[[(LLNSWindow*)window contentView] bounds]];  }  void getWindowSize(NSWindowRef window, float* size) @@ -313,9 +314,7 @@ void makeWindowOrderFront(NSWindowRef window)  void convertScreenToWindow(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; +    NSRect point = NSMakeRect(coord[0], coord[1], 0,0);  	point = [(LLNSWindow*)window convertRectFromScreen:point];  	coord[0] = point.origin.x;  	coord[1] = point.origin.y; @@ -323,28 +322,18 @@ void convertScreenToWindow(NSWindowRef window, float *coord)  void convertRectToScreen(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.size.width = coord[2]; -	point.size.height = coord[3]; -	 -	point = [(LLNSWindow*)window convertRectToScreen:point]; -	 -	coord[0] = point.origin.x; -	coord[1] = point.origin.y; -	coord[2] = point.size.width; -	coord[3] = point.size.height; +    NSRect rect = NSMakeRect(coord[0], coord[1], coord[2], coord[3]);; +    rect = [(LLNSWindow*)window convertRectToScreen:rect]; + +	coord[0] = rect.origin.x; +	coord[1] = rect.origin.y; +	coord[2] = rect.size.width; +	coord[3] = rect.size.height;  }  void convertRectFromScreen(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.size.width = coord[2]; -	point.size.height = coord[3]; -	 +	NSRect point = NSMakeRect(coord[0], coord[1], coord[2], coord[3]);  	point = [(LLNSWindow*)window convertRectFromScreen:point];  	coord[0] = point.origin.x; @@ -353,23 +342,13 @@ void convertRectFromScreen(NSWindowRef window, float *coord)  	coord[3] = point.size.height;  } -void convertScreenToView(NSWindowRef window, float *coord) -{ -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.origin = [(LLNSWindow*)window convertScreenToBase:point.origin]; -	point.origin = [[(LLNSWindow*)window contentView] convertPoint:point.origin fromView:nil]; -} -  void convertWindowToScreen(NSWindowRef window, float *coord)  { -	NSPoint point; -	point.x = coord[0]; -	point.y = coord[1]; -	point = [(LLNSWindow*)window convertToScreenFromLocalPoint:point relativeToView:[(LLNSWindow*)window contentView]]; -	coord[0] = point.x; -	coord[1] = point.y; +    NSRect rect = NSMakeRect(coord[0], coord[1], 0, 0); +    rect = [(LLNSWindow*)window convertRectToScreen:rect]; + +      coord[0] = rect.origin.x; +    coord[1] = [[NSScreen screens][0] frame].size.height - rect.origin.y;  }  void closeWindow(NSWindowRef window) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 3aca4660f3..3ed935c0f2 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -986,7 +986,7 @@ bool LLWindowMacOSX::getPosition(LLCoordScreen *position)      }      else if(mWindow)      { -        const CGPoint & pos = getContentViewBoundsPosition(mWindow); +        CGPoint pos = getContentViewRect(mWindow).origin;          position->mX = pos.x;          position->mY = pos.y; @@ -1013,7 +1013,7 @@ bool LLWindowMacOSX::getSize(LLCoordScreen *size)      }      else if(mWindow)      { -        const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); +        CGSize sz = getBackingViewRect(mWindow, mGLView).size;          size->mX = sz.width;          size->mY = sz.height; @@ -1039,7 +1039,7 @@ bool LLWindowMacOSX::getSize(LLCoordWindow *size)      }      else if(mWindow)      { -        const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); +        CGSize sz = getBackingViewRect(mWindow, mGLView).size;          size->mX = sz.width;          size->mY = sz.height; @@ -1225,6 +1225,12 @@ void LLWindowMacOSX::setMouseClipping( bool b )      adjustCursorDecouple();  } +#if LL_DARWIN +// For CGSetLocalEventsSuppressionInterval there is no replacement in modern API +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)  {      bool result = false; @@ -1262,6 +1268,10 @@ bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)      return result;  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  bool LLWindowMacOSX::getCursorPosition(LLCoordWindow *position)  {      float cursor_point[2]; @@ -1486,8 +1496,9 @@ bool LLWindowMacOSX::convertCoords(LLCoordScreen from, LLCoordWindow* to)          convertScreenToWindow(mWindow, mouse_point); -        to->mX = mouse_point[0]; -        to->mY = mouse_point[1]; +        float scale_factor = getSystemUISize(); +        to->mX = mouse_point[0] * scale_factor; +        to->mY = mouse_point[1] * scale_factor;          return true;      } @@ -1499,9 +1510,9 @@ bool LLWindowMacOSX::convertCoords(LLCoordWindow from, LLCoordScreen *to)      if(mWindow)      {          float mouse_point[2]; - -        mouse_point[0] = from.mX; -        mouse_point[1] = from.mY; +        float scale_factor = getSystemUISize(); +        mouse_point[0] = from.mX / scale_factor; +        mouse_point[1] = from.mY / scale_factor;          convertWindowToScreen(mWindow, mouse_point); @@ -2638,7 +2649,7 @@ MASK LLWindowMacOSX::modifiersToMask(S16 modifiers)  F32 LLWindowMacOSX::getSystemUISize()  { -    return gHiDPISupport ? ::getDeviceUnitSize(mGLView) : LLWindow::getSystemUISize(); +    return ::getDeviceUnitSize(mGLView);  }  #if LL_OS_DRAGDROP_ENABLED diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 7de1a40d93..110c5756d0 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -174,9 +174,6 @@ protected:      bool    shouldPostQuit() { return mPostQuit; } -    //Satisfy MAINT-3135 and MAINT-3288 with a flag. -    /*virtual */ void setOldResize(bool oldresize) override {setResizeMode(oldresize, mGLView); } -  private:      void restoreGLContext(); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 03cc10e5d6..cfc2038be9 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -812,7 +812,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,      //  }      // SL-12971 dual GPU display -    DISPLAY_DEVICEA display_device; +    DISPLAY_DEVICE display_device;      int             display_index = -1;      DWORD           display_flags = 0; // EDD_GET_DEVICE_INTERFACE_NAME ?      const size_t    display_bytes = sizeof(display_device); @@ -823,23 +823,23 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,          {              // CHAR DeviceName  [ 32] Adapter name              // CHAR DeviceString[128] -            CHAR text[256]; +            WCHAR text[256]; -            size_t name_len = strlen(display_device.DeviceName  ); -            size_t desc_len = strlen(display_device.DeviceString); +            size_t name_len = lstrlen(display_device.DeviceName  ); +            size_t desc_len = lstrlen(display_device.DeviceString); -            const CHAR *name = name_len ? display_device.DeviceName   : "???"; -            const CHAR *desc = desc_len ? display_device.DeviceString : "???"; +            const WCHAR *name = name_len ? display_device.DeviceName   : TEXT("???"); +            const WCHAR *desc = desc_len ? display_device.DeviceString : TEXT("???"); -            sprintf(text, "Display Device %d: %s, %s", display_index, name, desc); -            LL_INFOS("Window") << text << LL_ENDL; +            wsprintf(text, TEXT("Display Device %d: %s, %s"), display_index, name, desc); +            LL_INFOS("Window") << ll_convert<std::string>(std::wstring(text)) << LL_ENDL;          }          ::ZeroMemory(&display_device,display_bytes);          display_device.cb = display_bytes;          display_index++; -    }  while( EnumDisplayDevicesA(NULL, display_index, &display_device, display_flags )); +    }  while( EnumDisplayDevices(NULL, display_index, &display_device, display_flags ));      LL_INFOS("Window") << "Total Display Devices: " << display_index << LL_ENDL; @@ -1698,6 +1698,11 @@ const   S32   max_format  = (S32)num_formats - 1;          return false;      } +    // Setup Tracy gpu context +    { +        LL_PROFILER_GPU_CONTEXT; +    } +      // Disable vertical sync for swap      toggleVSync(enable_vsync); @@ -1729,8 +1734,6 @@ const   S32   max_format  = (S32)num_formats - 1;          swapBuffers();      } -    LL_PROFILER_GPU_CONTEXT; -      return true;  } @@ -1963,7 +1966,7 @@ void LLWindowWin32::setTitle(const std::string title)      // to support non-ascii usernames (and region names?)      mWindowThread->post([=]()          { -            SetWindowTextA(mWindowHandle, title.c_str()); +            SetWindowText(mWindowHandle, ll_convert<std::wstring>(title).c_str());          });  } @@ -3288,7 +3291,7 @@ bool LLWindowWin32::pasteTextFromClipboard(LLWString &dst)                  WCHAR *utf16str = (WCHAR*) GlobalLock(h_data);                  if (utf16str)                  { -                    dst = utf16str_to_wstring(utf16str); +                    dst = ll_convert<LLWString>(std::wstring(utf16str));                      LLWStringUtil::removeWindowsCR(dst);                      GlobalUnlock(h_data);                      success = true; @@ -3313,8 +3316,8 @@ bool LLWindowWin32::copyTextToClipboard(const LLWString& wstr)          // Provide a copy of the data in Unicode format.          LLWString sanitized_string(wstr);          LLWStringUtil::addCRLF(sanitized_string); -        llutf16string out_utf16 = wstring_to_utf16str(sanitized_string); -        const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(WCHAR); +        std::wstring out_utf16 = ll_convert<std::wstring>(sanitized_string); +        const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(wchar_t);          // Memory is allocated and then ownership of it is transfered to the system.          HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16); @@ -3674,7 +3677,7 @@ void LLSplashScreenWin32::showImpl()      ShowWindow(mWindow, SW_SHOW);      // Should set taskbar text without creating a header for the window (caption) -    SetWindowTextA(mWindow, "Second Life"); +    SetWindowText(mWindow, TEXT("Second Life"));  } @@ -3811,8 +3814,7 @@ void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url, bool async)      // reliablly on Vista.      // this is madness.. no, this is.. -    LLWString url_wstring = utf8str_to_wstring( escaped_url ); -    llutf16string url_utf16 = wstring_to_utf16str( url_wstring ); +    std::wstring url_utf16 = ll_convert<std::wstring>(escaped_url);      // let the OS decide what to use to open the URL      SHELLEXECUTEINFO sei = { sizeof( sei ) }; @@ -4100,7 +4102,7 @@ void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont)  U32 LLWindowWin32::fillReconvertString(const LLWString &text,      S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string)  { -    const llutf16string text_utf16 = wstring_to_utf16str(text); +    const std::wstring text_utf16 = ll_convert<std::wstring>(text);      const DWORD required_size = sizeof(RECONVERTSTRING) + (static_cast<DWORD>(text_utf16.length()) + 1) * sizeof(WCHAR);      if (reconvert_string && reconvert_string->dwSize >= required_size)      { @@ -4200,7 +4202,7 @@ void LLWindowWin32::handleCompositionMessage(const U32 indexes)              size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, data, size);              if (size > 0)              { -                result_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); +                result_string = ll_convert_wide_to_wstring(std::wstring(data, size / sizeof(WCHAR)));              }              delete[] data;              needs_update = true; @@ -4217,7 +4219,7 @@ void LLWindowWin32::handleCompositionMessage(const U32 indexes)              if (size > 0)              {                  preedit_string_utf16_length = size / sizeof(WCHAR); -                preedit_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); +                preedit_string = ll_convert_wide_to_wstring(std::wstring(data, size / sizeof(WCHAR)));              }              delete[] data;              needs_update = true;  | 
