summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/CMakeLists.txt1
-rw-r--r--indra/llwindow/llmousehandler.cpp63
-rw-r--r--indra/llwindow/llmousehandler.h21
-rw-r--r--indra/llwindow/llwindow.cpp28
-rw-r--r--indra/llwindow/llwindow.h6
-rw-r--r--indra/llwindow/llwindowmacosx.cpp21
-rw-r--r--indra/llwindow/llwindowsdl.cpp79
-rw-r--r--indra/llwindow/llwindowsdl.h6
8 files changed, 203 insertions, 22 deletions
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt
index 95e315f38e..afce0c06c3 100644
--- a/indra/llwindow/CMakeLists.txt
+++ b/indra/llwindow/CMakeLists.txt
@@ -46,6 +46,7 @@ set(llwindows_HEADER_FILES
set(viewer_SOURCE_FILES
llwindow.cpp
+ llmousehandler.cpp
)
set(viewer_HEADER_FILES
diff --git a/indra/llwindow/llmousehandler.cpp b/indra/llwindow/llmousehandler.cpp
new file mode 100644
index 0000000000..daf39f8d83
--- /dev/null
+++ b/indra/llwindow/llmousehandler.cpp
@@ -0,0 +1,63 @@
+/**
+ * @file llmousehandler.cpp
+ * @brief LLMouseHandler class implementation
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ *
+ * Copyright (c) 2001-2007, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llmousehandler.h"
+
+//virtual
+BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down)
+{
+ BOOL handled = FALSE;
+ if (down)
+ {
+ switch (clicktype)
+ {
+ case CLICK_LEFT: handled = handleMouseDown(x, y, mask); break;
+ case CLICK_RIGHT: handled = handleRightMouseDown(x, y, mask); break;
+ case CLICK_MIDDLE: handled = handleMiddleMouseDown(x, y, mask); break;
+ case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
+ default:
+ llwarns << "Unhandled enum." << llendl;
+ }
+ }
+ else
+ {
+ switch (clicktype)
+ {
+ case CLICK_LEFT: handled = handleMouseUp(x, y, mask); break;
+ case CLICK_RIGHT: handled = handleRightMouseUp(x, y, mask); break;
+ case CLICK_MIDDLE: handled = handleMiddleMouseUp(x, y, mask); break;
+ case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
+ default:
+ llwarns << "Unhandled enum." << llendl;
+ }
+ }
+ return handled;
+}
diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h
index f3a2edd8a2..7bd0f2eebf 100644
--- a/indra/llwindow/llmousehandler.h
+++ b/indra/llwindow/llmousehandler.h
@@ -33,9 +33,10 @@
#ifndef LL_MOUSEHANDLER_H
#define LL_MOUSEHANDLER_H
-#include "llstring.h"
+#include "linden_common.h"
+#include "llrect.h"
-// Abstract interface.
+// Mostly-abstract interface.
// Intended for use via multiple inheritance.
// A class may have as many interfaces as it likes, but never needs to inherit one more than once.
@@ -49,13 +50,23 @@ public:
SHOW_IF_NOT_BLOCKED,
SHOW_ALWAYS,
} EShowToolTip;
+ typedef enum {
+ CLICK_LEFT,
+ CLICK_MIDDLE,
+ CLICK_RIGHT,
+ CLICK_DOUBLELEFT
+ } EClickType;
+ virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0;
- virtual BOOL handleHover(S32 x, S32 y, MASK mask) = 0;
- virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) = 0;
- virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
+ virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask) = 0;
+ virtual BOOL handleMiddleMouseUp(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask) = 0;
+ virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
+
+ virtual BOOL handleHover(S32 x, S32 y, MASK mask) = 0;
+ virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) = 0;
virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) = 0;
virtual EShowToolTip getShowToolTip() { return SHOW_IF_NOT_BLOCKED; };
virtual const std::string& getName() const = 0;
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index fb4770e847..7e412a14de 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -308,6 +308,28 @@ void *LLWindow::getMediaWindow()
return getPlatformWindow();
}
+//virtual
+void LLWindow::processMiscNativeEvents()
+{
+ // do nothing unless subclassed
+}
+
+//virtual
+BOOL LLWindow::isPrimaryTextAvailable()
+{
+ return FALSE; // no
+}
+//virtual
+BOOL LLWindow::pasteTextFromPrimary(LLWString &dst)
+{
+ return FALSE; // fail
+}
+// virtual
+BOOL LLWindow::copyTextToPrimary(const LLWString &src)
+{
+ return FALSE; // fail
+}
+
// static
std::vector<std::string> LLWindow::getDynamicFallbackFontList()
{
@@ -322,12 +344,6 @@ std::vector<std::string> LLWindow::getDynamicFallbackFontList()
#endif
}
-//virtual
-void LLWindow::processMiscNativeEvents()
-{
- // do nothing unless subclassed
-}
-
#define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400)
#define UTF16_IS_LOW_SURROGATE(U) ((U16)((U) - 0xDC00) < 0x0400)
#define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000)
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 9e01596b81..8361771b66 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -144,9 +144,15 @@ public:
virtual void captureMouse() = 0;
virtual void releaseMouse() = 0;
virtual void setMouseClipping( BOOL b ) = 0;
+
virtual BOOL isClipboardTextAvailable() = 0;
virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
+
+ virtual BOOL isPrimaryTextAvailable();
+ virtual BOOL pasteTextFromPrimary(LLWString &dst);
+ virtual BOOL copyTextToPrimary(const LLWString &src);
+
virtual void flashIcon(F32 seconds) = 0;
virtual F32 getGamma() = 0;
virtual BOOL setGamma(const F32 gamma) = 0; // Set the gamma
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 4f6df0f152..65a40dcef4 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -2527,19 +2527,33 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
}
mCallbacks->handleFocusLost(this);
break;
+
case kEventWindowBoundsChanging:
{
+ // This is where we would constrain move/resize to a particular screen
+
+ const S32 MIN_WIDTH = 320;
+ const S32 MIN_HEIGHT = 240;
+
Rect currentBounds;
Rect previousBounds;
GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &currentBounds);
GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &previousBounds);
- // This is where we would constrain move/resize to a particular screen
- if(0)
+
+ if ((currentBounds.right - currentBounds.left) < MIN_WIDTH)
{
- SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &currentBounds);
+ currentBounds.right = currentBounds.left + MIN_WIDTH;
}
+
+ if ((currentBounds.bottom - currentBounds.top) < MIN_HEIGHT)
+ {
+ currentBounds.bottom = currentBounds.top + MIN_HEIGHT;
+ }
+
+ SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &currentBounds);
+ result = noErr;
}
break;
@@ -2597,7 +2611,6 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
// BringToFront(mWindow);
// result = noErr;
break;
-
}
break;
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index d6ee7acbaa..24bd70d57f 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -222,8 +222,8 @@ LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width,
ll_try_gtk_init();
#endif // LL_GTK
- // Get the original aspect ratio of the main device.
- mOriginalAspectRatio = 1024.0 / 768.0; // !!! *FIX: ? //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay);
+ // Assume 4:3 aspect ratio until we know better
+ mOriginalAspectRatio = 1024.0 / 768.0;
if (title.empty())
mWindowTitle = "SDL Window"; // *FIX: (???)
@@ -444,14 +444,20 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
<< int(r_sdl_version->minor) << "."
<< int(r_sdl_version->patch) << llendl;
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo( );
- if (!videoInfo)
+ const SDL_VideoInfo *video_info = SDL_GetVideoInfo( );
+ if (!video_info)
{
llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl;
setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK);
return FALSE;
}
+ if (video_info->current_h > 0)
+ {
+ mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h;
+ llinfos << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << llendl;
+ }
+
SDL_EnableUNICODE(1);
SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str());
@@ -643,7 +649,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
// fallback to letting SDL detect VRAM.
// note: I've not seen SDL's detection ever actually find
// VRAM != 0, but if SDL *does* detect it then that's a bonus.
- gGLManager.mVRAM = videoInfo->video_mem / 1024;
+ gGLManager.mVRAM = video_info->video_mem / 1024;
if (gGLManager.mVRAM != 0)
{
llinfos << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << llendl;
@@ -1272,6 +1278,49 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &text)
return FALSE; // failure
}
+
+BOOL LLWindowSDL::isPrimaryTextAvailable()
+{
+ if (ll_try_gtk_init())
+ {
+ GtkClipboard * const clipboard =
+ gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ return gtk_clipboard_wait_is_text_available(clipboard) ?
+ TRUE : FALSE;
+ }
+ return FALSE; // failure
+}
+
+BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &text)
+{
+ if (ll_try_gtk_init())
+ {
+ GtkClipboard * const clipboard =
+ gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gchar * const data = gtk_clipboard_wait_for_text(clipboard);
+ if (data)
+ {
+ text = LLWString(utf8str_to_wstring(data));
+ g_free(data);
+ return TRUE;
+ }
+ }
+ return FALSE; // failure
+}
+
+BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text)
+{
+ if (ll_try_gtk_init())
+ {
+ const std::string utf8 = wstring_to_utf8str(text);
+ GtkClipboard * const clipboard =
+ gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text(clipboard, utf8.c_str(), utf8.length());
+ return TRUE;
+ }
+ return FALSE; // failure
+}
+
#else
BOOL LLWindowSDL::isClipboardTextAvailable()
@@ -1288,6 +1337,22 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s)
{
return FALSE; // unsupported
}
+
+BOOL LLWindowSDL::isPrimaryTextAvailable()
+{
+ return FALSE; // unsupported
+}
+
+BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &dst)
+{
+ return FALSE; // unsupported
+}
+
+BOOL LLWindowSDL::copyTextToPrimary(const LLWString &s)
+{
+ return FALSE; // unsupported
+}
+
#endif // LL_GTK
LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions)
@@ -1962,14 +2027,14 @@ void LLWindowSDL::captureMouse()
// window, and in a less obnoxious way than SDL_WM_GrabInput
// which would confine the cursor to the window too.
- //llinfos << "LLWindowSDL::captureMouse" << llendl;
+ lldebugs << "LLWindowSDL::captureMouse" << llendl;
}
void LLWindowSDL::releaseMouse()
{
// see LWindowSDL::captureMouse()
- //llinfos << "LLWindowSDL::releaseMouse" << llendl;
+ lldebugs << "LLWindowSDL::releaseMouse" << llendl;
}
void LLWindowSDL::hideCursor()
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index cebb151764..632d8fc1fa 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -80,9 +80,15 @@ public:
/*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse();
/*virtual*/ void setMouseClipping( BOOL b );
+
/*virtual*/ BOOL isClipboardTextAvailable();
/*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
/*virtual*/ BOOL copyTextToClipboard(const LLWString & src);
+
+ /*virtual*/ BOOL isPrimaryTextAvailable();
+ /*virtual*/ BOOL pasteTextFromPrimary(LLWString &dst);
+ /*virtual*/ BOOL copyTextToPrimary(const LLWString & src);
+
/*virtual*/ void flashIcon(F32 seconds);
/*virtual*/ F32 getGamma();
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma