From eba6d0236fc9b7f4a54189766709948599d4b8a2 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 21 Oct 2009 16:01:52 -0700 Subject: Backed out changeset: 57dc52edbbc9 --- indra/llwindow/llwindowcallbacks.cpp | 5 +++ indra/llwindow/llwindowcallbacks.h | 1 + indra/llwindow/llwindowwin32.cpp | 66 +++++++++++++++++++++++++++++++++--- indra/newview/llviewerwindow.cpp | 14 ++++++++ indra/newview/llviewerwindow.h | 3 +- 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index 72f9997149..fda2c7ee6f 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,6 +163,11 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } +BOOL LLWindowCallbacks::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void *data) +{ + return FALSE; +} + BOOL LLWindowCallbacks::handleTimerEvent(LLWindow *window) { return FALSE; diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index abc66c42a2..e1e257943a 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -68,6 +68,7 @@ public: virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); + virtual BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void *data); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index c608c21d05..94c3e1af8c 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -52,6 +52,7 @@ #include #include // for _spawn #include +#include #include // Require DirectInput version 8 @@ -1348,6 +1349,9 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } SetWindowLong(mWindowHandle, GWL_USERDATA, (U32)this); + + // register this window as handling drag/drop events from the OS + DragAcceptFiles( mWindowHandle, TRUE ); //register joystick timer callback SetTimer( mWindowHandle, 0, 1000 / 30, NULL ); // 30 fps timer @@ -2333,11 +2337,65 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ return 0; case WM_COPYDATA: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); - // received a URL - PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; - window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); + // received a URL + PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; + window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); + }; return 0; + + case WM_DROPFILES: + { + // HDROP contains what we need + HDROP hdrop = (HDROP)w_param; + + // get location in window space where drop occured and convert to OpenGL coordinate space + POINT pt; + DragQueryPoint( hdrop, &pt ); + LLCoordGL gl_coord; + LLCoordWindow cursor_coord_window( pt.x, pt.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + + // get payload (eventually, this needs to more advanced and grab size of payload dynamically + static char file_name[ 1024 ]; + DragQueryFileA( hdrop, 0, file_name, 1024 ); + void* url = (void*)( file_name ); + + // if it's a .URL or .lnk ("shortcut") file + if ( std::string( file_name ).find( ".lnk" ) != std::string::npos || + std::string( file_name ).find( ".URL" ) != std::string::npos ) + { + // read through file - looks like a 2 line file with second line URL= but who knows.. + std::ifstream file_handle( file_name ); + if ( file_handle.is_open() ) + { + std::string line; + while ( ! file_handle.eof() ) + { + std::getline( file_handle, line ); + if ( ! file_handle.eof() ) + { + std::string prefix( "URL=" ); + if ( line.find( prefix, 0 ) != std::string::npos ) + { + line = line.substr( 4 ); // skip off the URL= bit + strcpy( (char*)url, line.c_str() ); + break; + }; + }; + }; + file_handle.close(); + }; + }; + + MASK mask = gKeyboard->currentMask(TRUE); + if (window_imp->mCallbacks->handleDrop(window_imp, gl_coord, mask, url ) ) + { + return 0; + } + } + break; } window_imp->mCallbacks->handlePauseWatchdog(window_imp); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c659e58e47..2bda6eddbc 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -815,6 +815,20 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS // Always handled as far as the OS is concerned. return TRUE; } + +BOOL LLViewerWindow::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void* data) +{ + LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); + + LLUUID object_id = pick_info.getObjectID(); + S32 object_face = pick_info.mObjectFace; + std::string url = std::string( (char*)data ); + + llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + + // Always handled as far as the OS is concerned. + return TRUE; +} BOOL LLViewerWindow::handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) { diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index d7c403739e..44704b99e3 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,8 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); + /*virtual*/ BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void* data); + void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); /*virtual*/ void handleFocus(LLWindow *window); -- cgit v1.2.3 From 19fc3fb32c3cd95fcfb5708b59b5620e506c5179 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 21 Oct 2009 17:40:36 -0700 Subject: Add setting for PrimMediaDragNDrop, and add implementation that sets the current URL and auto play on drop --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llviewerwindow.cpp | 24 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 91d5e04665..9adf893e4b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -5305,6 +5305,17 @@ Value 13 + PrimMediaDragNDrop + + Comment + Enable drag and drop + Persist + 1 + Type + Boolean + Value + 1 + PrimMediaMaxRetries Comment diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2bda6eddbc..a080243086 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -79,6 +79,7 @@ #include "timing.h" #include "llviewermenu.h" #include "lltooltip.h" +#include "llmediaentry.h" // newview includes #include "llagent.h" @@ -818,14 +819,27 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS BOOL LLViewerWindow::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void* data) { - LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); + if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) + { + LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); - LLUUID object_id = pick_info.getObjectID(); - S32 object_face = pick_info.mObjectFace; - std::string url = std::string( (char*)data ); + LLUUID object_id = pick_info.getObjectID(); + S32 object_face = pick_info.mObjectFace; + std::string url = std::string( (char*)data ); - llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); + if (obj) + { + LLSD media_data; + /// XXX home URL too? + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; + obj->syncMediaData(object_face, media_data, true, true); + obj->sendMediaDataUpdate(); + } + } // Always handled as far as the OS is concerned. return TRUE; } -- cgit v1.2.3 From caa631bf5b69ef1e39989b8e1e4b3372491cb9b4 Mon Sep 17 00:00:00 2001 From: callum Date: Tue, 27 Oct 2009 17:52:04 -0700 Subject: Added IDropTarget interface. Still lots of cleanup but this works ok. You can drag over from Firefox or IE onto a prim --- indra/llwindow/lldragdropwin32.cpp | 295 ++ indra/llwindow/lldragdropwin32.h | 55 + indra/llwindow/llwindowcallbacks.cpp | 2 +- indra/llwindow/llwindowcallbacks.h | 2 +- indra/llwindow/llwindowwin32.cpp | 7371 +++++++++++++++++----------------- indra/llwindow/llwindowwin32.h | 5 + indra/newview/llviewerwindow.cpp | 4 +- indra/newview/llviewerwindow.h | 2 +- 8 files changed, 4057 insertions(+), 3679 deletions(-) create mode 100644 indra/llwindow/lldragdropwin32.cpp create mode 100644 indra/llwindow/lldragdropwin32.h diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp new file mode 100644 index 0000000000..0daff85395 --- /dev/null +++ b/indra/llwindow/lldragdropwin32.cpp @@ -0,0 +1,295 @@ +/** + * @file lldragdrop32.cpp + * @brief Handler for Windows specific drag and drop (OS to client) code + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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$ + */ + +#if LL_WINDOWS + +#include "linden_common.h" + +#define WIN32_LEAN_AND_MEAN +#include + +#include "llwindowwin32.h" +#include "llkeyboardwin32.h" +#include "lldragdropwin32.h" + +#include "llwindowcallbacks.h" + +#include +#include +#include +#include +#include + +// FIXME: this should be done in CMake +#pragma comment( lib, "shlwapi.lib" ) + +class LLDragDropWin32Target: + public IDropTarget +{ + public: + LLDragDropWin32Target( HWND hWnd ) : + mWindowHandle( hWnd ), + mRefCount( 0 ) + { + strcpy(szFileDropped,""); + bDropTargetValid = false; + bTextDropped = false; + }; + + /* IUnknown methods */ + STDMETHOD_( ULONG, AddRef )( void ) + { + return ++mRefCount; + }; + + STDMETHOD_( ULONG, Release )( void ) + { + if ( --mRefCount == 0 ) + { + delete this; + return 0; + } + return mRefCount; + }; + + STDMETHOD ( QueryInterface )( REFIID iid, void ** ppvObject ) + { + if ( iid == IID_IUnknown || iid == IID_IDropTarget ) + { + *ppvObject = this; + AddRef(); + return S_OK; + }; + + *ppvObject = NULL; + return E_NOINTERFACE; + }; + + /* IDropTarget methods */ + STDMETHOD (DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + { + HRESULT hr = E_INVALIDARG; + bDropTargetValid = false; + bTextDropped = false; + *pdwEffect=DROPEFFECT_NONE; + + FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + STGMEDIUM medium; + + if (pDataObj && SUCCEEDED (pDataObj->GetData (&fmte, &medium))) + { + // We can Handle Only one File At a time !!! + if (1 == DragQueryFile ((HDROP)medium.hGlobal,0xFFFFFFFF,NULL,0 )) + { + // Get the File Name + if (DragQueryFileA((HDROP)medium.hGlobal, 0, szFileDropped,MAX_PATH)) + { + if (!PathIsDirectoryA(szFileDropped)) + { + char szTempFile[MAX_PATH]; + _splitpath(szFileDropped,NULL,NULL,NULL,szTempFile); + +// if (!stricmp(szTempFile,".lnk")) +// { +// if (ResolveLink(szFileDropped,szTempFile)) +// { +// strcpy(szFileDropped,szTempFile); +// *pdwEffect=DROPEFFECT_COPY; +// We Want to Create a Copy +// bDropTargetValid = true; +// hr = S_OK; +// } +// } +// else +// { + *pdwEffect=DROPEFFECT_COPY; + //We Want to Create a Copy + bDropTargetValid = true; + hr = S_OK; +// } + } + } + } + + if (medium.pUnkForRelease) + medium.pUnkForRelease->Release (); + else + GlobalFree (medium.hGlobal); + } + else + { + fmte.cfFormat = CF_TEXT; + fmte.ptd = NULL; + fmte.dwAspect = DVASPECT_CONTENT; + fmte.lindex = -1; + fmte.tymed = TYMED_HGLOBAL; + + // Does the drag source provide CF_TEXT ? + if (NOERROR == pDataObj->QueryGetData(&fmte)) + { + bDropTargetValid = true; + bTextDropped = true; + *pdwEffect=DROPEFFECT_COPY; + hr = S_OK; + } + } + return hr; + + + + }; + + STDMETHOD (DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + { + HRESULT hr = S_OK; + if (bDropTargetValid) + *pdwEffect=DROPEFFECT_COPY; + + return hr; + }; + + STDMETHOD (DragLeave)(void) + { + HRESULT hr = S_OK; + strcpy(szFileDropped,""); + return hr; + }; + + STDMETHOD (Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + { + HRESULT hr = S_OK; + if (bDropTargetValid) + { + *pdwEffect=DROPEFFECT_COPY; + + FORMATETC fmte; + STGMEDIUM medium; + + if (bTextDropped) + { + fmte.cfFormat = CF_TEXT; + fmte.ptd = NULL; + fmte.dwAspect = DVASPECT_CONTENT; + fmte.lindex = -1; + fmte.tymed = TYMED_HGLOBAL; + + hr = pDataObj->GetData(&fmte, &medium); + HGLOBAL hText = medium.hGlobal; + LPSTR lpszText = (LPSTR)GlobalLock(hText); + + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( pt.x, pt.y); + LLCoordWindow cursor_coord_window( pt.x, pt.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + llinfos << "### (Drop) URL is: " << lpszText << llendl; + llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; + llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; + llinfos << llendl; + + MASK mask = gKeyboard->currentMask(TRUE); + window_imp->completeDropRequest( gl_coord, mask, std::string( lpszText ) ); + }; + + GlobalUnlock(hText); + ReleaseStgMedium(&medium); + } + } + return hr; + }; + + private: + ULONG mRefCount; + HWND mWindowHandle; + char szFileDropped[1024]; + bool bDropTargetValid; + bool bTextDropped; + friend class LLWindowWin32; +}; + +LLDragDropWin32::LLDragDropWin32() : + mDropTarget( NULL ), + mDropWindowHandle( NULL ) + +{ +} + +LLDragDropWin32::~LLDragDropWin32() +{ +} + +bool LLDragDropWin32::init( HWND hWnd ) +{ + if (NOERROR != OleInitialize(NULL)) + return FALSE; + + mDropTarget = new LLDragDropWin32Target( hWnd ); + if ( mDropTarget ) + { + HRESULT result = CoLockObjectExternal( mDropTarget, TRUE, TRUE ); + if ( S_OK == result ) + { + result = RegisterDragDrop( hWnd, mDropTarget ); + if ( S_OK != result ) + { + // RegisterDragDrop failed + return false; + }; + + // all ok + mDropWindowHandle = hWnd; + } + else + { + // Unable to lock OLE object + return false; + }; + }; + + // success + return true; +} + +void LLDragDropWin32::reset() +{ + if ( mDropTarget ) + { + CoLockObjectExternal( mDropTarget, FALSE, TRUE ); + RevokeDragDrop( mDropWindowHandle ); + mDropTarget->Release(); + }; + + OleUninitialize(); +} + +#endif diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h new file mode 100644 index 0000000000..6137e5eb65 --- /dev/null +++ b/indra/llwindow/lldragdropwin32.h @@ -0,0 +1,55 @@ +/** + * @file lldragdrop32.cpp + * @brief Handler for Windows specific drag and drop (OS to client) code + * + * $LicenseInfo:firstyear=2004&license=viewergpl$ + * + * Copyright (c) 2004-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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$ + */ + +#ifndef LL_LLDRAGDROP32_H +#define LL_LLDRAGDROP32_H + +#include +#include +#include +#include + +class LLDragDropWin32 +{ + public: + LLDragDropWin32(); + ~LLDragDropWin32(); + + bool init( HWND hWnd ); + void reset(); + + private: + IDropTarget* mDropTarget; + HWND mDropWindowHandle; +}; + +#endif diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index fda2c7ee6f..1098529e1c 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,7 +163,7 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } -BOOL LLWindowCallbacks::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void *data) +BOOL LLWindowCallbacks::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data ) { return FALSE; } diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index e1e257943a..3a09100168 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -68,7 +68,7 @@ public: virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); - virtual BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void *data); + virtual BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 94c3e1af8c..da096b9a0a 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1,2366 +1,2376 @@ -/** - * @file llwindowwin32.cpp - * @brief Platform-dependent implementation of llwindow - * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 "linden_common.h" - -#if LL_WINDOWS && !LL_MESA_HEADLESS - -#include "llwindowwin32.h" - -// LLWindow library includes -#include "llkeyboardwin32.h" -#include "llpreeditor.h" -#include "llwindowcallbacks.h" - -// Linden library includes -#include "llerror.h" -#include "llgl.h" -#include "llstring.h" - -// System includes -#include -#include -#include -#include // for _spawn -#include +/** + * @file llwindowwin32.cpp + * @brief Platform-dependent implementation of llwindow + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 "linden_common.h" + +#if LL_WINDOWS && !LL_MESA_HEADLESS + +#include "llwindowwin32.h" + +// LLWindow library includes +#include "llkeyboardwin32.h" +#include "lldragdropwin32.h" +#include "llpreeditor.h" +#include "llwindowcallbacks.h" + +// Linden library includes +#include "llerror.h" +#include "llgl.h" +#include "llstring.h" + +// System includes +#include +#include +#include +#include // for _spawn +#include #include -#include - -// Require DirectInput version 8 -#define DIRECTINPUT_VERSION 0x0800 - -#include -#include - -#include "llmemtype.h" -// culled from winuser.h -#ifndef WM_MOUSEWHEEL /* Added to be compatible with later SDK's */ -const S32 WM_MOUSEWHEEL = 0x020A; -#endif -#ifndef WHEEL_DELTA /* Added to be compatible with later SDK's */ -const S32 WHEEL_DELTA = 120; /* Value for rolling one detent */ -#endif -const S32 MAX_MESSAGE_PER_UPDATE = 20; -const S32 BITS_PER_PIXEL = 32; -const S32 MAX_NUM_RESOLUTIONS = 32; -const F32 ICON_FLASH_TIME = 0.5f; - -extern BOOL gDebugWindowProc; - -LPWSTR gIconResource = IDI_APPLICATION; - -LLW32MsgCallback gAsyncMsgCallback = NULL; - -// -// LLWindowWin32 -// - -void show_window_creation_error(const std::string& title) -{ - LL_WARNS("Window") << title << LL_ENDL; -} - -//static -BOOL LLWindowWin32::sIsClassRegistered = FALSE; - -BOOL LLWindowWin32::sLanguageTextInputAllowed = TRUE; -BOOL LLWindowWin32::sWinIMEOpened = FALSE; -HKL LLWindowWin32::sWinInputLocale = 0; -DWORD LLWindowWin32::sWinIMEConversionMode = IME_CMODE_NATIVE; -DWORD LLWindowWin32::sWinIMESentenceMode = IME_SMODE_AUTOMATIC; -LLCoordWindow LLWindowWin32::sWinIMEWindowPosition(-1,-1); - -// The following class LLWinImm delegates Windows IMM APIs. -// We need this because some language versions of Windows, -// e.g., US version of Windows XP, doesn't install IMM32.DLL -// as a default, and we can't link against imm32.lib statically. -// I believe DLL loading of this type is best suited to do -// in a static initialization of a class. What I'm not sure is -// whether it follows the Linden Conding Standard... -// See http://wiki.secondlife.com/wiki/Coding_standards#Static_Members - -class LLWinImm -{ -public: - static bool isAvailable() { return sTheInstance.mHImmDll != NULL; } - -public: - // Wrappers for IMM API. - static BOOL isIME(HKL hkl); - static HWND getDefaultIMEWnd(HWND hwnd); - static HIMC getContext(HWND hwnd); - static BOOL releaseContext(HWND hwnd, HIMC himc); - static BOOL getOpenStatus(HIMC himc); - static BOOL setOpenStatus(HIMC himc, BOOL status); - static BOOL getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence); - static BOOL setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence); - static BOOL getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); - static BOOL setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); - static LONG getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length); - static BOOL setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength); - static BOOL setCompositionFont(HIMC himc, LPLOGFONTW logfont); - static BOOL setCandidateWindow(HIMC himc, LPCANDIDATEFORM candidate_form); - static BOOL notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value); - -private: - LLWinImm(); - ~LLWinImm(); - -private: - // Pointers to IMM API. - BOOL (WINAPI *mImmIsIME)(HKL); - HWND (WINAPI *mImmGetDefaultIMEWnd)(HWND); - HIMC (WINAPI *mImmGetContext)(HWND); - BOOL (WINAPI *mImmReleaseContext)(HWND, HIMC); - BOOL (WINAPI *mImmGetOpenStatus)(HIMC); - BOOL (WINAPI *mImmSetOpenStatus)(HIMC, BOOL); - BOOL (WINAPI *mImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); - BOOL (WINAPI *mImmSetConversionStatus)(HIMC, DWORD, DWORD); - BOOL (WINAPI *mImmGetCompostitionWindow)(HIMC, LPCOMPOSITIONFORM); - BOOL (WINAPI *mImmSetCompostitionWindow)(HIMC, LPCOMPOSITIONFORM); - LONG (WINAPI *mImmGetCompositionString)(HIMC, DWORD, LPVOID, DWORD); - BOOL (WINAPI *mImmSetCompositionString)(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD); - BOOL (WINAPI *mImmSetCompositionFont)(HIMC, LPLOGFONTW); - BOOL (WINAPI *mImmSetCandidateWindow)(HIMC, LPCANDIDATEFORM); - BOOL (WINAPI *mImmNotifyIME)(HIMC, DWORD, DWORD, DWORD); - -private: - HMODULE mHImmDll; - static LLWinImm sTheInstance; -}; - -LLWinImm LLWinImm::sTheInstance; - -LLWinImm::LLWinImm() : mHImmDll(NULL) -{ - // Check system metrics - if ( !GetSystemMetrics( SM_DBCSENABLED ) ) - return; - - - mHImmDll = LoadLibraryA("Imm32"); - if (mHImmDll != NULL) - { - mImmIsIME = (BOOL (WINAPI *)(HKL)) GetProcAddress(mHImmDll, "ImmIsIME"); - mImmGetDefaultIMEWnd = (HWND (WINAPI *)(HWND)) GetProcAddress(mHImmDll, "ImmGetDefaultIMEWnd"); - mImmGetContext = (HIMC (WINAPI *)(HWND)) GetProcAddress(mHImmDll, "ImmGetContext"); - mImmReleaseContext = (BOOL (WINAPI *)(HWND, HIMC)) GetProcAddress(mHImmDll, "ImmReleaseContext"); - mImmGetOpenStatus = (BOOL (WINAPI *)(HIMC)) GetProcAddress(mHImmDll, "ImmGetOpenStatus"); - mImmSetOpenStatus = (BOOL (WINAPI *)(HIMC, BOOL)) GetProcAddress(mHImmDll, "ImmSetOpenStatus"); - mImmGetConversionStatus = (BOOL (WINAPI *)(HIMC, LPDWORD, LPDWORD)) GetProcAddress(mHImmDll, "ImmGetConversionStatus"); - mImmSetConversionStatus = (BOOL (WINAPI *)(HIMC, DWORD, DWORD)) GetProcAddress(mHImmDll, "ImmSetConversionStatus"); - mImmGetCompostitionWindow = (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(mHImmDll, "ImmGetCompositionWindow"); - mImmSetCompostitionWindow = (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(mHImmDll, "ImmSetCompositionWindow"); - mImmGetCompositionString= (LONG (WINAPI *)(HIMC, DWORD, LPVOID, DWORD)) GetProcAddress(mHImmDll, "ImmGetCompositionStringW"); - mImmSetCompositionString= (BOOL (WINAPI *)(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD)) GetProcAddress(mHImmDll, "ImmSetCompositionStringW"); - mImmSetCompositionFont = (BOOL (WINAPI *)(HIMC, LPLOGFONTW)) GetProcAddress(mHImmDll, "ImmSetCompositionFontW"); - mImmSetCandidateWindow = (BOOL (WINAPI *)(HIMC, LPCANDIDATEFORM)) GetProcAddress(mHImmDll, "ImmSetCandidateWindow"); - mImmNotifyIME = (BOOL (WINAPI *)(HIMC, DWORD, DWORD, DWORD)) GetProcAddress(mHImmDll, "ImmNotifyIME"); - - if (mImmIsIME == NULL || - mImmGetDefaultIMEWnd == NULL || - mImmGetContext == NULL || - mImmReleaseContext == NULL || - mImmGetOpenStatus == NULL || - mImmSetOpenStatus == NULL || - mImmGetConversionStatus == NULL || - mImmSetConversionStatus == NULL || - mImmGetCompostitionWindow == NULL || - mImmSetCompostitionWindow == NULL || - mImmGetCompositionString == NULL || - mImmSetCompositionString == NULL || - mImmSetCompositionFont == NULL || - mImmSetCandidateWindow == NULL || - mImmNotifyIME == NULL) - { - // If any of the above API entires are not found, we can't use IMM API. - // So, turn off the IMM support. We should log some warning message in - // the case, since it is very unusual; these APIs are available from - // the beginning, and all versions of IMM32.DLL should have them all. - // Unfortunately, this code may be executed before initialization of - // the logging channel (llwarns), and we can't do it here... Yes, this - // is one of disadvantages to use static constraction to DLL loading. - FreeLibrary(mHImmDll); - mHImmDll = NULL; - - // If we unload the library, make sure all the function pointers are cleared - mImmIsIME = NULL; - mImmGetDefaultIMEWnd = NULL; - mImmGetContext = NULL; - mImmReleaseContext = NULL; - mImmGetOpenStatus = NULL; - mImmSetOpenStatus = NULL; - mImmGetConversionStatus = NULL; - mImmSetConversionStatus = NULL; - mImmGetCompostitionWindow = NULL; - mImmSetCompostitionWindow = NULL; - mImmGetCompositionString = NULL; - mImmSetCompositionString = NULL; - mImmSetCompositionFont = NULL; - mImmSetCandidateWindow = NULL; - mImmNotifyIME = NULL; - } - } -} - - -// static -BOOL LLWinImm::isIME(HKL hkl) -{ - if ( sTheInstance.mImmIsIME ) - return sTheInstance.mImmIsIME(hkl); - return FALSE; -} - -// static -HIMC LLWinImm::getContext(HWND hwnd) -{ - if ( sTheInstance.mImmGetContext ) - return sTheInstance.mImmGetContext(hwnd); - return 0; -} - -//static -BOOL LLWinImm::releaseContext(HWND hwnd, HIMC himc) -{ - if ( sTheInstance.mImmIsIME ) - return sTheInstance.mImmReleaseContext(hwnd, himc); - return FALSE; -} - -// static -BOOL LLWinImm::getOpenStatus(HIMC himc) -{ - if ( sTheInstance.mImmGetOpenStatus ) - return sTheInstance.mImmGetOpenStatus(himc); - return FALSE; -} - -// static -BOOL LLWinImm::setOpenStatus(HIMC himc, BOOL status) -{ - if ( sTheInstance.mImmSetOpenStatus ) - return sTheInstance.mImmSetOpenStatus(himc, status); - return FALSE; -} - -// static -BOOL LLWinImm::getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence) -{ - if ( sTheInstance.mImmGetConversionStatus ) - return sTheInstance.mImmGetConversionStatus(himc, conversion, sentence); - return FALSE; -} - -// static -BOOL LLWinImm::setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence) -{ - if ( sTheInstance.mImmSetConversionStatus ) - return sTheInstance.mImmSetConversionStatus(himc, conversion, sentence); - return FALSE; -} - -// static -BOOL LLWinImm::getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) -{ - if ( sTheInstance.mImmGetCompostitionWindow ) - return sTheInstance.mImmGetCompostitionWindow(himc, form); - return FALSE; -} - -// static -BOOL LLWinImm::setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) -{ - if ( sTheInstance.mImmSetCompostitionWindow ) - return sTheInstance.mImmSetCompostitionWindow(himc, form); - return FALSE; -} - - -// static -LONG LLWinImm::getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length) -{ - if ( sTheInstance.mImmGetCompositionString ) - return sTheInstance.mImmGetCompositionString(himc, index, data, length); - return FALSE; -} - - -// static -BOOL LLWinImm::setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength) -{ - if ( sTheInstance.mImmSetCompositionString ) - return sTheInstance.mImmSetCompositionString(himc, index, pComp, compLength, pRead, readLength); - return FALSE; -} - -// static -BOOL LLWinImm::setCompositionFont(HIMC himc, LPLOGFONTW pFont) -{ - if ( sTheInstance.mImmSetCompositionFont ) - return sTheInstance.mImmSetCompositionFont(himc, pFont); - return FALSE; -} - -// static -BOOL LLWinImm::setCandidateWindow(HIMC himc, LPCANDIDATEFORM form) -{ - if ( sTheInstance.mImmSetCandidateWindow ) - return sTheInstance.mImmSetCandidateWindow(himc, form); - return FALSE; -} - -// static -BOOL LLWinImm::notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value) -{ - if ( sTheInstance.mImmNotifyIME ) - return sTheInstance.mImmNotifyIME(himc, action, index, value); - return FALSE; -} - - - - -// ---------------------------------------------------------------------------------------- -LLWinImm::~LLWinImm() -{ - if (mHImmDll != NULL) - { - FreeLibrary(mHImmDll); - mHImmDll = NULL; - } -} - - -LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, - const std::string& title, const std::string& name, S32 x, S32 y, S32 width, - S32 height, U32 flags, - BOOL fullscreen, BOOL clearBg, - BOOL disable_vsync, BOOL use_gl, - BOOL ignore_pixel_depth, - U32 fsaa_samples) - : LLWindow(callbacks, fullscreen, flags) -{ - mFSAASamples = fsaa_samples; - mIconResource = gIconResource; - mOverrideAspectRatio = 0.f; - mNativeAspectRatio = 0.f; - mMousePositionModified = FALSE; - mInputProcessingPaused = FALSE; - mPreeditor = NULL; - mhDC = NULL; - mhRC = NULL; - - // Initialize the keyboard - gKeyboard = new LLKeyboardWin32(); - gKeyboard->setCallbacks(callbacks); - - // Initialize (boot strap) the Language text input management, - // based on the system's (user's) default settings. - allowLanguageTextInput(mPreeditor, FALSE); - - WNDCLASS wc; - RECT window_rect; - - // Set the window title - if (title.empty()) - { - mWindowTitle = new WCHAR[50]; - wsprintf(mWindowTitle, L"OpenGL Window"); - } - else - { - mWindowTitle = new WCHAR[256]; // Assume title length < 255 chars. - mbstowcs(mWindowTitle, title.c_str(), 255); - mWindowTitle[255] = 0; - } - - // Set the window class name - if (name.empty()) - { - mWindowClassName = new WCHAR[50]; - wsprintf(mWindowClassName, L"OpenGL Window"); - } - else - { - mWindowClassName = new WCHAR[256]; // Assume title length < 255 chars. - mbstowcs(mWindowClassName, name.c_str(), 255); - mWindowClassName[255] = 0; - } - - - // We're not clipping yet - SetRect( &mOldMouseClip, 0, 0, 0, 0 ); - - // Make an instance of our window then define the window class - mhInstance = GetModuleHandle(NULL); - mWndProc = NULL; - - mSwapMethod = SWAP_METHOD_UNDEFINED; - - // No WPARAM yet. - mLastSizeWParam = 0; - - // Windows GDI rects don't include rightmost pixel - window_rect.left = (long) 0; - window_rect.right = (long) width; - window_rect.top = (long) 0; - window_rect.bottom = (long) height; - - // Grab screen size to sanitize the window - S32 window_border_y = GetSystemMetrics(SM_CYBORDER); - S32 virtual_screen_x = GetSystemMetrics(SM_XVIRTUALSCREEN); - S32 virtual_screen_y = GetSystemMetrics(SM_YVIRTUALSCREEN); - S32 virtual_screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); - S32 virtual_screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); - - if (x < virtual_screen_x) x = virtual_screen_x; - if (y < virtual_screen_y - window_border_y) y = virtual_screen_y - window_border_y; - - if (x + width > virtual_screen_x + virtual_screen_width) x = virtual_screen_x + virtual_screen_width - width; - if (y + height > virtual_screen_y + virtual_screen_height) y = virtual_screen_y + virtual_screen_height - height; - - if (!sIsClassRegistered) - { - // Force redraw when resized and create a private device context - - // Makes double click messages. - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; - - // Set message handler function - wc.lpfnWndProc = (WNDPROC) mainWindowProc; - - // unused - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - - wc.hInstance = mhInstance; - wc.hIcon = LoadIcon(mhInstance, mIconResource); - - // We will set the cursor ourselves - wc.hCursor = NULL; - - // background color is not used - if (clearBg) - { - wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - } - else - { - wc.hbrBackground = (HBRUSH) NULL; - } - - // we don't use windows menus - wc.lpszMenuName = NULL; - - wc.lpszClassName = mWindowClassName; - - if (!RegisterClass(&wc)) - { - OSMessageBox(mCallbacks->translateString("MBRegClassFailed"), - mCallbacks->translateString("MBError"), OSMB_OK); - return; - } - sIsClassRegistered = TRUE; - } - - //----------------------------------------------------------------------- - // Get the current refresh rate - //----------------------------------------------------------------------- - - DEVMODE dev_mode; - DWORD current_refresh; - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) - { - current_refresh = dev_mode.dmDisplayFrequency; - mNativeAspectRatio = ((F32)dev_mode.dmPelsWidth) / ((F32)dev_mode.dmPelsHeight); - } - else - { - current_refresh = 60; - } - - //----------------------------------------------------------------------- - // Drop resolution and go fullscreen - // use a display mode with our desired size and depth, with a refresh - // rate as close at possible to the users' default - //----------------------------------------------------------------------- - if (mFullscreen) - { - BOOL success = FALSE; - DWORD closest_refresh = 0; - - for (S32 mode_num = 0;; mode_num++) - { - if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) - { - break; - } - - if (dev_mode.dmPelsWidth == width && - dev_mode.dmPelsHeight == height && - dev_mode.dmBitsPerPel == BITS_PER_PIXEL) - { - success = TRUE; - if ((dev_mode.dmDisplayFrequency - current_refresh) - < (closest_refresh - current_refresh)) - { - closest_refresh = dev_mode.dmDisplayFrequency; - } - } - } - - if (closest_refresh == 0) - { - LL_WARNS("Window") << "Couldn't find display mode " << width << " by " << height << " at " << BITS_PER_PIXEL << " bits per pixel" << LL_ENDL; - success = FALSE; - } - - // If we found a good resolution, use it. - if (success) - { - success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); - } - - // Keep a copy of the actual current device mode in case we minimize - // and change the screen resolution. JC - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); - - // If it failed, we don't want to run fullscreen - if (success) - { - mFullscreen = TRUE; - mFullscreenWidth = dev_mode.dmPelsWidth; - mFullscreenHeight = dev_mode.dmPelsHeight; - mFullscreenBits = dev_mode.dmBitsPerPel; - mFullscreenRefresh = dev_mode.dmDisplayFrequency; - - LL_INFOS("Window") << "Running at " << dev_mode.dmPelsWidth - << "x" << dev_mode.dmPelsHeight - << "x" << dev_mode.dmBitsPerPel - << " @ " << dev_mode.dmDisplayFrequency - << LL_ENDL; - } - else - { - mFullscreen = FALSE; - mFullscreenWidth = -1; - mFullscreenHeight = -1; - mFullscreenBits = -1; - mFullscreenRefresh = -1; - - std::map args; - args["[WIDTH]"] = llformat("%d", width); - args["[HEIGHT]"] = llformat ("%d", height); - OSMessageBox(mCallbacks->translateString("MBFullScreenErr", args), - mCallbacks->translateString("MBError"), OSMB_OK); - } - } - - // TODO: add this after resolving _WIN32_WINNT issue - // if (!fullscreen) - // { - // TRACKMOUSEEVENT track_mouse_event; - // track_mouse_event.cbSize = sizeof( TRACKMOUSEEVENT ); - // track_mouse_event.dwFlags = TME_LEAVE; - // track_mouse_event.hwndTrack = mWindowHandle; - // track_mouse_event.dwHoverTime = HOVER_DEFAULT; - // TrackMouseEvent( &track_mouse_event ); - // } - - - //----------------------------------------------------------------------- - // Create GL drawing context - //----------------------------------------------------------------------- - LLCoordScreen windowPos(x,y); - LLCoordScreen windowSize(window_rect.right - window_rect.left, - window_rect.bottom - window_rect.top); - if (!switchContext(mFullscreen, windowSize, TRUE, &windowPos)) - { - return; - } - - //start with arrow cursor - initCursors(); - setCursor( UI_CURSOR_ARROW ); - - // Initialize (boot strap) the Language text input management, - // based on the system's (or user's) default settings. - allowLanguageTextInput(NULL, FALSE); -} - - -LLWindowWin32::~LLWindowWin32() -{ - delete [] mWindowTitle; - mWindowTitle = NULL; - - delete [] mSupportedResolutions; - mSupportedResolutions = NULL; - - delete mWindowClassName; - mWindowClassName = NULL; -} - -void LLWindowWin32::show() -{ - ShowWindow(mWindowHandle, SW_SHOW); - SetForegroundWindow(mWindowHandle); - SetFocus(mWindowHandle); -} - -void LLWindowWin32::hide() -{ - setMouseClipping(FALSE); - ShowWindow(mWindowHandle, SW_HIDE); -} - -void LLWindowWin32::minimize() -{ - setMouseClipping(FALSE); - showCursor(); - ShowWindow(mWindowHandle, SW_MINIMIZE); -} - - -void LLWindowWin32::restore() -{ - ShowWindow(mWindowHandle, SW_RESTORE); - SetForegroundWindow(mWindowHandle); - SetFocus(mWindowHandle); -} - - -// close() destroys all OS-specific code associated with a window. -// Usually called from LLWindowManager::destroyWindow() -void LLWindowWin32::close() -{ - LL_DEBUGS("Window") << "Closing LLWindowWin32" << LL_ENDL; - // Is window is already closed? - if (!mWindowHandle) - { - return; - } - - // Make sure cursor is visible and we haven't mangled the clipping state. - setMouseClipping(FALSE); - showCursor(); - - // Go back to screen mode written in the registry. - if (mFullscreen) - { - resetDisplayResolution(); - } - - // Clean up remaining GL state - LL_DEBUGS("Window") << "Shutting down GL" << LL_ENDL; - gGLManager.shutdownGL(); - - LL_DEBUGS("Window") << "Releasing Context" << LL_ENDL; - if (mhRC) - { - if (!wglMakeCurrent(NULL, NULL)) - { - LL_WARNS("Window") << "Release of DC and RC failed" << LL_ENDL; - } - - if (!wglDeleteContext(mhRC)) - { - LL_WARNS("Window") << "Release of rendering context failed" << LL_ENDL; - } - - mhRC = NULL; - } - - // Restore gamma to the system values. - restoreGamma(); - - if (mhDC && !ReleaseDC(mWindowHandle, mhDC)) - { - LL_WARNS("Window") << "Release of ghDC failed" << LL_ENDL; - mhDC = NULL; - } - - LL_DEBUGS("Window") << "Destroying Window" << LL_ENDL; - - // Don't process events in our mainWindowProc any longer. - SetWindowLong(mWindowHandle, GWL_USERDATA, NULL); - - // Make sure we don't leave a blank toolbar button. - ShowWindow(mWindowHandle, SW_HIDE); - - // This causes WM_DESTROY to be sent *immediately* - if (!DestroyWindow(mWindowHandle)) - { - OSMessageBox(mCallbacks->translateString("MBDestroyWinFailed"), - mCallbacks->translateString("MBShutdownErr"), - OSMB_OK); - } - - mWindowHandle = NULL; -} - -BOOL LLWindowWin32::isValid() -{ - return (mWindowHandle != NULL); -} - -BOOL LLWindowWin32::getVisible() -{ - return (mWindowHandle && IsWindowVisible(mWindowHandle)); -} - -BOOL LLWindowWin32::getMinimized() -{ - return (mWindowHandle && IsIconic(mWindowHandle)); -} - -BOOL LLWindowWin32::getMaximized() -{ - return (mWindowHandle && IsZoomed(mWindowHandle)); -} - -BOOL LLWindowWin32::maximize() -{ - BOOL success = FALSE; - if (!mWindowHandle) return success; - - WINDOWPLACEMENT placement; - placement.length = sizeof(WINDOWPLACEMENT); - - success = GetWindowPlacement(mWindowHandle, &placement); - if (!success) return success; - - placement.showCmd = SW_MAXIMIZE; - - success = SetWindowPlacement(mWindowHandle, &placement); - return success; -} - -BOOL LLWindowWin32::getFullscreen() -{ - return mFullscreen; -} - -BOOL LLWindowWin32::getPosition(LLCoordScreen *position) -{ - RECT window_rect; - - if (!mWindowHandle || - !GetWindowRect(mWindowHandle, &window_rect) || - NULL == position) - { - return FALSE; - } - - position->mX = window_rect.left; - position->mY = window_rect.top; - return TRUE; -} - -BOOL LLWindowWin32::getSize(LLCoordScreen *size) -{ - RECT window_rect; - - if (!mWindowHandle || - !GetWindowRect(mWindowHandle, &window_rect) || - NULL == size) - { - return FALSE; - } - - size->mX = window_rect.right - window_rect.left; - size->mY = window_rect.bottom - window_rect.top; - return TRUE; -} - -BOOL LLWindowWin32::getSize(LLCoordWindow *size) -{ - RECT client_rect; - - if (!mWindowHandle || - !GetClientRect(mWindowHandle, &client_rect) || - NULL == size) - { - return FALSE; - } - - size->mX = client_rect.right - client_rect.left; - size->mY = client_rect.bottom - client_rect.top; - return TRUE; -} - -BOOL LLWindowWin32::setPosition(const LLCoordScreen position) -{ - LLCoordScreen size; - - if (!mWindowHandle) - { - return FALSE; - } - getSize(&size); - moveWindow(position, size); - return TRUE; -} - -BOOL LLWindowWin32::setSize(const LLCoordScreen size) -{ - LLCoordScreen position; - - getPosition(&position); - if (!mWindowHandle) - { - return FALSE; - } - - moveWindow(position, size); - return TRUE; -} - -// changing fullscreen resolution -BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp) -{ - GLuint pixel_format; - DEVMODE dev_mode; - DWORD current_refresh; - DWORD dw_ex_style; - DWORD dw_style; - RECT window_rect; - S32 width = size.mX; - S32 height = size.mY; - BOOL auto_show = FALSE; - - if (mhRC) - { - auto_show = TRUE; - resetDisplayResolution(); - } - - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) - { - current_refresh = dev_mode.dmDisplayFrequency; - } - else - { - current_refresh = 60; - } - - gGLManager.shutdownGL(); - //destroy gl context - if (mhRC) - { - if (!wglMakeCurrent(NULL, NULL)) - { - LL_WARNS("Window") << "Release of DC and RC failed" << LL_ENDL; - } - - if (!wglDeleteContext(mhRC)) - { - LL_WARNS("Window") << "Release of rendering context failed" << LL_ENDL; - } - - mhRC = NULL; - } - - if (fullscreen) - { - mFullscreen = TRUE; - BOOL success = FALSE; - DWORD closest_refresh = 0; - - for (S32 mode_num = 0;; mode_num++) - { - if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) - { - break; - } - - if (dev_mode.dmPelsWidth == width && - dev_mode.dmPelsHeight == height && - dev_mode.dmBitsPerPel == BITS_PER_PIXEL) - { - success = TRUE; - if ((dev_mode.dmDisplayFrequency - current_refresh) - < (closest_refresh - current_refresh)) - { - closest_refresh = dev_mode.dmDisplayFrequency; - } - } - } - - if (closest_refresh == 0) - { - LL_WARNS("Window") << "Couldn't find display mode " << width << " by " << height << " at " << BITS_PER_PIXEL << " bits per pixel" << LL_ENDL; - return FALSE; - } - - // If we found a good resolution, use it. - if (success) - { - success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); - } - - // Keep a copy of the actual current device mode in case we minimize - // and change the screen resolution. JC - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); - - if (success) - { - mFullscreen = TRUE; - mFullscreenWidth = dev_mode.dmPelsWidth; - mFullscreenHeight = dev_mode.dmPelsHeight; - mFullscreenBits = dev_mode.dmBitsPerPel; - mFullscreenRefresh = dev_mode.dmDisplayFrequency; - - LL_INFOS("Window") << "Running at " << dev_mode.dmPelsWidth - << "x" << dev_mode.dmPelsHeight - << "x" << dev_mode.dmBitsPerPel - << " @ " << dev_mode.dmDisplayFrequency - << LL_ENDL; - - window_rect.left = (long) 0; - window_rect.right = (long) width; // Windows GDI rects don't include rightmost pixel - window_rect.top = (long) 0; - window_rect.bottom = (long) height; - dw_ex_style = WS_EX_APPWINDOW; - dw_style = WS_POPUP; - - // Move window borders out not to cover window contents - AdjustWindowRectEx(&window_rect, dw_style, FALSE, dw_ex_style); - } - // If it failed, we don't want to run fullscreen - else - { - mFullscreen = FALSE; - mFullscreenWidth = -1; - mFullscreenHeight = -1; - mFullscreenBits = -1; - mFullscreenRefresh = -1; - - LL_INFOS("Window") << "Unable to run fullscreen at " << width << "x" << height << LL_ENDL; - return FALSE; - } - } - else - { - mFullscreen = FALSE; - window_rect.left = (long) (posp ? posp->mX : 0); - window_rect.right = (long) width + window_rect.left; // Windows GDI rects don't include rightmost pixel - window_rect.top = (long) (posp ? posp->mY : 0); - window_rect.bottom = (long) height + window_rect.top; - // Window with an edge - dw_ex_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dw_style = WS_OVERLAPPEDWINDOW; - } - - // don't post quit messages when destroying old windows - mPostQuit = FALSE; - - // create window - DestroyWindow(mWindowHandle); - mWindowHandle = CreateWindowEx(dw_ex_style, - mWindowClassName, - mWindowTitle, - WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dw_style, - window_rect.left, // x pos - window_rect.top, // y pos - window_rect.right - window_rect.left, // width - window_rect.bottom - window_rect.top, // height - NULL, - NULL, - mhInstance, - NULL); - - //----------------------------------------------------------------------- - // Create GL drawing context - //----------------------------------------------------------------------- - static PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - BITS_PER_PIXEL, - 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused - 8, // alpha bits - 0, // alpha shift - 0, // accum bits - 0, 0, 0, 0, // accum RGBA - 24, // depth bits - 8, // stencil bits, avi added for stencil test - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if (!(mhDC = GetDC(mWindowHandle))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBDevContextErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - // Verify what pixel format we actually received. - if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), - &pfd)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (pfd.cColorBits < 32) - { - close(); - OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (pfd.cAlphaBits < 8) - { - close(); - OSMessageBox(mCallbacks->translateString("MBAlpha"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!SetPixelFormat(mhDC, pixel_format, &pfd)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!(mhRC = wglCreateContext(mhDC))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBGLContextErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!wglMakeCurrent(mhDC, mhRC)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBGLContextActErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - gGLManager.initWGL(); - - if (wglChoosePixelFormatARB) - { - // OK, at this point, use the ARB wglChoosePixelFormatsARB function to see if we - // can get exactly what we want. - GLint attrib_list[256]; - S32 cur_attrib = 0; - - attrib_list[cur_attrib++] = WGL_DEPTH_BITS_ARB; - attrib_list[cur_attrib++] = 24; - - attrib_list[cur_attrib++] = WGL_STENCIL_BITS_ARB; - attrib_list[cur_attrib++] = 8; - - attrib_list[cur_attrib++] = WGL_DRAW_TO_WINDOW_ARB; - attrib_list[cur_attrib++] = GL_TRUE; - - attrib_list[cur_attrib++] = WGL_ACCELERATION_ARB; - attrib_list[cur_attrib++] = WGL_FULL_ACCELERATION_ARB; - - attrib_list[cur_attrib++] = WGL_SUPPORT_OPENGL_ARB; - attrib_list[cur_attrib++] = GL_TRUE; - - attrib_list[cur_attrib++] = WGL_DOUBLE_BUFFER_ARB; - attrib_list[cur_attrib++] = GL_TRUE; - - attrib_list[cur_attrib++] = WGL_COLOR_BITS_ARB; - attrib_list[cur_attrib++] = 24; - - attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB; - attrib_list[cur_attrib++] = 8; - - U32 end_attrib = 0; - if (mFSAASamples > 0) - { - end_attrib = cur_attrib; - attrib_list[cur_attrib++] = WGL_SAMPLE_BUFFERS_ARB; - attrib_list[cur_attrib++] = GL_TRUE; - - attrib_list[cur_attrib++] = WGL_SAMPLES_ARB; - attrib_list[cur_attrib++] = mFSAASamples; - } - - // End the list - attrib_list[cur_attrib++] = 0; - - GLint pixel_formats[256]; - U32 num_formats = 0; - - // First we try and get a 32 bit depth pixel format - BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); - if (!result) - { - close(); - show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit"); - return FALSE; - } - - if (!num_formats) - { - if (end_attrib > 0) - { - LL_INFOS("Window") << "No valid pixel format for " << mFSAASamples << "x anti-aliasing." << LL_ENDL; - attrib_list[end_attrib] = 0; - - BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); - if (!result) - { - close(); - show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit no AA"); - return FALSE; - } - } - - if (!num_formats) - { - LL_INFOS("Window") << "No 32 bit z-buffer, trying 24 bits instead" << LL_ENDL; - // Try 24-bit format - attrib_list[1] = 24; - BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); - if (!result) - { - close(); - show_window_creation_error("Error after wglChoosePixelFormatARB 24-bit"); - return FALSE; - } - - if (!num_formats) - { - LL_WARNS("Window") << "Couldn't get 24 bit z-buffer,trying 16 bits instead!" << LL_ENDL; - attrib_list[1] = 16; - BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); - if (!result || !num_formats) - { - close(); - show_window_creation_error("Error after wglChoosePixelFormatARB 16-bit"); - return FALSE; - } - } - } - - LL_INFOS("Window") << "Choosing pixel formats: " << num_formats << " pixel formats returned" << LL_ENDL; - } - - - - S32 swap_method = 0; - S32 cur_format = num_formats-1; - GLint swap_query = WGL_SWAP_METHOD_ARB; - - BOOL found_format = FALSE; - - while (!found_format && wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) - { - if (swap_method == WGL_SWAP_UNDEFINED_ARB || cur_format <= 0) - { - found_format = TRUE; - } - else - { - --cur_format; - } - } - - pixel_format = pixel_formats[cur_format]; - - if (mhDC != 0) // Does The Window Have A Device Context? - { - wglMakeCurrent(mhDC, 0); // Set The Current Active Rendering Context To Zero - if (mhRC != 0) // Does The Window Have A Rendering Context? - { - wglDeleteContext (mhRC); // Release The Rendering Context - mhRC = 0; // Zero The Rendering Context - - } - ReleaseDC (mWindowHandle, mhDC); // Release The Device Context - mhDC = 0; // Zero The Device Context - } - DestroyWindow (mWindowHandle); // Destroy The Window - - - mWindowHandle = CreateWindowEx(dw_ex_style, - mWindowClassName, - mWindowTitle, - WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dw_style, - window_rect.left, // x pos - window_rect.top, // y pos - window_rect.right - window_rect.left, // width - window_rect.bottom - window_rect.top, // height - NULL, - NULL, - mhInstance, - NULL); - - if (!(mhDC = GetDC(mWindowHandle))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBDevContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!SetPixelFormat(mhDC, pixel_format, &pfd)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) - { - switch (swap_method) - { - case WGL_SWAP_EXCHANGE_ARB: - mSwapMethod = SWAP_METHOD_EXCHANGE; - LL_DEBUGS("Window") << "Swap Method: Exchange" << LL_ENDL; - break; - case WGL_SWAP_COPY_ARB: - mSwapMethod = SWAP_METHOD_COPY; - LL_DEBUGS("Window") << "Swap Method: Copy" << LL_ENDL; - break; - case WGL_SWAP_UNDEFINED_ARB: - mSwapMethod = SWAP_METHOD_UNDEFINED; - LL_DEBUGS("Window") << "Swap Method: Undefined" << LL_ENDL; - break; - default: - mSwapMethod = SWAP_METHOD_UNDEFINED; - LL_DEBUGS("Window") << "Swap Method: Unknown" << LL_ENDL; - break; - } - } - } - else - { - LL_WARNS("Window") << "No wgl_ARB_pixel_format extension, using default ChoosePixelFormat!" << LL_ENDL; - } - - // Verify what pixel format we actually received. - if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), - &pfd)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - LL_INFOS("Window") << "GL buffer: Color Bits " << S32(pfd.cColorBits) - << " Alpha Bits " << S32(pfd.cAlphaBits) - << " Depth Bits " << S32(pfd.cDepthBits) - << LL_ENDL; - - // make sure we have 32 bits per pixel - if (pfd.cColorBits < 32 || GetDeviceCaps(mhDC, BITSPIXEL) < 32) - { - close(); - OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (pfd.cAlphaBits < 8) - { - close(); - OSMessageBox(mCallbacks->translateString("MBAlpha"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!(mhRC = wglCreateContext(mhDC))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBGLContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!wglMakeCurrent(mhDC, mhRC)) - { - close(); - OSMessageBox(mCallbacks->translateString("MBGLContextActErr"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - if (!gGLManager.initGL()) - { - close(); - OSMessageBox(mCallbacks->translateString("MBVideoDrvErr"), mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } - - // Disable vertical sync for swap - if (disable_vsync && wglSwapIntervalEXT) - { - LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL; - wglSwapIntervalEXT(0); - } - else - { - LL_DEBUGS("Window") << "Keeping vertical sync" << LL_ENDL; - } - - SetWindowLong(mWindowHandle, GWL_USERDATA, (U32)this); - - // register this window as handling drag/drop events from the OS - DragAcceptFiles( mWindowHandle, TRUE ); - - //register joystick timer callback - SetTimer( mWindowHandle, 0, 1000 / 30, NULL ); // 30 fps timer - - // ok to post quit messages now - mPostQuit = TRUE; - - if (auto_show) - { - show(); - glClearColor(0.0f, 0.0f, 0.0f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); - swapBuffers(); - } - - return TRUE; -} - -void LLWindowWin32::moveWindow( const LLCoordScreen& position, const LLCoordScreen& size ) -{ - if( mIsMouseClipping ) - { - RECT client_rect_in_screen_space; - if( getClientRectInScreenSpace( &client_rect_in_screen_space ) ) - { - ClipCursor( &client_rect_in_screen_space ); - } - } - - // if the window was already maximized, MoveWindow seems to still set the maximized flag even if - // the window is smaller than maximized. - // So we're going to do a restore first (which is a ShowWindow call) (SL-44655). - - // THIS CAUSES DEV-15484 and DEV-15949 - //ShowWindow(mWindowHandle, SW_RESTORE); - // NOW we can call MoveWindow - MoveWindow(mWindowHandle, position.mX, position.mY, size.mX, size.mY, TRUE); -} - -BOOL LLWindowWin32::setCursorPosition(const LLCoordWindow position) -{ - LLCoordScreen screen_pos; - - mMousePositionModified = TRUE; - if (!mWindowHandle) - { - return FALSE; - } - - if (!convertCoords(position, &screen_pos)) - { - return FALSE; - } - - // Inform the application of the new mouse position (needed for per-frame - // hover/picking to function). - LLCoordGL gl_pos; - convertCoords(position, &gl_pos); - mCallbacks->handleMouseMove(this, gl_pos, (MASK)0); - - // DEV-18951 VWR-8524 Camera moves wildly when alt-clicking. - // Because we have preemptively notified the application of the new - // mouse position via handleMouseMove() above, we need to clear out - // any stale mouse move events. RN/JC - MSG msg; - while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) - { } - - return SetCursorPos(screen_pos.mX, screen_pos.mY); -} - -BOOL LLWindowWin32::getCursorPosition(LLCoordWindow *position) -{ - POINT cursor_point; - LLCoordScreen screen_pos; - - if (!mWindowHandle || - !GetCursorPos(&cursor_point)) - { - return FALSE; - } - - screen_pos.mX = cursor_point.x; - screen_pos.mY = cursor_point.y; - - return convertCoords(screen_pos, position); -} - -void LLWindowWin32::hideCursor() -{ - while (ShowCursor(FALSE) >= 0) - { - // nothing, wait for cursor to push down - } - mCursorHidden = TRUE; - mHideCursorPermanent = TRUE; -} - -void LLWindowWin32::showCursor() -{ - // makes sure the cursor shows up - while (ShowCursor(TRUE) < 0) - { - // do nothing, wait for cursor to pop out - } - mCursorHidden = FALSE; - mHideCursorPermanent = FALSE; -} - -void LLWindowWin32::showCursorFromMouseMove() -{ - if (!mHideCursorPermanent) - { - showCursor(); - } -} - -void LLWindowWin32::hideCursorUntilMouseMove() -{ - if (!mHideCursorPermanent) - { - hideCursor(); - mHideCursorPermanent = FALSE; - } -} - -BOOL LLWindowWin32::isCursorHidden() -{ - return mCursorHidden; -} - - -HCURSOR LLWindowWin32::loadColorCursor(LPCTSTR name) -{ - return (HCURSOR)LoadImage(mhInstance, - name, - IMAGE_CURSOR, - 0, // default width - 0, // default height - LR_DEFAULTCOLOR); -} - - -void LLWindowWin32::initCursors() -{ - mCursor[ UI_CURSOR_ARROW ] = LoadCursor(NULL, IDC_ARROW); - mCursor[ UI_CURSOR_WAIT ] = LoadCursor(NULL, IDC_WAIT); - mCursor[ UI_CURSOR_HAND ] = LoadCursor(NULL, IDC_HAND); - mCursor[ UI_CURSOR_IBEAM ] = LoadCursor(NULL, IDC_IBEAM); - mCursor[ UI_CURSOR_CROSS ] = LoadCursor(NULL, IDC_CROSS); - mCursor[ UI_CURSOR_SIZENWSE ] = LoadCursor(NULL, IDC_SIZENWSE); - mCursor[ UI_CURSOR_SIZENESW ] = LoadCursor(NULL, IDC_SIZENESW); - mCursor[ UI_CURSOR_SIZEWE ] = LoadCursor(NULL, IDC_SIZEWE); - mCursor[ UI_CURSOR_SIZENS ] = LoadCursor(NULL, IDC_SIZENS); - mCursor[ UI_CURSOR_NO ] = LoadCursor(NULL, IDC_NO); - mCursor[ UI_CURSOR_WORKING ] = LoadCursor(NULL, IDC_APPSTARTING); - - HMODULE module = GetModuleHandle(NULL); - mCursor[ UI_CURSOR_TOOLGRAB ] = LoadCursor(module, TEXT("TOOLGRAB")); - mCursor[ UI_CURSOR_TOOLLAND ] = LoadCursor(module, TEXT("TOOLLAND")); - mCursor[ UI_CURSOR_TOOLFOCUS ] = LoadCursor(module, TEXT("TOOLFOCUS")); - mCursor[ UI_CURSOR_TOOLCREATE ] = LoadCursor(module, TEXT("TOOLCREATE")); - mCursor[ UI_CURSOR_ARROWDRAG ] = LoadCursor(module, TEXT("ARROWDRAG")); - mCursor[ UI_CURSOR_ARROWCOPY ] = LoadCursor(module, TEXT("ARROWCOPY")); - mCursor[ UI_CURSOR_ARROWDRAGMULTI ] = LoadCursor(module, TEXT("ARROWDRAGMULTI")); - mCursor[ UI_CURSOR_ARROWCOPYMULTI ] = LoadCursor(module, TEXT("ARROWCOPYMULTI")); - mCursor[ UI_CURSOR_NOLOCKED ] = LoadCursor(module, TEXT("NOLOCKED")); - mCursor[ UI_CURSOR_ARROWLOCKED ]= LoadCursor(module, TEXT("ARROWLOCKED")); - mCursor[ UI_CURSOR_GRABLOCKED ] = LoadCursor(module, TEXT("GRABLOCKED")); - mCursor[ UI_CURSOR_TOOLTRANSLATE ] = LoadCursor(module, TEXT("TOOLTRANSLATE")); - mCursor[ UI_CURSOR_TOOLROTATE ] = LoadCursor(module, TEXT("TOOLROTATE")); - mCursor[ UI_CURSOR_TOOLSCALE ] = LoadCursor(module, TEXT("TOOLSCALE")); - mCursor[ UI_CURSOR_TOOLCAMERA ] = LoadCursor(module, TEXT("TOOLCAMERA")); - mCursor[ UI_CURSOR_TOOLPAN ] = LoadCursor(module, TEXT("TOOLPAN")); - mCursor[ UI_CURSOR_TOOLZOOMIN ] = LoadCursor(module, TEXT("TOOLZOOMIN")); - mCursor[ UI_CURSOR_TOOLPICKOBJECT3 ] = LoadCursor(module, TEXT("TOOLPICKOBJECT3")); - mCursor[ UI_CURSOR_PIPETTE ] = LoadCursor(module, TEXT("TOOLPIPETTE")); - - // Color cursors - mCursor[UI_CURSOR_TOOLPLAY] = loadColorCursor(TEXT("TOOLPLAY")); - mCursor[UI_CURSOR_TOOLPAUSE] = loadColorCursor(TEXT("TOOLPAUSE")); - mCursor[UI_CURSOR_TOOLMEDIAOPEN] = loadColorCursor(TEXT("TOOLMEDIAOPEN")); - - // Note: custom cursors that are not found make LoadCursor() return NULL. - for( S32 i = 0; i < UI_CURSOR_COUNT; i++ ) - { - if( !mCursor[i] ) - { - mCursor[i] = LoadCursor(NULL, IDC_ARROW); - } - } -} - - - -void LLWindowWin32::setCursor(ECursorType cursor) -{ - if (cursor == UI_CURSOR_ARROW - && mBusyCount > 0) - { - cursor = UI_CURSOR_WORKING; - } - - if( mCurrentCursor != cursor ) - { - mCurrentCursor = cursor; - SetCursor( mCursor[cursor] ); - } -} - -ECursorType LLWindowWin32::getCursor() const -{ - return mCurrentCursor; -} - -void LLWindowWin32::captureMouse() -{ - SetCapture(mWindowHandle); -} - -void LLWindowWin32::releaseMouse() -{ - // *NOTE:Mani ReleaseCapture will spawn new windows messages... - // which will in turn call our MainWindowProc. It therefore requires - // pausing *and more importantly resumption* of the mainlooptimeout... - // just like DispatchMessage below. - mCallbacks->handlePauseWatchdog(this); - ReleaseCapture(); - mCallbacks->handleResumeWatchdog(this); -} - - -void LLWindowWin32::delayInputProcessing() -{ - mInputProcessingPaused = TRUE; -} - -void LLWindowWin32::gatherInput() -{ - MSG msg; - int msg_count = 0; - - LLMemType m1(LLMemType::MTYPE_GATHER_INPUT); - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) && msg_count < MAX_MESSAGE_PER_UPDATE) - { - mCallbacks->handlePingWatchdog(this, "Main:TranslateGatherInput"); - TranslateMessage(&msg); - - // turn watchdog off in here to not fail if windows is doing something wacky - mCallbacks->handlePauseWatchdog(this); - DispatchMessage(&msg); - mCallbacks->handleResumeWatchdog(this); - msg_count++; - - if ( mInputProcessingPaused ) - { - break; - } - /* Attempted workaround for problem where typing fast and hitting - return would result in only part of the text being sent. JC - - BOOL key_posted = TranslateMessage(&msg); - DispatchMessage(&msg); - msg_count++; - - // If a key was translated, a WM_CHAR might have been posted to the end - // of the event queue. We need it immediately. - if (key_posted && msg.message == WM_KEYDOWN) - { - if (PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - msg_count++; - } - } - */ - mCallbacks->handlePingWatchdog(this, "Main:AsyncCallbackGatherInput"); - // For async host by name support. Really hacky. - if (gAsyncMsgCallback && (LL_WM_HOST_RESOLVED == msg.message)) - { - gAsyncMsgCallback(msg); - } - } - - mInputProcessingPaused = FALSE; - - // clear this once we've processed all mouse messages that might have occurred after - // we slammed the mouse position - mMousePositionModified = FALSE; -} - -static LLFastTimer::DeclareTimer FTM_KEYHANDLER("Handle Keyboard"); -static LLFastTimer::DeclareTimer FTM_MOUSEHANDLER("Handle Mouse"); - -LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param) -{ - LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(h_wnd, GWL_USERDATA); - - - if (NULL != window_imp) - { - window_imp->mCallbacks->handleResumeWatchdog(window_imp); - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:StartWndProc"); - // Has user provided their own window callback? - if (NULL != window_imp->mWndProc) - { - if (!window_imp->mWndProc(h_wnd, u_msg, w_param, l_param)) - { - // user has handled window message - return 0; - } - } - - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:PreSwitchWndProc"); - - // Juggle to make sure we can get negative positions for when - // mouse is outside window. - LLCoordWindow window_coord((S32)(S16)LOWORD(l_param), (S32)(S16)HIWORD(l_param)); - - // This doesn't work, as LOWORD returns unsigned short. - //LLCoordWindow window_coord(LOWORD(l_param), HIWORD(l_param)); - LLCoordGL gl_coord; - - // pass along extended flag in mask - MASK mask = (l_param>>16 & KF_EXTENDED) ? MASK_EXTENDED : 0x0; - BOOL eat_keystroke = TRUE; - - switch(u_msg) - { - RECT update_rect; - S32 update_width; - S32 update_height; - - case WM_TIMER: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_TIMER"); - window_imp->mCallbacks->handleTimerEvent(window_imp); - break; - - case WM_DEVICECHANGE: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DEVICECHANGE"); - if (gDebugWindowProc) - { - llinfos << " WM_DEVICECHANGE: wParam=" << w_param - << "; lParam=" << l_param << llendl; - } - if (w_param == DBT_DEVNODES_CHANGED || w_param == DBT_DEVICEARRIVAL) - { - if (window_imp->mCallbacks->handleDeviceChange(window_imp)) - { - return 0; - } - } - break; - - case WM_PAINT: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_PAINT"); - GetUpdateRect(window_imp->mWindowHandle, &update_rect, FALSE); - update_width = update_rect.right - update_rect.left + 1; - update_height = update_rect.bottom - update_rect.top + 1; - window_imp->mCallbacks->handlePaint(window_imp, update_rect.left, update_rect.top, - update_width, update_height); - break; - case WM_PARENTNOTIFY: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_PARENTNOTIFY"); - u_msg = u_msg; - break; - - case WM_SETCURSOR: - // This message is sent whenever the cursor is moved in a window. - // You need to set the appropriate cursor appearance. - - // Only take control of cursor over client region of window - // This allows Windows(tm) to handle resize cursors, etc. - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SETCURSOR"); - if (LOWORD(l_param) == HTCLIENT) - { - SetCursor(window_imp->mCursor[ window_imp->mCurrentCursor] ); - return 0; - } - break; - - case WM_ENTERMENULOOP: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ENTERMENULOOP"); - window_imp->mCallbacks->handleWindowBlock(window_imp); - break; - - case WM_EXITMENULOOP: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_EXITMENULOOP"); - window_imp->mCallbacks->handleWindowUnblock(window_imp); - break; - - case WM_ACTIVATEAPP: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ACTIVATEAPP"); - { - // This message should be sent whenever the app gains or loses focus. - BOOL activating = (BOOL) w_param; - BOOL minimized = window_imp->getMinimized(); - - if (gDebugWindowProc) - { - LL_INFOS("Window") << "WINDOWPROC ActivateApp " - << " activating " << S32(activating) - << " minimized " << S32(minimized) - << " fullscreen " << S32(window_imp->mFullscreen) - << LL_ENDL; - } - - if (window_imp->mFullscreen) - { - // When we run fullscreen, restoring or minimizing the app needs - // to switch the screen resolution - if (activating) - { - window_imp->setFullscreenResolution(); - window_imp->restore(); - } - else - { - window_imp->minimize(); - window_imp->resetDisplayResolution(); - } - } - - window_imp->mCallbacks->handleActivateApp(window_imp, activating); - - break; - } - - case WM_ACTIVATE: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ACTIVATE"); - { - // Can be one of WA_ACTIVE, WA_CLICKACTIVE, or WA_INACTIVE - BOOL activating = (LOWORD(w_param) != WA_INACTIVE); - - BOOL minimized = BOOL(HIWORD(w_param)); - - if (!activating && LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->interruptLanguageTextInput(); - } - - // JC - I'm not sure why, but if we don't report that we handled the - // WM_ACTIVATE message, the WM_ACTIVATEAPP messages don't work - // properly when we run fullscreen. - if (gDebugWindowProc) - { - LL_INFOS("Window") << "WINDOWPROC Activate " - << " activating " << S32(activating) - << " minimized " << S32(minimized) - << LL_ENDL; - } - - // Don't handle this. - break; - } - - case WM_QUERYOPEN: - // TODO: use this to return a nice icon - break; - - case WM_SYSCOMMAND: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SYSCOMMAND"); - switch(w_param) - { - case SC_KEYMENU: - // Disallow the ALT key from triggering the default system menu. - return 0; - - case SC_SCREENSAVE: - case SC_MONITORPOWER: - // eat screen save messages and prevent them! - return 0; - } - break; - - case WM_CLOSE: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_CLOSE"); - // Will the app allow the window to close? - if (window_imp->mCallbacks->handleCloseRequest(window_imp)) - { - // Get the app to initiate cleanup. - window_imp->mCallbacks->handleQuit(window_imp); - // The app is responsible for calling destroyWindow when done with GL - } - return 0; - - case WM_DESTROY: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DESTROY"); - if (window_imp->shouldPostQuit()) - { - PostQuitMessage(0); // Posts WM_QUIT with an exit code of 0 - } - return 0; - - case WM_COMMAND: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COMMAND"); - if (!HIWORD(w_param)) // this message is from a menu - { - window_imp->mCallbacks->handleMenuSelect(window_imp, LOWORD(w_param)); - } - break; - - case WM_SYSKEYDOWN: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SYSKEYDOWN"); - // allow system keys, such as ALT-F4 to be processed by Windows - eat_keystroke = FALSE; - case WM_KEYDOWN: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYDOWN"); - { - if (gDebugWindowProc) - { - LL_INFOS("Window") << "Debug WindowProc WM_KEYDOWN " - << " key " << S32(w_param) - << LL_ENDL; - } - if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke) - { - return 0; - } - // pass on to windows if we didn't handle it - break; - } - case WM_SYSKEYUP: - eat_keystroke = FALSE; - case WM_KEYUP: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYUP"); - LLFastTimer t2(FTM_KEYHANDLER); - - if (gDebugWindowProc) - { - LL_INFOS("Window") << "Debug WindowProc WM_KEYUP " - << " key " << S32(w_param) - << LL_ENDL; - } - if (gKeyboard->handleKeyUp(w_param, mask) && eat_keystroke) - { - return 0; - } - - // pass on to windows - break; - } - case WM_IME_SETCONTEXT: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_SETCONTEXT"); - if (gDebugWindowProc) - { - llinfos << "WM_IME_SETCONTEXT" << llendl; - } - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - l_param &= ~ISC_SHOWUICOMPOSITIONWINDOW; - // Invoke DefWinProc with the modified LPARAM. - } - break; - - case WM_IME_STARTCOMPOSITION: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_STARTCOMPOSITION"); - if (gDebugWindowProc) - { - llinfos << "WM_IME_STARTCOMPOSITION" << llendl; - } - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->handleStartCompositionMessage(); - return 0; - } - break; - - case WM_IME_ENDCOMPOSITION: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_ENDCOMPOSITION"); - if (gDebugWindowProc) - { - llinfos << "WM_IME_ENDCOMPOSITION" << llendl; - } - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - return 0; - } - break; - - case WM_IME_COMPOSITION: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_COMPOSITION"); - if (gDebugWindowProc) - { - llinfos << "WM_IME_COMPOSITION" << llendl; - } - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->handleCompositionMessage(l_param); - return 0; - } - break; - - case WM_IME_REQUEST: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_REQUEST"); - if (gDebugWindowProc) - { - llinfos << "WM_IME_REQUEST" << llendl; - } - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - LRESULT result = 0; - if (window_imp->handleImeRequests(w_param, l_param, &result)) - { - return result; - } - } - break; - - case WM_CHAR: - // Should really use WM_UNICHAR eventually, but it requires a specific Windows version and I need - // to figure out how that works. - Doug - // - // ... Well, I don't think so. - // How it works is explained in Win32 API document, but WM_UNICHAR didn't work - // as specified at least on Windows XP SP1 Japanese version. I have never used - // it since then, and I'm not sure whether it has been fixed now, but I don't think - // it is worth trying. The good old WM_CHAR works just fine even for supplementary - // characters. We just need to take care of surrogate pairs sent as two WM_CHAR's - // by ourselves. It is not that tough. -- Alissa Sabre @ SL - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_CHAR"); - if (gDebugWindowProc) - { - LL_INFOS("Window") << "Debug WindowProc WM_CHAR " - << " key " << S32(w_param) - << LL_ENDL; - } - // Even if LLWindowCallbacks::handleUnicodeChar(llwchar, BOOL) returned FALSE, - // we *did* processed the event, so I believe we should not pass it to DefWindowProc... - window_imp->handleUnicodeUTF16((U16)w_param, gKeyboard->currentMask(FALSE)); - return 0; - - case WM_LBUTTONDOWN: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->interruptLanguageTextInput(); - } - - // Because we move the cursor position in the app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleMouseDown(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_LBUTTONDBLCLK: - //RN: ignore right button double clicks for now - //case WM_RBUTTONDBLCLK: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDBLCLK"); - // Because we move the cursor position in the app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleDoubleClick(window_imp, gl_coord, mask) ) - { - return 0; - } - } - break; - - case WM_LBUTTONUP: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); - //if (gDebugClicks) - //{ - // LL_INFOS("Window") << "WndProc left button up" << LL_ENDL; - //} - // Because we move the cursor position in the app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleMouseUp(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->interruptLanguageTextInput(); - } - - // Because we move the cursor position in the llviewerapp, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleRightMouseDown(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_RBUTTONUP: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); - // Because we move the cursor position in the app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleRightMouseUp(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_MBUTTONDOWN: -// case WM_MBUTTONDBLCLK: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); - if (LLWinImm::isAvailable() && window_imp->mPreeditor) - { - window_imp->interruptLanguageTextInput(); - } - - // Because we move the cursor position in tllviewerhe app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleMiddleMouseDown(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_MBUTTONUP: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); - // Because we move the cursor position in tllviewerhe app, we need to query - // to find out where the cursor at the time the event is handled. - // If we don't do this, many clicks could get buffered up, and if the - // first click changes the cursor position, all subsequent clicks - // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; - if (window_imp->mMousePositionModified) - { - window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - } - else - { - window_imp->convertCoords(window_coord, &gl_coord); - } - MASK mask = gKeyboard->currentMask(TRUE); - // generate move event to update mouse coordinates - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - if (window_imp->mCallbacks->handleMiddleMouseUp(window_imp, gl_coord, mask)) - { - return 0; - } - } - break; - - case WM_MOUSEWHEEL: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEWHEEL"); - static short z_delta = 0; - - z_delta += HIWORD(w_param); - // cout << "z_delta " << z_delta << endl; - - // current mouse wheels report changes in increments of zDelta (+120, -120) - // Future, higher resolution mouse wheels may report smaller deltas. - // So we sum the deltas and only act when we've exceeded WHEEL_DELTA - // - // If the user rapidly spins the wheel, we can get messages with - // large deltas, like 480 or so. Thus we need to scroll more quickly. - if (z_delta <= -WHEEL_DELTA || WHEEL_DELTA <= z_delta) - { - window_imp->mCallbacks->handleScrollWheel(window_imp, -z_delta / WHEEL_DELTA); - z_delta = 0; - } - return 0; - } - /* - // TODO: add this after resolving _WIN32_WINNT issue - case WM_MOUSELEAVE: - { - window_imp->mCallbacks->handleMouseLeave(window_imp); - - // TRACKMOUSEEVENT track_mouse_event; - // track_mouse_event.cbSize = sizeof( TRACKMOUSEEVENT ); - // track_mouse_event.dwFlags = TME_LEAVE; - // track_mouse_event.hwndTrack = h_wnd; - // track_mouse_event.dwHoverTime = HOVER_DEFAULT; - // TrackMouseEvent( &track_mouse_event ); - return 0; - } - */ - // Handle mouse movement within the window - case WM_MOUSEMOVE: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEMOVE"); - window_imp->convertCoords(window_coord, &gl_coord); - MASK mask = gKeyboard->currentMask(TRUE); - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); - return 0; - } - - case WM_SIZE: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SIZE"); - S32 width = S32( LOWORD(l_param) ); - S32 height = S32( HIWORD(l_param) ); - - if (gDebugWindowProc) - { - BOOL maximized = ( w_param == SIZE_MAXIMIZED ); - BOOL restored = ( w_param == SIZE_RESTORED ); - BOOL minimized = ( w_param == SIZE_MINIMIZED ); - - LL_INFOS("Window") << "WINDOWPROC Size " - << width << "x" << height - << " max " << S32(maximized) - << " min " << S32(minimized) - << " rest " << S32(restored) - << LL_ENDL; - } - - // There's an odd behavior with WM_SIZE that I would call a bug. If - // the window is maximized, and you call MoveWindow() with a size smaller - // than a maximized window, it ends up sending WM_SIZE with w_param set - // to SIZE_MAXIMIZED -- which isn't true. So the logic below doesn't work. - // (SL-44655). Fixed it by calling ShowWindow(SW_RESTORE) first (see - // LLWindowWin32::moveWindow in this file). - - // If we are now restored, but we weren't before, this - // means that the window was un-minimized. - if (w_param == SIZE_RESTORED && window_imp->mLastSizeWParam != SIZE_RESTORED) - { - window_imp->mCallbacks->handleActivate(window_imp, TRUE); - } - - // handle case of window being maximized from fully minimized state - if (w_param == SIZE_MAXIMIZED && window_imp->mLastSizeWParam != SIZE_MAXIMIZED) - { - window_imp->mCallbacks->handleActivate(window_imp, TRUE); - } - - // Also handle the minimization case - if (w_param == SIZE_MINIMIZED && window_imp->mLastSizeWParam != SIZE_MINIMIZED) - { - window_imp->mCallbacks->handleActivate(window_imp, FALSE); - } - - // Actually resize all of our views - if (w_param != SIZE_MINIMIZED) - { - // Ignore updates for minimizing and minimized "windows" - window_imp->mCallbacks->handleResize( window_imp, - LOWORD(l_param), - HIWORD(l_param) ); - } - - window_imp->mLastSizeWParam = w_param; - - return 0; - } - - case WM_SETFOCUS: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SETFOCUS"); - if (gDebugWindowProc) - { - LL_INFOS("Window") << "WINDOWPROC SetFocus" << LL_ENDL; - } - window_imp->mCallbacks->handleFocus(window_imp); - return 0; - - case WM_KILLFOCUS: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KILLFOCUS"); - if (gDebugWindowProc) - { - LL_INFOS("Window") << "WINDOWPROC KillFocus" << LL_ENDL; - } - window_imp->mCallbacks->handleFocusLost(window_imp); - return 0; - - case WM_COPYDATA: - { - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); - // received a URL - PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; - window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); - }; - return 0; - - case WM_DROPFILES: - { - // HDROP contains what we need - HDROP hdrop = (HDROP)w_param; - - // get location in window space where drop occured and convert to OpenGL coordinate space - POINT pt; - DragQueryPoint( hdrop, &pt ); - LLCoordGL gl_coord; - LLCoordWindow cursor_coord_window( pt.x, pt.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - - // get payload (eventually, this needs to more advanced and grab size of payload dynamically - static char file_name[ 1024 ]; +#include + +// Require DirectInput version 8 +#define DIRECTINPUT_VERSION 0x0800 + +#include +#include + +#include "llmemtype.h" +// culled from winuser.h +#ifndef WM_MOUSEWHEEL /* Added to be compatible with later SDK's */ +const S32 WM_MOUSEWHEEL = 0x020A; +#endif +#ifndef WHEEL_DELTA /* Added to be compatible with later SDK's */ +const S32 WHEEL_DELTA = 120; /* Value for rolling one detent */ +#endif +const S32 MAX_MESSAGE_PER_UPDATE = 20; +const S32 BITS_PER_PIXEL = 32; +const S32 MAX_NUM_RESOLUTIONS = 32; +const F32 ICON_FLASH_TIME = 0.5f; + +extern BOOL gDebugWindowProc; + +LPWSTR gIconResource = IDI_APPLICATION; + +LLW32MsgCallback gAsyncMsgCallback = NULL; + +// +// LLWindowWin32 +// + +void show_window_creation_error(const std::string& title) +{ + LL_WARNS("Window") << title << LL_ENDL; +} + +//static +BOOL LLWindowWin32::sIsClassRegistered = FALSE; + +BOOL LLWindowWin32::sLanguageTextInputAllowed = TRUE; +BOOL LLWindowWin32::sWinIMEOpened = FALSE; +HKL LLWindowWin32::sWinInputLocale = 0; +DWORD LLWindowWin32::sWinIMEConversionMode = IME_CMODE_NATIVE; +DWORD LLWindowWin32::sWinIMESentenceMode = IME_SMODE_AUTOMATIC; +LLCoordWindow LLWindowWin32::sWinIMEWindowPosition(-1,-1); + +// The following class LLWinImm delegates Windows IMM APIs. +// We need this because some language versions of Windows, +// e.g., US version of Windows XP, doesn't install IMM32.DLL +// as a default, and we can't link against imm32.lib statically. +// I believe DLL loading of this type is best suited to do +// in a static initialization of a class. What I'm not sure is +// whether it follows the Linden Conding Standard... +// See http://wiki.secondlife.com/wiki/Coding_standards#Static_Members + +class LLWinImm +{ +public: + static bool isAvailable() { return sTheInstance.mHImmDll != NULL; } + +public: + // Wrappers for IMM API. + static BOOL isIME(HKL hkl); + static HWND getDefaultIMEWnd(HWND hwnd); + static HIMC getContext(HWND hwnd); + static BOOL releaseContext(HWND hwnd, HIMC himc); + static BOOL getOpenStatus(HIMC himc); + static BOOL setOpenStatus(HIMC himc, BOOL status); + static BOOL getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence); + static BOOL setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence); + static BOOL getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); + static BOOL setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); + static LONG getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length); + static BOOL setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength); + static BOOL setCompositionFont(HIMC himc, LPLOGFONTW logfont); + static BOOL setCandidateWindow(HIMC himc, LPCANDIDATEFORM candidate_form); + static BOOL notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value); + +private: + LLWinImm(); + ~LLWinImm(); + +private: + // Pointers to IMM API. + BOOL (WINAPI *mImmIsIME)(HKL); + HWND (WINAPI *mImmGetDefaultIMEWnd)(HWND); + HIMC (WINAPI *mImmGetContext)(HWND); + BOOL (WINAPI *mImmReleaseContext)(HWND, HIMC); + BOOL (WINAPI *mImmGetOpenStatus)(HIMC); + BOOL (WINAPI *mImmSetOpenStatus)(HIMC, BOOL); + BOOL (WINAPI *mImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); + BOOL (WINAPI *mImmSetConversionStatus)(HIMC, DWORD, DWORD); + BOOL (WINAPI *mImmGetCompostitionWindow)(HIMC, LPCOMPOSITIONFORM); + BOOL (WINAPI *mImmSetCompostitionWindow)(HIMC, LPCOMPOSITIONFORM); + LONG (WINAPI *mImmGetCompositionString)(HIMC, DWORD, LPVOID, DWORD); + BOOL (WINAPI *mImmSetCompositionString)(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD); + BOOL (WINAPI *mImmSetCompositionFont)(HIMC, LPLOGFONTW); + BOOL (WINAPI *mImmSetCandidateWindow)(HIMC, LPCANDIDATEFORM); + BOOL (WINAPI *mImmNotifyIME)(HIMC, DWORD, DWORD, DWORD); + +private: + HMODULE mHImmDll; + static LLWinImm sTheInstance; +}; + +LLWinImm LLWinImm::sTheInstance; + +LLWinImm::LLWinImm() : mHImmDll(NULL) +{ + // Check system metrics + if ( !GetSystemMetrics( SM_DBCSENABLED ) ) + return; + + + mHImmDll = LoadLibraryA("Imm32"); + if (mHImmDll != NULL) + { + mImmIsIME = (BOOL (WINAPI *)(HKL)) GetProcAddress(mHImmDll, "ImmIsIME"); + mImmGetDefaultIMEWnd = (HWND (WINAPI *)(HWND)) GetProcAddress(mHImmDll, "ImmGetDefaultIMEWnd"); + mImmGetContext = (HIMC (WINAPI *)(HWND)) GetProcAddress(mHImmDll, "ImmGetContext"); + mImmReleaseContext = (BOOL (WINAPI *)(HWND, HIMC)) GetProcAddress(mHImmDll, "ImmReleaseContext"); + mImmGetOpenStatus = (BOOL (WINAPI *)(HIMC)) GetProcAddress(mHImmDll, "ImmGetOpenStatus"); + mImmSetOpenStatus = (BOOL (WINAPI *)(HIMC, BOOL)) GetProcAddress(mHImmDll, "ImmSetOpenStatus"); + mImmGetConversionStatus = (BOOL (WINAPI *)(HIMC, LPDWORD, LPDWORD)) GetProcAddress(mHImmDll, "ImmGetConversionStatus"); + mImmSetConversionStatus = (BOOL (WINAPI *)(HIMC, DWORD, DWORD)) GetProcAddress(mHImmDll, "ImmSetConversionStatus"); + mImmGetCompostitionWindow = (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(mHImmDll, "ImmGetCompositionWindow"); + mImmSetCompostitionWindow = (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(mHImmDll, "ImmSetCompositionWindow"); + mImmGetCompositionString= (LONG (WINAPI *)(HIMC, DWORD, LPVOID, DWORD)) GetProcAddress(mHImmDll, "ImmGetCompositionStringW"); + mImmSetCompositionString= (BOOL (WINAPI *)(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD)) GetProcAddress(mHImmDll, "ImmSetCompositionStringW"); + mImmSetCompositionFont = (BOOL (WINAPI *)(HIMC, LPLOGFONTW)) GetProcAddress(mHImmDll, "ImmSetCompositionFontW"); + mImmSetCandidateWindow = (BOOL (WINAPI *)(HIMC, LPCANDIDATEFORM)) GetProcAddress(mHImmDll, "ImmSetCandidateWindow"); + mImmNotifyIME = (BOOL (WINAPI *)(HIMC, DWORD, DWORD, DWORD)) GetProcAddress(mHImmDll, "ImmNotifyIME"); + + if (mImmIsIME == NULL || + mImmGetDefaultIMEWnd == NULL || + mImmGetContext == NULL || + mImmReleaseContext == NULL || + mImmGetOpenStatus == NULL || + mImmSetOpenStatus == NULL || + mImmGetConversionStatus == NULL || + mImmSetConversionStatus == NULL || + mImmGetCompostitionWindow == NULL || + mImmSetCompostitionWindow == NULL || + mImmGetCompositionString == NULL || + mImmSetCompositionString == NULL || + mImmSetCompositionFont == NULL || + mImmSetCandidateWindow == NULL || + mImmNotifyIME == NULL) + { + // If any of the above API entires are not found, we can't use IMM API. + // So, turn off the IMM support. We should log some warning message in + // the case, since it is very unusual; these APIs are available from + // the beginning, and all versions of IMM32.DLL should have them all. + // Unfortunately, this code may be executed before initialization of + // the logging channel (llwarns), and we can't do it here... Yes, this + // is one of disadvantages to use static constraction to DLL loading. + FreeLibrary(mHImmDll); + mHImmDll = NULL; + + // If we unload the library, make sure all the function pointers are cleared + mImmIsIME = NULL; + mImmGetDefaultIMEWnd = NULL; + mImmGetContext = NULL; + mImmReleaseContext = NULL; + mImmGetOpenStatus = NULL; + mImmSetOpenStatus = NULL; + mImmGetConversionStatus = NULL; + mImmSetConversionStatus = NULL; + mImmGetCompostitionWindow = NULL; + mImmSetCompostitionWindow = NULL; + mImmGetCompositionString = NULL; + mImmSetCompositionString = NULL; + mImmSetCompositionFont = NULL; + mImmSetCandidateWindow = NULL; + mImmNotifyIME = NULL; + } + } +} + + +// static +BOOL LLWinImm::isIME(HKL hkl) +{ + if ( sTheInstance.mImmIsIME ) + return sTheInstance.mImmIsIME(hkl); + return FALSE; +} + +// static +HIMC LLWinImm::getContext(HWND hwnd) +{ + if ( sTheInstance.mImmGetContext ) + return sTheInstance.mImmGetContext(hwnd); + return 0; +} + +//static +BOOL LLWinImm::releaseContext(HWND hwnd, HIMC himc) +{ + if ( sTheInstance.mImmIsIME ) + return sTheInstance.mImmReleaseContext(hwnd, himc); + return FALSE; +} + +// static +BOOL LLWinImm::getOpenStatus(HIMC himc) +{ + if ( sTheInstance.mImmGetOpenStatus ) + return sTheInstance.mImmGetOpenStatus(himc); + return FALSE; +} + +// static +BOOL LLWinImm::setOpenStatus(HIMC himc, BOOL status) +{ + if ( sTheInstance.mImmSetOpenStatus ) + return sTheInstance.mImmSetOpenStatus(himc, status); + return FALSE; +} + +// static +BOOL LLWinImm::getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence) +{ + if ( sTheInstance.mImmGetConversionStatus ) + return sTheInstance.mImmGetConversionStatus(himc, conversion, sentence); + return FALSE; +} + +// static +BOOL LLWinImm::setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence) +{ + if ( sTheInstance.mImmSetConversionStatus ) + return sTheInstance.mImmSetConversionStatus(himc, conversion, sentence); + return FALSE; +} + +// static +BOOL LLWinImm::getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) +{ + if ( sTheInstance.mImmGetCompostitionWindow ) + return sTheInstance.mImmGetCompostitionWindow(himc, form); + return FALSE; +} + +// static +BOOL LLWinImm::setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) +{ + if ( sTheInstance.mImmSetCompostitionWindow ) + return sTheInstance.mImmSetCompostitionWindow(himc, form); + return FALSE; +} + + +// static +LONG LLWinImm::getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length) +{ + if ( sTheInstance.mImmGetCompositionString ) + return sTheInstance.mImmGetCompositionString(himc, index, data, length); + return FALSE; +} + + +// static +BOOL LLWinImm::setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength) +{ + if ( sTheInstance.mImmSetCompositionString ) + return sTheInstance.mImmSetCompositionString(himc, index, pComp, compLength, pRead, readLength); + return FALSE; +} + +// static +BOOL LLWinImm::setCompositionFont(HIMC himc, LPLOGFONTW pFont) +{ + if ( sTheInstance.mImmSetCompositionFont ) + return sTheInstance.mImmSetCompositionFont(himc, pFont); + return FALSE; +} + +// static +BOOL LLWinImm::setCandidateWindow(HIMC himc, LPCANDIDATEFORM form) +{ + if ( sTheInstance.mImmSetCandidateWindow ) + return sTheInstance.mImmSetCandidateWindow(himc, form); + return FALSE; +} + +// static +BOOL LLWinImm::notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value) +{ + if ( sTheInstance.mImmNotifyIME ) + return sTheInstance.mImmNotifyIME(himc, action, index, value); + return FALSE; +} + + + + +// ---------------------------------------------------------------------------------------- +LLWinImm::~LLWinImm() +{ + if (mHImmDll != NULL) + { + FreeLibrary(mHImmDll); + mHImmDll = NULL; + } +} + + +LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, + S32 height, U32 flags, + BOOL fullscreen, BOOL clearBg, + BOOL disable_vsync, BOOL use_gl, + BOOL ignore_pixel_depth, + U32 fsaa_samples) + : LLWindow(callbacks, fullscreen, flags) +{ + mFSAASamples = fsaa_samples; + mIconResource = gIconResource; + mOverrideAspectRatio = 0.f; + mNativeAspectRatio = 0.f; + mMousePositionModified = FALSE; + mInputProcessingPaused = FALSE; + mPreeditor = NULL; + mhDC = NULL; + mhRC = NULL; + + // Initialize the keyboard + gKeyboard = new LLKeyboardWin32(); + gKeyboard->setCallbacks(callbacks); + + // Initialize the Drag and Drop functionality + mDragDrop = new LLDragDropWin32; + + // Initialize (boot strap) the Language text input management, + // based on the system's (user's) default settings. + allowLanguageTextInput(mPreeditor, FALSE); + + WNDCLASS wc; + RECT window_rect; + + // Set the window title + if (title.empty()) + { + mWindowTitle = new WCHAR[50]; + wsprintf(mWindowTitle, L"OpenGL Window"); + } + else + { + mWindowTitle = new WCHAR[256]; // Assume title length < 255 chars. + mbstowcs(mWindowTitle, title.c_str(), 255); + mWindowTitle[255] = 0; + } + + // Set the window class name + if (name.empty()) + { + mWindowClassName = new WCHAR[50]; + wsprintf(mWindowClassName, L"OpenGL Window"); + } + else + { + mWindowClassName = new WCHAR[256]; // Assume title length < 255 chars. + mbstowcs(mWindowClassName, name.c_str(), 255); + mWindowClassName[255] = 0; + } + + + // We're not clipping yet + SetRect( &mOldMouseClip, 0, 0, 0, 0 ); + + // Make an instance of our window then define the window class + mhInstance = GetModuleHandle(NULL); + mWndProc = NULL; + + mSwapMethod = SWAP_METHOD_UNDEFINED; + + // No WPARAM yet. + mLastSizeWParam = 0; + + // Windows GDI rects don't include rightmost pixel + window_rect.left = (long) 0; + window_rect.right = (long) width; + window_rect.top = (long) 0; + window_rect.bottom = (long) height; + + // Grab screen size to sanitize the window + S32 window_border_y = GetSystemMetrics(SM_CYBORDER); + S32 virtual_screen_x = GetSystemMetrics(SM_XVIRTUALSCREEN); + S32 virtual_screen_y = GetSystemMetrics(SM_YVIRTUALSCREEN); + S32 virtual_screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + S32 virtual_screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + + if (x < virtual_screen_x) x = virtual_screen_x; + if (y < virtual_screen_y - window_border_y) y = virtual_screen_y - window_border_y; + + if (x + width > virtual_screen_x + virtual_screen_width) x = virtual_screen_x + virtual_screen_width - width; + if (y + height > virtual_screen_y + virtual_screen_height) y = virtual_screen_y + virtual_screen_height - height; + + if (!sIsClassRegistered) + { + // Force redraw when resized and create a private device context + + // Makes double click messages. + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; + + // Set message handler function + wc.lpfnWndProc = (WNDPROC) mainWindowProc; + + // unused + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + wc.hInstance = mhInstance; + wc.hIcon = LoadIcon(mhInstance, mIconResource); + + // We will set the cursor ourselves + wc.hCursor = NULL; + + // background color is not used + if (clearBg) + { + wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + } + else + { + wc.hbrBackground = (HBRUSH) NULL; + } + + // we don't use windows menus + wc.lpszMenuName = NULL; + + wc.lpszClassName = mWindowClassName; + + if (!RegisterClass(&wc)) + { + OSMessageBox(mCallbacks->translateString("MBRegClassFailed"), + mCallbacks->translateString("MBError"), OSMB_OK); + return; + } + sIsClassRegistered = TRUE; + } + + //----------------------------------------------------------------------- + // Get the current refresh rate + //----------------------------------------------------------------------- + + DEVMODE dev_mode; + DWORD current_refresh; + if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) + { + current_refresh = dev_mode.dmDisplayFrequency; + mNativeAspectRatio = ((F32)dev_mode.dmPelsWidth) / ((F32)dev_mode.dmPelsHeight); + } + else + { + current_refresh = 60; + } + + //----------------------------------------------------------------------- + // Drop resolution and go fullscreen + // use a display mode with our desired size and depth, with a refresh + // rate as close at possible to the users' default + //----------------------------------------------------------------------- + if (mFullscreen) + { + BOOL success = FALSE; + DWORD closest_refresh = 0; + + for (S32 mode_num = 0;; mode_num++) + { + if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) + { + break; + } + + if (dev_mode.dmPelsWidth == width && + dev_mode.dmPelsHeight == height && + dev_mode.dmBitsPerPel == BITS_PER_PIXEL) + { + success = TRUE; + if ((dev_mode.dmDisplayFrequency - current_refresh) + < (closest_refresh - current_refresh)) + { + closest_refresh = dev_mode.dmDisplayFrequency; + } + } + } + + if (closest_refresh == 0) + { + LL_WARNS("Window") << "Couldn't find display mode " << width << " by " << height << " at " << BITS_PER_PIXEL << " bits per pixel" << LL_ENDL; + success = FALSE; + } + + // If we found a good resolution, use it. + if (success) + { + success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); + } + + // Keep a copy of the actual current device mode in case we minimize + // and change the screen resolution. JC + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); + + // If it failed, we don't want to run fullscreen + if (success) + { + mFullscreen = TRUE; + mFullscreenWidth = dev_mode.dmPelsWidth; + mFullscreenHeight = dev_mode.dmPelsHeight; + mFullscreenBits = dev_mode.dmBitsPerPel; + mFullscreenRefresh = dev_mode.dmDisplayFrequency; + + LL_INFOS("Window") << "Running at " << dev_mode.dmPelsWidth + << "x" << dev_mode.dmPelsHeight + << "x" << dev_mode.dmBitsPerPel + << " @ " << dev_mode.dmDisplayFrequency + << LL_ENDL; + } + else + { + mFullscreen = FALSE; + mFullscreenWidth = -1; + mFullscreenHeight = -1; + mFullscreenBits = -1; + mFullscreenRefresh = -1; + + std::map args; + args["[WIDTH]"] = llformat("%d", width); + args["[HEIGHT]"] = llformat ("%d", height); + OSMessageBox(mCallbacks->translateString("MBFullScreenErr", args), + mCallbacks->translateString("MBError"), OSMB_OK); + } + } + + // TODO: add this after resolving _WIN32_WINNT issue + // if (!fullscreen) + // { + // TRACKMOUSEEVENT track_mouse_event; + // track_mouse_event.cbSize = sizeof( TRACKMOUSEEVENT ); + // track_mouse_event.dwFlags = TME_LEAVE; + // track_mouse_event.hwndTrack = mWindowHandle; + // track_mouse_event.dwHoverTime = HOVER_DEFAULT; + // TrackMouseEvent( &track_mouse_event ); + // } + + + //----------------------------------------------------------------------- + // Create GL drawing context + //----------------------------------------------------------------------- + LLCoordScreen windowPos(x,y); + LLCoordScreen windowSize(window_rect.right - window_rect.left, + window_rect.bottom - window_rect.top); + if (!switchContext(mFullscreen, windowSize, TRUE, &windowPos)) + { + return; + } + + //start with arrow cursor + initCursors(); + setCursor( UI_CURSOR_ARROW ); + + // Initialize (boot strap) the Language text input management, + // based on the system's (or user's) default settings. + allowLanguageTextInput(NULL, FALSE); +} + + +LLWindowWin32::~LLWindowWin32() +{ + delete mDragDrop; + + delete [] mWindowTitle; + mWindowTitle = NULL; + + delete [] mSupportedResolutions; + mSupportedResolutions = NULL; + + delete mWindowClassName; + mWindowClassName = NULL; +} + +void LLWindowWin32::show() +{ + ShowWindow(mWindowHandle, SW_SHOW); + SetForegroundWindow(mWindowHandle); + SetFocus(mWindowHandle); +} + +void LLWindowWin32::hide() +{ + setMouseClipping(FALSE); + ShowWindow(mWindowHandle, SW_HIDE); +} + +void LLWindowWin32::minimize() +{ + setMouseClipping(FALSE); + showCursor(); + ShowWindow(mWindowHandle, SW_MINIMIZE); +} + + +void LLWindowWin32::restore() +{ + ShowWindow(mWindowHandle, SW_RESTORE); + SetForegroundWindow(mWindowHandle); + SetFocus(mWindowHandle); +} + + +// close() destroys all OS-specific code associated with a window. +// Usually called from LLWindowManager::destroyWindow() +void LLWindowWin32::close() +{ + LL_DEBUGS("Window") << "Closing LLWindowWin32" << LL_ENDL; + // Is window is already closed? + if (!mWindowHandle) + { + return; + } + + mDragDrop->reset(); + + // Make sure cursor is visible and we haven't mangled the clipping state. + setMouseClipping(FALSE); + showCursor(); + + // Go back to screen mode written in the registry. + if (mFullscreen) + { + resetDisplayResolution(); + } + + // Clean up remaining GL state + LL_DEBUGS("Window") << "Shutting down GL" << LL_ENDL; + gGLManager.shutdownGL(); + + LL_DEBUGS("Window") << "Releasing Context" << LL_ENDL; + if (mhRC) + { + if (!wglMakeCurrent(NULL, NULL)) + { + LL_WARNS("Window") << "Release of DC and RC failed" << LL_ENDL; + } + + if (!wglDeleteContext(mhRC)) + { + LL_WARNS("Window") << "Release of rendering context failed" << LL_ENDL; + } + + mhRC = NULL; + } + + // Restore gamma to the system values. + restoreGamma(); + + if (mhDC && !ReleaseDC(mWindowHandle, mhDC)) + { + LL_WARNS("Window") << "Release of ghDC failed" << LL_ENDL; + mhDC = NULL; + } + + LL_DEBUGS("Window") << "Destroying Window" << LL_ENDL; + + // Don't process events in our mainWindowProc any longer. + SetWindowLong(mWindowHandle, GWL_USERDATA, NULL); + + // Make sure we don't leave a blank toolbar button. + ShowWindow(mWindowHandle, SW_HIDE); + + // This causes WM_DESTROY to be sent *immediately* + if (!DestroyWindow(mWindowHandle)) + { + OSMessageBox(mCallbacks->translateString("MBDestroyWinFailed"), + mCallbacks->translateString("MBShutdownErr"), + OSMB_OK); + } + + mWindowHandle = NULL; +} + +BOOL LLWindowWin32::isValid() +{ + return (mWindowHandle != NULL); +} + +BOOL LLWindowWin32::getVisible() +{ + return (mWindowHandle && IsWindowVisible(mWindowHandle)); +} + +BOOL LLWindowWin32::getMinimized() +{ + return (mWindowHandle && IsIconic(mWindowHandle)); +} + +BOOL LLWindowWin32::getMaximized() +{ + return (mWindowHandle && IsZoomed(mWindowHandle)); +} + +BOOL LLWindowWin32::maximize() +{ + BOOL success = FALSE; + if (!mWindowHandle) return success; + + WINDOWPLACEMENT placement; + placement.length = sizeof(WINDOWPLACEMENT); + + success = GetWindowPlacement(mWindowHandle, &placement); + if (!success) return success; + + placement.showCmd = SW_MAXIMIZE; + + success = SetWindowPlacement(mWindowHandle, &placement); + return success; +} + +BOOL LLWindowWin32::getFullscreen() +{ + return mFullscreen; +} + +BOOL LLWindowWin32::getPosition(LLCoordScreen *position) +{ + RECT window_rect; + + if (!mWindowHandle || + !GetWindowRect(mWindowHandle, &window_rect) || + NULL == position) + { + return FALSE; + } + + position->mX = window_rect.left; + position->mY = window_rect.top; + return TRUE; +} + +BOOL LLWindowWin32::getSize(LLCoordScreen *size) +{ + RECT window_rect; + + if (!mWindowHandle || + !GetWindowRect(mWindowHandle, &window_rect) || + NULL == size) + { + return FALSE; + } + + size->mX = window_rect.right - window_rect.left; + size->mY = window_rect.bottom - window_rect.top; + return TRUE; +} + +BOOL LLWindowWin32::getSize(LLCoordWindow *size) +{ + RECT client_rect; + + if (!mWindowHandle || + !GetClientRect(mWindowHandle, &client_rect) || + NULL == size) + { + return FALSE; + } + + size->mX = client_rect.right - client_rect.left; + size->mY = client_rect.bottom - client_rect.top; + return TRUE; +} + +BOOL LLWindowWin32::setPosition(const LLCoordScreen position) +{ + LLCoordScreen size; + + if (!mWindowHandle) + { + return FALSE; + } + getSize(&size); + moveWindow(position, size); + return TRUE; +} + +BOOL LLWindowWin32::setSize(const LLCoordScreen size) +{ + LLCoordScreen position; + + getPosition(&position); + if (!mWindowHandle) + { + return FALSE; + } + + moveWindow(position, size); + return TRUE; +} + +// changing fullscreen resolution +BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp) +{ + GLuint pixel_format; + DEVMODE dev_mode; + DWORD current_refresh; + DWORD dw_ex_style; + DWORD dw_style; + RECT window_rect; + S32 width = size.mX; + S32 height = size.mY; + BOOL auto_show = FALSE; + + if (mhRC) + { + auto_show = TRUE; + resetDisplayResolution(); + } + + if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) + { + current_refresh = dev_mode.dmDisplayFrequency; + } + else + { + current_refresh = 60; + } + + gGLManager.shutdownGL(); + //destroy gl context + if (mhRC) + { + if (!wglMakeCurrent(NULL, NULL)) + { + LL_WARNS("Window") << "Release of DC and RC failed" << LL_ENDL; + } + + if (!wglDeleteContext(mhRC)) + { + LL_WARNS("Window") << "Release of rendering context failed" << LL_ENDL; + } + + mhRC = NULL; + } + + if (fullscreen) + { + mFullscreen = TRUE; + BOOL success = FALSE; + DWORD closest_refresh = 0; + + for (S32 mode_num = 0;; mode_num++) + { + if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) + { + break; + } + + if (dev_mode.dmPelsWidth == width && + dev_mode.dmPelsHeight == height && + dev_mode.dmBitsPerPel == BITS_PER_PIXEL) + { + success = TRUE; + if ((dev_mode.dmDisplayFrequency - current_refresh) + < (closest_refresh - current_refresh)) + { + closest_refresh = dev_mode.dmDisplayFrequency; + } + } + } + + if (closest_refresh == 0) + { + LL_WARNS("Window") << "Couldn't find display mode " << width << " by " << height << " at " << BITS_PER_PIXEL << " bits per pixel" << LL_ENDL; + return FALSE; + } + + // If we found a good resolution, use it. + if (success) + { + success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); + } + + // Keep a copy of the actual current device mode in case we minimize + // and change the screen resolution. JC + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); + + if (success) + { + mFullscreen = TRUE; + mFullscreenWidth = dev_mode.dmPelsWidth; + mFullscreenHeight = dev_mode.dmPelsHeight; + mFullscreenBits = dev_mode.dmBitsPerPel; + mFullscreenRefresh = dev_mode.dmDisplayFrequency; + + LL_INFOS("Window") << "Running at " << dev_mode.dmPelsWidth + << "x" << dev_mode.dmPelsHeight + << "x" << dev_mode.dmBitsPerPel + << " @ " << dev_mode.dmDisplayFrequency + << LL_ENDL; + + window_rect.left = (long) 0; + window_rect.right = (long) width; // Windows GDI rects don't include rightmost pixel + window_rect.top = (long) 0; + window_rect.bottom = (long) height; + dw_ex_style = WS_EX_APPWINDOW; + dw_style = WS_POPUP; + + // Move window borders out not to cover window contents + AdjustWindowRectEx(&window_rect, dw_style, FALSE, dw_ex_style); + } + // If it failed, we don't want to run fullscreen + else + { + mFullscreen = FALSE; + mFullscreenWidth = -1; + mFullscreenHeight = -1; + mFullscreenBits = -1; + mFullscreenRefresh = -1; + + LL_INFOS("Window") << "Unable to run fullscreen at " << width << "x" << height << LL_ENDL; + return FALSE; + } + } + else + { + mFullscreen = FALSE; + window_rect.left = (long) (posp ? posp->mX : 0); + window_rect.right = (long) width + window_rect.left; // Windows GDI rects don't include rightmost pixel + window_rect.top = (long) (posp ? posp->mY : 0); + window_rect.bottom = (long) height + window_rect.top; + // Window with an edge + dw_ex_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + dw_style = WS_OVERLAPPEDWINDOW; + } + + // don't post quit messages when destroying old windows + mPostQuit = FALSE; + + // create window + DestroyWindow(mWindowHandle); + mWindowHandle = CreateWindowEx(dw_ex_style, + mWindowClassName, + mWindowTitle, + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dw_style, + window_rect.left, // x pos + window_rect.top, // y pos + window_rect.right - window_rect.left, // width + window_rect.bottom - window_rect.top, // height + NULL, + NULL, + mhInstance, + NULL); + + //----------------------------------------------------------------------- + // Create GL drawing context + //----------------------------------------------------------------------- + static PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + BITS_PER_PIXEL, + 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused + 8, // alpha bits + 0, // alpha shift + 0, // accum bits + 0, 0, 0, 0, // accum RGBA + 24, // depth bits + 8, // stencil bits, avi added for stencil test + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + if (!(mhDC = GetDC(mWindowHandle))) + { + close(); + OSMessageBox(mCallbacks->translateString("MBDevContextErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) + { + close(); + OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + // Verify what pixel format we actually received. + if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), + &pfd)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (pfd.cColorBits < 32) + { + close(); + OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (pfd.cAlphaBits < 8) + { + close(); + OSMessageBox(mCallbacks->translateString("MBAlpha"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!SetPixelFormat(mhDC, pixel_format, &pfd)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!(mhRC = wglCreateContext(mhDC))) + { + close(); + OSMessageBox(mCallbacks->translateString("MBGLContextErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!wglMakeCurrent(mhDC, mhRC)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBGLContextActErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + gGLManager.initWGL(); + + if (wglChoosePixelFormatARB) + { + // OK, at this point, use the ARB wglChoosePixelFormatsARB function to see if we + // can get exactly what we want. + GLint attrib_list[256]; + S32 cur_attrib = 0; + + attrib_list[cur_attrib++] = WGL_DEPTH_BITS_ARB; + attrib_list[cur_attrib++] = 24; + + attrib_list[cur_attrib++] = WGL_STENCIL_BITS_ARB; + attrib_list[cur_attrib++] = 8; + + attrib_list[cur_attrib++] = WGL_DRAW_TO_WINDOW_ARB; + attrib_list[cur_attrib++] = GL_TRUE; + + attrib_list[cur_attrib++] = WGL_ACCELERATION_ARB; + attrib_list[cur_attrib++] = WGL_FULL_ACCELERATION_ARB; + + attrib_list[cur_attrib++] = WGL_SUPPORT_OPENGL_ARB; + attrib_list[cur_attrib++] = GL_TRUE; + + attrib_list[cur_attrib++] = WGL_DOUBLE_BUFFER_ARB; + attrib_list[cur_attrib++] = GL_TRUE; + + attrib_list[cur_attrib++] = WGL_COLOR_BITS_ARB; + attrib_list[cur_attrib++] = 24; + + attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB; + attrib_list[cur_attrib++] = 8; + + U32 end_attrib = 0; + if (mFSAASamples > 0) + { + end_attrib = cur_attrib; + attrib_list[cur_attrib++] = WGL_SAMPLE_BUFFERS_ARB; + attrib_list[cur_attrib++] = GL_TRUE; + + attrib_list[cur_attrib++] = WGL_SAMPLES_ARB; + attrib_list[cur_attrib++] = mFSAASamples; + } + + // End the list + attrib_list[cur_attrib++] = 0; + + GLint pixel_formats[256]; + U32 num_formats = 0; + + // First we try and get a 32 bit depth pixel format + BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + if (!result) + { + close(); + show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit"); + return FALSE; + } + + if (!num_formats) + { + if (end_attrib > 0) + { + LL_INFOS("Window") << "No valid pixel format for " << mFSAASamples << "x anti-aliasing." << LL_ENDL; + attrib_list[end_attrib] = 0; + + BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + if (!result) + { + close(); + show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit no AA"); + return FALSE; + } + } + + if (!num_formats) + { + LL_INFOS("Window") << "No 32 bit z-buffer, trying 24 bits instead" << LL_ENDL; + // Try 24-bit format + attrib_list[1] = 24; + BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + if (!result) + { + close(); + show_window_creation_error("Error after wglChoosePixelFormatARB 24-bit"); + return FALSE; + } + + if (!num_formats) + { + LL_WARNS("Window") << "Couldn't get 24 bit z-buffer,trying 16 bits instead!" << LL_ENDL; + attrib_list[1] = 16; + BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + if (!result || !num_formats) + { + close(); + show_window_creation_error("Error after wglChoosePixelFormatARB 16-bit"); + return FALSE; + } + } + } + + LL_INFOS("Window") << "Choosing pixel formats: " << num_formats << " pixel formats returned" << LL_ENDL; + } + + + + S32 swap_method = 0; + S32 cur_format = num_formats-1; + GLint swap_query = WGL_SWAP_METHOD_ARB; + + BOOL found_format = FALSE; + + while (!found_format && wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) + { + if (swap_method == WGL_SWAP_UNDEFINED_ARB || cur_format <= 0) + { + found_format = TRUE; + } + else + { + --cur_format; + } + } + + pixel_format = pixel_formats[cur_format]; + + if (mhDC != 0) // Does The Window Have A Device Context? + { + wglMakeCurrent(mhDC, 0); // Set The Current Active Rendering Context To Zero + if (mhRC != 0) // Does The Window Have A Rendering Context? + { + wglDeleteContext (mhRC); // Release The Rendering Context + mhRC = 0; // Zero The Rendering Context + + } + ReleaseDC (mWindowHandle, mhDC); // Release The Device Context + mhDC = 0; // Zero The Device Context + } + DestroyWindow (mWindowHandle); // Destroy The Window + + + mWindowHandle = CreateWindowEx(dw_ex_style, + mWindowClassName, + mWindowTitle, + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dw_style, + window_rect.left, // x pos + window_rect.top, // y pos + window_rect.right - window_rect.left, // width + window_rect.bottom - window_rect.top, // height + NULL, + NULL, + mhInstance, + NULL); + + if (!(mhDC = GetDC(mWindowHandle))) + { + close(); + OSMessageBox(mCallbacks->translateString("MBDevContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!SetPixelFormat(mhDC, pixel_format, &pfd)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) + { + switch (swap_method) + { + case WGL_SWAP_EXCHANGE_ARB: + mSwapMethod = SWAP_METHOD_EXCHANGE; + LL_DEBUGS("Window") << "Swap Method: Exchange" << LL_ENDL; + break; + case WGL_SWAP_COPY_ARB: + mSwapMethod = SWAP_METHOD_COPY; + LL_DEBUGS("Window") << "Swap Method: Copy" << LL_ENDL; + break; + case WGL_SWAP_UNDEFINED_ARB: + mSwapMethod = SWAP_METHOD_UNDEFINED; + LL_DEBUGS("Window") << "Swap Method: Undefined" << LL_ENDL; + break; + default: + mSwapMethod = SWAP_METHOD_UNDEFINED; + LL_DEBUGS("Window") << "Swap Method: Unknown" << LL_ENDL; + break; + } + } + } + else + { + LL_WARNS("Window") << "No wgl_ARB_pixel_format extension, using default ChoosePixelFormat!" << LL_ENDL; + } + + // Verify what pixel format we actually received. + if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), + &pfd)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + LL_INFOS("Window") << "GL buffer: Color Bits " << S32(pfd.cColorBits) + << " Alpha Bits " << S32(pfd.cAlphaBits) + << " Depth Bits " << S32(pfd.cDepthBits) + << LL_ENDL; + + // make sure we have 32 bits per pixel + if (pfd.cColorBits < 32 || GetDeviceCaps(mhDC, BITSPIXEL) < 32) + { + close(); + OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (pfd.cAlphaBits < 8) + { + close(); + OSMessageBox(mCallbacks->translateString("MBAlpha"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!(mhRC = wglCreateContext(mhDC))) + { + close(); + OSMessageBox(mCallbacks->translateString("MBGLContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!wglMakeCurrent(mhDC, mhRC)) + { + close(); + OSMessageBox(mCallbacks->translateString("MBGLContextActErr"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + if (!gGLManager.initGL()) + { + close(); + OSMessageBox(mCallbacks->translateString("MBVideoDrvErr"), mCallbacks->translateString("MBError"), OSMB_OK); + return FALSE; + } + + // Disable vertical sync for swap + if (disable_vsync && wglSwapIntervalEXT) + { + LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL; + wglSwapIntervalEXT(0); + } + else + { + LL_DEBUGS("Window") << "Keeping vertical sync" << LL_ENDL; + } + + SetWindowLong(mWindowHandle, GWL_USERDATA, (U32)this); + + // register this window as handling drag/drop events from the OS + DragAcceptFiles( mWindowHandle, TRUE ); + + mDragDrop->init( mWindowHandle ); + + //register joystick timer callback + SetTimer( mWindowHandle, 0, 1000 / 30, NULL ); // 30 fps timer + + // ok to post quit messages now + mPostQuit = TRUE; + + if (auto_show) + { + show(); + glClearColor(0.0f, 0.0f, 0.0f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + swapBuffers(); + } + + return TRUE; +} + +void LLWindowWin32::moveWindow( const LLCoordScreen& position, const LLCoordScreen& size ) +{ + if( mIsMouseClipping ) + { + RECT client_rect_in_screen_space; + if( getClientRectInScreenSpace( &client_rect_in_screen_space ) ) + { + ClipCursor( &client_rect_in_screen_space ); + } + } + + // if the window was already maximized, MoveWindow seems to still set the maximized flag even if + // the window is smaller than maximized. + // So we're going to do a restore first (which is a ShowWindow call) (SL-44655). + + // THIS CAUSES DEV-15484 and DEV-15949 + //ShowWindow(mWindowHandle, SW_RESTORE); + // NOW we can call MoveWindow + MoveWindow(mWindowHandle, position.mX, position.mY, size.mX, size.mY, TRUE); +} + +BOOL LLWindowWin32::setCursorPosition(const LLCoordWindow position) +{ + LLCoordScreen screen_pos; + + mMousePositionModified = TRUE; + if (!mWindowHandle) + { + return FALSE; + } + + if (!convertCoords(position, &screen_pos)) + { + return FALSE; + } + + // Inform the application of the new mouse position (needed for per-frame + // hover/picking to function). + LLCoordGL gl_pos; + convertCoords(position, &gl_pos); + mCallbacks->handleMouseMove(this, gl_pos, (MASK)0); + + // DEV-18951 VWR-8524 Camera moves wildly when alt-clicking. + // Because we have preemptively notified the application of the new + // mouse position via handleMouseMove() above, we need to clear out + // any stale mouse move events. RN/JC + MSG msg; + while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) + { } + + return SetCursorPos(screen_pos.mX, screen_pos.mY); +} + +BOOL LLWindowWin32::getCursorPosition(LLCoordWindow *position) +{ + POINT cursor_point; + LLCoordScreen screen_pos; + + if (!mWindowHandle || + !GetCursorPos(&cursor_point)) + { + return FALSE; + } + + screen_pos.mX = cursor_point.x; + screen_pos.mY = cursor_point.y; + + return convertCoords(screen_pos, position); +} + +void LLWindowWin32::hideCursor() +{ + while (ShowCursor(FALSE) >= 0) + { + // nothing, wait for cursor to push down + } + mCursorHidden = TRUE; + mHideCursorPermanent = TRUE; +} + +void LLWindowWin32::showCursor() +{ + // makes sure the cursor shows up + while (ShowCursor(TRUE) < 0) + { + // do nothing, wait for cursor to pop out + } + mCursorHidden = FALSE; + mHideCursorPermanent = FALSE; +} + +void LLWindowWin32::showCursorFromMouseMove() +{ + if (!mHideCursorPermanent) + { + showCursor(); + } +} + +void LLWindowWin32::hideCursorUntilMouseMove() +{ + if (!mHideCursorPermanent) + { + hideCursor(); + mHideCursorPermanent = FALSE; + } +} + +BOOL LLWindowWin32::isCursorHidden() +{ + return mCursorHidden; +} + + +HCURSOR LLWindowWin32::loadColorCursor(LPCTSTR name) +{ + return (HCURSOR)LoadImage(mhInstance, + name, + IMAGE_CURSOR, + 0, // default width + 0, // default height + LR_DEFAULTCOLOR); +} + + +void LLWindowWin32::initCursors() +{ + mCursor[ UI_CURSOR_ARROW ] = LoadCursor(NULL, IDC_ARROW); + mCursor[ UI_CURSOR_WAIT ] = LoadCursor(NULL, IDC_WAIT); + mCursor[ UI_CURSOR_HAND ] = LoadCursor(NULL, IDC_HAND); + mCursor[ UI_CURSOR_IBEAM ] = LoadCursor(NULL, IDC_IBEAM); + mCursor[ UI_CURSOR_CROSS ] = LoadCursor(NULL, IDC_CROSS); + mCursor[ UI_CURSOR_SIZENWSE ] = LoadCursor(NULL, IDC_SIZENWSE); + mCursor[ UI_CURSOR_SIZENESW ] = LoadCursor(NULL, IDC_SIZENESW); + mCursor[ UI_CURSOR_SIZEWE ] = LoadCursor(NULL, IDC_SIZEWE); + mCursor[ UI_CURSOR_SIZENS ] = LoadCursor(NULL, IDC_SIZENS); + mCursor[ UI_CURSOR_NO ] = LoadCursor(NULL, IDC_NO); + mCursor[ UI_CURSOR_WORKING ] = LoadCursor(NULL, IDC_APPSTARTING); + + HMODULE module = GetModuleHandle(NULL); + mCursor[ UI_CURSOR_TOOLGRAB ] = LoadCursor(module, TEXT("TOOLGRAB")); + mCursor[ UI_CURSOR_TOOLLAND ] = LoadCursor(module, TEXT("TOOLLAND")); + mCursor[ UI_CURSOR_TOOLFOCUS ] = LoadCursor(module, TEXT("TOOLFOCUS")); + mCursor[ UI_CURSOR_TOOLCREATE ] = LoadCursor(module, TEXT("TOOLCREATE")); + mCursor[ UI_CURSOR_ARROWDRAG ] = LoadCursor(module, TEXT("ARROWDRAG")); + mCursor[ UI_CURSOR_ARROWCOPY ] = LoadCursor(module, TEXT("ARROWCOPY")); + mCursor[ UI_CURSOR_ARROWDRAGMULTI ] = LoadCursor(module, TEXT("ARROWDRAGMULTI")); + mCursor[ UI_CURSOR_ARROWCOPYMULTI ] = LoadCursor(module, TEXT("ARROWCOPYMULTI")); + mCursor[ UI_CURSOR_NOLOCKED ] = LoadCursor(module, TEXT("NOLOCKED")); + mCursor[ UI_CURSOR_ARROWLOCKED ]= LoadCursor(module, TEXT("ARROWLOCKED")); + mCursor[ UI_CURSOR_GRABLOCKED ] = LoadCursor(module, TEXT("GRABLOCKED")); + mCursor[ UI_CURSOR_TOOLTRANSLATE ] = LoadCursor(module, TEXT("TOOLTRANSLATE")); + mCursor[ UI_CURSOR_TOOLROTATE ] = LoadCursor(module, TEXT("TOOLROTATE")); + mCursor[ UI_CURSOR_TOOLSCALE ] = LoadCursor(module, TEXT("TOOLSCALE")); + mCursor[ UI_CURSOR_TOOLCAMERA ] = LoadCursor(module, TEXT("TOOLCAMERA")); + mCursor[ UI_CURSOR_TOOLPAN ] = LoadCursor(module, TEXT("TOOLPAN")); + mCursor[ UI_CURSOR_TOOLZOOMIN ] = LoadCursor(module, TEXT("TOOLZOOMIN")); + mCursor[ UI_CURSOR_TOOLPICKOBJECT3 ] = LoadCursor(module, TEXT("TOOLPICKOBJECT3")); + mCursor[ UI_CURSOR_PIPETTE ] = LoadCursor(module, TEXT("TOOLPIPETTE")); + + // Color cursors + mCursor[UI_CURSOR_TOOLPLAY] = loadColorCursor(TEXT("TOOLPLAY")); + mCursor[UI_CURSOR_TOOLPAUSE] = loadColorCursor(TEXT("TOOLPAUSE")); + mCursor[UI_CURSOR_TOOLMEDIAOPEN] = loadColorCursor(TEXT("TOOLMEDIAOPEN")); + + // Note: custom cursors that are not found make LoadCursor() return NULL. + for( S32 i = 0; i < UI_CURSOR_COUNT; i++ ) + { + if( !mCursor[i] ) + { + mCursor[i] = LoadCursor(NULL, IDC_ARROW); + } + } +} + + + +void LLWindowWin32::setCursor(ECursorType cursor) +{ + if (cursor == UI_CURSOR_ARROW + && mBusyCount > 0) + { + cursor = UI_CURSOR_WORKING; + } + + if( mCurrentCursor != cursor ) + { + mCurrentCursor = cursor; + SetCursor( mCursor[cursor] ); + } +} + +ECursorType LLWindowWin32::getCursor() const +{ + return mCurrentCursor; +} + +void LLWindowWin32::captureMouse() +{ + SetCapture(mWindowHandle); +} + +void LLWindowWin32::releaseMouse() +{ + // *NOTE:Mani ReleaseCapture will spawn new windows messages... + // which will in turn call our MainWindowProc. It therefore requires + // pausing *and more importantly resumption* of the mainlooptimeout... + // just like DispatchMessage below. + mCallbacks->handlePauseWatchdog(this); + ReleaseCapture(); + mCallbacks->handleResumeWatchdog(this); +} + + +void LLWindowWin32::delayInputProcessing() +{ + mInputProcessingPaused = TRUE; +} + +void LLWindowWin32::gatherInput() +{ + MSG msg; + int msg_count = 0; + + LLMemType m1(LLMemType::MTYPE_GATHER_INPUT); + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) && msg_count < MAX_MESSAGE_PER_UPDATE) + { + mCallbacks->handlePingWatchdog(this, "Main:TranslateGatherInput"); + TranslateMessage(&msg); + + // turn watchdog off in here to not fail if windows is doing something wacky + mCallbacks->handlePauseWatchdog(this); + DispatchMessage(&msg); + mCallbacks->handleResumeWatchdog(this); + msg_count++; + + if ( mInputProcessingPaused ) + { + break; + } + /* Attempted workaround for problem where typing fast and hitting + return would result in only part of the text being sent. JC + + BOOL key_posted = TranslateMessage(&msg); + DispatchMessage(&msg); + msg_count++; + + // If a key was translated, a WM_CHAR might have been posted to the end + // of the event queue. We need it immediately. + if (key_posted && msg.message == WM_KEYDOWN) + { + if (PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + msg_count++; + } + } + */ + mCallbacks->handlePingWatchdog(this, "Main:AsyncCallbackGatherInput"); + // For async host by name support. Really hacky. + if (gAsyncMsgCallback && (LL_WM_HOST_RESOLVED == msg.message)) + { + gAsyncMsgCallback(msg); + } + } + + mInputProcessingPaused = FALSE; + + // clear this once we've processed all mouse messages that might have occurred after + // we slammed the mouse position + mMousePositionModified = FALSE; +} + +static LLFastTimer::DeclareTimer FTM_KEYHANDLER("Handle Keyboard"); +static LLFastTimer::DeclareTimer FTM_MOUSEHANDLER("Handle Mouse"); + +LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param) +{ + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(h_wnd, GWL_USERDATA); + + + if (NULL != window_imp) + { + window_imp->mCallbacks->handleResumeWatchdog(window_imp); + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:StartWndProc"); + // Has user provided their own window callback? + if (NULL != window_imp->mWndProc) + { + if (!window_imp->mWndProc(h_wnd, u_msg, w_param, l_param)) + { + // user has handled window message + return 0; + } + } + + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:PreSwitchWndProc"); + + // Juggle to make sure we can get negative positions for when + // mouse is outside window. + LLCoordWindow window_coord((S32)(S16)LOWORD(l_param), (S32)(S16)HIWORD(l_param)); + + // This doesn't work, as LOWORD returns unsigned short. + //LLCoordWindow window_coord(LOWORD(l_param), HIWORD(l_param)); + LLCoordGL gl_coord; + + // pass along extended flag in mask + MASK mask = (l_param>>16 & KF_EXTENDED) ? MASK_EXTENDED : 0x0; + BOOL eat_keystroke = TRUE; + + switch(u_msg) + { + RECT update_rect; + S32 update_width; + S32 update_height; + + case WM_TIMER: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_TIMER"); + window_imp->mCallbacks->handleTimerEvent(window_imp); + break; + + case WM_DEVICECHANGE: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DEVICECHANGE"); + if (gDebugWindowProc) + { + llinfos << " WM_DEVICECHANGE: wParam=" << w_param + << "; lParam=" << l_param << llendl; + } + if (w_param == DBT_DEVNODES_CHANGED || w_param == DBT_DEVICEARRIVAL) + { + if (window_imp->mCallbacks->handleDeviceChange(window_imp)) + { + return 0; + } + } + break; + + case WM_PAINT: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_PAINT"); + GetUpdateRect(window_imp->mWindowHandle, &update_rect, FALSE); + update_width = update_rect.right - update_rect.left + 1; + update_height = update_rect.bottom - update_rect.top + 1; + window_imp->mCallbacks->handlePaint(window_imp, update_rect.left, update_rect.top, + update_width, update_height); + break; + case WM_PARENTNOTIFY: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_PARENTNOTIFY"); + u_msg = u_msg; + break; + + case WM_SETCURSOR: + // This message is sent whenever the cursor is moved in a window. + // You need to set the appropriate cursor appearance. + + // Only take control of cursor over client region of window + // This allows Windows(tm) to handle resize cursors, etc. + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SETCURSOR"); + if (LOWORD(l_param) == HTCLIENT) + { + SetCursor(window_imp->mCursor[ window_imp->mCurrentCursor] ); + return 0; + } + break; + + case WM_ENTERMENULOOP: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ENTERMENULOOP"); + window_imp->mCallbacks->handleWindowBlock(window_imp); + break; + + case WM_EXITMENULOOP: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_EXITMENULOOP"); + window_imp->mCallbacks->handleWindowUnblock(window_imp); + break; + + case WM_ACTIVATEAPP: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ACTIVATEAPP"); + { + // This message should be sent whenever the app gains or loses focus. + BOOL activating = (BOOL) w_param; + BOOL minimized = window_imp->getMinimized(); + + if (gDebugWindowProc) + { + LL_INFOS("Window") << "WINDOWPROC ActivateApp " + << " activating " << S32(activating) + << " minimized " << S32(minimized) + << " fullscreen " << S32(window_imp->mFullscreen) + << LL_ENDL; + } + + if (window_imp->mFullscreen) + { + // When we run fullscreen, restoring or minimizing the app needs + // to switch the screen resolution + if (activating) + { + window_imp->setFullscreenResolution(); + window_imp->restore(); + } + else + { + window_imp->minimize(); + window_imp->resetDisplayResolution(); + } + } + + window_imp->mCallbacks->handleActivateApp(window_imp, activating); + + break; + } + + case WM_ACTIVATE: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_ACTIVATE"); + { + // Can be one of WA_ACTIVE, WA_CLICKACTIVE, or WA_INACTIVE + BOOL activating = (LOWORD(w_param) != WA_INACTIVE); + + BOOL minimized = BOOL(HIWORD(w_param)); + + if (!activating && LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->interruptLanguageTextInput(); + } + + // JC - I'm not sure why, but if we don't report that we handled the + // WM_ACTIVATE message, the WM_ACTIVATEAPP messages don't work + // properly when we run fullscreen. + if (gDebugWindowProc) + { + LL_INFOS("Window") << "WINDOWPROC Activate " + << " activating " << S32(activating) + << " minimized " << S32(minimized) + << LL_ENDL; + } + + // Don't handle this. + break; + } + + case WM_QUERYOPEN: + // TODO: use this to return a nice icon + break; + + case WM_SYSCOMMAND: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SYSCOMMAND"); + switch(w_param) + { + case SC_KEYMENU: + // Disallow the ALT key from triggering the default system menu. + return 0; + + case SC_SCREENSAVE: + case SC_MONITORPOWER: + // eat screen save messages and prevent them! + return 0; + } + break; + + case WM_CLOSE: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_CLOSE"); + // Will the app allow the window to close? + if (window_imp->mCallbacks->handleCloseRequest(window_imp)) + { + // Get the app to initiate cleanup. + window_imp->mCallbacks->handleQuit(window_imp); + // The app is responsible for calling destroyWindow when done with GL + } + return 0; + + case WM_DESTROY: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DESTROY"); + if (window_imp->shouldPostQuit()) + { + PostQuitMessage(0); // Posts WM_QUIT with an exit code of 0 + } + return 0; + + case WM_COMMAND: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COMMAND"); + if (!HIWORD(w_param)) // this message is from a menu + { + window_imp->mCallbacks->handleMenuSelect(window_imp, LOWORD(w_param)); + } + break; + + case WM_SYSKEYDOWN: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SYSKEYDOWN"); + // allow system keys, such as ALT-F4 to be processed by Windows + eat_keystroke = FALSE; + case WM_KEYDOWN: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYDOWN"); + { + if (gDebugWindowProc) + { + LL_INFOS("Window") << "Debug WindowProc WM_KEYDOWN " + << " key " << S32(w_param) + << LL_ENDL; + } + if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke) + { + return 0; + } + // pass on to windows if we didn't handle it + break; + } + case WM_SYSKEYUP: + eat_keystroke = FALSE; + case WM_KEYUP: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYUP"); + LLFastTimer t2(FTM_KEYHANDLER); + + if (gDebugWindowProc) + { + LL_INFOS("Window") << "Debug WindowProc WM_KEYUP " + << " key " << S32(w_param) + << LL_ENDL; + } + if (gKeyboard->handleKeyUp(w_param, mask) && eat_keystroke) + { + return 0; + } + + // pass on to windows + break; + } + case WM_IME_SETCONTEXT: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_SETCONTEXT"); + if (gDebugWindowProc) + { + llinfos << "WM_IME_SETCONTEXT" << llendl; + } + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + l_param &= ~ISC_SHOWUICOMPOSITIONWINDOW; + // Invoke DefWinProc with the modified LPARAM. + } + break; + + case WM_IME_STARTCOMPOSITION: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_STARTCOMPOSITION"); + if (gDebugWindowProc) + { + llinfos << "WM_IME_STARTCOMPOSITION" << llendl; + } + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->handleStartCompositionMessage(); + return 0; + } + break; + + case WM_IME_ENDCOMPOSITION: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_ENDCOMPOSITION"); + if (gDebugWindowProc) + { + llinfos << "WM_IME_ENDCOMPOSITION" << llendl; + } + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + return 0; + } + break; + + case WM_IME_COMPOSITION: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_COMPOSITION"); + if (gDebugWindowProc) + { + llinfos << "WM_IME_COMPOSITION" << llendl; + } + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->handleCompositionMessage(l_param); + return 0; + } + break; + + case WM_IME_REQUEST: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_REQUEST"); + if (gDebugWindowProc) + { + llinfos << "WM_IME_REQUEST" << llendl; + } + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + LRESULT result = 0; + if (window_imp->handleImeRequests(w_param, l_param, &result)) + { + return result; + } + } + break; + + case WM_CHAR: + // Should really use WM_UNICHAR eventually, but it requires a specific Windows version and I need + // to figure out how that works. - Doug + // + // ... Well, I don't think so. + // How it works is explained in Win32 API document, but WM_UNICHAR didn't work + // as specified at least on Windows XP SP1 Japanese version. I have never used + // it since then, and I'm not sure whether it has been fixed now, but I don't think + // it is worth trying. The good old WM_CHAR works just fine even for supplementary + // characters. We just need to take care of surrogate pairs sent as two WM_CHAR's + // by ourselves. It is not that tough. -- Alissa Sabre @ SL + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_CHAR"); + if (gDebugWindowProc) + { + LL_INFOS("Window") << "Debug WindowProc WM_CHAR " + << " key " << S32(w_param) + << LL_ENDL; + } + // Even if LLWindowCallbacks::handleUnicodeChar(llwchar, BOOL) returned FALSE, + // we *did* processed the event, so I believe we should not pass it to DefWindowProc... + window_imp->handleUnicodeUTF16((U16)w_param, gKeyboard->currentMask(FALSE)); + return 0; + + case WM_LBUTTONDOWN: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDOWN"); + LLFastTimer t2(FTM_MOUSEHANDLER); + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->interruptLanguageTextInput(); + } + + // Because we move the cursor position in the app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleMouseDown(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_LBUTTONDBLCLK: + //RN: ignore right button double clicks for now + //case WM_RBUTTONDBLCLK: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDBLCLK"); + // Because we move the cursor position in the app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleDoubleClick(window_imp, gl_coord, mask) ) + { + return 0; + } + } + break; + + case WM_LBUTTONUP: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONUP"); + LLFastTimer t2(FTM_MOUSEHANDLER); + //if (gDebugClicks) + //{ + // LL_INFOS("Window") << "WndProc left button up" << LL_ENDL; + //} + // Because we move the cursor position in the app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleMouseUp(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_RBUTTONDBLCLK: + case WM_RBUTTONDOWN: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONDOWN"); + LLFastTimer t2(FTM_MOUSEHANDLER); + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->interruptLanguageTextInput(); + } + + // Because we move the cursor position in the llviewerapp, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleRightMouseDown(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_RBUTTONUP: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONUP"); + LLFastTimer t2(FTM_MOUSEHANDLER); + // Because we move the cursor position in the app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleRightMouseUp(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_MBUTTONDOWN: +// case WM_MBUTTONDBLCLK: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONDOWN"); + LLFastTimer t2(FTM_MOUSEHANDLER); + if (LLWinImm::isAvailable() && window_imp->mPreeditor) + { + window_imp->interruptLanguageTextInput(); + } + + // Because we move the cursor position in tllviewerhe app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleMiddleMouseDown(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_MBUTTONUP: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONUP"); + LLFastTimer t2(FTM_MOUSEHANDLER); + // Because we move the cursor position in tllviewerhe app, we need to query + // to find out where the cursor at the time the event is handled. + // If we don't do this, many clicks could get buffered up, and if the + // first click changes the cursor position, all subsequent clicks + // will occur at the wrong location. JC + LLCoordWindow cursor_coord_window; + if (window_imp->mMousePositionModified) + { + window_imp->getCursorPosition(&cursor_coord_window); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + } + else + { + window_imp->convertCoords(window_coord, &gl_coord); + } + MASK mask = gKeyboard->currentMask(TRUE); + // generate move event to update mouse coordinates + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + if (window_imp->mCallbacks->handleMiddleMouseUp(window_imp, gl_coord, mask)) + { + return 0; + } + } + break; + + case WM_MOUSEWHEEL: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEWHEEL"); + static short z_delta = 0; + + z_delta += HIWORD(w_param); + // cout << "z_delta " << z_delta << endl; + + // current mouse wheels report changes in increments of zDelta (+120, -120) + // Future, higher resolution mouse wheels may report smaller deltas. + // So we sum the deltas and only act when we've exceeded WHEEL_DELTA + // + // If the user rapidly spins the wheel, we can get messages with + // large deltas, like 480 or so. Thus we need to scroll more quickly. + if (z_delta <= -WHEEL_DELTA || WHEEL_DELTA <= z_delta) + { + window_imp->mCallbacks->handleScrollWheel(window_imp, -z_delta / WHEEL_DELTA); + z_delta = 0; + } + return 0; + } + /* + // TODO: add this after resolving _WIN32_WINNT issue + case WM_MOUSELEAVE: + { + window_imp->mCallbacks->handleMouseLeave(window_imp); + + // TRACKMOUSEEVENT track_mouse_event; + // track_mouse_event.cbSize = sizeof( TRACKMOUSEEVENT ); + // track_mouse_event.dwFlags = TME_LEAVE; + // track_mouse_event.hwndTrack = h_wnd; + // track_mouse_event.dwHoverTime = HOVER_DEFAULT; + // TrackMouseEvent( &track_mouse_event ); + return 0; + } + */ + // Handle mouse movement within the window + case WM_MOUSEMOVE: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEMOVE"); + window_imp->convertCoords(window_coord, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + return 0; + } + + case WM_SIZE: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SIZE"); + S32 width = S32( LOWORD(l_param) ); + S32 height = S32( HIWORD(l_param) ); + + if (gDebugWindowProc) + { + BOOL maximized = ( w_param == SIZE_MAXIMIZED ); + BOOL restored = ( w_param == SIZE_RESTORED ); + BOOL minimized = ( w_param == SIZE_MINIMIZED ); + + LL_INFOS("Window") << "WINDOWPROC Size " + << width << "x" << height + << " max " << S32(maximized) + << " min " << S32(minimized) + << " rest " << S32(restored) + << LL_ENDL; + } + + // There's an odd behavior with WM_SIZE that I would call a bug. If + // the window is maximized, and you call MoveWindow() with a size smaller + // than a maximized window, it ends up sending WM_SIZE with w_param set + // to SIZE_MAXIMIZED -- which isn't true. So the logic below doesn't work. + // (SL-44655). Fixed it by calling ShowWindow(SW_RESTORE) first (see + // LLWindowWin32::moveWindow in this file). + + // If we are now restored, but we weren't before, this + // means that the window was un-minimized. + if (w_param == SIZE_RESTORED && window_imp->mLastSizeWParam != SIZE_RESTORED) + { + window_imp->mCallbacks->handleActivate(window_imp, TRUE); + } + + // handle case of window being maximized from fully minimized state + if (w_param == SIZE_MAXIMIZED && window_imp->mLastSizeWParam != SIZE_MAXIMIZED) + { + window_imp->mCallbacks->handleActivate(window_imp, TRUE); + } + + // Also handle the minimization case + if (w_param == SIZE_MINIMIZED && window_imp->mLastSizeWParam != SIZE_MINIMIZED) + { + window_imp->mCallbacks->handleActivate(window_imp, FALSE); + } + + // Actually resize all of our views + if (w_param != SIZE_MINIMIZED) + { + // Ignore updates for minimizing and minimized "windows" + window_imp->mCallbacks->handleResize( window_imp, + LOWORD(l_param), + HIWORD(l_param) ); + } + + window_imp->mLastSizeWParam = w_param; + + return 0; + } + + case WM_SETFOCUS: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SETFOCUS"); + if (gDebugWindowProc) + { + LL_INFOS("Window") << "WINDOWPROC SetFocus" << LL_ENDL; + } + window_imp->mCallbacks->handleFocus(window_imp); + return 0; + + case WM_KILLFOCUS: + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KILLFOCUS"); + if (gDebugWindowProc) + { + LL_INFOS("Window") << "WINDOWPROC KillFocus" << LL_ENDL; + } + window_imp->mCallbacks->handleFocusLost(window_imp); + return 0; + + case WM_COPYDATA: + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); + // received a URL + PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; + window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); + }; + return 0; + + case WM_DROPFILES: + { + // HDROP contains what we need + HDROP hdrop = (HDROP)w_param; + + // get location in window space where drop occured and convert to OpenGL coordinate space + POINT pt; + DragQueryPoint( hdrop, &pt ); + LLCoordGL gl_coord; + LLCoordWindow cursor_coord_window( pt.x, pt.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + + // get payload (eventually, this needs to more advanced and grab size of payload dynamically + static char file_name[ 1024 ]; DragQueryFileA( hdrop, 0, file_name, 1024 ); - void* url = (void*)( file_name ); + void* url = (void*)( file_name ); // if it's a .URL or .lnk ("shortcut") file if ( std::string( file_name ).find( ".lnk" ) != std::string::npos || @@ -2390,1316 +2400,1329 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ }; MASK mask = gKeyboard->currentMask(TRUE); - if (window_imp->mCallbacks->handleDrop(window_imp, gl_coord, mask, url ) ) - { - return 0; - } - } - break; - } - - window_imp->mCallbacks->handlePauseWatchdog(window_imp); - } - - - // pass unhandled messages down to Windows - return DefWindowProc(h_wnd, u_msg, w_param, l_param); -} - -BOOL LLWindowWin32::convertCoords(LLCoordGL from, LLCoordWindow *to) -{ - S32 client_height; - RECT client_rect; - LLCoordWindow window_position; - - if (!mWindowHandle || - !GetClientRect(mWindowHandle, &client_rect) || - NULL == to) - { - return FALSE; - } - - to->mX = from.mX; - client_height = client_rect.bottom - client_rect.top; - to->mY = client_height - from.mY - 1; - - return TRUE; -} - -BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordGL* to) -{ - S32 client_height; - RECT client_rect; - - if (!mWindowHandle || - !GetClientRect(mWindowHandle, &client_rect) || - NULL == to) - { - return FALSE; - } - - to->mX = from.mX; - client_height = client_rect.bottom - client_rect.top; - to->mY = client_height - from.mY - 1; - - return TRUE; -} - -BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordWindow* to) -{ - POINT mouse_point; - - mouse_point.x = from.mX; - mouse_point.y = from.mY; - BOOL result = ScreenToClient(mWindowHandle, &mouse_point); - - if (result) - { - to->mX = mouse_point.x; - to->mY = mouse_point.y; - } - - return result; -} - -BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordScreen *to) -{ - POINT mouse_point; - - mouse_point.x = from.mX; - mouse_point.y = from.mY; - BOOL result = ClientToScreen(mWindowHandle, &mouse_point); - - if (result) - { - to->mX = mouse_point.x; - to->mY = mouse_point.y; - } - - return result; -} - -BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordGL *to) -{ - LLCoordWindow window_coord; - - if (!mWindowHandle || (NULL == to)) - { - return FALSE; - } - - convertCoords(from, &window_coord); - convertCoords(window_coord, to); - return TRUE; -} - -BOOL LLWindowWin32::convertCoords(LLCoordGL from, LLCoordScreen *to) -{ - LLCoordWindow window_coord; - - if (!mWindowHandle || (NULL == to)) - { - return FALSE; - } - - convertCoords(from, &window_coord); - convertCoords(window_coord, to); - return TRUE; -} - - -BOOL LLWindowWin32::isClipboardTextAvailable() -{ - return IsClipboardFormatAvailable(CF_UNICODETEXT); -} - - -BOOL LLWindowWin32::pasteTextFromClipboard(LLWString &dst) -{ - BOOL success = FALSE; - - if (IsClipboardFormatAvailable(CF_UNICODETEXT)) - { - if (OpenClipboard(mWindowHandle)) - { - HGLOBAL h_data = GetClipboardData(CF_UNICODETEXT); - if (h_data) - { - WCHAR *utf16str = (WCHAR*) GlobalLock(h_data); - if (utf16str) - { - dst = utf16str_to_wstring(utf16str); - LLWStringUtil::removeCRLF(dst); - GlobalUnlock(h_data); - success = TRUE; - } - } - CloseClipboard(); - } - } - - return success; -} - - -BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr) -{ - BOOL success = FALSE; - - if (OpenClipboard(mWindowHandle)) - { - EmptyClipboard(); - - // 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); - - // Memory is allocated and then ownership of it is transfered to the system. - HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16); - if (hglobal_copy_utf16) - { - WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16); - if (copy_utf16) - { - memcpy(copy_utf16, out_utf16.c_str(), size_utf16); /* Flawfinder: ignore */ - GlobalUnlock(hglobal_copy_utf16); - - if (SetClipboardData(CF_UNICODETEXT, hglobal_copy_utf16)) - { - success = TRUE; - } - } - } - - CloseClipboard(); - } - - return success; -} - -// Constrains the mouse to the window. -void LLWindowWin32::setMouseClipping( BOOL b ) -{ - if( b != mIsMouseClipping ) - { - BOOL success = FALSE; - - if( b ) - { - GetClipCursor( &mOldMouseClip ); - - RECT client_rect_in_screen_space; - if( getClientRectInScreenSpace( &client_rect_in_screen_space ) ) - { - success = ClipCursor( &client_rect_in_screen_space ); - } - } - else - { - // Must restore the old mouse clip, which may be set by another window. - success = ClipCursor( &mOldMouseClip ); - SetRect( &mOldMouseClip, 0, 0, 0, 0 ); - } - - if( success ) - { - mIsMouseClipping = b; - } - } -} - -BOOL LLWindowWin32::getClientRectInScreenSpace( RECT* rectp ) -{ - BOOL success = FALSE; - - RECT client_rect; - if( mWindowHandle && GetClientRect(mWindowHandle, &client_rect) ) - { - POINT top_left; - top_left.x = client_rect.left; - top_left.y = client_rect.top; - ClientToScreen(mWindowHandle, &top_left); - - POINT bottom_right; - bottom_right.x = client_rect.right; - bottom_right.y = client_rect.bottom; - ClientToScreen(mWindowHandle, &bottom_right); - - SetRect( rectp, - top_left.x, - top_left.y, - bottom_right.x, - bottom_right.y ); - - success = TRUE; - } - - return success; -} - -void LLWindowWin32::flashIcon(F32 seconds) -{ - FLASHWINFO flash_info; - - flash_info.cbSize = sizeof(FLASHWINFO); - flash_info.hwnd = mWindowHandle; - flash_info.dwFlags = FLASHW_TRAY; - flash_info.uCount = UINT(seconds / ICON_FLASH_TIME); - flash_info.dwTimeout = DWORD(1000.f * ICON_FLASH_TIME); // milliseconds - FlashWindowEx(&flash_info); -} - -F32 LLWindowWin32::getGamma() -{ - return mCurrentGamma; -} - -BOOL LLWindowWin32::restoreGamma() -{ - return SetDeviceGammaRamp(mhDC, mPrevGammaRamp); -} - -BOOL LLWindowWin32::setGamma(const F32 gamma) -{ - mCurrentGamma = gamma; - - LL_DEBUGS("Window") << "Setting gamma to " << gamma << LL_ENDL; - - for ( int i = 0; i < 256; ++i ) - { - int mult = 256 - ( int ) ( ( gamma - 1.0f ) * 128.0f ); - - int value = mult * i; - - if ( value > 0xffff ) - value = 0xffff; - - mCurrentGammaRamp [ 0 * 256 + i ] = - mCurrentGammaRamp [ 1 * 256 + i ] = - mCurrentGammaRamp [ 2 * 256 + i ] = ( WORD )value; - }; - - return SetDeviceGammaRamp ( mhDC, mCurrentGammaRamp ); -} - -void LLWindowWin32::setFSAASamples(const U32 fsaa_samples) -{ - mFSAASamples = fsaa_samples; -} - -U32 LLWindowWin32::getFSAASamples() -{ - return mFSAASamples; -} - -LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_resolutions) -{ - if (!mSupportedResolutions) - { - mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS]; - DEVMODE dev_mode; - - mNumSupportedResolutions = 0; - for (S32 mode_num = 0; mNumSupportedResolutions < MAX_NUM_RESOLUTIONS; mode_num++) - { - if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) - { - break; - } - - if (dev_mode.dmBitsPerPel == BITS_PER_PIXEL && - dev_mode.dmPelsWidth >= 800 && - dev_mode.dmPelsHeight >= 600) - { - BOOL resolution_exists = FALSE; - for(S32 i = 0; i < mNumSupportedResolutions; i++) - { - if (mSupportedResolutions[i].mWidth == dev_mode.dmPelsWidth && - mSupportedResolutions[i].mHeight == dev_mode.dmPelsHeight) - { - resolution_exists = TRUE; - } - } - if (!resolution_exists) - { - mSupportedResolutions[mNumSupportedResolutions].mWidth = dev_mode.dmPelsWidth; - mSupportedResolutions[mNumSupportedResolutions].mHeight = dev_mode.dmPelsHeight; - mNumSupportedResolutions++; - } - } - } - } - - num_resolutions = mNumSupportedResolutions; - return mSupportedResolutions; -} - - -F32 LLWindowWin32::getNativeAspectRatio() -{ - if (mOverrideAspectRatio > 0.f) - { - return mOverrideAspectRatio; - } - else if (mNativeAspectRatio > 0.f) - { - // we grabbed this value at startup, based on the user's desktop settings - return mNativeAspectRatio; - } - // RN: this hack presumes that the largest supported resolution is monitor-limited - // and that pixels in that mode are square, therefore defining the native aspect ratio - // of the monitor...this seems to work to a close approximation for most CRTs/LCDs - S32 num_resolutions; - LLWindowResolution* resolutions = getSupportedResolutions(num_resolutions); - - return ((F32)resolutions[num_resolutions - 1].mWidth / (F32)resolutions[num_resolutions - 1].mHeight); -} - -F32 LLWindowWin32::getPixelAspectRatio() -{ - F32 pixel_aspect = 1.f; - if (getFullscreen()) - { - LLCoordScreen screen_size; - getSize(&screen_size); - pixel_aspect = getNativeAspectRatio() * (F32)screen_size.mY / (F32)screen_size.mX; - } - - return pixel_aspect; -} - -// Change display resolution. Returns true if successful. -// protected -BOOL LLWindowWin32::setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh) -{ - DEVMODE dev_mode; - dev_mode.dmSize = sizeof(dev_mode); - BOOL success = FALSE; - - // Don't change anything if we don't have to - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) - { - if (dev_mode.dmPelsWidth == width && - dev_mode.dmPelsHeight == height && - dev_mode.dmBitsPerPel == bits && - dev_mode.dmDisplayFrequency == refresh ) - { - // ...display mode identical, do nothing - return TRUE; - } - } - - memset(&dev_mode, 0, sizeof(dev_mode)); - dev_mode.dmSize = sizeof(dev_mode); - dev_mode.dmPelsWidth = width; - dev_mode.dmPelsHeight = height; - dev_mode.dmBitsPerPel = bits; - dev_mode.dmDisplayFrequency = refresh; - dev_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; - - // CDS_FULLSCREEN indicates that this is a temporary change to the device mode. - LONG cds_result = ChangeDisplaySettings(&dev_mode, CDS_FULLSCREEN); - - success = (DISP_CHANGE_SUCCESSFUL == cds_result); - - if (!success) - { - LL_WARNS("Window") << "setDisplayResolution failed, " - << width << "x" << height << "x" << bits << " @ " << refresh << LL_ENDL; - } - - return success; -} - -// protected -BOOL LLWindowWin32::setFullscreenResolution() -{ - if (mFullscreen) - { - return setDisplayResolution( mFullscreenWidth, mFullscreenHeight, mFullscreenBits, mFullscreenRefresh); - } - else - { - return FALSE; - } -} - -// protected -BOOL LLWindowWin32::resetDisplayResolution() -{ - LL_DEBUGS("Window") << "resetDisplayResolution START" << LL_ENDL; - - LONG cds_result = ChangeDisplaySettings(NULL, 0); - - BOOL success = (DISP_CHANGE_SUCCESSFUL == cds_result); - - if (!success) - { - LL_WARNS("Window") << "resetDisplayResolution failed" << LL_ENDL; - } - - LL_DEBUGS("Window") << "resetDisplayResolution END" << LL_ENDL; - - return success; -} - -void LLWindowWin32::swapBuffers() -{ - SwapBuffers(mhDC); -} - - -// -// LLSplashScreenImp -// -LLSplashScreenWin32::LLSplashScreenWin32() -: mWindow(NULL) -{ -} - -LLSplashScreenWin32::~LLSplashScreenWin32() -{ -} - -void LLSplashScreenWin32::showImpl() -{ - // This appears to work. ??? - HINSTANCE hinst = GetModuleHandle(NULL); - - mWindow = CreateDialog(hinst, - TEXT("SPLASHSCREEN"), - NULL, // no parent - (DLGPROC) LLSplashScreenWin32::windowProc); - ShowWindow(mWindow, SW_SHOW); -} - - -void LLSplashScreenWin32::updateImpl(const std::string& mesg) -{ - if (!mWindow) return; - - WCHAR w_mesg[1024]; - mbstowcs(w_mesg, mesg.c_str(), 1024); - - SendDlgItemMessage(mWindow, - 666, // HACK: text id - WM_SETTEXT, - FALSE, - (LPARAM)w_mesg); -} - - -void LLSplashScreenWin32::hideImpl() -{ - if (mWindow) - { - DestroyWindow(mWindow); - mWindow = NULL; - } -} - - -// static -LRESULT CALLBACK LLSplashScreenWin32::windowProc(HWND h_wnd, UINT u_msg, - WPARAM w_param, LPARAM l_param) -{ - // Just give it to windows - return DefWindowProc(h_wnd, u_msg, w_param, l_param); -} - -// -// Helper Funcs -// - -S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type) -{ - UINT uType; - - switch(type) - { - case OSMB_OK: - uType = MB_OK; - break; - case OSMB_OKCANCEL: - uType = MB_OKCANCEL; - break; - case OSMB_YESNO: - uType = MB_YESNO; - break; - default: - uType = MB_OK; - break; - } - - // HACK! Doesn't properly handle wide strings! - int retval_win = MessageBoxA(NULL, text.c_str(), caption.c_str(), uType); - S32 retval; - - switch(retval_win) - { - case IDYES: - retval = OSBTN_YES; - break; - case IDNO: - retval = OSBTN_NO; - break; - case IDOK: - retval = OSBTN_OK; - break; - case IDCANCEL: - retval = OSBTN_CANCEL; - break; - default: - retval = OSBTN_CANCEL; - break; - } - - return retval; -} - - -void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url ) -{ - bool found = false; - S32 i; - for (i = 0; i < gURLProtocolWhitelistCount; i++) - { - if (escaped_url.find(gURLProtocolWhitelist[i]) == 0) - { - found = true; - break; - } - } - - if (!found) - { - LL_WARNS("Window") << "spawn_web_browser() called for url with protocol not on whitelist: " << escaped_url << LL_ENDL; - return; - } - - LL_INFOS("Window") << "Opening URL " << escaped_url << LL_ENDL; - - // replaced ShellExecute code with ShellExecuteEx since ShellExecute doesn't work - // 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 ); - - // let the OS decide what to use to open the URL - SHELLEXECUTEINFO sei = { sizeof( sei ) }; - sei.fMask = SEE_MASK_FLAG_DDEWAIT; - sei.nShow = SW_SHOWNORMAL; - sei.lpVerb = L"open"; - sei.lpFile = url_utf16.c_str(); - ShellExecuteEx( &sei ); - - //// TODO: LEAVING OLD CODE HERE SO I DON'T BONE OTHER MERGES - //// DELETE THIS ONCE THE MERGES ARE DONE - - // Figure out the user's default web browser - // HKEY_CLASSES_ROOT\http\shell\open\command - /* - std::string reg_path_str = gURLProtocolWhitelistHandler[i] + "\\shell\\open\\command"; - WCHAR reg_path_wstr[256]; - mbstowcs( reg_path_wstr, reg_path_str.c_str(), LL_ARRAY_SIZE(reg_path_wstr) ); - - HKEY key; - WCHAR browser_open_wstr[1024]; - DWORD buffer_length = 1024; - RegOpenKeyEx(HKEY_CLASSES_ROOT, reg_path_wstr, 0, KEY_QUERY_VALUE, &key); - RegQueryValueEx(key, NULL, NULL, NULL, (LPBYTE)browser_open_wstr, &buffer_length); - RegCloseKey(key); - - // Convert to STL string - LLWString browser_open_wstring = utf16str_to_wstring(browser_open_wstr); - - if (browser_open_wstring.length() < 2) - { - LL_WARNS("Window") << "Invalid browser executable in registry " << browser_open_wstring << LL_ENDL; - return; - } - - // Extract the process that's supposed to be launched - LLWString browser_executable; - if (browser_open_wstring[0] == '"') - { - // executable is quoted, find the matching quote - size_t quote_pos = browser_open_wstring.find('"', 1); - // copy out the string including both quotes - browser_executable = browser_open_wstring.substr(0, quote_pos+1); - } - else - { - // executable not quoted, find a space - size_t space_pos = browser_open_wstring.find(' ', 1); - browser_executable = browser_open_wstring.substr(0, space_pos); - } - - LL_DEBUGS("Window") << "Browser reg key: " << wstring_to_utf8str(browser_open_wstring) << LL_ENDL; - LL_INFOS("Window") << "Browser executable: " << wstring_to_utf8str(browser_executable) << LL_ENDL; - - // Convert URL to wide string for Windows API - // Assume URL is UTF8, as can come from scripts - LLWString url_wstring = utf8str_to_wstring(escaped_url); - llutf16string url_utf16 = wstring_to_utf16str(url_wstring); - - // Convert executable and path to wide string for Windows API - llutf16string browser_exec_utf16 = wstring_to_utf16str(browser_executable); - - // ShellExecute returns HINSTANCE for backwards compatiblity. - // MS docs say to cast to int and compare to 32. - HWND our_window = NULL; - LPCWSTR directory_wstr = NULL; - int retval = (int) ShellExecute(our_window, // Flawfinder: ignore - L"open", - browser_exec_utf16.c_str(), - url_utf16.c_str(), - directory_wstr, - SW_SHOWNORMAL); - if (retval > 32) - { - LL_DEBUGS("Window") << "load_url success with " << retval << LL_ENDL; - } - else - { - LL_INFOS("Window") << "load_url failure with " << retval << LL_ENDL; - } - */ -} - - -BOOL LLWindowWin32::dialogColorPicker( F32 *r, F32 *g, F32 *b ) -{ - BOOL retval = FALSE; - - static CHOOSECOLOR cc; - static COLORREF crCustColors[16]; - cc.lStructSize = sizeof(CHOOSECOLOR); - cc.hwndOwner = mWindowHandle; - cc.hInstance = NULL; - cc.rgbResult = RGB ((*r * 255.f),(*g *255.f),(*b * 255.f)); - //cc.rgbResult = RGB (0x80,0x80,0x80); - cc.lpCustColors = crCustColors; - cc.Flags = CC_RGBINIT | CC_FULLOPEN; - cc.lCustData = 0; - cc.lpfnHook = NULL; - cc.lpTemplateName = NULL; - - // This call is modal, so pause agent - //send_agent_pause(); // this is in newview and we don't want to set up a dependency - { - retval = ChooseColor(&cc); - } - //send_agent_resume(); // this is in newview and we don't want to set up a dependency - - *b = ((F32)((cc.rgbResult >> 16) & 0xff)) / 255.f; - - *g = ((F32)((cc.rgbResult >> 8) & 0xff)) / 255.f; - - *r = ((F32)(cc.rgbResult & 0xff)) / 255.f; - - return (retval); -} - -void *LLWindowWin32::getPlatformWindow() -{ - return (void*)mWindowHandle; -} - -void LLWindowWin32::bringToFront() -{ - BringWindowToTop(mWindowHandle); -} - -// set (OS) window focus back to the client -void LLWindowWin32::focusClient() -{ - SetFocus ( mWindowHandle ); -} - -void LLWindowWin32::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) -{ - if (b == sLanguageTextInputAllowed || !LLWinImm::isAvailable()) - { - return; - } - - if (preeditor != mPreeditor && !b) - { - // This condition may occur with a call to - // setEnabled(BOOL) from LLTextEditor or LLLineEditor - // when the control is not focused. - // We need to silently ignore the case so that - // the language input status of the focused control - // is not disturbed. - return; - } - - // Take care of old and new preeditors. - if (preeditor != mPreeditor || !b) - { - if (sLanguageTextInputAllowed) - { - interruptLanguageTextInput(); - } - mPreeditor = (b ? preeditor : NULL); - } - - sLanguageTextInputAllowed = b; - - if ( sLanguageTextInputAllowed ) - { - // Allowing: Restore the previous IME status, so that the user has a feeling that the previous - // text input continues naturally. Be careful, however, the IME status is meaningful only during the user keeps - // using same Input Locale (aka Keyboard Layout). - if (sWinIMEOpened && GetKeyboardLayout(0) == sWinInputLocale) - { - HIMC himc = LLWinImm::getContext(mWindowHandle); - LLWinImm::setOpenStatus(himc, TRUE); - LLWinImm::setConversionStatus(himc, sWinIMEConversionMode, sWinIMESentenceMode); - LLWinImm::releaseContext(mWindowHandle, himc); - } - } - else - { - // Disallowing: Turn off the IME so that succeeding key events bypass IME and come to us directly. - // However, do it after saving the current IME status. We need to restore the status when - // allowing language text input again. - sWinInputLocale = GetKeyboardLayout(0); - sWinIMEOpened = LLWinImm::isIME(sWinInputLocale); - if (sWinIMEOpened) - { - HIMC himc = LLWinImm::getContext(mWindowHandle); - sWinIMEOpened = LLWinImm::getOpenStatus(himc); - if (sWinIMEOpened) - { - LLWinImm::getConversionStatus(himc, &sWinIMEConversionMode, &sWinIMESentenceMode); - - // We need both ImmSetConversionStatus and ImmSetOpenStatus here to surely disable IME's - // keyboard hooking, because Some IME reacts only on the former and some other on the latter... - LLWinImm::setConversionStatus(himc, IME_CMODE_NOCONVERSION, sWinIMESentenceMode); - LLWinImm::setOpenStatus(himc, FALSE); - } - LLWinImm::releaseContext(mWindowHandle, himc); - } - } -} - -void LLWindowWin32::fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, - CANDIDATEFORM *form) -{ - LLCoordWindow caret_coord, top_left, bottom_right; - convertCoords(caret, &caret_coord); - convertCoords(LLCoordGL(bounds.mLeft, bounds.mTop), &top_left); - convertCoords(LLCoordGL(bounds.mRight, bounds.mBottom), &bottom_right); - - memset(form, 0, sizeof(CANDIDATEFORM)); - form->dwStyle = CFS_EXCLUDE; - form->ptCurrentPos.x = caret_coord.mX; - form->ptCurrentPos.y = caret_coord.mY; - form->rcArea.left = top_left.mX; - form->rcArea.top = top_left.mY; - form->rcArea.right = bottom_right.mX; - form->rcArea.bottom = bottom_right.mY; -} - - -// Put the IME window at the right place (near current text input). Point coordinates should be the top of the current text line. -void LLWindowWin32::setLanguageTextInput( const LLCoordGL & position ) -{ - if (sLanguageTextInputAllowed && LLWinImm::isAvailable()) - { - HIMC himc = LLWinImm::getContext(mWindowHandle); - - LLCoordWindow win_pos; - convertCoords( position, &win_pos ); - - if ( win_pos.mX >= 0 && win_pos.mY >= 0 && - (win_pos.mX != sWinIMEWindowPosition.mX) || (win_pos.mY != sWinIMEWindowPosition.mY) ) - { - COMPOSITIONFORM ime_form; - memset( &ime_form, 0, sizeof(ime_form) ); - ime_form.dwStyle = CFS_POINT; - ime_form.ptCurrentPos.x = win_pos.mX; - ime_form.ptCurrentPos.y = win_pos.mY; - - LLWinImm::setCompositionWindow( himc, &ime_form ); - - sWinIMEWindowPosition.set( win_pos.mX, win_pos.mY ); - } - - LLWinImm::releaseContext(mWindowHandle, himc); - } -} - - -void LLWindowWin32::fillCharPosition(const LLCoordGL& caret, const LLRect& bounds, const LLRect& control, - IMECHARPOSITION *char_position) -{ - LLCoordScreen caret_coord, top_left, bottom_right; - convertCoords(caret, &caret_coord); - convertCoords(LLCoordGL(bounds.mLeft, bounds.mTop), &top_left); - convertCoords(LLCoordGL(bounds.mRight, bounds.mBottom), &bottom_right); - - char_position->pt.x = caret_coord.mX; - char_position->pt.y = top_left.mY; // Windows wants the coordinate of upper left corner of a character... - char_position->cLineHeight = bottom_right.mY - top_left.mY; - char_position->rcDocument.left = top_left.mX; - char_position->rcDocument.top = top_left.mY; - char_position->rcDocument.right = bottom_right.mX; - char_position->rcDocument.bottom = bottom_right.mY; -} - -void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont) -{ - // Our font is a list of FreeType recognized font files that may - // not have a corresponding ones in Windows' fonts. Hence, we - // can't simply tell Windows which font we are using. We will - // notify a _standard_ font for a current input locale instead. - // We use a hard-coded knowledge about the Windows' standard - // configuration to do so... - - memset(logfont, 0, sizeof(LOGFONT)); - - const WORD lang_id = LOWORD(GetKeyboardLayout(0)); - switch (PRIMARYLANGID(lang_id)) - { - case LANG_CHINESE: - // We need to identify one of two Chinese fonts. - switch (SUBLANGID(lang_id)) - { - case SUBLANG_CHINESE_SIMPLIFIED: - case SUBLANG_CHINESE_SINGAPORE: - logfont->lfCharSet = GB2312_CHARSET; - lstrcpy(logfont->lfFaceName, TEXT("SimHei")); - break; - case SUBLANG_CHINESE_TRADITIONAL: - case SUBLANG_CHINESE_HONGKONG: - case SUBLANG_CHINESE_MACAU: - default: - logfont->lfCharSet = CHINESEBIG5_CHARSET; - lstrcpy(logfont->lfFaceName, TEXT("MingLiU")); - break; - } - break; - case LANG_JAPANESE: - logfont->lfCharSet = SHIFTJIS_CHARSET; - lstrcpy(logfont->lfFaceName, TEXT("MS Gothic")); - break; - case LANG_KOREAN: - logfont->lfCharSet = HANGUL_CHARSET; - lstrcpy(logfont->lfFaceName, TEXT("Gulim")); - break; - default: - logfont->lfCharSet = ANSI_CHARSET; - lstrcpy(logfont->lfFaceName, TEXT("Tahoma")); - break; - } - - logfont->lfHeight = mPreeditor->getPreeditFontSize(); - logfont->lfWeight = FW_NORMAL; -} - -U32 LLWindowWin32::fillReconvertString(const LLWString &text, - S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string) -{ - const llutf16string text_utf16 = wstring_to_utf16str(text); - const DWORD required_size = sizeof(RECONVERTSTRING) + (text_utf16.length() + 1) * sizeof(WCHAR); - if (reconvert_string && reconvert_string->dwSize >= required_size) - { - const DWORD focus_utf16_at = wstring_utf16_length(text, 0, focus); - const DWORD focus_utf16_length = wstring_utf16_length(text, focus, focus_length); - - reconvert_string->dwVersion = 0; - reconvert_string->dwStrLen = text_utf16.length(); - reconvert_string->dwStrOffset = sizeof(RECONVERTSTRING); - reconvert_string->dwCompStrLen = focus_utf16_length; - reconvert_string->dwCompStrOffset = focus_utf16_at * sizeof(WCHAR); - reconvert_string->dwTargetStrLen = 0; - reconvert_string->dwTargetStrOffset = focus_utf16_at * sizeof(WCHAR); - - const LPWSTR text = (LPWSTR)((BYTE *)reconvert_string + sizeof(RECONVERTSTRING)); - memcpy(text, text_utf16.c_str(), (text_utf16.length() + 1) * sizeof(WCHAR)); - } - return required_size; -} - -void LLWindowWin32::updateLanguageTextInputArea() -{ - if (!mPreeditor || !LLWinImm::isAvailable()) - { - return; - } - - LLCoordGL caret_coord; - LLRect preedit_bounds; - if (mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL)) - { - mLanguageTextInputPointGL = caret_coord; - mLanguageTextInputAreaGL = preedit_bounds; - - CANDIDATEFORM candidate_form; - fillCandidateForm(caret_coord, preedit_bounds, &candidate_form); - - HIMC himc = LLWinImm::getContext(mWindowHandle); - // Win32 document says there may be up to 4 candidate windows. - // This magic number 4 appears only in the document, and - // there are no constant/macro for the value... - for (int i = 3; i >= 0; --i) - { - candidate_form.dwIndex = i; - LLWinImm::setCandidateWindow(himc, &candidate_form); - } - LLWinImm::releaseContext(mWindowHandle, himc); - } -} - -void LLWindowWin32::interruptLanguageTextInput() -{ - if (mPreeditor) - { - if (LLWinImm::isAvailable()) - { - HIMC himc = LLWinImm::getContext(mWindowHandle); - LLWinImm::notifyIME(himc, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); - LLWinImm::releaseContext(mWindowHandle, himc); - } - - // Win32 document says there will be no composition string - // after NI_COMPOSITIONSTR returns. The following call to - // resetPreedit should be a NOP unless IME goes mad... - mPreeditor->resetPreedit(); - } -} - -void LLWindowWin32::handleStartCompositionMessage() -{ - // Let IME know the font to use in feedback UI. - LOGFONT logfont; - fillCompositionLogfont(&logfont); - HIMC himc = LLWinImm::getContext(mWindowHandle); - LLWinImm::setCompositionFont(himc, &logfont); - LLWinImm::releaseContext(mWindowHandle, himc); -} - -// Handle WM_IME_COMPOSITION message. - -void LLWindowWin32::handleCompositionMessage(const U32 indexes) -{ - BOOL needs_update = FALSE; - LLWString result_string; - LLWString preedit_string; - S32 preedit_string_utf16_length = 0; - LLPreeditor::segment_lengths_t preedit_segment_lengths; - LLPreeditor::standouts_t preedit_standouts; - - // Step I: Receive details of preedits from IME. - - HIMC himc = LLWinImm::getContext(mWindowHandle); - - if (indexes & GCS_RESULTSTR) - { - LONG size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, NULL, 0); - if (size >= 0) - { - const LPWSTR data = new WCHAR[size / sizeof(WCHAR) + 1]; - size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, data, size); - if (size > 0) - { - result_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); - } - delete[] data; - needs_update = TRUE; - } - } - - if (indexes & GCS_COMPSTR) - { - LONG size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, NULL, 0); - if (size >= 0) - { - const LPWSTR data = new WCHAR[size / sizeof(WCHAR) + 1]; - size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, data, size); - if (size > 0) - { - preedit_string_utf16_length = size / sizeof(WCHAR); - preedit_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); - } - delete[] data; - needs_update = TRUE; - } - } - - if ((indexes & GCS_COMPCLAUSE) && preedit_string.length() > 0) - { - LONG size = LLWinImm::getCompositionString(himc, GCS_COMPCLAUSE, NULL, 0); - if (size > 0) - { - const LPDWORD data = new DWORD[size / sizeof(DWORD)]; - size = LLWinImm::getCompositionString(himc, GCS_COMPCLAUSE, data, size); - if (size >= sizeof(DWORD) * 2 - && data[0] == 0 && data[size / sizeof(DWORD) - 1] == preedit_string_utf16_length) - { - preedit_segment_lengths.resize(size / sizeof(DWORD) - 1); - S32 offset = 0; - for (U32 i = 0; i < preedit_segment_lengths.size(); i++) - { - const S32 length = wstring_wstring_length_from_utf16_length(preedit_string, offset, data[i + 1] - data[i]); - preedit_segment_lengths[i] = length; - offset += length; - } - } - delete[] data; - } - } - - if ((indexes & GCS_COMPATTR) && preedit_segment_lengths.size() > 1) - { - LONG size = LLWinImm::getCompositionString(himc, GCS_COMPATTR, NULL, 0); - if (size > 0) - { - const LPBYTE data = new BYTE[size / sizeof(BYTE)]; - size = LLWinImm::getCompositionString(himc, GCS_COMPATTR, data, size); - if (size == preedit_string_utf16_length) - { - preedit_standouts.assign(preedit_segment_lengths.size(), FALSE); - S32 offset = 0; - for (U32 i = 0; i < preedit_segment_lengths.size(); i++) - { - if (ATTR_TARGET_CONVERTED == data[offset] || ATTR_TARGET_NOTCONVERTED == data[offset]) - { - preedit_standouts[i] = TRUE; - } - offset += wstring_utf16_length(preedit_string, offset, preedit_segment_lengths[i]); - } - } - delete[] data; - } - } - - S32 caret_position = preedit_string.length(); - if (indexes & GCS_CURSORPOS) - { - const S32 caret_position_utf16 = LLWinImm::getCompositionString(himc, GCS_CURSORPOS, NULL, 0); - if (caret_position_utf16 >= 0 && caret_position <= preedit_string_utf16_length) - { - caret_position = wstring_wstring_length_from_utf16_length(preedit_string, 0, caret_position_utf16); - } - } - - if (indexes == 0) - { - // I'm not sure this condition really happens, but - // Windows SDK document says it is an indication - // of "reset everything." - needs_update = TRUE; - } - - LLWinImm::releaseContext(mWindowHandle, himc); - - // Step II: Update the active preeditor. - - if (needs_update) - { - mPreeditor->resetPreedit(); - - if (result_string.length() > 0) - { - for (LLWString::const_iterator i = result_string.begin(); i != result_string.end(); i++) - { - mPreeditor->handleUnicodeCharHere(*i); - } - } - - if (preedit_string.length() == 0) - { - preedit_segment_lengths.clear(); - preedit_standouts.clear(); - } - else - { - if (preedit_segment_lengths.size() == 0) - { - preedit_segment_lengths.assign(1, preedit_string.length()); - } - if (preedit_standouts.size() == 0) - { - preedit_standouts.assign(preedit_segment_lengths.size(), FALSE); - } - } - mPreeditor->updatePreedit(preedit_string, preedit_segment_lengths, preedit_standouts, caret_position); - - // Some IME doesn't query char position after WM_IME_COMPOSITION, - // so we need to update them actively. - updateLanguageTextInputArea(); - } -} - -// Given a text and a focus range, find_context finds and returns a -// surrounding context of the focused subtext. A variable pointed -// to by offset receives the offset in llwchars of the beginning of -// the returned context string in the given wtext. - -static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_length, S32 *offset) -{ - static const S32 CONTEXT_EXCESS = 30; // This value is by experiences. - - const S32 e = llmin((S32) wtext.length(), focus + focus_length + CONTEXT_EXCESS); - S32 end = focus + focus_length; - while (end < e && '\n' != wtext[end]) - { - end++; - } - - const S32 s = llmax(0, focus - CONTEXT_EXCESS); - S32 start = focus; - while (start > s && '\n' != wtext[start - 1]) - { - --start; - } - - *offset = start; - return wtext.substr(start, end - start); -} - -// Handle WM_IME_REQUEST message. -// If it handled the message, returns TRUE. Otherwise, FALSE. -// When it handled the message, the value to be returned from -// the Window Procedure is set to *result. - -BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result) -{ - if ( mPreeditor ) - { - switch (request) - { - case IMR_CANDIDATEWINDOW: // http://msdn2.microsoft.com/en-us/library/ms776080.aspx - { - LLCoordGL caret_coord; - LLRect preedit_bounds; - mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL); - - CANDIDATEFORM *const form = (CANDIDATEFORM *)param; - DWORD const dwIndex = form->dwIndex; - fillCandidateForm(caret_coord, preedit_bounds, form); - form->dwIndex = dwIndex; - - *result = 1; - return TRUE; - } - case IMR_QUERYCHARPOSITION: - { - IMECHARPOSITION *const char_position = (IMECHARPOSITION *)param; - - // char_position->dwCharPos counts in number of - // WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the - // number to getPreeditLocation. - - const LLWString & wtext = mPreeditor->getPreeditString(); - S32 preedit, preedit_length; - mPreeditor->getPreeditRange(&preedit, &preedit_length); - LLCoordGL caret_coord; - LLRect preedit_bounds, text_control; - const S32 position = wstring_wstring_length_from_utf16_length(wtext, preedit, char_position->dwCharPos); - - if (!mPreeditor->getPreeditLocation(position, &caret_coord, &preedit_bounds, &text_control)) - { - LL_WARNS("Window") << "*** IMR_QUERYCHARPOSITON called but getPreeditLocation failed." << LL_ENDL; - return FALSE; - } - fillCharPosition(caret_coord, preedit_bounds, text_control, char_position); - - *result = 1; - return TRUE; - } - case IMR_COMPOSITIONFONT: - { - fillCompositionLogfont((LOGFONT *)param); - - *result = 1; - return TRUE; - } - case IMR_RECONVERTSTRING: - { - mPreeditor->resetPreedit(); - const LLWString & wtext = mPreeditor->getPreeditString(); - S32 select, select_length; - mPreeditor->getSelectionRange(&select, &select_length); - - S32 context_offset; - const LLWString context = find_context(wtext, select, select_length, &context_offset); - - RECONVERTSTRING * const reconvert_string = (RECONVERTSTRING *)param; - const U32 size = fillReconvertString(context, select - context_offset, select_length, reconvert_string); - if (reconvert_string) - { - if (select_length == 0) - { - // Let the IME to decide the reconversion range, and - // adjust the reconvert_string structure accordingly. - HIMC himc = LLWinImm::getContext(mWindowHandle); - const BOOL adjusted = LLWinImm::setCompositionString(himc, - SCS_QUERYRECONVERTSTRING, reconvert_string, size, NULL, 0); - LLWinImm::releaseContext(mWindowHandle, himc); - if (adjusted) - { - const llutf16string & text_utf16 = wstring_to_utf16str(context); - const S32 new_preedit_start = reconvert_string->dwCompStrOffset / sizeof(WCHAR); - const S32 new_preedit_end = new_preedit_start + reconvert_string->dwCompStrLen; - select = utf16str_wstring_length(text_utf16, new_preedit_start); - select_length = utf16str_wstring_length(text_utf16, new_preedit_end) - select; - select += context_offset; - } - } - mPreeditor->markAsPreedit(select, select_length); - } - - *result = size; - return TRUE; - } - case IMR_CONFIRMRECONVERTSTRING: - { - *result = FALSE; - return TRUE; - } - case IMR_DOCUMENTFEED: - { - const LLWString & wtext = mPreeditor->getPreeditString(); - S32 preedit, preedit_length; - mPreeditor->getPreeditRange(&preedit, &preedit_length); - - S32 context_offset; - LLWString context = find_context(wtext, preedit, preedit_length, &context_offset); - preedit -= context_offset; - if (preedit_length) - { - // IMR_DOCUMENTFEED may be called when we have an active preedit. - // We should pass the context string *excluding* the preedit string. - // Otherwise, some IME are confused. - context.erase(preedit, preedit_length); - } - - RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)param; - *result = fillReconvertString(context, preedit, 0, reconvert_string); - return TRUE; - } - default: - return FALSE; - } - } - - return FALSE; -} - -//static -std::vector LLWindowWin32::getDynamicFallbackFontList() -{ - // Fonts previously in getFontListSans() have moved to fonts.xml. - return std::vector(); -} - - -#endif // LL_WINDOWS + + if ( window_imp->completeDropRequest( gl_coord, mask, (char*)url ) ) + { + return 0; + }; + } + break; + } + + window_imp->mCallbacks->handlePauseWatchdog(window_imp); + } + + + // pass unhandled messages down to Windows + return DefWindowProc(h_wnd, u_msg, w_param, l_param); +} + +BOOL LLWindowWin32::convertCoords(LLCoordGL from, LLCoordWindow *to) +{ + S32 client_height; + RECT client_rect; + LLCoordWindow window_position; + + if (!mWindowHandle || + !GetClientRect(mWindowHandle, &client_rect) || + NULL == to) + { + return FALSE; + } + + to->mX = from.mX; + client_height = client_rect.bottom - client_rect.top; + to->mY = client_height - from.mY - 1; + + return TRUE; +} + +BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordGL* to) +{ + S32 client_height; + RECT client_rect; + + if (!mWindowHandle || + !GetClientRect(mWindowHandle, &client_rect) || + NULL == to) + { + return FALSE; + } + + to->mX = from.mX; + client_height = client_rect.bottom - client_rect.top; + to->mY = client_height - from.mY - 1; + + return TRUE; +} + +BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordWindow* to) +{ + POINT mouse_point; + + mouse_point.x = from.mX; + mouse_point.y = from.mY; + BOOL result = ScreenToClient(mWindowHandle, &mouse_point); + + if (result) + { + to->mX = mouse_point.x; + to->mY = mouse_point.y; + } + + return result; +} + +BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordScreen *to) +{ + POINT mouse_point; + + mouse_point.x = from.mX; + mouse_point.y = from.mY; + BOOL result = ClientToScreen(mWindowHandle, &mouse_point); + + if (result) + { + to->mX = mouse_point.x; + to->mY = mouse_point.y; + } + + return result; +} + +BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordGL *to) +{ + LLCoordWindow window_coord; + + if (!mWindowHandle || (NULL == to)) + { + return FALSE; + } + + convertCoords(from, &window_coord); + convertCoords(window_coord, to); + return TRUE; +} + +BOOL LLWindowWin32::convertCoords(LLCoordGL from, LLCoordScreen *to) +{ + LLCoordWindow window_coord; + + if (!mWindowHandle || (NULL == to)) + { + return FALSE; + } + + convertCoords(from, &window_coord); + convertCoords(window_coord, to); + return TRUE; +} + + +BOOL LLWindowWin32::isClipboardTextAvailable() +{ + return IsClipboardFormatAvailable(CF_UNICODETEXT); +} + + +BOOL LLWindowWin32::pasteTextFromClipboard(LLWString &dst) +{ + BOOL success = FALSE; + + if (IsClipboardFormatAvailable(CF_UNICODETEXT)) + { + if (OpenClipboard(mWindowHandle)) + { + HGLOBAL h_data = GetClipboardData(CF_UNICODETEXT); + if (h_data) + { + WCHAR *utf16str = (WCHAR*) GlobalLock(h_data); + if (utf16str) + { + dst = utf16str_to_wstring(utf16str); + LLWStringUtil::removeCRLF(dst); + GlobalUnlock(h_data); + success = TRUE; + } + } + CloseClipboard(); + } + } + + return success; +} + + +BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr) +{ + BOOL success = FALSE; + + if (OpenClipboard(mWindowHandle)) + { + EmptyClipboard(); + + // 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); + + // Memory is allocated and then ownership of it is transfered to the system. + HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16); + if (hglobal_copy_utf16) + { + WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16); + if (copy_utf16) + { + memcpy(copy_utf16, out_utf16.c_str(), size_utf16); /* Flawfinder: ignore */ + GlobalUnlock(hglobal_copy_utf16); + + if (SetClipboardData(CF_UNICODETEXT, hglobal_copy_utf16)) + { + success = TRUE; + } + } + } + + CloseClipboard(); + } + + return success; +} + +// Constrains the mouse to the window. +void LLWindowWin32::setMouseClipping( BOOL b ) +{ + if( b != mIsMouseClipping ) + { + BOOL success = FALSE; + + if( b ) + { + GetClipCursor( &mOldMouseClip ); + + RECT client_rect_in_screen_space; + if( getClientRectInScreenSpace( &client_rect_in_screen_space ) ) + { + success = ClipCursor( &client_rect_in_screen_space ); + } + } + else + { + // Must restore the old mouse clip, which may be set by another window. + success = ClipCursor( &mOldMouseClip ); + SetRect( &mOldMouseClip, 0, 0, 0, 0 ); + } + + if( success ) + { + mIsMouseClipping = b; + } + } +} + +BOOL LLWindowWin32::getClientRectInScreenSpace( RECT* rectp ) +{ + BOOL success = FALSE; + + RECT client_rect; + if( mWindowHandle && GetClientRect(mWindowHandle, &client_rect) ) + { + POINT top_left; + top_left.x = client_rect.left; + top_left.y = client_rect.top; + ClientToScreen(mWindowHandle, &top_left); + + POINT bottom_right; + bottom_right.x = client_rect.right; + bottom_right.y = client_rect.bottom; + ClientToScreen(mWindowHandle, &bottom_right); + + SetRect( rectp, + top_left.x, + top_left.y, + bottom_right.x, + bottom_right.y ); + + success = TRUE; + } + + return success; +} + +void LLWindowWin32::flashIcon(F32 seconds) +{ + FLASHWINFO flash_info; + + flash_info.cbSize = sizeof(FLASHWINFO); + flash_info.hwnd = mWindowHandle; + flash_info.dwFlags = FLASHW_TRAY; + flash_info.uCount = UINT(seconds / ICON_FLASH_TIME); + flash_info.dwTimeout = DWORD(1000.f * ICON_FLASH_TIME); // milliseconds + FlashWindowEx(&flash_info); +} + +F32 LLWindowWin32::getGamma() +{ + return mCurrentGamma; +} + +BOOL LLWindowWin32::restoreGamma() +{ + return SetDeviceGammaRamp(mhDC, mPrevGammaRamp); +} + +BOOL LLWindowWin32::setGamma(const F32 gamma) +{ + mCurrentGamma = gamma; + + LL_DEBUGS("Window") << "Setting gamma to " << gamma << LL_ENDL; + + for ( int i = 0; i < 256; ++i ) + { + int mult = 256 - ( int ) ( ( gamma - 1.0f ) * 128.0f ); + + int value = mult * i; + + if ( value > 0xffff ) + value = 0xffff; + + mCurrentGammaRamp [ 0 * 256 + i ] = + mCurrentGammaRamp [ 1 * 256 + i ] = + mCurrentGammaRamp [ 2 * 256 + i ] = ( WORD )value; + }; + + return SetDeviceGammaRamp ( mhDC, mCurrentGammaRamp ); +} + +void LLWindowWin32::setFSAASamples(const U32 fsaa_samples) +{ + mFSAASamples = fsaa_samples; +} + +U32 LLWindowWin32::getFSAASamples() +{ + return mFSAASamples; +} + +LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_resolutions) +{ + if (!mSupportedResolutions) + { + mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS]; + DEVMODE dev_mode; + + mNumSupportedResolutions = 0; + for (S32 mode_num = 0; mNumSupportedResolutions < MAX_NUM_RESOLUTIONS; mode_num++) + { + if (!EnumDisplaySettings(NULL, mode_num, &dev_mode)) + { + break; + } + + if (dev_mode.dmBitsPerPel == BITS_PER_PIXEL && + dev_mode.dmPelsWidth >= 800 && + dev_mode.dmPelsHeight >= 600) + { + BOOL resolution_exists = FALSE; + for(S32 i = 0; i < mNumSupportedResolutions; i++) + { + if (mSupportedResolutions[i].mWidth == dev_mode.dmPelsWidth && + mSupportedResolutions[i].mHeight == dev_mode.dmPelsHeight) + { + resolution_exists = TRUE; + } + } + if (!resolution_exists) + { + mSupportedResolutions[mNumSupportedResolutions].mWidth = dev_mode.dmPelsWidth; + mSupportedResolutions[mNumSupportedResolutions].mHeight = dev_mode.dmPelsHeight; + mNumSupportedResolutions++; + } + } + } + } + + num_resolutions = mNumSupportedResolutions; + return mSupportedResolutions; +} + + +F32 LLWindowWin32::getNativeAspectRatio() +{ + if (mOverrideAspectRatio > 0.f) + { + return mOverrideAspectRatio; + } + else if (mNativeAspectRatio > 0.f) + { + // we grabbed this value at startup, based on the user's desktop settings + return mNativeAspectRatio; + } + // RN: this hack presumes that the largest supported resolution is monitor-limited + // and that pixels in that mode are square, therefore defining the native aspect ratio + // of the monitor...this seems to work to a close approximation for most CRTs/LCDs + S32 num_resolutions; + LLWindowResolution* resolutions = getSupportedResolutions(num_resolutions); + + return ((F32)resolutions[num_resolutions - 1].mWidth / (F32)resolutions[num_resolutions - 1].mHeight); +} + +F32 LLWindowWin32::getPixelAspectRatio() +{ + F32 pixel_aspect = 1.f; + if (getFullscreen()) + { + LLCoordScreen screen_size; + getSize(&screen_size); + pixel_aspect = getNativeAspectRatio() * (F32)screen_size.mY / (F32)screen_size.mX; + } + + return pixel_aspect; +} + +// Change display resolution. Returns true if successful. +// protected +BOOL LLWindowWin32::setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh) +{ + DEVMODE dev_mode; + dev_mode.dmSize = sizeof(dev_mode); + BOOL success = FALSE; + + // Don't change anything if we don't have to + if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) + { + if (dev_mode.dmPelsWidth == width && + dev_mode.dmPelsHeight == height && + dev_mode.dmBitsPerPel == bits && + dev_mode.dmDisplayFrequency == refresh ) + { + // ...display mode identical, do nothing + return TRUE; + } + } + + memset(&dev_mode, 0, sizeof(dev_mode)); + dev_mode.dmSize = sizeof(dev_mode); + dev_mode.dmPelsWidth = width; + dev_mode.dmPelsHeight = height; + dev_mode.dmBitsPerPel = bits; + dev_mode.dmDisplayFrequency = refresh; + dev_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; + + // CDS_FULLSCREEN indicates that this is a temporary change to the device mode. + LONG cds_result = ChangeDisplaySettings(&dev_mode, CDS_FULLSCREEN); + + success = (DISP_CHANGE_SUCCESSFUL == cds_result); + + if (!success) + { + LL_WARNS("Window") << "setDisplayResolution failed, " + << width << "x" << height << "x" << bits << " @ " << refresh << LL_ENDL; + } + + return success; +} + +// protected +BOOL LLWindowWin32::setFullscreenResolution() +{ + if (mFullscreen) + { + return setDisplayResolution( mFullscreenWidth, mFullscreenHeight, mFullscreenBits, mFullscreenRefresh); + } + else + { + return FALSE; + } +} + +// protected +BOOL LLWindowWin32::resetDisplayResolution() +{ + LL_DEBUGS("Window") << "resetDisplayResolution START" << LL_ENDL; + + LONG cds_result = ChangeDisplaySettings(NULL, 0); + + BOOL success = (DISP_CHANGE_SUCCESSFUL == cds_result); + + if (!success) + { + LL_WARNS("Window") << "resetDisplayResolution failed" << LL_ENDL; + } + + LL_DEBUGS("Window") << "resetDisplayResolution END" << LL_ENDL; + + return success; +} + +void LLWindowWin32::swapBuffers() +{ + SwapBuffers(mhDC); +} + + +// +// LLSplashScreenImp +// +LLSplashScreenWin32::LLSplashScreenWin32() +: mWindow(NULL) +{ +} + +LLSplashScreenWin32::~LLSplashScreenWin32() +{ +} + +void LLSplashScreenWin32::showImpl() +{ + // This appears to work. ??? + HINSTANCE hinst = GetModuleHandle(NULL); + + mWindow = CreateDialog(hinst, + TEXT("SPLASHSCREEN"), + NULL, // no parent + (DLGPROC) LLSplashScreenWin32::windowProc); + ShowWindow(mWindow, SW_SHOW); +} + + +void LLSplashScreenWin32::updateImpl(const std::string& mesg) +{ + if (!mWindow) return; + + WCHAR w_mesg[1024]; + mbstowcs(w_mesg, mesg.c_str(), 1024); + + SendDlgItemMessage(mWindow, + 666, // HACK: text id + WM_SETTEXT, + FALSE, + (LPARAM)w_mesg); +} + + +void LLSplashScreenWin32::hideImpl() +{ + if (mWindow) + { + DestroyWindow(mWindow); + mWindow = NULL; + } +} + + +// static +LRESULT CALLBACK LLSplashScreenWin32::windowProc(HWND h_wnd, UINT u_msg, + WPARAM w_param, LPARAM l_param) +{ + // Just give it to windows + return DefWindowProc(h_wnd, u_msg, w_param, l_param); +} + +// +// Helper Funcs +// + +S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type) +{ + UINT uType; + + switch(type) + { + case OSMB_OK: + uType = MB_OK; + break; + case OSMB_OKCANCEL: + uType = MB_OKCANCEL; + break; + case OSMB_YESNO: + uType = MB_YESNO; + break; + default: + uType = MB_OK; + break; + } + + // HACK! Doesn't properly handle wide strings! + int retval_win = MessageBoxA(NULL, text.c_str(), caption.c_str(), uType); + S32 retval; + + switch(retval_win) + { + case IDYES: + retval = OSBTN_YES; + break; + case IDNO: + retval = OSBTN_NO; + break; + case IDOK: + retval = OSBTN_OK; + break; + case IDCANCEL: + retval = OSBTN_CANCEL; + break; + default: + retval = OSBTN_CANCEL; + break; + } + + return retval; +} + + +void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url ) +{ + bool found = false; + S32 i; + for (i = 0; i < gURLProtocolWhitelistCount; i++) + { + if (escaped_url.find(gURLProtocolWhitelist[i]) == 0) + { + found = true; + break; + } + } + + if (!found) + { + LL_WARNS("Window") << "spawn_web_browser() called for url with protocol not on whitelist: " << escaped_url << LL_ENDL; + return; + } + + LL_INFOS("Window") << "Opening URL " << escaped_url << LL_ENDL; + + // replaced ShellExecute code with ShellExecuteEx since ShellExecute doesn't work + // 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 ); + + // let the OS decide what to use to open the URL + SHELLEXECUTEINFO sei = { sizeof( sei ) }; + sei.fMask = SEE_MASK_FLAG_DDEWAIT; + sei.nShow = SW_SHOWNORMAL; + sei.lpVerb = L"open"; + sei.lpFile = url_utf16.c_str(); + ShellExecuteEx( &sei ); + + //// TODO: LEAVING OLD CODE HERE SO I DON'T BONE OTHER MERGES + //// DELETE THIS ONCE THE MERGES ARE DONE + + // Figure out the user's default web browser + // HKEY_CLASSES_ROOT\http\shell\open\command + /* + std::string reg_path_str = gURLProtocolWhitelistHandler[i] + "\\shell\\open\\command"; + WCHAR reg_path_wstr[256]; + mbstowcs( reg_path_wstr, reg_path_str.c_str(), LL_ARRAY_SIZE(reg_path_wstr) ); + + HKEY key; + WCHAR browser_open_wstr[1024]; + DWORD buffer_length = 1024; + RegOpenKeyEx(HKEY_CLASSES_ROOT, reg_path_wstr, 0, KEY_QUERY_VALUE, &key); + RegQueryValueEx(key, NULL, NULL, NULL, (LPBYTE)browser_open_wstr, &buffer_length); + RegCloseKey(key); + + // Convert to STL string + LLWString browser_open_wstring = utf16str_to_wstring(browser_open_wstr); + + if (browser_open_wstring.length() < 2) + { + LL_WARNS("Window") << "Invalid browser executable in registry " << browser_open_wstring << LL_ENDL; + return; + } + + // Extract the process that's supposed to be launched + LLWString browser_executable; + if (browser_open_wstring[0] == '"') + { + // executable is quoted, find the matching quote + size_t quote_pos = browser_open_wstring.find('"', 1); + // copy out the string including both quotes + browser_executable = browser_open_wstring.substr(0, quote_pos+1); + } + else + { + // executable not quoted, find a space + size_t space_pos = browser_open_wstring.find(' ', 1); + browser_executable = browser_open_wstring.substr(0, space_pos); + } + + LL_DEBUGS("Window") << "Browser reg key: " << wstring_to_utf8str(browser_open_wstring) << LL_ENDL; + LL_INFOS("Window") << "Browser executable: " << wstring_to_utf8str(browser_executable) << LL_ENDL; + + // Convert URL to wide string for Windows API + // Assume URL is UTF8, as can come from scripts + LLWString url_wstring = utf8str_to_wstring(escaped_url); + llutf16string url_utf16 = wstring_to_utf16str(url_wstring); + + // Convert executable and path to wide string for Windows API + llutf16string browser_exec_utf16 = wstring_to_utf16str(browser_executable); + + // ShellExecute returns HINSTANCE for backwards compatiblity. + // MS docs say to cast to int and compare to 32. + HWND our_window = NULL; + LPCWSTR directory_wstr = NULL; + int retval = (int) ShellExecute(our_window, // Flawfinder: ignore + L"open", + browser_exec_utf16.c_str(), + url_utf16.c_str(), + directory_wstr, + SW_SHOWNORMAL); + if (retval > 32) + { + LL_DEBUGS("Window") << "load_url success with " << retval << LL_ENDL; + } + else + { + LL_INFOS("Window") << "load_url failure with " << retval << LL_ENDL; + } + */ +} + + +BOOL LLWindowWin32::dialogColorPicker( F32 *r, F32 *g, F32 *b ) +{ + BOOL retval = FALSE; + + static CHOOSECOLOR cc; + static COLORREF crCustColors[16]; + cc.lStructSize = sizeof(CHOOSECOLOR); + cc.hwndOwner = mWindowHandle; + cc.hInstance = NULL; + cc.rgbResult = RGB ((*r * 255.f),(*g *255.f),(*b * 255.f)); + //cc.rgbResult = RGB (0x80,0x80,0x80); + cc.lpCustColors = crCustColors; + cc.Flags = CC_RGBINIT | CC_FULLOPEN; + cc.lCustData = 0; + cc.lpfnHook = NULL; + cc.lpTemplateName = NULL; + + // This call is modal, so pause agent + //send_agent_pause(); // this is in newview and we don't want to set up a dependency + { + retval = ChooseColor(&cc); + } + //send_agent_resume(); // this is in newview and we don't want to set up a dependency + + *b = ((F32)((cc.rgbResult >> 16) & 0xff)) / 255.f; + + *g = ((F32)((cc.rgbResult >> 8) & 0xff)) / 255.f; + + *r = ((F32)(cc.rgbResult & 0xff)) / 255.f; + + return (retval); +} + +void *LLWindowWin32::getPlatformWindow() +{ + return (void*)mWindowHandle; +} + +void LLWindowWin32::bringToFront() +{ + BringWindowToTop(mWindowHandle); +} + +// set (OS) window focus back to the client +void LLWindowWin32::focusClient() +{ + SetFocus ( mWindowHandle ); +} + +void LLWindowWin32::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) +{ + if (b == sLanguageTextInputAllowed || !LLWinImm::isAvailable()) + { + return; + } + + if (preeditor != mPreeditor && !b) + { + // This condition may occur with a call to + // setEnabled(BOOL) from LLTextEditor or LLLineEditor + // when the control is not focused. + // We need to silently ignore the case so that + // the language input status of the focused control + // is not disturbed. + return; + } + + // Take care of old and new preeditors. + if (preeditor != mPreeditor || !b) + { + if (sLanguageTextInputAllowed) + { + interruptLanguageTextInput(); + } + mPreeditor = (b ? preeditor : NULL); + } + + sLanguageTextInputAllowed = b; + + if ( sLanguageTextInputAllowed ) + { + // Allowing: Restore the previous IME status, so that the user has a feeling that the previous + // text input continues naturally. Be careful, however, the IME status is meaningful only during the user keeps + // using same Input Locale (aka Keyboard Layout). + if (sWinIMEOpened && GetKeyboardLayout(0) == sWinInputLocale) + { + HIMC himc = LLWinImm::getContext(mWindowHandle); + LLWinImm::setOpenStatus(himc, TRUE); + LLWinImm::setConversionStatus(himc, sWinIMEConversionMode, sWinIMESentenceMode); + LLWinImm::releaseContext(mWindowHandle, himc); + } + } + else + { + // Disallowing: Turn off the IME so that succeeding key events bypass IME and come to us directly. + // However, do it after saving the current IME status. We need to restore the status when + // allowing language text input again. + sWinInputLocale = GetKeyboardLayout(0); + sWinIMEOpened = LLWinImm::isIME(sWinInputLocale); + if (sWinIMEOpened) + { + HIMC himc = LLWinImm::getContext(mWindowHandle); + sWinIMEOpened = LLWinImm::getOpenStatus(himc); + if (sWinIMEOpened) + { + LLWinImm::getConversionStatus(himc, &sWinIMEConversionMode, &sWinIMESentenceMode); + + // We need both ImmSetConversionStatus and ImmSetOpenStatus here to surely disable IME's + // keyboard hooking, because Some IME reacts only on the former and some other on the latter... + LLWinImm::setConversionStatus(himc, IME_CMODE_NOCONVERSION, sWinIMESentenceMode); + LLWinImm::setOpenStatus(himc, FALSE); + } + LLWinImm::releaseContext(mWindowHandle, himc); + } + } +} + +void LLWindowWin32::fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, + CANDIDATEFORM *form) +{ + LLCoordWindow caret_coord, top_left, bottom_right; + convertCoords(caret, &caret_coord); + convertCoords(LLCoordGL(bounds.mLeft, bounds.mTop), &top_left); + convertCoords(LLCoordGL(bounds.mRight, bounds.mBottom), &bottom_right); + + memset(form, 0, sizeof(CANDIDATEFORM)); + form->dwStyle = CFS_EXCLUDE; + form->ptCurrentPos.x = caret_coord.mX; + form->ptCurrentPos.y = caret_coord.mY; + form->rcArea.left = top_left.mX; + form->rcArea.top = top_left.mY; + form->rcArea.right = bottom_right.mX; + form->rcArea.bottom = bottom_right.mY; +} + + +// Put the IME window at the right place (near current text input). Point coordinates should be the top of the current text line. +void LLWindowWin32::setLanguageTextInput( const LLCoordGL & position ) +{ + if (sLanguageTextInputAllowed && LLWinImm::isAvailable()) + { + HIMC himc = LLWinImm::getContext(mWindowHandle); + + LLCoordWindow win_pos; + convertCoords( position, &win_pos ); + + if ( win_pos.mX >= 0 && win_pos.mY >= 0 && + (win_pos.mX != sWinIMEWindowPosition.mX) || (win_pos.mY != sWinIMEWindowPosition.mY) ) + { + COMPOSITIONFORM ime_form; + memset( &ime_form, 0, sizeof(ime_form) ); + ime_form.dwStyle = CFS_POINT; + ime_form.ptCurrentPos.x = win_pos.mX; + ime_form.ptCurrentPos.y = win_pos.mY; + + LLWinImm::setCompositionWindow( himc, &ime_form ); + + sWinIMEWindowPosition.set( win_pos.mX, win_pos.mY ); + } + + LLWinImm::releaseContext(mWindowHandle, himc); + } +} + + +void LLWindowWin32::fillCharPosition(const LLCoordGL& caret, const LLRect& bounds, const LLRect& control, + IMECHARPOSITION *char_position) +{ + LLCoordScreen caret_coord, top_left, bottom_right; + convertCoords(caret, &caret_coord); + convertCoords(LLCoordGL(bounds.mLeft, bounds.mTop), &top_left); + convertCoords(LLCoordGL(bounds.mRight, bounds.mBottom), &bottom_right); + + char_position->pt.x = caret_coord.mX; + char_position->pt.y = top_left.mY; // Windows wants the coordinate of upper left corner of a character... + char_position->cLineHeight = bottom_right.mY - top_left.mY; + char_position->rcDocument.left = top_left.mX; + char_position->rcDocument.top = top_left.mY; + char_position->rcDocument.right = bottom_right.mX; + char_position->rcDocument.bottom = bottom_right.mY; +} + +void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont) +{ + // Our font is a list of FreeType recognized font files that may + // not have a corresponding ones in Windows' fonts. Hence, we + // can't simply tell Windows which font we are using. We will + // notify a _standard_ font for a current input locale instead. + // We use a hard-coded knowledge about the Windows' standard + // configuration to do so... + + memset(logfont, 0, sizeof(LOGFONT)); + + const WORD lang_id = LOWORD(GetKeyboardLayout(0)); + switch (PRIMARYLANGID(lang_id)) + { + case LANG_CHINESE: + // We need to identify one of two Chinese fonts. + switch (SUBLANGID(lang_id)) + { + case SUBLANG_CHINESE_SIMPLIFIED: + case SUBLANG_CHINESE_SINGAPORE: + logfont->lfCharSet = GB2312_CHARSET; + lstrcpy(logfont->lfFaceName, TEXT("SimHei")); + break; + case SUBLANG_CHINESE_TRADITIONAL: + case SUBLANG_CHINESE_HONGKONG: + case SUBLANG_CHINESE_MACAU: + default: + logfont->lfCharSet = CHINESEBIG5_CHARSET; + lstrcpy(logfont->lfFaceName, TEXT("MingLiU")); + break; + } + break; + case LANG_JAPANESE: + logfont->lfCharSet = SHIFTJIS_CHARSET; + lstrcpy(logfont->lfFaceName, TEXT("MS Gothic")); + break; + case LANG_KOREAN: + logfont->lfCharSet = HANGUL_CHARSET; + lstrcpy(logfont->lfFaceName, TEXT("Gulim")); + break; + default: + logfont->lfCharSet = ANSI_CHARSET; + lstrcpy(logfont->lfFaceName, TEXT("Tahoma")); + break; + } + + logfont->lfHeight = mPreeditor->getPreeditFontSize(); + logfont->lfWeight = FW_NORMAL; +} + +U32 LLWindowWin32::fillReconvertString(const LLWString &text, + S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string) +{ + const llutf16string text_utf16 = wstring_to_utf16str(text); + const DWORD required_size = sizeof(RECONVERTSTRING) + (text_utf16.length() + 1) * sizeof(WCHAR); + if (reconvert_string && reconvert_string->dwSize >= required_size) + { + const DWORD focus_utf16_at = wstring_utf16_length(text, 0, focus); + const DWORD focus_utf16_length = wstring_utf16_length(text, focus, focus_length); + + reconvert_string->dwVersion = 0; + reconvert_string->dwStrLen = text_utf16.length(); + reconvert_string->dwStrOffset = sizeof(RECONVERTSTRING); + reconvert_string->dwCompStrLen = focus_utf16_length; + reconvert_string->dwCompStrOffset = focus_utf16_at * sizeof(WCHAR); + reconvert_string->dwTargetStrLen = 0; + reconvert_string->dwTargetStrOffset = focus_utf16_at * sizeof(WCHAR); + + const LPWSTR text = (LPWSTR)((BYTE *)reconvert_string + sizeof(RECONVERTSTRING)); + memcpy(text, text_utf16.c_str(), (text_utf16.length() + 1) * sizeof(WCHAR)); + } + return required_size; +} + +void LLWindowWin32::updateLanguageTextInputArea() +{ + if (!mPreeditor || !LLWinImm::isAvailable()) + { + return; + } + + LLCoordGL caret_coord; + LLRect preedit_bounds; + if (mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL)) + { + mLanguageTextInputPointGL = caret_coord; + mLanguageTextInputAreaGL = preedit_bounds; + + CANDIDATEFORM candidate_form; + fillCandidateForm(caret_coord, preedit_bounds, &candidate_form); + + HIMC himc = LLWinImm::getContext(mWindowHandle); + // Win32 document says there may be up to 4 candidate windows. + // This magic number 4 appears only in the document, and + // there are no constant/macro for the value... + for (int i = 3; i >= 0; --i) + { + candidate_form.dwIndex = i; + LLWinImm::setCandidateWindow(himc, &candidate_form); + } + LLWinImm::releaseContext(mWindowHandle, himc); + } +} + +void LLWindowWin32::interruptLanguageTextInput() +{ + if (mPreeditor) + { + if (LLWinImm::isAvailable()) + { + HIMC himc = LLWinImm::getContext(mWindowHandle); + LLWinImm::notifyIME(himc, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); + LLWinImm::releaseContext(mWindowHandle, himc); + } + + // Win32 document says there will be no composition string + // after NI_COMPOSITIONSTR returns. The following call to + // resetPreedit should be a NOP unless IME goes mad... + mPreeditor->resetPreedit(); + } +} + +void LLWindowWin32::handleStartCompositionMessage() +{ + // Let IME know the font to use in feedback UI. + LOGFONT logfont; + fillCompositionLogfont(&logfont); + HIMC himc = LLWinImm::getContext(mWindowHandle); + LLWinImm::setCompositionFont(himc, &logfont); + LLWinImm::releaseContext(mWindowHandle, himc); +} + +// Handle WM_IME_COMPOSITION message. + +void LLWindowWin32::handleCompositionMessage(const U32 indexes) +{ + BOOL needs_update = FALSE; + LLWString result_string; + LLWString preedit_string; + S32 preedit_string_utf16_length = 0; + LLPreeditor::segment_lengths_t preedit_segment_lengths; + LLPreeditor::standouts_t preedit_standouts; + + // Step I: Receive details of preedits from IME. + + HIMC himc = LLWinImm::getContext(mWindowHandle); + + if (indexes & GCS_RESULTSTR) + { + LONG size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, NULL, 0); + if (size >= 0) + { + const LPWSTR data = new WCHAR[size / sizeof(WCHAR) + 1]; + size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, data, size); + if (size > 0) + { + result_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); + } + delete[] data; + needs_update = TRUE; + } + } + + if (indexes & GCS_COMPSTR) + { + LONG size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, NULL, 0); + if (size >= 0) + { + const LPWSTR data = new WCHAR[size / sizeof(WCHAR) + 1]; + size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, data, size); + if (size > 0) + { + preedit_string_utf16_length = size / sizeof(WCHAR); + preedit_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); + } + delete[] data; + needs_update = TRUE; + } + } + + if ((indexes & GCS_COMPCLAUSE) && preedit_string.length() > 0) + { + LONG size = LLWinImm::getCompositionString(himc, GCS_COMPCLAUSE, NULL, 0); + if (size > 0) + { + const LPDWORD data = new DWORD[size / sizeof(DWORD)]; + size = LLWinImm::getCompositionString(himc, GCS_COMPCLAUSE, data, size); + if (size >= sizeof(DWORD) * 2 + && data[0] == 0 && data[size / sizeof(DWORD) - 1] == preedit_string_utf16_length) + { + preedit_segment_lengths.resize(size / sizeof(DWORD) - 1); + S32 offset = 0; + for (U32 i = 0; i < preedit_segment_lengths.size(); i++) + { + const S32 length = wstring_wstring_length_from_utf16_length(preedit_string, offset, data[i + 1] - data[i]); + preedit_segment_lengths[i] = length; + offset += length; + } + } + delete[] data; + } + } + + if ((indexes & GCS_COMPATTR) && preedit_segment_lengths.size() > 1) + { + LONG size = LLWinImm::getCompositionString(himc, GCS_COMPATTR, NULL, 0); + if (size > 0) + { + const LPBYTE data = new BYTE[size / sizeof(BYTE)]; + size = LLWinImm::getCompositionString(himc, GCS_COMPATTR, data, size); + if (size == preedit_string_utf16_length) + { + preedit_standouts.assign(preedit_segment_lengths.size(), FALSE); + S32 offset = 0; + for (U32 i = 0; i < preedit_segment_lengths.size(); i++) + { + if (ATTR_TARGET_CONVERTED == data[offset] || ATTR_TARGET_NOTCONVERTED == data[offset]) + { + preedit_standouts[i] = TRUE; + } + offset += wstring_utf16_length(preedit_string, offset, preedit_segment_lengths[i]); + } + } + delete[] data; + } + } + + S32 caret_position = preedit_string.length(); + if (indexes & GCS_CURSORPOS) + { + const S32 caret_position_utf16 = LLWinImm::getCompositionString(himc, GCS_CURSORPOS, NULL, 0); + if (caret_position_utf16 >= 0 && caret_position <= preedit_string_utf16_length) + { + caret_position = wstring_wstring_length_from_utf16_length(preedit_string, 0, caret_position_utf16); + } + } + + if (indexes == 0) + { + // I'm not sure this condition really happens, but + // Windows SDK document says it is an indication + // of "reset everything." + needs_update = TRUE; + } + + LLWinImm::releaseContext(mWindowHandle, himc); + + // Step II: Update the active preeditor. + + if (needs_update) + { + mPreeditor->resetPreedit(); + + if (result_string.length() > 0) + { + for (LLWString::const_iterator i = result_string.begin(); i != result_string.end(); i++) + { + mPreeditor->handleUnicodeCharHere(*i); + } + } + + if (preedit_string.length() == 0) + { + preedit_segment_lengths.clear(); + preedit_standouts.clear(); + } + else + { + if (preedit_segment_lengths.size() == 0) + { + preedit_segment_lengths.assign(1, preedit_string.length()); + } + if (preedit_standouts.size() == 0) + { + preedit_standouts.assign(preedit_segment_lengths.size(), FALSE); + } + } + mPreeditor->updatePreedit(preedit_string, preedit_segment_lengths, preedit_standouts, caret_position); + + // Some IME doesn't query char position after WM_IME_COMPOSITION, + // so we need to update them actively. + updateLanguageTextInputArea(); + } +} + +// Given a text and a focus range, find_context finds and returns a +// surrounding context of the focused subtext. A variable pointed +// to by offset receives the offset in llwchars of the beginning of +// the returned context string in the given wtext. + +static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_length, S32 *offset) +{ + static const S32 CONTEXT_EXCESS = 30; // This value is by experiences. + + const S32 e = llmin((S32) wtext.length(), focus + focus_length + CONTEXT_EXCESS); + S32 end = focus + focus_length; + while (end < e && '\n' != wtext[end]) + { + end++; + } + + const S32 s = llmax(0, focus - CONTEXT_EXCESS); + S32 start = focus; + while (start > s && '\n' != wtext[start - 1]) + { + --start; + } + + *offset = start; + return wtext.substr(start, end - start); +} + +// final stage of handling drop requests - both from WM_DROPFILES message +// for files and via IDropTarget interface requests. +BOOL LLWindowWin32::completeDropRequest( const LLCoordGL gl_coord, const MASK mask, const std::string url ) +{ + if ( mCallbacks->handleDrop( this, gl_coord, mask, url ) ) + { + return TRUE; + }; + + return FALSE; +}; + +// Handle WM_IME_REQUEST message. +// If it handled the message, returns TRUE. Otherwise, FALSE. +// When it handled the message, the value to be returned from +// the Window Procedure is set to *result. + +BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result) +{ + if ( mPreeditor ) + { + switch (request) + { + case IMR_CANDIDATEWINDOW: // http://msdn2.microsoft.com/en-us/library/ms776080.aspx + { + LLCoordGL caret_coord; + LLRect preedit_bounds; + mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL); + + CANDIDATEFORM *const form = (CANDIDATEFORM *)param; + DWORD const dwIndex = form->dwIndex; + fillCandidateForm(caret_coord, preedit_bounds, form); + form->dwIndex = dwIndex; + + *result = 1; + return TRUE; + } + case IMR_QUERYCHARPOSITION: + { + IMECHARPOSITION *const char_position = (IMECHARPOSITION *)param; + + // char_position->dwCharPos counts in number of + // WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the + // number to getPreeditLocation. + + const LLWString & wtext = mPreeditor->getPreeditString(); + S32 preedit, preedit_length; + mPreeditor->getPreeditRange(&preedit, &preedit_length); + LLCoordGL caret_coord; + LLRect preedit_bounds, text_control; + const S32 position = wstring_wstring_length_from_utf16_length(wtext, preedit, char_position->dwCharPos); + + if (!mPreeditor->getPreeditLocation(position, &caret_coord, &preedit_bounds, &text_control)) + { + LL_WARNS("Window") << "*** IMR_QUERYCHARPOSITON called but getPreeditLocation failed." << LL_ENDL; + return FALSE; + } + fillCharPosition(caret_coord, preedit_bounds, text_control, char_position); + + *result = 1; + return TRUE; + } + case IMR_COMPOSITIONFONT: + { + fillCompositionLogfont((LOGFONT *)param); + + *result = 1; + return TRUE; + } + case IMR_RECONVERTSTRING: + { + mPreeditor->resetPreedit(); + const LLWString & wtext = mPreeditor->getPreeditString(); + S32 select, select_length; + mPreeditor->getSelectionRange(&select, &select_length); + + S32 context_offset; + const LLWString context = find_context(wtext, select, select_length, &context_offset); + + RECONVERTSTRING * const reconvert_string = (RECONVERTSTRING *)param; + const U32 size = fillReconvertString(context, select - context_offset, select_length, reconvert_string); + if (reconvert_string) + { + if (select_length == 0) + { + // Let the IME to decide the reconversion range, and + // adjust the reconvert_string structure accordingly. + HIMC himc = LLWinImm::getContext(mWindowHandle); + const BOOL adjusted = LLWinImm::setCompositionString(himc, + SCS_QUERYRECONVERTSTRING, reconvert_string, size, NULL, 0); + LLWinImm::releaseContext(mWindowHandle, himc); + if (adjusted) + { + const llutf16string & text_utf16 = wstring_to_utf16str(context); + const S32 new_preedit_start = reconvert_string->dwCompStrOffset / sizeof(WCHAR); + const S32 new_preedit_end = new_preedit_start + reconvert_string->dwCompStrLen; + select = utf16str_wstring_length(text_utf16, new_preedit_start); + select_length = utf16str_wstring_length(text_utf16, new_preedit_end) - select; + select += context_offset; + } + } + mPreeditor->markAsPreedit(select, select_length); + } + + *result = size; + return TRUE; + } + case IMR_CONFIRMRECONVERTSTRING: + { + *result = FALSE; + return TRUE; + } + case IMR_DOCUMENTFEED: + { + const LLWString & wtext = mPreeditor->getPreeditString(); + S32 preedit, preedit_length; + mPreeditor->getPreeditRange(&preedit, &preedit_length); + + S32 context_offset; + LLWString context = find_context(wtext, preedit, preedit_length, &context_offset); + preedit -= context_offset; + if (preedit_length) + { + // IMR_DOCUMENTFEED may be called when we have an active preedit. + // We should pass the context string *excluding* the preedit string. + // Otherwise, some IME are confused. + context.erase(preedit, preedit_length); + } + + RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)param; + *result = fillReconvertString(context, preedit, 0, reconvert_string); + return TRUE; + } + default: + return FALSE; + } + } + + return FALSE; +} + +//static +std::vector LLWindowWin32::getDynamicFallbackFontList() +{ + // Fonts previously in getFontListSans() have moved to fonts.xml. + return std::vector(); +} + + +#endif // LL_WINDOWS diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index e14324c9f1..1382cf93a2 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -39,6 +39,7 @@ #include #include "llwindow.h" +#include "lldragdropwin32.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) @@ -112,6 +113,8 @@ public: /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); + BOOL completeDropRequest( const LLCoordGL gl_coord, const MASK mask, const std::string url ); + static std::vector getDynamicFallbackFontList(); protected: @@ -206,6 +209,8 @@ protected: LLPreeditor *mPreeditor; + LLDragDropWin32* mDragDrop; + friend class LLWindowManager; }; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a080243086..220f90c2f5 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -817,7 +817,7 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS return TRUE; } -BOOL LLViewerWindow::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void* data) +BOOL LLViewerWindow::handleDrop( LLWindow *window, LLCoordGL pos, MASK mask, std::string data ) { if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { @@ -825,7 +825,7 @@ BOOL LLViewerWindow::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, voi LLUUID object_id = pick_info.getObjectID(); S32 object_face = pick_info.mObjectFace; - std::string url = std::string( (char*)data ); + std::string url = data; llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 44704b99e3..cf024df9bf 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,7 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, void* data); + /*virtual*/ BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data); void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); -- cgit v1.2.3 From 66ce1b04297cd48520e666a3fa903af143f89c57 Mon Sep 17 00:00:00 2001 From: callum Date: Mon, 2 Nov 2009 15:05:38 -0800 Subject: Added CMake file for new cpp/h file --- indra/llwindow/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 7b1cab696f..b4a3f74451 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -102,11 +102,13 @@ if (WINDOWS) llwindowwin32.cpp lldxhardware.cpp llkeyboardwin32.cpp + lldragdropwin32.cpp ) list(APPEND llwindow_HEADER_FILES llwindowwin32.h lldxhardware.h llkeyboardwin32.h + lldragdropwin32.h ) list(APPEND llwindow_LINK_LIBRARIES comdlg32 # Common Dialogs for ChooseColor -- cgit v1.2.3 From 996740607a11ac7f8633f12b65ead0508e1435fa Mon Sep 17 00:00:00 2001 From: callum Date: Tue, 3 Nov 2009 09:33:21 -0800 Subject: Convert screen coordinates from IDropAction to window coordinates. --- indra/llwindow/lldragdropwin32.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 0daff85395..d05dbf19a5 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -209,11 +209,18 @@ class LLDragDropWin32Target: LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mWindowHandle, GWL_USERDATA); if (NULL != window_imp) { - LLCoordGL gl_coord( pt.x, pt.y); - LLCoordWindow cursor_coord_window( pt.x, pt.y ); + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); window_imp->convertCoords(cursor_coord_window, &gl_coord); llinfos << "### (Drop) URL is: " << lpszText << llendl; llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; + llinfos << "### window coords are: " << pt2.x << " x " << pt2.y << llendl; llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; llinfos << llendl; -- cgit v1.2.3 From 4f0731d722c41b6717d08b8165e941a06edd3a1f Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 5 Nov 2009 17:51:04 -0800 Subject: make drop add media if not there, navigate if already there --- indra/newview/llviewerwindow.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b43479689f..ead99613fb 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -831,12 +831,27 @@ BOOL LLViewerWindow::handleDrop( LLWindow *window, LLCoordGL pos, MASK mask, st LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); if (obj) { - LLSD media_data; - /// XXX home URL too? - media_data[LLMediaEntry::CURRENT_URL_KEY] = url; - media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; - obj->syncMediaData(object_face, media_data, true, true); - obj->sendMediaDataUpdate(); + LLTextureEntry *te = obj->getTE(object_face); + if (te) + { + if (! te->hasMedia()) + { + // Create new media entry + LLSD media_data; + // XXX Should we really do Home URL too? + media_data[LLMediaEntry::HOME_URL_KEY] = url; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; + obj->syncMediaData(object_face, media_data, true, true); + // XXX This shouldn't be necessary, should it ?!? + obj->getMediaImpl(object_face)->navigateReload(); + obj->sendMediaDataUpdate(); + } + else { + // just navigate to the URL + obj->getMediaImpl(object_face)->navigateTo(url); + } + } } } // Always handled as far as the OS is concerned. -- cgit v1.2.3 From bf5ce0fcbd9a71ce1372db0f42395ba47747fd78 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 12 Nov 2009 11:06:29 -0800 Subject: Change 'handleDrop()' API to 'handleDragNDrop', which now takes a "drop" BOOL --- indra/llwindow/lldragdropwin32.cpp | 18 ++++++++++++++++- indra/llwindow/llwindowcallbacks.cpp | 2 +- indra/llwindow/llwindowcallbacks.h | 2 +- indra/llwindow/llwindowwin32.cpp | 13 ++++-------- indra/llwindow/llwindowwin32.h | 2 +- indra/newview/llviewerwindow.cpp | 39 +++++++++++++++++++++--------------- indra/newview/llviewerwindow.h | 2 +- 7 files changed, 48 insertions(+), 30 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index d05dbf19a5..879f2d2b90 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -171,6 +171,22 @@ class LLDragDropWin32Target: STDMETHOD (DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) { HRESULT hr = S_OK; + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + bDropTargetValid = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); + } if (bDropTargetValid) *pdwEffect=DROPEFFECT_COPY; @@ -225,7 +241,7 @@ class LLDragDropWin32Target: llinfos << llendl; MASK mask = gKeyboard->currentMask(TRUE); - window_imp->completeDropRequest( gl_coord, mask, std::string( lpszText ) ); + window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, std::string( lpszText ) ); }; GlobalUnlock(hText); diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index 1098529e1c..b8927a1ac4 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,7 +163,7 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } -BOOL LLWindowCallbacks::handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data ) +BOOL LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) { return FALSE; } diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index 3a09100168..8e7605a650 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -68,7 +68,7 @@ public: virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); - virtual BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data); + virtual BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index da096b9a0a..eda8cf15b0 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -2401,7 +2401,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ MASK mask = gKeyboard->currentMask(TRUE); - if ( window_imp->completeDropRequest( gl_coord, mask, (char*)url ) ) + if ( window_imp->completeDragNDropRequest( gl_coord, mask, true, (char*)url ) ) { return 0; }; @@ -3578,15 +3578,10 @@ static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_leng // final stage of handling drop requests - both from WM_DROPFILES message // for files and via IDropTarget interface requests. -BOOL LLWindowWin32::completeDropRequest( const LLCoordGL gl_coord, const MASK mask, const std::string url ) +BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ) { - if ( mCallbacks->handleDrop( this, gl_coord, mask, url ) ) - { - return TRUE; - }; - - return FALSE; -}; + return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url ); +} // Handle WM_IME_REQUEST message. // If it handled the message, returns TRUE. Otherwise, FALSE. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 1382cf93a2..e99c26b7f1 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -113,7 +113,7 @@ public: /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); - BOOL completeDropRequest( const LLCoordGL gl_coord, const MASK mask, const std::string url ); + BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ); static std::vector getDynamicFallbackFontList(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 06d6819b5e..d2f81f21ac 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -819,8 +819,9 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS return TRUE; } -BOOL LLViewerWindow::handleDrop( LLWindow *window, LLCoordGL pos, MASK mask, std::string data ) +BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) { + BOOL result = FALSE; if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); @@ -837,28 +838,34 @@ BOOL LLViewerWindow::handleDrop( LLWindow *window, LLCoordGL pos, MASK mask, st LLTextureEntry *te = obj->getTE(object_face); if (te) { - if (! te->hasMedia()) + if (drop) { - // Create new media entry - LLSD media_data; - // XXX Should we really do Home URL too? - media_data[LLMediaEntry::HOME_URL_KEY] = url; - media_data[LLMediaEntry::CURRENT_URL_KEY] = url; - media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; - obj->syncMediaData(object_face, media_data, true, true); - // XXX This shouldn't be necessary, should it ?!? - obj->getMediaImpl(object_face)->navigateReload(); - obj->sendMediaDataUpdate(); + if (! te->hasMedia()) + { + // Create new media entry + LLSD media_data; + // XXX Should we really do Home URL too? + media_data[LLMediaEntry::HOME_URL_KEY] = url; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; + obj->syncMediaData(object_face, media_data, true, true); + // XXX This shouldn't be necessary, should it ?!? + obj->getMediaImpl(object_face)->navigateReload(); + obj->sendMediaDataUpdate(); + } + else { + // just navigate to the URL + obj->getMediaImpl(object_face)->navigateTo(url); + } } else { - // just navigate to the URL - obj->getMediaImpl(object_face)->navigateTo(url); + // XXX TODO: make object glow? Hard because how do we "unglow?" } + result = TRUE; } } } - // Always handled as far as the OS is concerned. - return TRUE; + return result; } BOOL LLViewerWindow::handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index cdc9eb4786..d7cfcff925 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,7 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ BOOL handleDrop(LLWindow *window, LLCoordGL pos, MASK mask, std::string data); + /*virtual*/ BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); -- cgit v1.2.3 From 778005a350308d51f114ece74b4e7f3e7af3d37e Mon Sep 17 00:00:00 2001 From: callum Date: Fri, 13 Nov 2009 17:43:55 -0800 Subject: Reworked IDropTarget COM interface impl - now much cleaner and doesn't crash! --- indra/llwindow/lldragdropwin32.cpp | 287 +++++++++++++++++-------------------- indra/llwindow/lldragdropwin32.h | 8 +- 2 files changed, 135 insertions(+), 160 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index d05dbf19a5..aac68e71af 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -34,216 +34,183 @@ #include "linden_common.h" -#define WIN32_LEAN_AND_MEAN -#include - #include "llwindowwin32.h" #include "llkeyboardwin32.h" -#include "lldragdropwin32.h" - #include "llwindowcallbacks.h" - -#include -#include -#include -#include -#include - -// FIXME: this should be done in CMake -#pragma comment( lib, "shlwapi.lib" ) +#include "lldragdropwin32.h" class LLDragDropWin32Target: public IDropTarget { public: + //////////////////////////////////////////////////////////////////////////////// + // LLDragDropWin32Target( HWND hWnd ) : - mWindowHandle( hWnd ), - mRefCount( 0 ) + mRefCount( 1 ), + mAppWindowHandle( hWnd ), + mAllowDrop( false) { - strcpy(szFileDropped,""); - bDropTargetValid = false; - bTextDropped = false; }; - /* IUnknown methods */ - STDMETHOD_( ULONG, AddRef )( void ) + //////////////////////////////////////////////////////////////////////////////// + // + ULONG __stdcall AddRef( void ) { - return ++mRefCount; + return InterlockedIncrement( &mRefCount ); }; - STDMETHOD_( ULONG, Release )( void ) + //////////////////////////////////////////////////////////////////////////////// + // + ULONG __stdcall Release( void ) { - if ( --mRefCount == 0 ) + LONG count = InterlockedDecrement( &mRefCount ); + + if ( count == 0 ) { delete this; return 0; } - return mRefCount; + else + { + return count; + }; }; - STDMETHOD ( QueryInterface )( REFIID iid, void ** ppvObject ) + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall QueryInterface( REFIID iid, void** ppvObject ) { if ( iid == IID_IUnknown || iid == IID_IDropTarget ) { - *ppvObject = this; AddRef(); + *ppvObject = this; return S_OK; + } + else + { + *ppvObject = 0; + return E_NOINTERFACE; }; - - *ppvObject = NULL; - return E_NOINTERFACE; }; - - /* IDropTarget methods */ - STDMETHOD (DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragEnter( IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) { - HRESULT hr = E_INVALIDARG; - bDropTargetValid = false; - bTextDropped = false; - *pdwEffect=DROPEFFECT_NONE; - - FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - STGMEDIUM medium; - - if (pDataObj && SUCCEEDED (pDataObj->GetData (&fmte, &medium))) - { - // We can Handle Only one File At a time !!! - if (1 == DragQueryFile ((HDROP)medium.hGlobal,0xFFFFFFFF,NULL,0 )) - { - // Get the File Name - if (DragQueryFileA((HDROP)medium.hGlobal, 0, szFileDropped,MAX_PATH)) - { - if (!PathIsDirectoryA(szFileDropped)) - { - char szTempFile[MAX_PATH]; - _splitpath(szFileDropped,NULL,NULL,NULL,szTempFile); - -// if (!stricmp(szTempFile,".lnk")) -// { -// if (ResolveLink(szFileDropped,szTempFile)) -// { -// strcpy(szFileDropped,szTempFile); -// *pdwEffect=DROPEFFECT_COPY; -// We Want to Create a Copy -// bDropTargetValid = true; -// hr = S_OK; -// } -// } -// else -// { - *pdwEffect=DROPEFFECT_COPY; - //We Want to Create a Copy - bDropTargetValid = true; - hr = S_OK; -// } - } - } - } - - if (medium.pUnkForRelease) - medium.pUnkForRelease->Release (); - else - GlobalFree (medium.hGlobal); - } - else + FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + + // support CF_TEXT using a HGLOBAL? + if ( S_OK == pDataObject->QueryGetData( &fmtetc ) ) { - fmte.cfFormat = CF_TEXT; - fmte.ptd = NULL; - fmte.dwAspect = DVASPECT_CONTENT; - fmte.lindex = -1; - fmte.tymed = TYMED_HGLOBAL; - - // Does the drag source provide CF_TEXT ? - if (NOERROR == pDataObj->QueryGetData(&fmte)) - { - bDropTargetValid = true; - bTextDropped = true; - *pdwEffect=DROPEFFECT_COPY; - hr = S_OK; - } - } - return hr; + mAllowDrop = true; + *pdwEffect = DROPEFFECT_COPY; + SetFocus( mAppWindowHandle ); + } + else + { + mAllowDrop = false; + *pdwEffect = DROPEFFECT_NONE; + }; + return S_OK; }; - STDMETHOD (DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragOver( DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) { - HRESULT hr = S_OK; - if (bDropTargetValid) - *pdwEffect=DROPEFFECT_COPY; + if ( mAllowDrop ) + { + *pdwEffect = DROPEFFECT_COPY; + } + else + { + *pdwEffect = DROPEFFECT_NONE; + }; - return hr; + return S_OK; }; - STDMETHOD (DragLeave)(void) + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragLeave( void ) { - HRESULT hr = S_OK; - strcpy(szFileDropped,""); - return hr; + return S_OK; }; - STDMETHOD (Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall Drop( IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) { - HRESULT hr = S_OK; - if (bDropTargetValid) + if ( mAllowDrop ) { - *pdwEffect=DROPEFFECT_COPY; - - FORMATETC fmte; - STGMEDIUM medium; + // construct a FORMATETC object + FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - if (bTextDropped) + // do we have text? + if( S_OK == pDataObject->QueryGetData( &fmtetc ) ) { - fmte.cfFormat = CF_TEXT; - fmte.ptd = NULL; - fmte.dwAspect = DVASPECT_CONTENT; - fmte.lindex = -1; - fmte.tymed = TYMED_HGLOBAL; - - hr = pDataObj->GetData(&fmte, &medium); - HGLOBAL hText = medium.hGlobal; - LPSTR lpszText = (LPSTR)GlobalLock(hText); - - LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mWindowHandle, GWL_USERDATA); - if (NULL != window_imp) + STGMEDIUM stgmed; + if( S_OK == pDataObject->GetData( &fmtetc, &stgmed ) ) { - LLCoordGL gl_coord( 0, 0 ); - - POINT pt2; - pt2.x = pt.x; - pt2.y = pt.y; - ScreenToClient( mWindowHandle, &pt2 ); - - LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - llinfos << "### (Drop) URL is: " << lpszText << llendl; - llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; - llinfos << "### window coords are: " << pt2.x << " x " << pt2.y << llendl; - llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; - llinfos << llendl; - - MASK mask = gKeyboard->currentMask(TRUE); - window_imp->completeDropRequest( gl_coord, mask, std::string( lpszText ) ); + // note: data is in an HGLOBAL - not 'regular' memory + PVOID data = GlobalLock( stgmed.hGlobal ); + + // window impl stored in Window data (neat!) + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong( mAppWindowHandle, GWL_USERDATA ); + if ( NULL != window_imp ) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt_client; + pt_client.x = pt.x; + pt_client.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt_client ); + + LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + llinfos << "### (Drop) URL is: " << data << llendl; + llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; + llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; + llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; + llinfos << llendl; + + // no keyboard modifier option yet but we could one day + MASK mask = gKeyboard->currentMask( TRUE ); + + // actually do the drop + window_imp->completeDropRequest( gl_coord, mask, std::string( (char*)data ) ); + }; + + GlobalUnlock( stgmed.hGlobal ); + + ReleaseStgMedium( &stgmed ); }; + }; - GlobalUnlock(hText); - ReleaseStgMedium(&medium); - } + *pdwEffect = DROPEFFECT_COPY; } - return hr; + else + { + *pdwEffect = DROPEFFECT_NONE; + }; + + return S_OK; }; - + + //////////////////////////////////////////////////////////////////////////////// + // private: - ULONG mRefCount; - HWND mWindowHandle; - char szFileDropped[1024]; - bool bDropTargetValid; - bool bTextDropped; + LONG mRefCount; + HWND mAppWindowHandle; + bool mAllowDrop; friend class LLWindowWin32; }; +//////////////////////////////////////////////////////////////////////////////// +// LLDragDropWin32::LLDragDropWin32() : mDropTarget( NULL ), mDropWindowHandle( NULL ) @@ -251,19 +218,23 @@ LLDragDropWin32::LLDragDropWin32() : { } +//////////////////////////////////////////////////////////////////////////////// +// LLDragDropWin32::~LLDragDropWin32() { } +//////////////////////////////////////////////////////////////////////////////// +// bool LLDragDropWin32::init( HWND hWnd ) { - if (NOERROR != OleInitialize(NULL)) + if ( NOERROR != OleInitialize( NULL ) ) return FALSE; mDropTarget = new LLDragDropWin32Target( hWnd ); if ( mDropTarget ) { - HRESULT result = CoLockObjectExternal( mDropTarget, TRUE, TRUE ); + HRESULT result = CoLockObjectExternal( mDropTarget, TRUE, FALSE ); if ( S_OK == result ) { result = RegisterDragDrop( hWnd, mDropTarget ); @@ -287,12 +258,14 @@ bool LLDragDropWin32::init( HWND hWnd ) return true; } +//////////////////////////////////////////////////////////////////////////////// +// void LLDragDropWin32::reset() { if ( mDropTarget ) { - CoLockObjectExternal( mDropTarget, FALSE, TRUE ); RevokeDragDrop( mDropWindowHandle ); + CoLockObjectExternal( mDropTarget, FALSE, TRUE ); mDropTarget->Release(); }; diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h index 6137e5eb65..624f4ad24b 100644 --- a/indra/llwindow/lldragdropwin32.h +++ b/indra/llwindow/lldragdropwin32.h @@ -33,10 +33,10 @@ #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H +#if LL_WINDOWS + #include #include -#include -#include class LLDragDropWin32 { @@ -52,4 +52,6 @@ class LLDragDropWin32 HWND mDropWindowHandle; }; -#endif +#endif // LL_WINDOWS + +#endif // LL_LLDRAGDROP32_H -- cgit v1.2.3 From 4419e367bcbe8c1b248e88eab8096f0b8ac4707c Mon Sep 17 00:00:00 2001 From: callum Date: Wed, 18 Nov 2009 21:15:44 -0800 Subject: Add support for removing the Windows specific drag/drop code from the codebase via a new CMake file (DragDrop.cmake). --- indra/cmake/DragDrop.cmake | 25 +++++++++++++++++++++++++ indra/llwindow/CMakeLists.txt | 1 + indra/llwindow/lldragdropwin32.cpp | 7 ++++++- indra/llwindow/lldragdropwin32.h | 29 ++++++++++++++++++++++++++--- indra/newview/CMakeLists.txt | 1 + 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 indra/cmake/DragDrop.cmake diff --git a/indra/cmake/DragDrop.cmake b/indra/cmake/DragDrop.cmake new file mode 100644 index 0000000000..a2d7df1312 --- /dev/null +++ b/indra/cmake/DragDrop.cmake @@ -0,0 +1,25 @@ +# -*- cmake -*- + +if (VIEWER) + + OPTION (OS_DRAG_DROP + "Build the viewer with OS level drag and drop turned on or off" + OFF) + + if (OS_DRAG_DROP) + + if (WINDOWS) + add_definitions(-DLL_OS_DRAGDROP_ENABLED=1) + endif (WINDOWS) + + if (DARWIN) + add_definitions(-DLL_OS_DRAGDROP_ENABLED=0) + endif (DARWIN) + + if (LINUX) + add_definitions(-DLL_OS_DRAGDROP_ENABLED=0) + endif (LINUX) + + endif (OS_DRAG_DROP) + +endif (VIEWER) diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index b4a3f74451..77c6fa57b6 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -12,6 +12,7 @@ project(llwindow) include(00-Common) include(DirectX) +include(DragDrop) include(LLCommon) include(LLImage) include(LLMath) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index aac68e71af..471c88675d 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -32,6 +32,8 @@ #if LL_WINDOWS +#if LL_OS_DRAGDROP_ENABLED + #include "linden_common.h" #include "llwindowwin32.h" @@ -272,4 +274,7 @@ void LLDragDropWin32::reset() OleUninitialize(); } -#endif +#endif // LL_OS_DRAGDROP_ENABLED + +#endif // LL_WINDOWS + diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h index 624f4ad24b..26c8e4aeff 100644 --- a/indra/llwindow/lldragdropwin32.h +++ b/indra/llwindow/lldragdropwin32.h @@ -30,11 +30,13 @@ * $/LicenseInfo$ */ +#if LL_WINDOWS + +#if LL_OS_DRAGDROP_ENABLED + #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H -#if LL_WINDOWS - #include #include @@ -51,7 +53,28 @@ class LLDragDropWin32 IDropTarget* mDropTarget; HWND mDropWindowHandle; }; +#endif // LL_LLDRAGDROP32_H -#endif // LL_WINDOWS +#else // LL_OS_DRAGDROP_ENABLED +#ifndef LL_LLDRAGDROP32_H +#define LL_LLDRAGDROP32_H + +#include +#include + +// imposter class that does nothing +class LLDragDropWin32 +{ + public: + LLDragDropWin32() {}; + ~LLDragDropWin32() {}; + + bool init( HWND hWnd ) { return false; }; + void reset() { }; +}; #endif // LL_LLDRAGDROP32_H + +#endif // LL_OS_DRAGDROP_ENABLED + +#endif // LL_WINDOWS diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b129bca1f3..352e9a9382 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -7,6 +7,7 @@ include(Boost) include(BuildVersion) include(DBusGlib) include(DirectX) +include(DragDrop) include(ELFIO) include(FMOD) include(OPENAL) -- cgit v1.2.3 From 9e53ad6111ce0e15cb10f2ffb47fee8b48d1c3db Mon Sep 17 00:00:00 2001 From: callum Date: Wed, 18 Nov 2009 21:17:39 -0800 Subject: Doh! Update the CMake file that controls drag and drop to turn it ON --- indra/cmake/DragDrop.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/cmake/DragDrop.cmake b/indra/cmake/DragDrop.cmake index a2d7df1312..739d011813 100644 --- a/indra/cmake/DragDrop.cmake +++ b/indra/cmake/DragDrop.cmake @@ -4,7 +4,7 @@ if (VIEWER) OPTION (OS_DRAG_DROP "Build the viewer with OS level drag and drop turned on or off" - OFF) + ON) if (OS_DRAG_DROP) -- cgit v1.2.3 From d4ba73ed721fa0811474fc53300f560539d38018 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 19 Nov 2009 09:24:26 -0800 Subject: Fix merge error --- indra/llwindow/lldragdropwin32.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 4fc64f2f69..b39cd83698 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -124,7 +124,7 @@ class LLDragDropWin32Target: if ( mAllowDrop ) { // XXX MAJOR MAJOR HACK! - LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mWindowHandle, GWL_USERDATA); + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); if (NULL != window_imp) { LLCoordGL gl_coord( 0, 0 ); @@ -132,12 +132,12 @@ class LLDragDropWin32Target: POINT pt2; pt2.x = pt.x; pt2.y = pt.y; - ScreenToClient( mWindowHandle, &pt2 ); + ScreenToClient( mAppWindowHandle, &pt2 ); LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - bDropTargetValid = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); + window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); } *pdwEffect = DROPEFFECT_COPY; } -- cgit v1.2.3 From dbe1f9755896e41e2064a3ee69725d753c67921f Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 23 Nov 2009 17:18:54 -0800 Subject: Highlight the object if it is being dragged over and can be dropped upon --- indra/newview/llviewerwindow.cpp | 10 ++++++++-- indra/newview/llviewerwindow.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 55e66e1138..17b9490f63 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -833,7 +833,8 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); - if (obj) + gPipeline.setHighlightObject(NULL); + if (obj && obj->permModify()) { LLTextureEntry *te = obj->getTE(object_face); if (te) @@ -859,11 +860,16 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas } } else { - // XXX TODO: make object glow? Hard because how do we "unglow?" + mDragHoveredObject = obj; + // Make the object glow + gPipeline.setHighlightObject(mDragHoveredObject->mDrawable); } result = TRUE; } } + else { + mDragHoveredObject = NULL; + } } return result; } diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 311fea3508..428c602b73 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -474,6 +474,9 @@ protected: static std::string sSnapshotDir; static std::string sMovieBaseName; + +private: + LLPointer mDragHoveredObject; }; void toggle_flying(void*); -- cgit v1.2.3 From 8d84b7ae4062d8680aae2bb8325813bdac0335ed Mon Sep 17 00:00:00 2001 From: callum Date: Tue, 24 Nov 2009 18:31:30 -0800 Subject: Add support for changing OS cursor when mouse passes over a prim you can drop on versus one you can't. --- indra/llwindow/lldragdropwin32.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index a10cfbf12f..6024931092 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -125,23 +125,29 @@ class LLDragDropWin32Target: { if ( mAllowDrop ) { - // XXX MAJOR MAJOR HACK! - LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); - if (NULL != window_imp) - { - LLCoordGL gl_coord( 0, 0 ); - - POINT pt2; - pt2.x = pt.x; - pt2.y = pt.y; - ScreenToClient( mAppWindowHandle, &pt2 ); + bool allowed_to_drop = false; - LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - MASK mask = gKeyboard->currentMask(TRUE); - window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); - } - *pdwEffect = DROPEFFECT_COPY; + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); + } + + if ( allowed_to_drop ) + *pdwEffect = DROPEFFECT_COPY; + else + *pdwEffect = DROPEFFECT_NONE; } else { -- cgit v1.2.3 From e2e7d544b6a114e70e3b46f516a4f0e8d7db4bd1 Mon Sep 17 00:00:00 2001 From: callum Date: Tue, 24 Nov 2009 20:20:53 -0800 Subject: Added support for dropping SURLs onto viewer Does right thing when logged in - needs some work at login page Removed (commented out) WM_DROPFILES code for now --- indra/llwindow/lldragdropwin32.cpp | 103 ++++++++++++++++++---------------- indra/llwindow/llwindowcallbacks.cpp | 2 +- indra/llwindow/llwindowcallbacks.h | 2 +- indra/llwindow/llwindowwin32.cpp | 105 ++++++++++++++++++----------------- indra/llwindow/llwindowwin32.h | 2 +- indra/newview/llviewerwindow.cpp | 10 +++- indra/newview/llviewerwindow.h | 2 +- 7 files changed, 121 insertions(+), 105 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 6024931092..74f96f6da3 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -54,6 +54,10 @@ class LLDragDropWin32Target: { }; + virtual ~LLDragDropWin32Target() + { + }; + //////////////////////////////////////////////////////////////////////////////// // ULONG __stdcall AddRef( void ) @@ -105,6 +109,20 @@ class LLDragDropWin32Target: if ( S_OK == pDataObject->QueryGetData( &fmtetc ) ) { mAllowDrop = true; + mDropUrl = std::string(); + mIsSlurl = false; + + STGMEDIUM stgmed; + if( S_OK == pDataObject->GetData( &fmtetc, &stgmed ) ) + { + PVOID data = GlobalLock( stgmed.hGlobal ); + mDropUrl = std::string( (char*)data ); + + mIsSlurl = ( mDropUrl.find( "slurl.com" ) != std::string::npos ); + + GlobalUnlock( stgmed.hGlobal ); + ReleaseStgMedium( &stgmed ); + }; *pdwEffect = DROPEFFECT_COPY; @@ -125,8 +143,6 @@ class LLDragDropWin32Target: { if ( mAllowDrop ) { - bool allowed_to_drop = false; - // XXX MAJOR MAJOR HACK! LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); if (NULL != window_imp) @@ -141,13 +157,17 @@ class LLDragDropWin32Target: LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); - } - if ( allowed_to_drop ) - *pdwEffect = DROPEFFECT_COPY; - else - *pdwEffect = DROPEFFECT_NONE; + bool allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ), mIsSlurl ); + if ( allowed_to_drop ) + *pdwEffect = DROPEFFECT_COPY; + else + *pdwEffect = DROPEFFECT_NONE; + + // special case for SLURLs - you can always drop them on the client window and we need a different cursor + if ( mIsSlurl ) + *pdwEffect = DROPEFFECT_LINK; + }; } else { @@ -161,6 +181,7 @@ class LLDragDropWin32Target: // HRESULT __stdcall DragLeave( void ) { + mDropUrl = std::string(); return S_OK; }; @@ -170,48 +191,30 @@ class LLDragDropWin32Target: { if ( mAllowDrop ) { - // construct a FORMATETC object - FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - - // do we have text? - if( S_OK == pDataObject->QueryGetData( &fmtetc ) ) + // window impl stored in Window data (neat!) + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong( mAppWindowHandle, GWL_USERDATA ); + if ( NULL != window_imp ) { - STGMEDIUM stgmed; - if( S_OK == pDataObject->GetData( &fmtetc, &stgmed ) ) - { - // note: data is in an HGLOBAL - not 'regular' memory - PVOID data = GlobalLock( stgmed.hGlobal ); - - // window impl stored in Window data (neat!) - LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong( mAppWindowHandle, GWL_USERDATA ); - if ( NULL != window_imp ) - { - LLCoordGL gl_coord( 0, 0 ); - - POINT pt_client; - pt_client.x = pt.x; - pt_client.y = pt.y; - ScreenToClient( mAppWindowHandle, &pt_client ); - - LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - llinfos << "### (Drop) URL is: " << data << llendl; - llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; - llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; - llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; - llinfos << llendl; - - // no keyboard modifier option yet but we could one day - MASK mask = gKeyboard->currentMask( TRUE ); - - // actually do the drop - window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, std::string( (char*)data ) ); - }; - - GlobalUnlock( stgmed.hGlobal ); - - ReleaseStgMedium( &stgmed ); - }; + LLCoordGL gl_coord( 0, 0 ); + + POINT pt_client; + pt_client.x = pt.x; + pt_client.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt_client ); + + LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + llinfos << "### (Drop) URL is: " << mDropUrl << llendl; + llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; + llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; + llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; + llinfos << llendl; + + // no keyboard modifier option yet but we could one day + MASK mask = gKeyboard->currentMask( TRUE ); + + // actually do the drop + window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, mDropUrl, mIsSlurl ); }; *pdwEffect = DROPEFFECT_COPY; @@ -230,6 +233,8 @@ class LLDragDropWin32Target: LONG mRefCount; HWND mAppWindowHandle; bool mAllowDrop; + std::string mDropUrl; + bool mIsSlurl; friend class LLWindowWin32; }; diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index b8927a1ac4..3b0aeeab1f 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,7 +163,7 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } -BOOL LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) +BOOL LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl ) { return FALSE; } diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index 8e7605a650..1b4a6cbda2 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -68,7 +68,7 @@ public: virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); - virtual BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); + virtual BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index eda8cf15b0..78bc3b9c58 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -2355,57 +2355,60 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ }; return 0; - case WM_DROPFILES: - { - // HDROP contains what we need - HDROP hdrop = (HDROP)w_param; - - // get location in window space where drop occured and convert to OpenGL coordinate space - POINT pt; - DragQueryPoint( hdrop, &pt ); - LLCoordGL gl_coord; - LLCoordWindow cursor_coord_window( pt.x, pt.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); - - // get payload (eventually, this needs to more advanced and grab size of payload dynamically - static char file_name[ 1024 ]; - DragQueryFileA( hdrop, 0, file_name, 1024 ); - void* url = (void*)( file_name ); - - // if it's a .URL or .lnk ("shortcut") file - if ( std::string( file_name ).find( ".lnk" ) != std::string::npos || - std::string( file_name ).find( ".URL" ) != std::string::npos ) - { - // read through file - looks like a 2 line file with second line URL= but who knows.. - std::ifstream file_handle( file_name ); - if ( file_handle.is_open() ) - { - std::string line; - while ( ! file_handle.eof() ) - { - std::getline( file_handle, line ); - if ( ! file_handle.eof() ) - { - std::string prefix( "URL=" ); - if ( line.find( prefix, 0 ) != std::string::npos ) - { - line = line.substr( 4 ); // skip off the URL= bit - strcpy( (char*)url, line.c_str() ); - break; - }; - }; - }; - file_handle.close(); - }; - }; + // only useful for droppnig files - could be used for file upload dialog one day + //case WM_DROPFILES: + // { + // // HDROP contains what we need + // HDROP hdrop = (HDROP)w_param; + + // // get location in window space where drop occured and convert to OpenGL coordinate space + // POINT pt; + // DragQueryPoint( hdrop, &pt ); + // LLCoordGL gl_coord; + // LLCoordWindow cursor_coord_window( pt.x, pt.y ); + // window_imp->convertCoords(cursor_coord_window, &gl_coord); + + // // get payload (eventually, this needs to more advanced and grab size of payload dynamically + // static char file_name[ 1024 ]; + // DragQueryFileA( hdrop, 0, file_name, 1024 ); + // void* url = (void*)( file_name ); + + // // if it's a .URL or .lnk ("shortcut") file + // if ( std::string( file_name ).find( ".lnk" ) != std::string::npos || + // std::string( file_name ).find( ".URL" ) != std::string::npos ) + // { + // // read through file - looks like a 2 line file with second line URL= but who knows.. + // std::ifstream file_handle( file_name ); + // if ( file_handle.is_open() ) + // { + // std::string line; + // while ( ! file_handle.eof() ) + // { + // std::getline( file_handle, line ); + // if ( ! file_handle.eof() ) + // { + // std::string prefix( "URL=" ); + // if ( line.find( prefix, 0 ) != std::string::npos ) + // { + // line = line.substr( 4 ); // skip off the URL= bit + // strcpy( (char*)url, line.c_str() ); + // break; + // }; + // }; + // }; + // file_handle.close(); + // }; + // }; + + // MASK mask = gKeyboard->currentMask(TRUE); + + // if ( window_imp->completeDragNDropRequest( gl_coord, mask, true, (char*)url, false ) ) + // { + // return 0; + // }; + // } - MASK mask = gKeyboard->currentMask(TRUE); - if ( window_imp->completeDragNDropRequest( gl_coord, mask, true, (char*)url ) ) - { - return 0; - }; - } break; } @@ -3578,9 +3581,9 @@ static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_leng // final stage of handling drop requests - both from WM_DROPFILES message // for files and via IDropTarget interface requests. -BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ) +BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url, BOOL is_slurl ) { - return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url ); + return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url, is_slurl ); } // Handle WM_IME_REQUEST message. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index e99c26b7f1..7f7acd5751 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -113,7 +113,7 @@ public: /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); - BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ); + BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url, BOOL is_slurl ); static std::vector getDynamicFallbackFontList(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 17b9490f63..dd84140d5b 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -80,6 +80,7 @@ #include "llviewermenu.h" #include "lltooltip.h" #include "llmediaentry.h" +#include "llurldispatcher.h" // newview includes #include "llagent.h" @@ -819,11 +820,18 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS return TRUE; } -BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) +BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl ) { BOOL result = FALSE; if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { + // special case SLURLs + if ( slurl ) + { + LLURLDispatcher::dispatch( data, NULL, true ); + return TRUE; + }; + LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); LLUUID object_id = pick_info.getObjectID(); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 428c602b73..4296495067 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,7 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); + /*virtual*/ BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl); void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); -- cgit v1.2.3 From 97af20b4ba4a400569e99a616fc026190d3eec6c Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 25 Nov 2009 09:52:20 -0800 Subject: Change drag highlighting to use LLSelectMgr::{un}highlightObjectOnly() instead of gPipeline.setHighlightObject(). The latter seems a little buggy. --- indra/newview/llviewerwindow.cpp | 14 ++++++++++---- indra/newview/llviewerwindow.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 17b9490f63..cc74c1fbe2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -833,7 +833,7 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); - gPipeline.setHighlightObject(NULL); + if (obj && obj->permModify()) { LLTextureEntry *te = obj->getTE(object_face); @@ -858,19 +858,25 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas // just navigate to the URL obj->getMediaImpl(object_face)->navigateTo(url); } + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = NULL; } else { mDragHoveredObject = obj; - // Make the object glow - gPipeline.setHighlightObject(mDragHoveredObject->mDrawable); + // Highlight the dragged object + LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); } result = TRUE; } } - else { + + if (!result && !mDragHoveredObject.isNull()) + { + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); mDragHoveredObject = NULL; } } + return result; } diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 428c602b73..c3aa1b2407 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -476,6 +476,7 @@ protected: static std::string sMovieBaseName; private: + // Object temporarily hovered over while dragging LLPointer mDragHoveredObject; }; -- cgit v1.2.3 From e0a7b7608f087b7d3a4b91ba7868e0a5c04aaa86 Mon Sep 17 00:00:00 2001 From: callum Date: Mon, 30 Nov 2009 20:19:39 -0800 Subject: Add support for dropping a region SLURL on login page and populating the UI --- indra/newview/llpanellogin.cpp | 15 +++++++++++++++ indra/newview/llpanellogin.h | 3 ++- indra/newview/llviewerwindow.cpp | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index d2a17dbd97..ba3782bf53 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -682,6 +682,21 @@ void LLPanelLogin::refreshLocation( bool force_visible ) #endif } +// static +void LLPanelLogin::updateLocationUI() +{ + std::string sim_string = LLURLSimString::sInstance.mSimString; + if (!sim_string.empty()) + { + // Replace "" with this region name + LLComboBox* combo = sInstance->getChild("start_location_combo"); + combo->remove(2); + combo->add( sim_string ); + combo->setTextEntry(sim_string); + combo->setCurrentByIndex( 2 ); + } +} + // static void LLPanelLogin::closePanel() { diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index acb2001c22..8f24450c08 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -70,6 +70,7 @@ public: static void addServer(const std::string& server, S32 domain_name); static void refreshLocation( bool force_visible ); + static void updateLocationUI(); static void getFields(std::string *firstname, std::string *lastname, std::string *password); @@ -99,7 +100,7 @@ private: static void onPassKey(LLLineEditor* caller, void* user_data); static void onSelectServer(LLUICtrl*, void*); static void onServerComboLostFocus(LLFocusableElement*); - + private: LLPointer mLogoImage; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f953a45890..31b30344be 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -50,6 +50,7 @@ #include "llviewquery.h" #include "llxmltree.h" +#include "llslurl.h" //#include "llviewercamera.h" #include "llrender.h" @@ -828,9 +829,12 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { // special case SLURLs - if ( slurl ) + if ( drop && slurl ) { LLURLDispatcher::dispatch( data, NULL, true ); + LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); + LLPanelLogin::refreshLocation( true ); + LLPanelLogin::updateLocationUI(); return TRUE; }; -- cgit v1.2.3 From c272582ab78d43c595eefb843126c999c09dfd4f Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 3 Dec 2009 11:48:28 -0800 Subject: Change API to no longer include slurl argument (its a platform-agnostic policy), add some code (not working yet) to implement DND on the mac --- indra/llwindow/llwindowcallbacks.cpp | 4 +- indra/llwindow/llwindowcallbacks.h | 11 ++++- indra/llwindow/llwindowmacosx.cpp | 96 +++++++++++++++++++++++++++++++++--- indra/llwindow/llwindowmacosx.h | 13 +++-- indra/newview/llviewerwindow.cpp | 22 ++++++--- indra/newview/llviewerwindow.h | 2 +- 6 files changed, 125 insertions(+), 23 deletions(-) diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index 3b0aeeab1f..a6d2352732 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,9 +163,9 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } -BOOL LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl ) +LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) { - return FALSE; + return LLWindowCallbacks::DND_NONE; } BOOL LLWindowCallbacks::handleTimerEvent(LLWindow *window) diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index 1b4a6cbda2..a109879da7 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -68,10 +68,17 @@ public: virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); - virtual BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); - + + enum DragNDropResult { + DND_NONE = 0, // No drop allowed + DND_MOVE, // Drop accepted would result in a "move" operation + DND_COPY, // Drop accepted would result in a "copy" operation + DND_LINK // Drop accepted would result in a "link" operation + }; + virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); + virtual void handlePingWatchdog(LLWindow *window, const char * msg); virtual void handlePauseWatchdog(LLWindow *window); virtual void handleResumeWatchdog(LLWindow *window); diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index af9a30cb25..0acda8ab3a 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -499,8 +499,9 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Set up window event handlers (some window-related events ONLY go to window handlers.) InstallStandardEventHandler(GetWindowEventTarget(mWindow)); - InstallWindowEventHandler (mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler - + InstallWindowEventHandler(mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler + InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this ); + InstallReceiveHandler( dragReceiveHandler, mWindow, (void*)this ); } { @@ -2172,11 +2173,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } else { - MASK mask = 0; - if(modifiers & shiftKey) { mask |= MASK_SHIFT; } - if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; } - if(modifiers & optionKey) { mask |= MASK_ALT; } - + MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); + llassert( actualType == typeUnicodeText ); // The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar. @@ -3377,3 +3375,87 @@ std::vector LLWindowMacOSX::getDynamicFallbackFontList() return std::vector(); } +// static +MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers) +{ + MASK mask = 0; + if(modifiers & shiftKey) { mask |= MASK_SHIFT; } + if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; } + if(modifiers & optionKey) { mask |= MASK_ALT; } + return mask; +} + +OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, + void * handlerRefCon, DragRef theDrag) +{ + LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; + return self->handleDragNDrop(theDrag, false); +} + +OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, + DragRef theDrag) +{ + LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; + return self->handleDragNDrop(theDrag, true); + +} + +OSErr LLWindowMacOSX::handleDragNDrop(DragRef theDrag, bool drop) +{ + OSErr result = noErr; + + UInt16 num_items = 0; + ::CountDragItems(theDrag, &num_items); + if (1 == num_items) + { + SInt16 modifiers, mouseDownModifiers, mouseUpModifiers; + ::GetDragModifiers(theDrag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); + MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); + + Point mouse_point; + // This will return the mouse point in global screen coords + ::GetDragMouse(theDrag, &mouse_point, NULL); + LLCoordScreen screen_coords(mouse_point.v, mouse_point.h); + LLCoordGL gl_pos; + convertCoords(screen_coords, &gl_pos); + + DragItemRef theItemRef; + ::GetDragItemReferenceNumber(theDrag, 0, &theItemRef); + + UInt16 numFlavors = 0; + ::CountDragItemFlavors(theDrag, theItemRef, &numFlavors); + + FlavorType theType = kScrapFlavorTypeUnicode; + std::string url; + for (UInt16 i=0; ihandleDragNDrop(this, gl_pos, mask, drop, url); + + if (LLWindowCallbacks::DND_NONE == res) + { + result = dragNotAcceptedErr; + } + } + else { + result = dragNotAcceptedErr; + } + + return result; +} + diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 17074080eb..24e44417f5 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -160,8 +160,12 @@ protected: void adjustCursorDecouple(bool warpingMouse = false); void fixWindowSize(void); void stopDockTileBounce(); - - + static MASK modifiersToMask(SInt16 modifiers); + static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, + void * handlerRefCon, DragRef theDrag); + static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag); + OSErr handleDragNDrop(DragRef theDrag, bool drop); + // // Platform specific variables // @@ -198,13 +202,16 @@ protected: NMRec mBounceRec; LLTimer mBounceTimer; - // Imput method management through Text Service Manager. + // Input method management through Text Service Manager. TSMDocumentID mTSMDocument; BOOL mLanguageTextInputAllowed; ScriptCode mTSMScriptCode; LangCode mTSMLangCode; LLPreeditor* mPreeditor; + // Storage for drag data + char mDragData[1024]; + static BOOL sUseMultGL; friend class LLWindowManager; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f953a45890..fe6c9439bb 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -822,16 +822,16 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS return TRUE; } -BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl ) +LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data) { - BOOL result = FALSE; + LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE; if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { // special case SLURLs - if ( slurl ) + if ( std::string::npos != data.find("slurl.com") ) { LLURLDispatcher::dispatch( data, NULL, true ); - return TRUE; + return LLWindowCallbacks::DND_MOVE; }; LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); @@ -863,24 +863,30 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas // XXX This shouldn't be necessary, should it ?!? obj->getMediaImpl(object_face)->navigateReload(); obj->sendMediaDataUpdate(); + + result = LLWindowCallbacks::DND_COPY; } else { // just navigate to the URL obj->getMediaImpl(object_face)->navigateTo(url); + + result = LLWindowCallbacks::DND_LINK; } LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); mDragHoveredObject = NULL; + } else { mDragHoveredObject = obj; // Highlight the dragged object LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + + result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } - result = TRUE; } } - if (!result && !mDragHoveredObject.isNull()) + if (result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull()) { LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); mDragHoveredObject = NULL; @@ -3312,8 +3318,8 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans } else { - llwarns << "List of last picks is empty" << llendl; - llwarns << "Using stub pick" << llendl; + lldebugs << "List of last picks is empty" << llendl; + lldebugs << "Using stub pick" << llendl; mLastPick = LLPickInfo(); } diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 11d19cf24d..dc58292a6a 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,7 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl); + /*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); -- cgit v1.2.3 From ff53d4ff9b497f4f0f30035d7e02e6df290db6a4 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 3 Dec 2009 12:19:02 -0800 Subject: Fix Windows build based on API change to handleDragNDrop() --- indra/llwindow/lldragdropwin32.cpp | 4 ++-- indra/llwindow/llwindowwin32.cpp | 4 ++-- indra/llwindow/llwindowwin32.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 74f96f6da3..a96f04ff1f 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -158,7 +158,7 @@ class LLDragDropWin32Target: window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - bool allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ), mIsSlurl ); + bool allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); if ( allowed_to_drop ) *pdwEffect = DROPEFFECT_COPY; else @@ -214,7 +214,7 @@ class LLDragDropWin32Target: MASK mask = gKeyboard->currentMask( TRUE ); // actually do the drop - window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, mDropUrl, mIsSlurl ); + window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, mDropUrl ); }; *pdwEffect = DROPEFFECT_COPY; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 78bc3b9c58..dc1e2c017c 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -3581,9 +3581,9 @@ static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_leng // final stage of handling drop requests - both from WM_DROPFILES message // for files and via IDropTarget interface requests. -BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url, BOOL is_slurl ) +BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ) { - return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url, is_slurl ); + return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url ); } // Handle WM_IME_REQUEST message. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 7f7acd5751..e99c26b7f1 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -113,7 +113,7 @@ public: /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); - BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url, BOOL is_slurl ); + BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ); static std::vector getDynamicFallbackFontList(); -- cgit v1.2.3 From bfe66526c83d260d3e69971d30786d1e061c2c47 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Thu, 3 Dec 2009 17:01:58 -0800 Subject: Rewrote LLWindowMacOSX::handleDragNDrop() to use pasteboard manager instead of old, busted scrap manager to extract the data. Also fixed a mouse coordinate issue that caused drag tracking to be off. --- indra/llwindow/llwindowmacosx.cpp | 141 +++++++++++++++++++++++++------------- indra/llwindow/llwindowmacosx.h | 3 - 2 files changed, 92 insertions(+), 52 deletions(-) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 0acda8ab3a..87296b1202 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -3386,75 +3386,118 @@ MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers) } OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, - void * handlerRefCon, DragRef theDrag) + void * handlerRefCon, DragRef drag) { + OSErr result = noErr; LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; - return self->handleDragNDrop(theDrag, false); + + lldebugs << "drag tracking handler, message = " << message << llendl; + + switch(message) + { + case kDragTrackingInWindow: + result = self->handleDragNDrop(drag, false); + break; + + case kDragTrackingEnterHandler: + case kDragTrackingLeaveHandler: + // TODO: We probably want to do something clever for these (at least for the LeaveHandler). + break; + + default: + break; + } + + return result; } OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, - DragRef theDrag) + DragRef drag) { LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; - return self->handleDragNDrop(theDrag, true); + return self->handleDragNDrop(drag, true); } -OSErr LLWindowMacOSX::handleDragNDrop(DragRef theDrag, bool drop) +OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, bool drop) { - OSErr result = noErr; + OSErr result = dragNotAcceptedErr; // overall function result + OSErr err = noErr; // for local error handling + + // Get the mouse position and modifiers of this drag. + SInt16 modifiers, mouseDownModifiers, mouseUpModifiers; + ::GetDragModifiers(drag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); + MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); + + Point mouse_point; + // This will return the mouse point in global screen coords + ::GetDragMouse(drag, &mouse_point, NULL); + LLCoordScreen screen_coords(mouse_point.h, mouse_point.v); + LLCoordGL gl_pos; + convertCoords(screen_coords, &gl_pos); - UInt16 num_items = 0; - ::CountDragItems(theDrag, &num_items); - if (1 == num_items) + // Look at the pasteboard and try to extract an URL from it + PasteboardRef pasteboard; + if(GetDragPasteboard(drag, &pasteboard) == noErr) { - SInt16 modifiers, mouseDownModifiers, mouseUpModifiers; - ::GetDragModifiers(theDrag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); - MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); - - Point mouse_point; - // This will return the mouse point in global screen coords - ::GetDragMouse(theDrag, &mouse_point, NULL); - LLCoordScreen screen_coords(mouse_point.v, mouse_point.h); - LLCoordGL gl_pos; - convertCoords(screen_coords, &gl_pos); - - DragItemRef theItemRef; - ::GetDragItemReferenceNumber(theDrag, 0, &theItemRef); + ItemCount num_items = 0; + // Treat an error here as an item count of 0 + (void)PasteboardGetItemCount(pasteboard, &num_items); - UInt16 numFlavors = 0; - ::CountDragItemFlavors(theDrag, theItemRef, &numFlavors); - - FlavorType theType = kScrapFlavorTypeUnicode; - std::string url; - for (UInt16 i=0; ihandleDragNDrop(this, gl_pos, mask, drop, url); - - if (LLWindowCallbacks::DND_NONE == res) - { - result = dragNotAcceptedErr; + if(flavors != NULL) + { + CFRelease(flavors); + } + + if(data != NULL) + { + std::string url; + url.assign((char*)CFDataGetBytePtr(data), CFDataGetLength(data)); + CFRelease(data); + + if(!url.empty()) + { + LLWindowCallbacks::DragNDropResult res = + mCallbacks->handleDragNDrop(this, gl_pos, mask, drop, url); + + if (LLWindowCallbacks::DND_NONE != res) + { + result = noErr; + } + } + } } } - else { - result = dragNotAcceptedErr; - } return result; } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 24e44417f5..23e33a6e07 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -209,9 +209,6 @@ protected: LangCode mTSMLangCode; LLPreeditor* mPreeditor; - // Storage for drag data - char mDragData[1024]; - static BOOL sUseMultGL; friend class LLWindowManager; -- cgit v1.2.3 From fe0b027d4d7381a532bb0f14f64ecffdeb7190b6 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Thu, 3 Dec 2009 17:40:58 -0800 Subject: Added the LLWindowCallbacks::DragNDropAction enum, and made the mac implementation and the cross-platform window callbacks use it (instead of 'bool drop'). This will break the windows impl until someone fixes it to match. --- indra/llwindow/llwindowcallbacks.cpp | 2 +- indra/llwindow/llwindowcallbacks.h | 9 ++- indra/llwindow/llwindowmacosx.cpp | 13 ++-- indra/llwindow/llwindowmacosx.h | 3 +- indra/newview/llviewerwindow.cpp | 122 ++++++++++++++++++++--------------- indra/newview/llviewerwindow.h | 2 +- 6 files changed, 91 insertions(+), 60 deletions(-) diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index a6d2352732..6d9f012cc3 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -163,7 +163,7 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da { } -LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data ) +LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data ) { return LLWindowCallbacks::DND_NONE; } diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index a109879da7..42add8dde0 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -70,6 +70,13 @@ public: virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); + + enum DragNDropAction { + DNDA_START_TRACKING = 0,// Start tracking an incoming drag + DNDA_TRACK, // User is dragging an incoming drag around the window + DNDA_STOP_TRACKING, // User is no longer dragging an incoming drag around the window (may have either cancelled or dropped on the window) + DNDA_DROPPED // User dropped an incoming drag on the window (this is the "commit" event) + }; enum DragNDropResult { DND_NONE = 0, // No drop allowed @@ -77,7 +84,7 @@ public: DND_COPY, // Drop accepted would result in a "copy" operation DND_LINK // Drop accepted would result in a "link" operation }; - virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); + virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data); virtual void handlePingWatchdog(LLWindow *window, const char * msg); virtual void handlePauseWatchdog(LLWindow *window); diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 87296b1202..02fa9df22d 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -3396,12 +3396,15 @@ OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef switch(message) { case kDragTrackingInWindow: - result = self->handleDragNDrop(drag, false); + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_TRACK); break; case kDragTrackingEnterHandler: + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_START_TRACKING); + break; + case kDragTrackingLeaveHandler: - // TODO: We probably want to do something clever for these (at least for the LeaveHandler). + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_STOP_TRACKING); break; default: @@ -3415,11 +3418,11 @@ OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefC DragRef drag) { LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; - return self->handleDragNDrop(drag, true); + return self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_DROPPED); } -OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, bool drop) +OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDropAction action) { OSErr result = dragNotAcceptedErr; // overall function result OSErr err = noErr; // for local error handling @@ -3488,7 +3491,7 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, bool drop) if(!url.empty()) { LLWindowCallbacks::DragNDropResult res = - mCallbacks->handleDragNDrop(this, gl_pos, mask, drop, url); + mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url); if (LLWindowCallbacks::DND_NONE != res) { diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 23e33a6e07..6af54c5471 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -34,6 +34,7 @@ #define LL_LLWINDOWMACOSX_H #include "llwindow.h" +#include "llwindowcallbacks.h" #include "lltimer.h" @@ -164,7 +165,7 @@ protected: static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, void * handlerRefCon, DragRef theDrag); static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag); - OSErr handleDragNDrop(DragRef theDrag, bool drop); + OSErr handleDragNDrop(DragRef theDrag, LLWindowCallbacks::DragNDropAction action); // // Platform specific variables diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e80a2ae11c..fed676775c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -823,71 +823,91 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS return TRUE; } -LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data) +LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, LLWindowCallbacks::DragNDropAction action, std::string data) { LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE; if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { - // special case SLURLs - if ( drop && std::string::npos != data.find("slurl.com") ) + + switch(action) { - LLURLDispatcher::dispatch( data, NULL, true ); - LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); - LLPanelLogin::refreshLocation( true ); - LLPanelLogin::updateLocationUI(); - return LLWindowCallbacks::DND_MOVE; - }; + // Much of the handling for these two cases is the same. + case LLWindowCallbacks::DNDA_TRACK: + case LLWindowCallbacks::DNDA_DROPPED: + { + bool drop = (LLWindowCallbacks::DNDA_DROPPED == action); + + // special case SLURLs + if ( drop && std::string::npos != data.find("slurl.com") ) + { + LLURLDispatcher::dispatch( data, NULL, true ); + LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); + LLPanelLogin::refreshLocation( true ); + LLPanelLogin::updateLocationUI(); + return LLWindowCallbacks::DND_MOVE; + }; - LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); + LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); - LLUUID object_id = pick_info.getObjectID(); - S32 object_face = pick_info.mObjectFace; - std::string url = data; + LLUUID object_id = pick_info.getObjectID(); + S32 object_face = pick_info.mObjectFace; + std::string url = data; - llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; - LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); - - if (obj && obj->permModify()) - { - LLTextureEntry *te = obj->getTE(object_face); - if (te) - { - if (drop) + LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); + + if (obj && obj->permModify()) { - if (! te->hasMedia()) + LLTextureEntry *te = obj->getTE(object_face); + if (te) { - // Create new media entry - LLSD media_data; - // XXX Should we really do Home URL too? - media_data[LLMediaEntry::HOME_URL_KEY] = url; - media_data[LLMediaEntry::CURRENT_URL_KEY] = url; - media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; - obj->syncMediaData(object_face, media_data, true, true); - // XXX This shouldn't be necessary, should it ?!? - obj->getMediaImpl(object_face)->navigateReload(); - obj->sendMediaDataUpdate(); - - result = LLWindowCallbacks::DND_COPY; - } - else { - // just navigate to the URL - obj->getMediaImpl(object_face)->navigateTo(url); - - result = LLWindowCallbacks::DND_LINK; + if (drop) + { + if (! te->hasMedia()) + { + // Create new media entry + LLSD media_data; + // XXX Should we really do Home URL too? + media_data[LLMediaEntry::HOME_URL_KEY] = url; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; + obj->syncMediaData(object_face, media_data, true, true); + // XXX This shouldn't be necessary, should it ?!? + obj->getMediaImpl(object_face)->navigateReload(); + obj->sendMediaDataUpdate(); + + result = LLWindowCallbacks::DND_COPY; + } + else { + // just navigate to the URL + obj->getMediaImpl(object_face)->navigateTo(url); + + result = LLWindowCallbacks::DND_LINK; + } + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = NULL; + + } + else { + mDragHoveredObject = obj; + // Highlight the dragged object + LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + + result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; + } } - LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); - mDragHoveredObject = NULL; - - } - else { - mDragHoveredObject = obj; - // Highlight the dragged object - LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); - - result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } } + break; + + case LLWindowCallbacks::DNDA_START_TRACKING: + // No special handling here yet -- we'll actually start tracking on the first DNDA_TRACK event. + break; + + case LLWindowCallbacks::DNDA_STOP_TRACKING: + // The cleanup case below will make sure things are unhilighted if necessary. + break; } if (result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull()) diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 2543d1096f..e209ff1ad9 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -170,7 +170,7 @@ public: /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - /*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data); + /*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, LLWindowCallbacks::DragNDropAction action, std::string data); void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); /*virtual*/ void handleMouseLeave(LLWindow *window); /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y); -- cgit v1.2.3 From 4c33c54ce03bffd3ad75be3dccaed2d26a68e157 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 3 Dec 2009 19:02:12 -0800 Subject: Fix windows build to now use DragNDropAction instead of a bool 'drop' --- indra/llwindow/lldragdropwin32.cpp | 95 +++++++++++++++++++++++++++++++------- indra/llwindow/llwindowwin32.cpp | 4 +- indra/llwindow/llwindowwin32.h | 3 +- 3 files changed, 83 insertions(+), 19 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index a96f04ff1f..4865570f07 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -117,15 +117,45 @@ class LLDragDropWin32Target: { PVOID data = GlobalLock( stgmed.hGlobal ); mDropUrl = std::string( (char*)data ); - - mIsSlurl = ( mDropUrl.find( "slurl.com" ) != std::string::npos ); + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_START_TRACKING, mDropUrl ); + + switch (result) + { + case LLWindowCallbacks::DND_COPY: + *pdwEffect = DROPEFFECT_COPY; + break; + case LLWindowCallbacks::DND_LINK: + *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } + }; GlobalUnlock( stgmed.hGlobal ); ReleaseStgMedium( &stgmed ); }; - - *pdwEffect = DROPEFFECT_COPY; - SetFocus( mAppWindowHandle ); } else @@ -158,15 +188,25 @@ class LLDragDropWin32Target: window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - bool allowed_to_drop = window_imp->completeDragNDropRequest( gl_coord, mask, FALSE, std::string( "" ) ); - if ( allowed_to_drop ) + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_TRACK, std::string( "" ) ); + + switch (result) + { + case LLWindowCallbacks::DND_COPY: *pdwEffect = DROPEFFECT_COPY; - else - *pdwEffect = DROPEFFECT_NONE; - - // special case for SLURLs - you can always drop them on the client window and we need a different cursor - if ( mIsSlurl ) + break; + case LLWindowCallbacks::DND_LINK: *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } }; } else @@ -181,7 +221,14 @@ class LLDragDropWin32Target: // HRESULT __stdcall DragLeave( void ) { - mDropUrl = std::string(); + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + MASK mask = gKeyboard->currentMask(TRUE); + window_imp->completeDragNDropRequest( gl_coord, mask, LLWindowCallbacks::DNDA_STOP_TRACKING, mDropUrl ); + }; return S_OK; }; @@ -214,10 +261,26 @@ class LLDragDropWin32Target: MASK mask = gKeyboard->currentMask( TRUE ); // actually do the drop - window_imp->completeDragNDropRequest( gl_coord, mask, TRUE, mDropUrl ); - }; + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_DROPPED, mDropUrl ); - *pdwEffect = DROPEFFECT_COPY; + switch (result) + { + case LLWindowCallbacks::DND_COPY: + *pdwEffect = DROPEFFECT_COPY; + break; + case LLWindowCallbacks::DND_LINK: + *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } + }; } else { diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index dc1e2c017c..322b9c9a01 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -3581,9 +3581,9 @@ static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_leng // final stage of handling drop requests - both from WM_DROPFILES message // for files and via IDropTarget interface requests. -BOOL LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ) +LLWindowCallbacks::DragNDropResult LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url ) { - return mCallbacks->handleDragNDrop( this, gl_coord, mask, drop, url ); + return mCallbacks->handleDragNDrop( this, gl_coord, mask, action, url ); } // Handle WM_IME_REQUEST message. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index e99c26b7f1..3e907cde00 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -39,6 +39,7 @@ #include #include "llwindow.h" +#include "llwindowcallbacks.h" #include "lldragdropwin32.h" // Hack for async host by name @@ -113,7 +114,7 @@ public: /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); - BOOL completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, BOOL drop, const std::string url ); + LLWindowCallbacks::DragNDropResult completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url ); static std::vector getDynamicFallbackFontList(); -- cgit v1.2.3 From 064c9be9aedf238530ccdc941861fd057580e5b1 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 16 Dec 2009 18:56:01 -0800 Subject: Don't allow drag if the cap URL is empty or if the whitelist does not pass --- indra/newview/llviewerwindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5d2ca331d6..e3de2891a1 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -827,9 +827,9 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, LLWindowCallbacks::DragNDropAction action, std::string data) { LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE; + if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) { - switch(action) { // Much of the handling for these two cases is the same. @@ -854,11 +854,11 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi S32 object_face = pick_info.mObjectFace; std::string url = data; - llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + lldebugs << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); - if (obj && obj->permModify()) + if (obj && obj->permModify() && !obj->getRegion()->getCapability("ObjectMedia").empty()) { LLTextureEntry *te = obj->getTE(object_face); if (te) @@ -881,10 +881,14 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi result = LLWindowCallbacks::DND_COPY; } else { - // just navigate to the URL - obj->getMediaImpl(object_face)->navigateTo(url); + // Check the whitelist + if (te->getMediaData()->checkCandidateUrl(url)) + { + // just navigate to the URL + obj->getMediaImpl(object_face)->navigateTo(url); - result = LLWindowCallbacks::DND_LINK; + result = LLWindowCallbacks::DND_LINK; + } } LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); mDragHoveredObject = NULL; -- cgit v1.2.3 From 3b110e76332712e7efb7972fb27324a763596b6c Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 18 Dec 2009 15:52:45 -0800 Subject: Fix crash when DnD onto an item with media but no impl --- indra/newview/llviewerwindow.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6c73cc18db..08f598b288 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -875,7 +875,8 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; obj->syncMediaData(object_face, media_data, true, true); // XXX This shouldn't be necessary, should it ?!? - obj->getMediaImpl(object_face)->navigateReload(); + if (obj->getMediaImpl(object_face)) + obj->getMediaImpl(object_face)->navigateReload(); obj->sendMediaDataUpdate(); result = LLWindowCallbacks::DND_COPY; @@ -885,8 +886,20 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi if (te->getMediaData()->checkCandidateUrl(url)) { // just navigate to the URL - obj->getMediaImpl(object_face)->navigateTo(url); - + if (obj->getMediaImpl(object_face)) + { + obj->getMediaImpl(object_face)->navigateTo(url); + } + else { + // This is very strange. Navigation should + // happen via the Impl, but we don't have one. + // This sends it to the server, which /should/ + // trigger us getting it. Hopefully. + LLSD media_data; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + obj->syncMediaData(object_face, media_data, true, true); + obj->sendMediaDataUpdate(); + } result = LLWindowCallbacks::DND_LINK; } } -- cgit v1.2.3 From 9204681c31184c4c76c8f41c48da76e174e3276a Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 18 Dec 2009 16:21:57 -0800 Subject: Fix slurl crashing, fix slurls highlighting objects, fix overlapping objects not "unhighlighting" --- indra/newview/llpanellogin.cpp | 2 ++ indra/newview/llviewerwindow.cpp | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index cdfa64ba57..ce83ab3e37 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -688,6 +688,8 @@ void LLPanelLogin::refreshLocation( bool force_visible ) // static void LLPanelLogin::updateLocationUI() { + if (!sInstance) return; + std::string sim_string = LLURLSimString::sInstance.mSimString; if (!sim_string.empty()) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 08f598b288..71fe8dd773 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -839,12 +839,15 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi bool drop = (LLWindowCallbacks::DNDA_DROPPED == action); // special case SLURLs - if ( drop && std::string::npos != data.find("slurl.com") ) + if (std::string::npos != data.find("slurl.com") ) { - LLURLDispatcher::dispatch( data, NULL, true ); - LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); - LLPanelLogin::refreshLocation( true ); - LLPanelLogin::updateLocationUI(); + if (drop) + { + LLURLDispatcher::dispatch( data, NULL, true ); + LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); + LLPanelLogin::refreshLocation( true ); + LLPanelLogin::updateLocationUI(); + } return LLWindowCallbacks::DND_MOVE; }; @@ -908,10 +911,13 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi } else { - mDragHoveredObject = obj; - // Highlight the dragged object - LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); - + if ( obj != mDragHoveredObject) + { + // Highlight the dragged object + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = obj; + LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + } result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } } -- cgit v1.2.3 From 75c1fb26649df73770459a31641c434e156e2c17 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 5 Jan 2010 15:03:27 -0800 Subject: Build fix: add missing #include --- indra/newview/llviewerwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 21bf567b0c..313f728489 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -83,6 +83,7 @@ #include "lltooltip.h" #include "llmediaentry.h" #include "llurldispatcher.h" +#include "llurlsimstring.h" // newview includes #include "llagent.h" -- cgit v1.2.3 From e57f6a5cee1cf03df2bf43cd7a8b2c42c3918f8b Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Thu, 7 Jan 2010 14:21:57 -0800 Subject: Fix drag and drop for windows. Makes Win32 state machine behave more like Mac. --- indra/llwindow/lldragdropwin32.cpp | 2 +- indra/newview/llviewerwindow.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 4865570f07..1e10626e8a 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -189,7 +189,7 @@ class LLDragDropWin32Target: MASK mask = gKeyboard->currentMask(TRUE); LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, - LLWindowCallbacks::DNDA_TRACK, std::string( "" ) ); + LLWindowCallbacks::DNDA_TRACK, mDropUrl ); switch (result) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 02b8158188..81fcfc13c2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -835,6 +835,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi // Much of the handling for these two cases is the same. case LLWindowCallbacks::DNDA_TRACK: case LLWindowCallbacks::DNDA_DROPPED: + case LLWindowCallbacks::DNDA_START_TRACKING: { bool drop = (LLWindowCallbacks::DNDA_DROPPED == action); @@ -925,10 +926,6 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi } break; - case LLWindowCallbacks::DNDA_START_TRACKING: - // No special handling here yet -- we'll actually start tracking on the first DNDA_TRACK event. - break; - case LLWindowCallbacks::DNDA_STOP_TRACKING: // The cleanup case below will make sure things are unhilighted if necessary. break; -- cgit v1.2.3 From 5d2167c66a027cc5e4e002dca51e163b0d08fe42 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Fri, 8 Jan 2010 15:10:59 -0800 Subject: Fix a typo bug caught by pyflakes. eys.exit(1) -> sys.exit(1) --- indra/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index eaecdd0ab6..9d606da1d9 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -504,7 +504,7 @@ class WindowsSetup(PlatformSetup): break else: print >> sys.stderr, 'Cannot find a Visual Studio installation!' - eys.exit(1) + sys.exit(1) return self._generator def _set_generator(self, gen): -- cgit v1.2.3 From 1500e90eccf237fb50f901528c5dc9d747f6d2f0 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 8 Jan 2010 15:11:03 -0800 Subject: Make sure mac build honors compile-time flag that en/disables OS drag and drop. Also fixed the cmake file to properly set LL_OS_DRAGDROP_ENABLED. --- indra/cmake/DragDrop.cmake | 6 ++---- indra/llwindow/llwindowmacosx.cpp | 5 +++++ indra/llwindow/llwindowmacosx.h | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/indra/cmake/DragDrop.cmake b/indra/cmake/DragDrop.cmake index 739d011813..e56264f187 100644 --- a/indra/cmake/DragDrop.cmake +++ b/indra/cmake/DragDrop.cmake @@ -2,9 +2,7 @@ if (VIEWER) - OPTION (OS_DRAG_DROP - "Build the viewer with OS level drag and drop turned on or off" - ON) + set(OS_DRAG_DROP ON CACHE BOOL "Build the viewer with OS level drag and drop turned on or off") if (OS_DRAG_DROP) @@ -13,7 +11,7 @@ if (VIEWER) endif (WINDOWS) if (DARWIN) - add_definitions(-DLL_OS_DRAGDROP_ENABLED=0) + add_definitions(-DLL_OS_DRAGDROP_ENABLED=1) endif (DARWIN) if (LINUX) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index ffc44a1e84..dc5a98756a 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -500,8 +500,10 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Set up window event handlers (some window-related events ONLY go to window handlers.) InstallStandardEventHandler(GetWindowEventTarget(mWindow)); InstallWindowEventHandler(mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler +#if LL_OS_DRAGDROP_ENABLED InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this ); InstallReceiveHandler( dragReceiveHandler, mWindow, (void*)this ); +#endif // LL_OS_DRAGDROP_ENABLED } { @@ -3387,6 +3389,8 @@ MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers) return mask; } +#if LL_OS_DRAGDROP_ENABLED + OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, void * handlerRefCon, DragRef drag) { @@ -3507,3 +3511,4 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop return result; } +#endif // LL_OS_DRAGDROP_ENABLED diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index bd3e46ebb4..09b8891db0 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -161,10 +161,13 @@ protected: void fixWindowSize(void); void stopDockTileBounce(); static MASK modifiersToMask(SInt16 modifiers); + +#if LL_OS_DRAGDROP_ENABLED static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, void * handlerRefCon, DragRef theDrag); static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag); OSErr handleDragNDrop(DragRef theDrag, LLWindowCallbacks::DragNDropAction action); +#endif // LL_OS_DRAGDROP_ENABLED // // Platform specific variables -- cgit v1.2.3 From e31d695247f89df1490afb4b9581f562fa99617c Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 8 Jan 2010 15:11:15 -0800 Subject: get rid of commented-out code --- indra/llwindow/llwindowwin32.cpp | 54 ---------------------------------------- 1 file changed, 54 deletions(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 439c10c95c..ed39786b37 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -2376,60 +2376,6 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ }; return 0; - // only useful for droppnig files - could be used for file upload dialog one day - //case WM_DROPFILES: - // { - // // HDROP contains what we need - // HDROP hdrop = (HDROP)w_param; - - // // get location in window space where drop occured and convert to OpenGL coordinate space - // POINT pt; - // DragQueryPoint( hdrop, &pt ); - // LLCoordGL gl_coord; - // LLCoordWindow cursor_coord_window( pt.x, pt.y ); - // window_imp->convertCoords(cursor_coord_window, &gl_coord); - - // // get payload (eventually, this needs to more advanced and grab size of payload dynamically - // static char file_name[ 1024 ]; - // DragQueryFileA( hdrop, 0, file_name, 1024 ); - // void* url = (void*)( file_name ); - - // // if it's a .URL or .lnk ("shortcut") file - // if ( std::string( file_name ).find( ".lnk" ) != std::string::npos || - // std::string( file_name ).find( ".URL" ) != std::string::npos ) - // { - // // read through file - looks like a 2 line file with second line URL= but who knows.. - // std::ifstream file_handle( file_name ); - // if ( file_handle.is_open() ) - // { - // std::string line; - // while ( ! file_handle.eof() ) - // { - // std::getline( file_handle, line ); - // if ( ! file_handle.eof() ) - // { - // std::string prefix( "URL=" ); - // if ( line.find( prefix, 0 ) != std::string::npos ) - // { - // line = line.substr( 4 ); // skip off the URL= bit - // strcpy( (char*)url, line.c_str() ); - // break; - // }; - // }; - // }; - // file_handle.close(); - // }; - // }; - - // MASK mask = gKeyboard->currentMask(TRUE); - - // if ( window_imp->completeDragNDropRequest( gl_coord, mask, true, (char*)url, false ) ) - // { - // return 0; - // }; - // } - - break; } -- cgit v1.2.3 From 010bfed411cffdb7037872a209adf51c77f48140 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Fri, 8 Jan 2010 15:50:09 -0800 Subject: DEV-44838 - This is an attempt at the minimal possible change to fix the quoting bug on windows. This commit is untested! The simplest approach to testing is to push into a repo watched by parabuild. Also, develop.py could be improved to use subprocess consistently across all platforms. Doing so could simplify the code, but until I understand how to test it better, I'm going to leave it alone. --- indra/develop.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/indra/develop.py b/indra/develop.py index 9d606da1d9..27c3d0ca2c 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -41,6 +41,7 @@ import shutil import socket import sys import commands +import subprocess class CommandError(Exception): pass @@ -576,16 +577,20 @@ class WindowsSetup(PlatformSetup): return "buildconsole %(prj)s.sln /build /cfg=%(cfg)s" % {'prj': self.project_name, 'cfg': config} # devenv.com is CLI friendly, devenv.exe... not so much. - return ('"%sdevenv.com" %s.sln /build %s' % - (self.find_visual_studio(), self.project_name, self.build_type)) + executable = '%sdevenv.com' % (self.find_visual_studio(),) + cmd = ('"%s" %s.sln /build %s' % + (executable, self.project_name, self.build_type)) + return (executable, cmd) #return ('devenv.com %s.sln /build %s' % # (self.project_name, self.build_type)) def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' + assert name is not None, 'On windows an executable path must be given in name.' while retries: retries = retries - 1 print "develop.py tries to run:", command + ret = subprocess.call(command, executable=name) ret = os.system(command) print "got ret", ret, "from", command if ret: @@ -617,18 +622,19 @@ class WindowsSetup(PlatformSetup): if prev_build == self.build_type: # Only run vstool if the build type has changed. continue - vstool_cmd = (os.path.join('tools','vstool','VSTool.exe') + + executable = os.path.join('tools','vstool','VSTool.exe') + vstool_cmd = (executable + ' --solution ' + os.path.join(build_dir,'SecondLife.sln') + ' --config ' + self.build_type + ' --startup secondlife-bin') print 'Running %r in %r' % (vstool_cmd, getcwd()) - self.run(vstool_cmd) + self.run(vstool_cmd, name=executable) print >> open(stamp, 'w'), self.build_type def run_build(self, opts, targets): cwd = getcwd() - build_cmd = self.get_build_cmd() + executable, build_cmd = self.get_build_cmd() for d in self.build_dirs(): try: @@ -637,11 +643,11 @@ class WindowsSetup(PlatformSetup): for t in targets: cmd = '%s /project %s %s' % (build_cmd, t, ' '.join(opts)) print 'Running %r in %r' % (cmd, d) - self.run(cmd, retry_on=4, retries=3) + self.run(cmd, name=executable, retry_on=4, retries=3) else: cmd = '%s %s' % (build_cmd, ' '.join(opts)) print 'Running %r in %r' % (cmd, d) - self.run(cmd, retry_on=4, retries=3) + self.run(cmd, name=executable, retry_on=4, retries=3) finally: os.chdir(cwd) -- cgit v1.2.3 From 6b33d5955a2c4ff34c17b58dd4a23b53a3c1dde7 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Fri, 8 Jan 2010 17:42:22 -0800 Subject: DEV-44838 - See if the executable parameter to subprocess.Popen must be absolute on windows. --- indra/develop.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/develop.py b/indra/develop.py index 27c3d0ca2c..dc1190699c 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -587,6 +587,8 @@ class WindowsSetup(PlatformSetup): def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' assert name is not None, 'On windows an executable path must be given in name.' + if not os.path.isfile(name): + name = self.find_in_path(name) while retries: retries = retries - 1 print "develop.py tries to run:", command -- cgit v1.2.3 From 61bc236b355e19bf09851b79c7d73b7210b4a7af Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Fri, 8 Jan 2010 17:58:56 -0800 Subject: DEV-44838 - Remove a typo line which would cause duplicate executions for every run call. --- indra/develop.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index dc1190699c..e19ecb7314 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -593,7 +593,6 @@ class WindowsSetup(PlatformSetup): retries = retries - 1 print "develop.py tries to run:", command ret = subprocess.call(command, executable=name) - ret = os.system(command) print "got ret", ret, "from", command if ret: if name is None: -- cgit v1.2.3 From 8246b382b732a9b49c49a012274cd17ce1af4e94 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Fri, 8 Jan 2010 18:00:32 -0800 Subject: DEV-44838 - find_in_path() returns a list of candidates. Select the first. --- indra/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index e19ecb7314..17ac1b3801 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -588,7 +588,7 @@ class WindowsSetup(PlatformSetup): '''Run a program. If the program fails, raise an exception.''' assert name is not None, 'On windows an executable path must be given in name.' if not os.path.isfile(name): - name = self.find_in_path(name) + name = self.find_in_path(name)[0] while retries: retries = retries - 1 print "develop.py tries to run:", command -- cgit v1.2.3 From f37f806660f66b064490b9c14d724273dc67fcbb Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Mon, 11 Jan 2010 10:38:13 -0800 Subject: DEV-44838 - Fix a bug introduced by inconsistently changing the get_build_cmd() interface. --- indra/develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/develop.py b/indra/develop.py index 17ac1b3801..a20badcfba 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -574,15 +574,15 @@ class WindowsSetup(PlatformSetup): if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]: config = '\"%s|Win32\"' % config - return "buildconsole %(prj)s.sln /build /cfg=%(cfg)s" % {'prj': self.project_name, 'cfg': config} + executable = self.find_in_path('buildconsole') + cmd = "%(bin)s %(prj)s.sln /build /cfg=%(cfg)s" % {'prj': self.project_name, 'cfg': config, 'bin': executable} + return (executable, cmd) # devenv.com is CLI friendly, devenv.exe... not so much. executable = '%sdevenv.com' % (self.find_visual_studio(),) cmd = ('"%s" %s.sln /build %s' % (executable, self.project_name, self.build_type)) return (executable, cmd) - #return ('devenv.com %s.sln /build %s' % - # (self.project_name, self.build_type)) def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' -- cgit v1.2.3 From 11eac588c2e26b42e269da9394bbb8918552fb1c Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Mon, 11 Jan 2010 10:45:01 -0800 Subject: DEV-44838 - Fix another bug introduced by passing "executable" in WindowsSetup.run(); find_in_path() does not handle absolute paths, but name is guaranteed to be an absolute path. This explains the bogus message in the log of the form "process $foo exited with nonzero status; process $foo is not found", described here: https://jira.lindenlab.com/jira/browse/DEV-44838?focusedCommentId=328441&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_328441 --- indra/develop.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/indra/develop.py b/indra/develop.py index a20badcfba..71569f15d2 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -595,10 +595,7 @@ class WindowsSetup(PlatformSetup): ret = subprocess.call(command, executable=name) print "got ret", ret, "from", command if ret: - if name is None: - name = command.split(None, 1)[0] - path = self.find_in_path(name) - if not path: + if not name: error = 'was not found' else: error = 'exited with status %d' % ret -- cgit v1.2.3 From 33df069238130a9e8c02a2aadcd41956780397db Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Mon, 11 Jan 2010 11:07:04 -0800 Subject: DEV-44838 - Fix a silly bug in yet another place: find_in_path returns a list, so select the first element. --- indra/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index 71569f15d2..897fbb6544 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -574,7 +574,7 @@ class WindowsSetup(PlatformSetup): if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]: config = '\"%s|Win32\"' % config - executable = self.find_in_path('buildconsole') + executable = self.find_in_path('buildconsole')[0] cmd = "%(bin)s %(prj)s.sln /build /cfg=%(cfg)s" % {'prj': self.project_name, 'cfg': config, 'bin': executable} return (executable, cmd) -- cgit v1.2.3 From 2d337ca8c6b05ecd7e8d4a8f0c3d88fabcc5bcbc Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Mon, 11 Jan 2010 12:30:27 -0800 Subject: DEV-44838 - See if buildconsole is confused by having the absolute path (with spaces) in the commandline. To accomplish this we put relative paths in the command string but lookup the absolute path for the executable parameter. --- indra/develop.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/indra/develop.py b/indra/develop.py index 897fbb6544..b8fdd1a815 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -574,7 +574,7 @@ class WindowsSetup(PlatformSetup): if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]: config = '\"%s|Win32\"' % config - executable = self.find_in_path('buildconsole')[0] + executable = 'buildconsole' cmd = "%(bin)s %(prj)s.sln /build /cfg=%(cfg)s" % {'prj': self.project_name, 'cfg': config, 'bin': executable} return (executable, cmd) @@ -587,18 +587,17 @@ class WindowsSetup(PlatformSetup): def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' assert name is not None, 'On windows an executable path must be given in name.' - if not os.path.isfile(name): - name = self.find_in_path(name)[0] + if os.path.isfile(name): + path = name + else: + path = self.find_in_path(name)[0] while retries: retries = retries - 1 print "develop.py tries to run:", command - ret = subprocess.call(command, executable=name) + ret = subprocess.call(command, executable=path) print "got ret", ret, "from", command if ret: - if not name: - error = 'was not found' - else: - error = 'exited with status %d' % ret + error = 'exited with status %d' % ret if retry_on is not None and retry_on == ret: print "Retrying... the command %r %s" % (name, error) else: -- cgit v1.2.3 From a74d494dd7c13e0307ee5ba526ba021583b1f2b5 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 11 Jan 2010 16:41:08 -0800 Subject: Fix unposted bug: drag feedback didn't check whitelist http://codereview.lindenlab.com/274039/show --- indra/newview/llviewerwindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 81fcfc13c2..5dd640539f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -912,14 +912,18 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi } else { - if ( obj != mDragHoveredObject) + // Check the whitelist, if there's media (otherwise just show it) + if (te->getMediaData() == NULL || te->getMediaData()->checkCandidateUrl(url)) { - // Highlight the dragged object - LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); - mDragHoveredObject = obj; - LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + if ( obj != mDragHoveredObject) + { + // Highlight the dragged object + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = obj; + LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + } + result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } - result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } } } -- cgit v1.2.3 From a3ca95e3bd0e288792f6024d9487d618730fd40f Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Mon, 11 Jan 2010 17:26:28 -0800 Subject: Fix that stops "Start Location" corruption if you drag an invalid http://slurl.com SLURL onto the login page --- indra/newview/llviewerwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 81fcfc13c2..c5c9e49934 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -840,7 +840,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi bool drop = (LLWindowCallbacks::DNDA_DROPPED == action); // special case SLURLs - if (std::string::npos != data.find("slurl.com") ) + if ( LLSLURL::isSLURL( data ) ) { if (drop) { -- cgit v1.2.3 From b06d655727c15530c1f65ccea83ab911f42e04ff Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 11 Jan 2010 18:44:00 -0800 Subject: Add cursor-change override while dragging on the mac This changes the setCursor() call in LLWindowMacOSX to be ignored if we're currently dragging via the OS http://codereview.lindenlab.com/273045 --- indra/llwindow/llwindowmacosx.cpp | 38 ++++++++++++++++++++++++++++++++++++-- indra/llwindow/llwindowmacosx.h | 2 ++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index dc5a98756a..783d1f39ca 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -278,6 +278,8 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, mMoveEventCampartorUPP = NewEventComparatorUPP(staticMoveEventComparator); mGlobalHandlerRef = NULL; mWindowHandlerRef = NULL; + + mDragOverrideCursor = -1; // We're not clipping yet SetRect( &mOldMouseClip, 0, 0, 0, 0 ); @@ -2795,6 +2797,8 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) { OSStatus result = noErr; + if (mDragOverrideCursor != -1) return; + if (cursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -3499,10 +3503,40 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop LLWindowCallbacks::DragNDropResult res = mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url); - if (LLWindowCallbacks::DND_NONE != res) + switch (res) { + case LLWindowCallbacks::DND_NONE: // No drop allowed + if (action == LLWindowCallbacks::DNDA_TRACK) + { + mDragOverrideCursor = kThemeNotAllowedCursor; + } + else { + mDragOverrideCursor = -1; + } + break; + case LLWindowCallbacks::DND_MOVE: // Drop accepted would result in a "move" operation + mDragOverrideCursor = kThemePointingHandCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_COPY: // Drop accepted would result in a "copy" operation + mDragOverrideCursor = kThemeCopyArrowCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_LINK: // Drop accepted would result in a "link" operation: + mDragOverrideCursor = kThemeAliasArrowCursor; + result = noErr; + break; + default: + mDragOverrideCursor = -1; + break; + } + if (mDragOverrideCursor == -1) { - result = noErr; + SetThemeCursor(kThemeArrowCursor); + } + else { + SetThemeCursor(mDragOverrideCursor); } + } } } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 09b8891db0..377f10b6d4 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -201,6 +201,8 @@ protected: U32 mFSAASamples; BOOL mForceRebuild; + S32 mDragOverrideCursor; + F32 mBounceTime; NMRec mBounceRec; LLTimer mBounceTimer; -- cgit v1.2.3 From df69302cd2f00dd44b5b34aeb3ba896ce7548556 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 12 Jan 2010 11:31:07 -0800 Subject: Add restoring of previous cursor to mac impl http://codereview.lindenlab.com/273045 --- indra/llwindow/llwindowmacosx.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 783d1f39ca..9ccd4c7f97 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -2797,8 +2797,14 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) { OSStatus result = noErr; - if (mDragOverrideCursor != -1) return; - + if (mDragOverrideCursor != -1) + { + // A drag is in progress...remember the requested cursor and we'll + // restore it when it is done + mCurrentCursor = cursor; + return; + } + if (cursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -3529,11 +3535,19 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop mDragOverrideCursor = -1; break; } + // This overrides the cursor being set by setCursor. + // This is a bit of a hack workaround because lots of areas + // within the viewer just blindly set the cursor. if (mDragOverrideCursor == -1) { - SetThemeCursor(kThemeArrowCursor); + // Restore the cursor + ECursorType temp_cursor = mCurrentCursor; + // get around the "setting the same cursor" code in setCursor() + mCurrentCursor = UI_CURSOR_COUNT; + setCursor(temp_cursor); } else { + // Override the cursor SetThemeCursor(mDragOverrideCursor); } -- cgit v1.2.3 From dd7840aa9e0627430753522c4480212cf032463e Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Wed, 13 Jan 2010 15:47:57 -0800 Subject: Add an assertion for my sanity. --- indra/develop.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/develop.py b/indra/develop.py index b8fdd1a815..59722c4bc2 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -630,6 +630,8 @@ class WindowsSetup(PlatformSetup): print >> open(stamp, 'w'), self.build_type def run_build(self, opts, targets): + for t in targets: + assert t.strip(), 'Unexpected empty targets: ' + repr(targets) cwd = getcwd() executable, build_cmd = self.get_build_cmd() -- cgit v1.2.3 From bee98d70e3a8eca7f6f6f80d4ee6a14939771ae0 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Wed, 13 Jan 2010 16:08:30 -0800 Subject: DEV-44838 - Add the string "DEV-44838" to assertion failures to future devs understand preconditions on windows run(). --- indra/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index 59722c4bc2..a8a7b63aa7 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -586,7 +586,7 @@ class WindowsSetup(PlatformSetup): def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' - assert name is not None, 'On windows an executable path must be given in name.' + assert name is not None, 'On windows an executable path must be given in name. [DEV-44838]' if os.path.isfile(name): path = name else: -- cgit v1.2.3 From d194d95391f03b8a60c779f50f830df014e4b71e Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Wed, 13 Jan 2010 16:09:07 -0800 Subject: DEV-44838 - Fix a logic flaw in the windows run() retry code which would re-execute a process if its exit status was 0. --- indra/develop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indra/develop.py b/indra/develop.py index a8a7b63aa7..0a2d3c5e52 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -596,7 +596,9 @@ class WindowsSetup(PlatformSetup): print "develop.py tries to run:", command ret = subprocess.call(command, executable=path) print "got ret", ret, "from", command - if ret: + if ret == 0: + break + else: error = 'exited with status %d' % ret if retry_on is not None and retry_on == ret: print "Retrying... the command %r %s" % (name, error) -- cgit v1.2.3 From 228d37a8d72146d9baed57c7406a9324ce8c0175 Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Tue, 19 Jan 2010 11:52:41 -0800 Subject: Fix for EXT-4191 - Drag and Drop viewer resolves some slurls to "//" --- indra/newview/llviewerwindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 45e153049b..d4ffe70f24 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -824,8 +824,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi { if (drop) { - LLURLDispatcher::dispatch( data, NULL, true ); - LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); + LLURLSimString::setStringRaw( LLSLURL::stripProtocol( data ) ); LLPanelLogin::refreshLocation( true ); LLPanelLogin::updateLocationUI(); } -- cgit v1.2.3 From 95fc42c3219151d085f139a8f239bdc5fb6b30f3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jan 2010 15:19:11 -0500 Subject: Ensure Lynx's Boost patch is in place -- Windows --- install.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.xml b/install.xml index 5069e44d46..5cb960c506 100644 --- a/install.xml +++ b/install.xml @@ -214,9 +214,9 @@ windows md5sum - 6746ae9fd9aff98b15f7b9f0f40334ab + acbf7a4165a917a4e087879d1756b355 url - http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-windows-20091204.tar.bz2 + http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-windows-20100119.tar.bz2 -- cgit v1.2.3 From dab8a89df68fe29ce3794d7763e9890da5ff7ed2 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jan 2010 12:23:25 -0800 Subject: Ensure Lynx's Boost patch is in place -- linux, linux64 --- install.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.xml b/install.xml index fdd7458384..e94654e175 100644 --- a/install.xml +++ b/install.xml @@ -200,16 +200,16 @@ linux md5sum - 7085044567999489d82b9ed28f16e480 + ee8e1b4bbcf137a84d6a85a1c51386ff url - http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-linux-20091202.tar.bz2 + http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-linux-20100119.tar.bz2 linux64 md5sum - b4aeefcba3d749f1e9f2a12c6f70192b + af4badd6b2c10bc4db82ff1256695892 url - http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-linux64-20091202.tar.bz2 + http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-linux64-20100119.tar.bz2 windows -- cgit v1.2.3 From 56c021f606d249e4b7ba334809b0332fe2fdcc11 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jan 2010 15:28:10 -0500 Subject: Ensure Lynx's Boost patch is in place -- darwin --- install.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.xml b/install.xml index fdd7458384..e08676d869 100644 --- a/install.xml +++ b/install.xml @@ -193,9 +193,9 @@ darwin md5sum - 609c469ee1857723260b5a9943b9c2c1 + 84821102cb819257a66c8f38732647fc url - http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-darwin-20091202.tar.bz2 + http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/boost-1.39.0-darwin-20100119.tar.bz2 linux -- cgit v1.2.3 From ae079af48d8ab6b1939168b0a2ac95876da66d24 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 20 Jan 2010 09:55:36 -0800 Subject: Add another setting controlling whether SLURL drag-and-drop performs a teleport --- indra/newview/app_settings/settings.xml | 13 ++- indra/newview/llviewerwindow.cpp | 146 +++++++++++++++++--------------- 2 files changed, 90 insertions(+), 69 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9f261978e6..6096504b96 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -5552,7 +5552,7 @@ PrimMediaDragNDrop Comment - Enable drag and drop + Enable drag and drop of URLs onto prim faces Persist 1 Type @@ -10786,6 +10786,17 @@ Value 0 + SLURLDragNDrop + + Comment + Enable drag and drop of SLURLs onto the viewer + Persist + 1 + Type + Boolean + Value + 1 + soundsbeacon Comment diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 45e153049b..e743d3419e 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -808,7 +808,10 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi { LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE; - if (gSavedSettings.getBOOL("PrimMediaDragNDrop")) + const bool prim_media_dnd_enabled = gSavedSettings.getBOOL("PrimMediaDragNDrop"); + const bool slurl_dnd_enabled = gSavedSettings.getBOOL("SLURLDragNDrop"); + + if ( prim_media_dnd_enabled || slurl_dnd_enabled ) { switch(action) { @@ -819,90 +822,96 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi { bool drop = (LLWindowCallbacks::DNDA_DROPPED == action); - // special case SLURLs - if ( LLSLURL::isSLURL( data ) ) + if (slurl_dnd_enabled) { - if (drop) + // special case SLURLs + if ( LLSLURL::isSLURL( data ) ) { - LLURLDispatcher::dispatch( data, NULL, true ); - LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); - LLPanelLogin::refreshLocation( true ); - LLPanelLogin::updateLocationUI(); - } - return LLWindowCallbacks::DND_MOVE; - }; + if (drop) + { + LLURLDispatcher::dispatch( data, NULL, true ); + LLURLSimString::setString( LLSLURL::stripProtocol( data ) ); + LLPanelLogin::refreshLocation( true ); + LLPanelLogin::updateLocationUI(); + } + return LLWindowCallbacks::DND_MOVE; + }; + } - LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); + if (prim_media_dnd_enabled) + { + LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ ); - LLUUID object_id = pick_info.getObjectID(); - S32 object_face = pick_info.mObjectFace; - std::string url = data; + LLUUID object_id = pick_info.getObjectID(); + S32 object_face = pick_info.mObjectFace; + std::string url = data; - lldebugs << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; + lldebugs << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl; - LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); + LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); - if (obj && obj->permModify() && !obj->getRegion()->getCapability("ObjectMedia").empty()) - { - LLTextureEntry *te = obj->getTE(object_face); - if (te) + if (obj && obj->permModify() && !obj->getRegion()->getCapability("ObjectMedia").empty()) { - if (drop) + LLTextureEntry *te = obj->getTE(object_face); + if (te) { - if (! te->hasMedia()) + if (drop) { - // Create new media entry - LLSD media_data; - // XXX Should we really do Home URL too? - media_data[LLMediaEntry::HOME_URL_KEY] = url; - media_data[LLMediaEntry::CURRENT_URL_KEY] = url; - media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; - obj->syncMediaData(object_face, media_data, true, true); - // XXX This shouldn't be necessary, should it ?!? - if (obj->getMediaImpl(object_face)) - obj->getMediaImpl(object_face)->navigateReload(); - obj->sendMediaDataUpdate(); - - result = LLWindowCallbacks::DND_COPY; - } - else { - // Check the whitelist - if (te->getMediaData()->checkCandidateUrl(url)) + if (! te->hasMedia()) { - // just navigate to the URL + // Create new media entry + LLSD media_data; + // XXX Should we really do Home URL too? + media_data[LLMediaEntry::HOME_URL_KEY] = url; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + media_data[LLMediaEntry::AUTO_PLAY_KEY] = true; + obj->syncMediaData(object_face, media_data, true, true); + // XXX This shouldn't be necessary, should it ?!? if (obj->getMediaImpl(object_face)) + obj->getMediaImpl(object_face)->navigateReload(); + obj->sendMediaDataUpdate(); + + result = LLWindowCallbacks::DND_COPY; + } + else { + // Check the whitelist + if (te->getMediaData()->checkCandidateUrl(url)) { - obj->getMediaImpl(object_face)->navigateTo(url); + // just navigate to the URL + if (obj->getMediaImpl(object_face)) + { + obj->getMediaImpl(object_face)->navigateTo(url); + } + else { + // This is very strange. Navigation should + // happen via the Impl, but we don't have one. + // This sends it to the server, which /should/ + // trigger us getting it. Hopefully. + LLSD media_data; + media_data[LLMediaEntry::CURRENT_URL_KEY] = url; + obj->syncMediaData(object_face, media_data, true, true); + obj->sendMediaDataUpdate(); + } + result = LLWindowCallbacks::DND_LINK; } - else { - // This is very strange. Navigation should - // happen via the Impl, but we don't have one. - // This sends it to the server, which /should/ - // trigger us getting it. Hopefully. - LLSD media_data; - media_data[LLMediaEntry::CURRENT_URL_KEY] = url; - obj->syncMediaData(object_face, media_data, true, true); - obj->sendMediaDataUpdate(); - } - result = LLWindowCallbacks::DND_LINK; } - } - LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); - mDragHoveredObject = NULL; + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = NULL; - } - else { - // Check the whitelist, if there's media (otherwise just show it) - if (te->getMediaData() == NULL || te->getMediaData()->checkCandidateUrl(url)) - { - if ( obj != mDragHoveredObject) + } + else { + // Check the whitelist, if there's media (otherwise just show it) + if (te->getMediaData() == NULL || te->getMediaData()->checkCandidateUrl(url)) { - // Highlight the dragged object - LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); - mDragHoveredObject = obj; - LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + if ( obj != mDragHoveredObject) + { + // Highlight the dragged object + LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); + mDragHoveredObject = obj; + LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject); + } + result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } - result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK; } } } @@ -915,7 +924,8 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi break; } - if (result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull()) + if (prim_media_dnd_enabled && + result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull()) { LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject); mDragHoveredObject = NULL; -- cgit v1.2.3 From 5fc9d8bddad16b7d8dc6d481107a8ce690fdf731 Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Wed, 20 Jan 2010 11:46:40 -0800 Subject: Remove a tab character from the end of a line to pass policy requirements. --- scripts/template_verifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py index d5fc119270..adcfcbcae6 100755 --- a/scripts/template_verifier.py +++ b/scripts/template_verifier.py @@ -103,7 +103,7 @@ MESSAGE_TEMPLATE = 'message_template.msg' PRODUCTION_ACCEPTABLE = (compatibility.Same, compatibility.Newer) DEVELOPMENT_ACCEPTABLE = ( compatibility.Same, compatibility.Newer, - compatibility.Older, compatibility.Mixed) + compatibility.Older, compatibility.Mixed) MAX_MASTER_AGE = 60 * 60 * 4 # refresh master cache every 4 hours -- cgit v1.2.3 From 5d8de7b7200c514bb874e4f60581c6df6cf3be5a Mon Sep 17 00:00:00 2001 From: Erica Date: Thu, 21 Jan 2010 10:52:58 -0800 Subject: getting chiclet stuff out of test floater since it causes a crash --- .../skins/default/xui/en/floater_test_checkbox.xml | 79 ---------------------- 1 file changed, 79 deletions(-) diff --git a/indra/newview/skins/default/xui/en/floater_test_checkbox.xml b/indra/newview/skins/default/xui/en/floater_test_checkbox.xml index 042b4226c3..9977e85a9d 100644 --- a/indra/newview/skins/default/xui/en/floater_test_checkbox.xml +++ b/indra/newview/skins/default/xui/en/floater_test_checkbox.xml @@ -71,83 +71,4 @@ name="font_checkbox" top_pad="14" width="150" /> - - - - - - - - - - - - - - - -- cgit v1.2.3 From 8cf95e16830521d5aa9467b1f4d84e4d1343bd31 Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 22 Jan 2010 20:27:58 +0200 Subject: Fixed normal bug EXT-4486(nearby voice list not aligned correctly): Corrected indent of my_panel content. Changed the order of buttons of avatar list item, notice that it affects all avatar lists(on people panel, group chat participants, etc). --HG-- branch : product-engine --- indra/newview/llavatarlistitem.cpp | 12 +++++----- indra/newview/llavatarlistitem.h | 2 +- .../default/xui/en/floater_voice_controls.xml | 3 ++- .../default/xui/en/panel_avatar_list_item.xml | 28 ++++++++++++---------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 66ab32f3e8..2bcd097717 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -440,17 +440,17 @@ LLAvatarListItem::icon_color_map_t& LLAvatarListItem::getItemIconColorMap() // static void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item) { + //speaking indicator width + padding + S32 speaking_indicator_width = avatar_item->getRect().getWidth() - avatar_item->mSpeakingIndicator->getRect().mLeft; + //profile btn width + padding - S32 profile_btn_width = avatar_item->getRect().getWidth() - avatar_item->mProfileBtn->getRect().mLeft; + S32 profile_btn_width = avatar_item->mSpeakingIndicator->getRect().mLeft - avatar_item->mProfileBtn->getRect().mLeft; //info btn width + padding S32 info_btn_width = avatar_item->mProfileBtn->getRect().mLeft - avatar_item->mInfoBtn->getRect().mLeft; - //speaking indicator width + padding - S32 speaking_indicator_width = avatar_item->mInfoBtn->getRect().mLeft - avatar_item->mSpeakingIndicator->getRect().mLeft; - // last interaction time textbox width + padding - S32 last_interaction_time_width = avatar_item->mSpeakingIndicator->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft; + S32 last_interaction_time_width = avatar_item->mInfoBtn->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft; // icon width + padding S32 icon_width = avatar_item->mAvatarName->getRect().mLeft - avatar_item->mAvatarIcon->getRect().mLeft; @@ -462,9 +462,9 @@ void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item) sChildrenWidths[--index] = icon_width; sChildrenWidths[--index] = 0; // for avatar name we don't need its width, it will be calculated as "left available space" sChildrenWidths[--index] = last_interaction_time_width; - sChildrenWidths[--index] = speaking_indicator_width; sChildrenWidths[--index] = info_btn_width; sChildrenWidths[--index] = profile_btn_width; + sChildrenWidths[--index] = speaking_indicator_width; } void LLAvatarListItem::updateChildren() diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index 479a4833cb..61c0a8660e 100644 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -129,9 +129,9 @@ private: * @see updateChildren() */ typedef enum e_avatar_item_child { + ALIC_SPEAKER_INDICATOR, ALIC_PROFILE_BUTTON, ALIC_INFO_BUTTON, - ALIC_SPEAKER_INDICATOR, ALIC_INTERACTION_TIME, ALIC_NAME, ALIC_ICON, diff --git a/indra/newview/skins/default/xui/en/floater_voice_controls.xml b/indra/newview/skins/default/xui/en/floater_voice_controls.xml index f473a51ff6..c4411db8c5 100644 --- a/indra/newview/skins/default/xui/en/floater_voice_controls.xml +++ b/indra/newview/skins/default/xui/en/floater_voice_controls.xml @@ -56,7 +56,7 @@ height="18" default_icon_name="Generic_Person" layout="topleft" - left="0" + left="5" name="user_icon" top="0" width="18" /> @@ -78,6 +78,7 @@ follows="top|right" height="16" layout="topleft" + right="-3" name="speaking_indicator" left_pad="5" visible="true" diff --git a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml index 615ade99a2..c605975c8e 100644 --- a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml +++ b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml @@ -65,28 +65,18 @@ height="15" layout="topleft" left_pad="5" + right="-72" name="last_interaction" text_color="LtGray_50" value="0s" width="24" /> - -- cgit v1.2.3 From 72b2cf291d67ae7a271b5745e50290d174a088b6 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 12:25:38 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- implemented cleanning of stored sort indexes to remove ones for landmarks not in Favorites while disconnecting viewer --HG-- branch : product-engine --- indra/newview/llviewerinventory.cpp | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index a3cbd80c84..1b141532ef 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1178,8 +1178,10 @@ const std::string& LLViewerInventoryItem::getName() const /** * Class to store sorting order of favorites landmarks in a local file. EXT-3985. * It replaced previously implemented solution to store sort index in landmark's name as a "@" prefix. + * Data are stored in user home directory. */ class LLFavoritesOrderStorage : public LLSingleton + , public LLDestroyClass { public: /** @@ -1193,12 +1195,27 @@ public: S32 getSortIndex(const LLUUID& inv_item_id); void removeSortIndex(const LLUUID& inv_item_id); + /** + * Implementation of LLDestroyClass. Calls cleanup() instance method. + * + * It is important this callback is called before gInventory is cleaned. + * For now it is called from LLAppViewer::cleanup() -> LLAppViewer::disconnectViewer(), + * Inventory is cleaned later from LLAppViewer::cleanup() after LLAppViewer::disconnectViewer() is called. + * @see cleanup() + */ + static void destroyClass(); + const static S32 NO_INDEX; private: friend class LLSingleton; LLFavoritesOrderStorage() { load(); } ~LLFavoritesOrderStorage() { save(); } + /** + * Removes sort indexes for items which are not in Favorites bar for now. + */ + void cleanup(); + const static std::string SORTING_DATA_FILE_NAME; void load(); @@ -1206,6 +1223,32 @@ private: typedef std::map sort_index_map_t; sort_index_map_t mSortIndexes; + + struct IsNotInFavorites + { + IsNotInFavorites(const LLInventoryModel::item_array_t& items) + : mFavoriteItems(items) + { + + } + + /** + * Returns true if specified item is not found among inventory items + */ + bool operator()(const sort_index_map_t::value_type& id_index_pair) const + { + LLPointer item = gInventory.getItem(id_index_pair.first); + if (item.isNull()) return true; + + LLInventoryModel::item_array_t::const_iterator found_it = + std::find(mFavoriteItems.begin(), mFavoriteItems.end(), item); + + return found_it == mFavoriteItems.end(); + } + private: + LLInventoryModel::item_array_t mFavoriteItems; + }; + }; const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml"; @@ -1231,6 +1274,12 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) mSortIndexes.erase(inv_item_id); } +// static +void LLFavoritesOrderStorage::destroyClass() +{ + LLFavoritesOrderStorage::instance().cleanup(); +} + void LLFavoritesOrderStorage::load() { // load per-resident sorting information @@ -1273,6 +1322,24 @@ void LLFavoritesOrderStorage::save() } } +void LLFavoritesOrderStorage::cleanup() +{ + const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); + + IsNotInFavorites is_not_in_fav(items); + + sort_index_map_t aTempMap; + //copy unremoved values from mSortIndexes to aTempMap + std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), + inserter(aTempMap, aTempMap.begin()), + is_not_in_fav); + + //Swap the contents of mSortIndexes and aTempMap + mSortIndexes.swap(aTempMap); +} // *TODO: mantipov: REMOVE, EXT-3985 -- cgit v1.2.3 From 540752ff2dcaaf565e8a9dff93079816ef572312 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 10:27:15 +0000 Subject: DEV-41686: Added a DisableMouseWarp debug option. Turning this option on makes alt-zooming and mouselook actually work when using Synergy. I believe this will also make it work for certain input devices, and Parallels, that control your cursor by setting its position in absolute coordinates. --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llviewerwindow.cpp | 17 ++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 1ef79aeec0..f3bda19ed1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2377,6 +2377,17 @@ Value 0 + DisableMouseWarp + + Comment + Disable warping of the mouse to the center of the screen during alt-zoom and mouse look. Useful with certain input devices, mouse sharing programs like Synergy, or running under Parallels. + Persist + 1 + Type + Boolean + Value + 0 + DisableRendering Comment diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b4c73dba26..8692cdcc57 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2269,15 +2269,18 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) void LLViewerWindow::moveCursorToCenter() { - S32 x = getWorldViewWidthScaled() / 2; - S32 y = getWorldViewHeightScaled() / 2; + if (! gSavedSettings.getBOOL("DisableMouseWarp")) + { + S32 x = getWorldViewWidthScaled() / 2; + S32 y = getWorldViewHeightScaled() / 2; - //on a forced move, all deltas get zeroed out to prevent jumping - mCurrentMousePoint.set(x,y); - mLastMousePoint.set(x,y); - mCurrentMouseDelta.set(0,0); + //on a forced move, all deltas get zeroed out to prevent jumping + mCurrentMousePoint.set(x,y); + mLastMousePoint.set(x,y); + mCurrentMouseDelta.set(0,0); - LLUI::setMousePositionScreen(x, y); + LLUI::setMousePositionScreen(x, y); + } } -- cgit v1.2.3 From 4666636cdc67beb3cbb1c81107ce1f1f368385e1 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 12:34:23 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- improvements: for now sort indexes are cleaned & saved only if something was changed amont them. --HG-- branch : product-engine --- indra/newview/llviewerinventory.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 1b141532ef..bcfb8ecbbd 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1208,7 +1208,7 @@ public: const static S32 NO_INDEX; private: friend class LLSingleton; - LLFavoritesOrderStorage() { load(); } + LLFavoritesOrderStorage() : mIsDirty(false) { load(); } ~LLFavoritesOrderStorage() { save(); } /** @@ -1224,6 +1224,8 @@ private: typedef std::map sort_index_map_t; sort_index_map_t mSortIndexes; + bool mIsDirty; + struct IsNotInFavorites { IsNotInFavorites(const LLInventoryModel::item_array_t& items) @@ -1257,6 +1259,7 @@ const S32 LLFavoritesOrderStorage::NO_INDEX = -1; void LLFavoritesOrderStorage::setSortIndex(const LLUUID& inv_item_id, S32 sort_index) { mSortIndexes[inv_item_id] = sort_index; + mIsDirty = true; } S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id) @@ -1272,6 +1275,7 @@ S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id) void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) { mSortIndexes.erase(inv_item_id); + mIsDirty = true; } // static @@ -1302,6 +1306,9 @@ void LLFavoritesOrderStorage::load() void LLFavoritesOrderStorage::save() { + // nothing to save if clean + if (!mIsDirty) return; + // If we quit from the login screen we will not have an SL account // name. Don't try to save, otherwise we'll dump a file in // C:\Program Files\SecondLife\ or similar. JC @@ -1324,6 +1331,9 @@ void LLFavoritesOrderStorage::save() void LLFavoritesOrderStorage::cleanup() { + // nothing to clean + if (!mIsDirty) return; + const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; -- cgit v1.2.3 From 8a7ca61479813f55481f1040f75cd6fc63e713d2 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 13:05:11 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- cleanup: removed deprecated code added for previous sollution to support custom sorting of favorite landmarks. For now previous implementation is removed, bug is FIXED. --HG-- branch : product-engine --- indra/newview/llfavoritesbar.cpp | 4 +-- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llviewerinventory.cpp | 50 ++++++++----------------------------- indra/newview/llviewerinventory.h | 4 --- 4 files changed, 13 insertions(+), 47 deletions(-) diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 0e42ff09d8..57e6619470 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -685,7 +685,7 @@ void LLFavoritesBarCtrl::updateButtons() { // an child's order and mItems should be same if (button->getLandmarkId() != item->getUUID() // sort order has been changed - || button->getLabelSelected() != item->getDisplayName() // favorite's name has been changed + || button->getLabelSelected() != item->getName() // favorite's name has been changed || button->getRect().mRight < rightest_point) // favbar's width has been changed { break; @@ -780,7 +780,7 @@ LLButton* LLFavoritesBarCtrl::createButton(const LLPointergetWidth(item->getDisplayName()) + 20; + int requred_width = mFont->getWidth(item->getName()) + 20; int width = requred_width > def_button_width? def_button_width : requred_width; LLFavoriteLandmarkButton* fav_btn = NULL; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 6c9c7d15be..e04d3ec5a0 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -5079,7 +5079,7 @@ void LLLandmarkBridgeAction::doIt() payload["asset_id"] = item->getAssetUUID(); LLSD args; - args["LOCATION"] = item->getDisplayName(); + args["LOCATION"] = item->getName(); LLNotificationsUtil::add("TeleportFromLandmark", args, payload); } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index bcfb8ecbbd..3001992630 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1172,7 +1172,7 @@ const std::string& LLViewerInventoryItem::getName() const return linked_category->getName(); } - return getDisplayName(); + return LLInventoryItem::getName(); } /** @@ -1340,42 +1340,17 @@ void LLFavoritesOrderStorage::cleanup() gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); IsNotInFavorites is_not_in_fav(items); - - sort_index_map_t aTempMap; - //copy unremoved values from mSortIndexes to aTempMap - std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), - inserter(aTempMap, aTempMap.begin()), - is_not_in_fav); - - //Swap the contents of mSortIndexes and aTempMap - mSortIndexes.swap(aTempMap); -} + sort_index_map_t aTempMap; + //copy unremoved values from mSortIndexes to aTempMap + std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), + inserter(aTempMap, aTempMap.begin()), + is_not_in_fav); -// *TODO: mantipov: REMOVE, EXT-3985 -const std::string& LLViewerInventoryItem::getDisplayName() const -{ - return LLInventoryItem::getName(); -/* - std::string result; - BOOL hasSortField = extractSortFieldAndDisplayName(0, &result); - - mDisplayName = LLInventoryItem::getName(); - - return mDisplayName = hasSortField ? result : LLInventoryItem::getName(); -*/ + //Swap the contents of mSortIndexes and aTempMap + mSortIndexes.swap(aTempMap); } -// *TODO: mantipov: REMOVE, EXT-3985 -// static -std::string LLViewerInventoryItem::getDisplayName(const std::string& name) -{ - llassert(false); - std::string result; - BOOL hasSortField = extractSortFieldAndDisplayName(name, 0, &result); - - return hasSortField ? result : name; -} S32 LLViewerInventoryItem::getSortField() const { @@ -1387,12 +1362,6 @@ void LLViewerInventoryItem::setSortField(S32 sortField) LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField); } -// *TODO: mantipov: REMOVE, EXT-3985 -void LLViewerInventoryItem::rename(const std::string& n) -{ - LLInventoryItem::rename(n); -} - const LLPermissions& LLViewerInventoryItem::getPermissions() const { // Use the actual permissions of the symlink, not its parent. @@ -1481,7 +1450,8 @@ U32 LLViewerInventoryItem::getCRC32() const return LLInventoryItem::getCRC32(); } -// *TODO: mantipov: REMOVE, EXT-3985 +// *TODO: mantipov: should be removed with LMSortPrefix patch in llinventorymodel.cpp, EXT-3985 +static char getSeparator() { return '@'; } BOOL LLViewerInventoryItem::extractSortFieldAndDisplayName(const std::string& name, S32* sortField, std::string* displayName) { using std::string; diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index cf104503a8..c24f76c87a 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -64,12 +64,8 @@ public: virtual LLAssetType::EType getType() const; virtual const LLUUID& getAssetUUID() const; virtual const std::string& getName() const; - virtual const std::string& getDisplayName() const; - static std::string getDisplayName(const std::string& name); - static char getSeparator() { return '@'; } virtual S32 getSortField() const; virtual void setSortField(S32 sortField); - virtual void rename(const std::string& new_name); virtual const LLPermissions& getPermissions() const; virtual const LLUUID& getCreatorUUID() const; virtual const std::string& getDescription() const; -- cgit v1.2.3 From d9b924edd2f5d511c5e506fafe2f01f983214711 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 11:26:08 +0000 Subject: EXT-4763: Turn off URL highlighting for toast alerts. --- indra/newview/lltoastalertpanel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp index c3ccb9380b..da31bb3e73 100644 --- a/indra/newview/lltoastalertpanel.cpp +++ b/indra/newview/lltoastalertpanel.cpp @@ -170,6 +170,7 @@ LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal params.tab_stop(false); params.wrap(true); params.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP); + params.allow_html(false); LLTextBox * msg_box = LLUICtrlFactory::create (params); // Compute max allowable height for the dialog text, so we can allocate -- cgit v1.2.3 From 3da01ec592edd2aaab1fe6dcaaaed6d13cc492b6 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 11:50:59 +0000 Subject: EXT-4747: Turn on URL hyperlinking for Pick Info descriptions. --- indra/newview/skins/default/xui/en/panel_pick_info.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/skins/default/xui/en/panel_pick_info.xml b/indra/newview/skins/default/xui/en/panel_pick_info.xml index 65ccd10cf0..7489988722 100644 --- a/indra/newview/skins/default/xui/en/panel_pick_info.xml +++ b/indra/newview/skins/default/xui/en/panel_pick_info.xml @@ -88,6 +88,7 @@ follows="all" height="100" width="280" + allow_html="true" hide_scrollbar="false" layout="topleft" left="10" -- cgit v1.2.3 From 57e1216f798dbbe479493c19658da36b96622290 Mon Sep 17 00:00:00 2001 From: Dmitry Zaporozhan Date: Fri, 29 Jan 2010 14:07:12 +0200 Subject: Fixed normal bug EXT-4374 - Gestures floater: 'Activate' btn applies unsaved changes to gesture. --HG-- branch : product-engine --- indra/newview/llpreviewgesture.cpp | 10 ++++++++-- indra/newview/llpreviewgesture.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 84bdaafacf..53e351e66e 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -155,6 +155,12 @@ LLPreviewGesture* LLPreviewGesture::show(const LLUUID& item_id, const LLUUID& ob return preview; } +void LLPreviewGesture::draw() +{ + // Skip LLPreview::draw() to avoid description update + LLFloater::draw(); +} + // virtual BOOL LLPreviewGesture::handleKeyHere(KEY key, MASK mask) { @@ -497,11 +503,9 @@ BOOL LLPreviewGesture::postBuild() if (item) { - childSetCommitCallback("desc", LLPreview::onText, this); childSetText("desc", item->getDescription()); childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe); - childSetCommitCallback("name", LLPreview::onText, this); childSetText("name", item->getName()); childSetPrevalidate("name", &LLLineEditor::prevalidateASCIIPrintableNoPipe); } @@ -1077,6 +1081,8 @@ void LLPreviewGesture::saveIfNeeded() } else { + LLPreview::onCommit(); + // Every save gets a new UUID. Yup. LLTransactionID tid; LLAssetID asset_id; diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h index 19fa1dcc37..5968e936ef 100644 --- a/indra/newview/llpreviewgesture.h +++ b/indra/newview/llpreviewgesture.h @@ -60,6 +60,7 @@ public: virtual ~LLPreviewGesture(); // LLView + /*virtual*/ void draw(); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, -- cgit v1.2.3 From a67598f762fd64506c9a867160007456d2327cb8 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Fri, 29 Jan 2010 14:18:31 +0200 Subject: cleaned cmake list a bit from llimpanel, lltoolbar and lloverlaybar --HG-- branch : product-engine --- indra/newview/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4c0c895a7d..41b08942eb 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -241,7 +241,6 @@ set(viewer_SOURCE_FILES llimfloater.cpp llimfloatercontainer.cpp llimhandler.cpp - llimpanel.cpp llimview.cpp llinspect.cpp llinspectavatar.cpp @@ -297,7 +296,6 @@ set(viewer_SOURCE_FILES llnotificationscripthandler.cpp llnotificationtiphandler.cpp lloutputmonitorctrl.cpp - lloverlaybar.cpp llpanelavatar.cpp llpanelavatartag.cpp llpanelblockedlist.cpp @@ -418,7 +416,6 @@ set(viewer_SOURCE_FILES lltoastnotifypanel.cpp lltoastpanel.cpp lltool.cpp - lltoolbar.cpp lltoolbrush.cpp lltoolcomp.cpp lltooldraganddrop.cpp @@ -747,7 +744,6 @@ set(viewer_HEADER_FILES llhudview.h llimfloater.h llimfloatercontainer.h - llimpanel.h llimview.h llinspect.h llinspectavatar.h @@ -799,7 +795,6 @@ set(viewer_HEADER_FILES llnotificationhandler.h llnotificationmanager.h lloutputmonitorctrl.h - lloverlaybar.h llpanelavatar.h llpanelavatartag.h llpanelblockedlist.h @@ -923,7 +918,6 @@ set(viewer_HEADER_FILES lltoastnotifypanel.h lltoastpanel.h lltool.h - lltoolbar.h lltoolbrush.h lltoolcomp.h lltooldraganddrop.h -- cgit v1.2.3 From 56d06544376dea0704d139b28d17d44e3c6fadf9 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Fri, 29 Jan 2010 14:18:56 +0200 Subject: got rid from lltoolbar.h includes --HG-- branch : product-engine --- indra/newview/llappviewer.cpp | 2 -- indra/newview/llviewermenu.cpp | 1 - indra/newview/llviewerwindow.cpp | 1 - 3 files changed, 4 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 9aa15789ed..9bb0977c1a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -163,7 +163,6 @@ #include "llvotree.h" #include "llvoavatar.h" #include "llfolderview.h" -#include "lltoolbar.h" #include "llagentpilot.h" #include "llvovolume.h" #include "llflexibleobject.h" @@ -414,7 +413,6 @@ static void settings_to_globals() LLVOAvatar::sVisibleInFirstPerson = gSavedSettings.getBOOL("FirstPersonAvatarVisible"); // clamp auto-open time to some minimum usable value LLFolderView::sAutoOpenTime = llmax(0.25f, gSavedSettings.getF32("FolderAutoOpenDelay")); - LLToolBar::sInventoryAutoOpenTime = gSavedSettings.getF32("InventoryAutoOpenDelay"); LLSelectMgr::sRectSelectInclusive = gSavedSettings.getBOOL("RectangleSelectInclusive"); LLSelectMgr::sRenderHiddenSelections = gSavedSettings.getBOOL("RenderHiddenSelections"); LLSelectMgr::sRenderLightRadius = gSavedSettings.getBOOL("RenderLightRadius"); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 96251f7571..12e2fa5156 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -82,7 +82,6 @@ #include "llsidetray.h" #include "llstatusbar.h" #include "lltextureview.h" -#include "lltoolbar.h" #include "lltoolcomp.h" #include "lltoolmgr.h" #include "lltoolpie.h" diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b4c73dba26..c43f58c8a2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -147,7 +147,6 @@ #include "lltexturefetch.h" #include "lltextureview.h" #include "lltool.h" -#include "lltoolbar.h" #include "lltoolcomp.h" #include "lltooldraganddrop.h" #include "lltoolface.h" -- cgit v1.2.3 From 943f8afa09480629ad659de9601b36b3dc565246 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 14:25:50 +0200 Subject: Fixed normal bug EXT-4743 ('Stop flying' button disappears if minimize undocked movement controls) - synchronized visibility of "stand_stop_flying_container" with a panel visibility when it is reparented from the Move Floater to container. --HG-- branch : product-engine --- indra/newview/llmoveview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index 5981baab60..4bf2bac649 100644 --- a/indra/newview/llmoveview.cpp +++ b/indra/newview/llmoveview.cpp @@ -651,6 +651,9 @@ void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view) // Detach from movement controls. parent->removeChild(this); mOriginalParent.get()->addChild(this); + // update parent with self visibility (it is changed in setVisible()). EXT-4743 + mOriginalParent.get()->setVisible(getVisible()); + mAttached = false; updatePosition(); // don't defer until next draw() to avoid flicker } -- cgit v1.2.3 From ac0fb461f6ad9e81349bd8814201a641a24f40a3 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Fri, 29 Jan 2010 14:42:57 +0200 Subject: got rid of lloverlaybar, llmediaremotectrl, llvoiceremotectrl dependencies, updated cmake list --HG-- branch : product-engine --- indra/newview/CMakeLists.txt | 4 ---- indra/newview/llviewercontrol.cpp | 31 ------------------------------- indra/newview/llviewerfloaterreg.cpp | 4 ---- indra/newview/llviewerparcelmgr.cpp | 1 - indra/newview/llviewerwindow.cpp | 1 - 5 files changed, 41 deletions(-) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 41b08942eb..3389ecbf4d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -272,7 +272,6 @@ set(viewer_SOURCE_FILES llmaniptranslate.cpp llmediactrl.cpp llmediadataclient.cpp - llmediaremotectrl.cpp llmemoryview.cpp llmenucommands.cpp llmetricperformancetester.cpp @@ -510,7 +509,6 @@ set(viewer_SOURCE_FILES llvoground.cpp llvoicechannel.cpp llvoiceclient.cpp - llvoiceremotectrl.cpp llvoicevisualizer.cpp llvoinventorylistener.cpp llvopartgroup.cpp @@ -776,7 +774,6 @@ set(viewer_HEADER_FILES llmaniptranslate.h llmediactrl.h llmediadataclient.h - llmediaremotectrl.h llmemoryview.h llmenucommands.h llmetricperformancetester.h @@ -1010,7 +1007,6 @@ set(viewer_HEADER_FILES llvoground.h llvoicechannel.h llvoiceclient.h - llvoiceremotectrl.h llvoicevisualizer.h llvoinventorylistener.h llvopartgroup.h diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 57434bd1e4..64eabe65cf 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -63,7 +63,6 @@ #include "llviewerjoystick.h" #include "llviewerparcelmgr.h" #include "llparcel.h" -#include "lloverlaybar.h" #include "llkeyboard.h" #include "llerrorcontrol.h" #include "llappviewer.h" @@ -257,35 +256,6 @@ static bool handleJoystickChanged(const LLSD& newvalue) return true; } -static bool handleAudioStreamMusicChanged(const LLSD& newvalue) -{ - if (gAudiop) - { - if ( newvalue.asBoolean() ) - { - if (LLViewerParcelMgr::getInstance()->getAgentParcel() - && !LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL().empty()) - { - // if music isn't playing, start it - if (gOverlayBar && !gOverlayBar->musicPlaying()) - { - LLOverlayBar::toggleMusicPlay(NULL); - } - } - } - else - { - // if music is playing, stop it. - if (gOverlayBar && gOverlayBar->musicPlaying()) - { - LLOverlayBar::toggleMusicPlay(NULL); - } - - } - } - return true; -} - static bool handleUseOcclusionChanged(const LLSD& newvalue) { LLPipeline::sUseOcclusion = (newvalue.asBoolean() && gGLManager.mHasOcclusionQuery @@ -592,7 +562,6 @@ void settings_setup_listeners() gSavedSettings.getControl("AudioLevelVoice")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); gSavedSettings.getControl("AudioLevelDoppler")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); gSavedSettings.getControl("AudioLevelRolloff")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); - gSavedSettings.getControl("AudioStreamingMusic")->getSignal()->connect(boost::bind(&handleAudioStreamMusicChanged, _2)); gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); gSavedSettings.getControl("MuteMusic")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); gSavedSettings.getControl("MuteMedia")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2)); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 3aca11963a..f93d78bf33 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -115,7 +115,6 @@ #include "llinspectobject.h" #include "llinspectremoteobject.h" #include "llinspecttoast.h" -#include "llmediaremotectrl.h" #include "llmoveview.h" #include "llnearbychat.h" #include "llpanelblockedlist.h" @@ -263,8 +262,5 @@ void LLViewerFloaterReg::registerFloaters() // *NOTE: Please keep these alphabetized for easier merges - // debug use only - LLFloaterReg::add("media_remote_ctrl", "floater_media_remote.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving } diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 10a95443f1..e233356632 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -69,7 +69,6 @@ #include "llviewerparceloverlay.h" #include "llviewerregion.h" #include "llworld.h" -#include "lloverlaybar.h" #include "roles_constants.h" #include "llweb.h" diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c43f58c8a2..03cc6e1262 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -128,7 +128,6 @@ #include "llmorphview.h" #include "llmoveview.h" #include "llnavigationbar.h" -#include "lloverlaybar.h" #include "llpreviewtexture.h" #include "llprogressview.h" #include "llresmgr.h" -- cgit v1.2.3 From 53173419000ba1d14aa99c59353e91f700915e07 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 13:14:14 +0000 Subject: EXT-4679: Removed reference to no-longer-supported abuse URL. --- indra/newview/skins/default/xui/en/notifications.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 41f4621d66..fc535205f1 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3851,7 +3851,7 @@ Are you sure you want to quit? type="alertmodal"> Use this tool to report violations of the [http://secondlife.com/corporate/tos.php Terms of Service] and [http://secondlife.com/corporate/cs.php Community Standards]. -All reported abuses are investigated and resolved. You can view the resolution by reading the [http://secondlife.com/support/incidentreport.php Incident Report]. +All reported abuses are investigated and resolved. -- cgit v1.2.3 From 10cbb9ea27e8e47a235efece1b30365b7f00e038 Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Fri, 29 Jan 2010 15:16:11 +0200 Subject: Fixed low bug EXT-4749 (There is misleading notification after voice has been turned off from preferences) - Added skipping "Voice not available at your current location" when agent voice is disabled --HG-- branch : product-engine --- indra/newview/llvoicechannel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 589999c026..9d49fb69d6 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -698,7 +698,11 @@ void LLVoiceChannelProximal::handleStatusChange(EStatusType status) // do not notify user when leaving proximal channel return; case STATUS_VOICE_DISABLED: - LLCallInfoDialog::show("unavailable", mNotifyArgs); + //skip showing "Voice not available at your current location" when agent voice is disabled (EXT-4749) + if(LLVoiceClient::voiceEnabled() && gVoiceClient->voiceWorking()) + { + LLCallInfoDialog::show("unavailable", mNotifyArgs); + } return; default: break; -- cgit v1.2.3 From ec5dbb60e71302a77f68cc604e7dfd52bcaa926a Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 13:36:39 +0000 Subject: EXT-4763: Revert my previous fix. We don't want to universally disabled URL highlighting for all toast alerts, e.g., the report abuse notification has URLs that we want users to be able to click on. I have a better plan... --- indra/newview/lltoastalertpanel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp index da31bb3e73..c3ccb9380b 100644 --- a/indra/newview/lltoastalertpanel.cpp +++ b/indra/newview/lltoastalertpanel.cpp @@ -170,7 +170,6 @@ LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal params.tab_stop(false); params.wrap(true); params.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP); - params.allow_html(false); LLTextBox * msg_box = LLUICtrlFactory::create (params); // Compute max allowable height for the dialog text, so we can allocate -- cgit v1.2.3 From f8bde94b9f9c83202f32268b57539fbe5c7cf271 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Fri, 29 Jan 2010 15:41:41 +0200 Subject: completely got rid of Communicate floater and stuff --HG-- branch : product-engine --- indra/newview/CMakeLists.txt | 4 ---- indra/newview/llgroupactions.cpp | 3 ++- indra/newview/llimview.cpp | 23 ++--------------------- indra/newview/llimview.h | 13 ++----------- indra/newview/llinventorypanel.cpp | 4 +++- indra/newview/llviewerfloaterreg.cpp | 3 +-- indra/newview/llviewermenu.cpp | 1 - indra/newview/llviewerwindow.cpp | 5 ----- 8 files changed, 10 insertions(+), 46 deletions(-) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3389ecbf4d..1c32c690a8 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -156,13 +156,11 @@ set(viewer_SOURCE_FILES llfloaterbuycurrency.cpp llfloaterbuyland.cpp llfloatercamera.cpp - llfloaterchatterbox.cpp llfloatercolorpicker.cpp llfloatercustomize.cpp llfloaterdaycycle.cpp llfloaterenvsettings.cpp llfloaterfonttest.cpp - llfloaterfriends.cpp llfloatergesture.cpp llfloatergodtools.cpp llfloatergroupinvite.cpp @@ -658,13 +656,11 @@ set(viewer_HEADER_FILES llfloaterbuycurrency.h llfloaterbuyland.h llfloatercamera.h - llfloaterchatterbox.h llfloatercolorpicker.h llfloatercustomize.h llfloaterdaycycle.h llfloaterenvsettings.h llfloaterfonttest.h - llfloaterfriends.h llfloatergesture.h llfloatergodtools.h llfloatergroupinvite.h diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index d6e2bb0445..3653371d76 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -75,11 +75,12 @@ public: return false; } + //*TODO by what to replace showing groups floater? if (tokens[0].asString() == "list") { if (tokens[1].asString() == "show") { - LLFloaterReg::showInstance("contacts", "groups"); + //LLFloaterReg::showInstance("contacts", "groups"); return true; } return false; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 213862df4b..675f73d43e 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -52,7 +52,6 @@ #include "llbottomtray.h" #include "llcallingcard.h" #include "llchat.h" -#include "llfloaterchatterbox.h" #include "llimfloater.h" #include "llgroupiconctrl.h" #include "llmd5.h" @@ -64,6 +63,7 @@ #include "llnotificationsutil.h" #include "llnearbychat.h" #include "llspeakers.h" //for LLIMSpeakerMgr +#include "lltextbox.h" #include "lltextutil.h" #include "llviewercontrol.h" #include "llviewerparcelmgr.h" @@ -2075,8 +2075,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response) // Member Functions // -LLIMMgr::LLIMMgr() : - mIMReceived(FALSE) +LLIMMgr::LLIMMgr() { mPendingInvitations = LLSD::emptyMap(); mPendingAgentListUpdates = LLSD::emptyMap(); @@ -2183,14 +2182,6 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess } } -void LLIMMgr::notifyNewIM() -{ - if(!LLFloaterReg::instanceVisible("communicate")) - { - mIMReceived = TRUE; - } -} - S32 LLIMMgr::getNumberOfUnreadIM() { std::map::iterator it; @@ -2217,16 +2208,6 @@ S32 LLIMMgr::getNumberOfUnreadParticipantMessages() return num; } -void LLIMMgr::clearNewIMNotification() -{ - mIMReceived = FALSE; -} - -BOOL LLIMMgr::getIMReceived() const -{ - return mIMReceived; -} - void LLIMMgr::autoStartCallOnStartup(const LLUUID& session_id) { LLIMModel::LLIMSession *session = LLIMModel::getInstance()->findIMSession(session_id); diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index 17406025f2..b573490fa3 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -39,8 +39,8 @@ #include "lllogchat.h" #include "llvoicechannel.h" -class LLFloaterChatterBox; -class LLUUID; + + class LLFriendObserver; class LLCallDialogManager; class LLIMSpeakerMgr; @@ -360,15 +360,9 @@ public: void processIMTypingStart(const LLIMInfo* im_info); void processIMTypingStop(const LLIMInfo* im_info); - void notifyNewIM(); - void clearNewIMNotification(); - // automatically start a call once the session has initialized void autoStartCallOnStartup(const LLUUID& session_id); - // IM received that you haven't seen yet - BOOL getIMReceived() const; - // Calc number of all unread IMs S32 getNumberOfUnreadIM(); @@ -446,9 +440,6 @@ private: typedef std::list session_observers_list_t; session_observers_list_t mSessionObservers; - // An IM has been received that you haven't seen yet. - BOOL mIMReceived; - LLSD mPendingInvitations; LLSD mPendingAgentListUpdates; }; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 7e71ac90b4..12a2c370d2 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -759,7 +759,9 @@ bool LLInventoryPanel::beginIMSession() S32 count = item_array.count(); if(count > 0) { - LLFloaterReg::showInstance("communicate"); + //*TODO by what to replace that? + //LLFloaterReg::showInstance("communicate"); + // create the session LLAvatarTracker& at = LLAvatarTracker::instance(); LLUUID id; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index f93d78bf33..658d1c9ddd 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -54,7 +54,6 @@ #include "llfloaterbulkpermission.h" #include "llfloaterbump.h" #include "llfloatercamera.h" -#include "llfloaterchatterbox.h" #include "llfloaterdaycycle.h" #include "llfloatersearch.h" #include "llfloaterenvsettings.h" @@ -153,7 +152,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); //LLFloaterReg::add("chat", "floater_chat_history.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("nearby_chat", "floater_nearby_chat.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("communicate", "floater_chatterbox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_day_cycle", "floater_day_cycle_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 12e2fa5156..f7f30a5136 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -53,7 +53,6 @@ #include "llfloaterbuycontents.h" #include "llfloaterbuycurrency.h" #include "llfloatercustomize.h" -#include "llfloaterchatterbox.h" #include "llfloatergodtools.h" #include "llfloaterinventory.h" #include "llfloaterland.h" diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 03cc6e1262..c70b830782 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -101,7 +101,6 @@ #include "llfloaterbuildoptions.h" #include "llfloaterbuyland.h" #include "llfloatercamera.h" -#include "llfloaterchatterbox.h" #include "llfloatercustomize.h" #include "llfloaterland.h" #include "llfloaterinspect.h" @@ -1461,10 +1460,6 @@ void LLViewerWindow::initWorldUI() bottom_tray_container->addChild(bottom_tray); bottom_tray_container->setVisible(TRUE); - // Pre initialize instance communicate instance; - // currently needs to happen before initializing chat or IM - LLFloaterReg::getInstance("communicate"); - LLRect morph_view_rect = full_window; morph_view_rect.stretch( -STATUS_BAR_HEIGHT ); morph_view_rect.mTop = full_window.mTop - 32; -- cgit v1.2.3 From efeaba0acd9b40d50a32e4c728489231fbaac7e8 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 15:48:50 +0200 Subject: Fixed normal bug EXT-4762 ( Crash on exit from viewer in LLPanelPeopleMenus::ContextMenu) - reason: attempt to delete instance of the LLContextMenu from the LLPanelPeopleMenus::ContextMenu after it was deleted by menu holder on viewer exit. - fix: check if menu is not dead via stored LLHandle of the menu before deleting. --HG-- branch : product-engine --- indra/newview/llpanelpeoplemenus.cpp | 10 +++++++++- indra/newview/llpanelpeoplemenus.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 501dac5dff..470cfca8fe 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -61,7 +61,14 @@ ContextMenu::~ContextMenu() // It can have registered Enable callbacks which are called from the LLMenuHolderGL::draw() // via selected item (menu_item_call) by calling LLMenuItemCallGL::buildDrawLabel. // we can have a crash via using callbacks of deleted instance of ContextMenu. EXT-4725 - if (mMenu) mMenu->die(); + + // menu holder deletes its menus on viewer exit, so we have no way to determine if instance + // of mMenu has already been deleted except of using LLHandle. EXT-4762. + if (!mMenuHandle.isDead()) + { + mMenu->die(); + mMenu = NULL; + } } void ContextMenu::show(LLView* spawning_view, const std::vector& uuids, S32 x, S32 y) @@ -86,6 +93,7 @@ void ContextMenu::show(LLView* spawning_view, const std::vector& uuids, std::copy(uuids.begin(), uuids.end(), mUUIDs.begin()); mMenu = createMenu(); + mMenuHandle = mMenu->getHandle(); mMenu->show(x, y); LLMenuGL::showPopup(spawning_view, mMenu, x, y); } diff --git a/indra/newview/llpanelpeoplemenus.h b/indra/newview/llpanelpeoplemenus.h index 7251f6dbbd..913638d8c8 100644 --- a/indra/newview/llpanelpeoplemenus.h +++ b/indra/newview/llpanelpeoplemenus.h @@ -62,6 +62,7 @@ protected: std::vector mUUIDs; LLContextMenu* mMenu; + LLHandle mMenuHandle; }; /** -- cgit v1.2.3 From d66d9afae1c7cd4484b72532c0103ce7a4db9e77 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 16:09:30 +0200 Subject: Fixed normal bug EXT-3882 ([BSI] block list contains the word block instead of (object)) - original issue has been fixed by Ramzi Linden in changeset eeabc4a70a6f at 2010-01-19 (Renaming multiple xml "MuteObject" nodes with unique names for block list and context menu). - changed panel title from "Blocked List" to "Block List" --HG-- branch : product-engine --- indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml index 39170b90ca..072ea882e6 100644 --- a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml +++ b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml @@ -29,7 +29,7 @@ text_color="white" top="5" width="250"> - Blocked List + Block List Date: Fri, 29 Jan 2010 14:30:26 +0000 Subject: EXT-4678: Support ... to turn off URL hyperlinking. We are running into a bunch of places where we don't want to allow hyperlinking of URLs like secondlife.com in text boxes. I've therefore added a new type of URL regex that disables URL hyperlinking. Simply enclose the URL in a tag, e.g.: secondlife.com --- indra/llui/lltextbase.cpp | 7 +++---- indra/llui/llurlentry.cpp | 24 +++++++++++++++++++++--- indra/llui/llurlentry.h | 14 ++++++++++++++ indra/llui/llurlmatch.cpp | 8 ++++++-- indra/llui/llurlmatch.h | 6 +++++- indra/llui/llurlregistry.cpp | 14 ++++++++++---- indra/llui/tests/llurlentry_test.cpp | 8 ++++++++ indra/llui/tests/llurlmatch_test.cpp | 30 +++++++++++++++--------------- 8 files changed, 82 insertions(+), 29 deletions(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 8abbc833e5..2ee2023875 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1606,11 +1606,10 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c } } - // output the styled Url (unless we've been asked to suppress it) - if (isBlackListUrl(match.getUrl())) + // output the styled Url (unless we've been asked to suppress hyperlinking) + if (match.isLinkDisabled()) { - std::string orig_url = text.substr(start, end-start); - appendAndHighlightText(orig_url, prepend_newline, part, style_params); + appendAndHighlightText(match.getLabel(), prepend_newline, part, style_params); } else { diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 4927e57a52..58148ad2aa 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -39,8 +39,9 @@ #include "lltrans.h" #include "lluicolortable.h" -LLUrlEntryBase::LLUrlEntryBase() -: mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")) +LLUrlEntryBase::LLUrlEntryBase() : + mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")), + mDisabledLink(false) { } @@ -204,7 +205,7 @@ LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol() mPattern = boost::regex("(" "\\bwww\\.\\S+\\.\\S+" // i.e. www.FOO.BAR "|" // or - "(?]+\\.(?:com|net|edu|org)([/:][^[:space:]<]*)?\\b" // i.e. FOO.net ")", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_http.xml"; @@ -641,3 +642,20 @@ std::string LLUrlEntryWorldMap::getLocation(const std::string &url) const // return the part of the Url after secondlife:///app/worldmap/ part return ::getStringAfterToken(url, "app/worldmap/"); } + +// +// LLUrlEntryNoLink lets us turn of URL detection with ... tags +// +LLUrlEntryNoLink::LLUrlEntryNoLink() +{ + mPattern = boost::regex("[^[:space:]<]+", + boost::regex::perl|boost::regex::icase); + mDisabledLink = true; +} + +std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + // return the text between the and tags + return url.substr(8, url.size()-8-9); +} + diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 4adffde99c..94455ac247 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -91,6 +91,9 @@ public: /// Return the name of a SL location described by this Url, if any virtual std::string getLocation(const std::string &url) const { return ""; } + /// is this a match for a URL that should not be hyperlinked? + bool isLinkDisabled() const { return mDisabledLink; } + protected: std::string getIDStringFromUrl(const std::string &url) const; std::string escapeUrl(const std::string &url) const; @@ -111,6 +114,7 @@ protected: std::string mTooltip; LLUIColor mColor; std::multimap mObservers; + bool mDisabledLink; }; /// @@ -267,4 +271,14 @@ public: /*virtual*/ std::string getLocation(const std::string &url) const; }; +/// +/// LLUrlEntryNoLink lets us turn of URL detection with ... tags +/// +class LLUrlEntryNoLink : public LLUrlEntryBase +{ +public: + LLUrlEntryNoLink(); + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); +}; + #endif diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp index 3b47145a22..72a199c220 100644 --- a/indra/llui/llurlmatch.cpp +++ b/indra/llui/llurlmatch.cpp @@ -41,14 +41,17 @@ LLUrlMatch::LLUrlMatch() : mLabel(""), mTooltip(""), mIcon(""), - mMenuName("") + mMenuName(""), + mLocation(""), + mDisabledLink(false) { } void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLUIColor& color, - const std::string &menu, const std::string &location) + const std::string &menu, const std::string &location, + bool disabled_link) { mStart = start; mEnd = end; @@ -59,4 +62,5 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, mColor = color; mMenuName = menu; mLocation = location; + mDisabledLink = disabled_link; } diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index 7f5767923a..e86762548b 100644 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -83,11 +83,14 @@ public: /// return the SL location that this Url describes, or "" if none. std::string getLocation() const { return mLocation; } + /// is this a match for a URL that should not be hyperlinked? + bool isLinkDisabled() const { return mDisabledLink; } + /// Change the contents of this match object (used by LLUrlRegistry) void setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLUIColor& color, const std::string &menu, - const std::string &location); + const std::string &location, bool disabled_link); private: U32 mStart; @@ -99,6 +102,7 @@ private: std::string mMenuName; std::string mLocation; LLUIColor mColor; + bool mDisabledLink; }; #endif diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index ad5c0911f8..55eb8950e9 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -44,6 +44,7 @@ void LLUrlRegistryNullCallback(const std::string &url, const std::string &label) LLUrlRegistry::LLUrlRegistry() { // Urls are matched in the order that they were registered + registerUrl(new LLUrlEntryNoLink()); registerUrl(new LLUrlEntrySLURL()); registerUrl(new LLUrlEntryHTTP()); registerUrl(new LLUrlEntryHTTPLabel()); @@ -176,7 +177,8 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_entry->getIcon(), match_entry->getColor(), match_entry->getMenuName(), - match_entry->getLocation(url)); + match_entry->getLocation(url), + match_entry->isLinkDisabled()); return true; } @@ -204,9 +206,13 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr S32 end = start + wurl.size() - 1; match.setValues(start, end, match.getUrl(), - match.getLabel(), match.getTooltip(), - match.getIcon(), match.getColor(), - match.getMenuName(), match.getLocation()); + match.getLabel(), + match.getTooltip(), + match.getIcon(), + match.getColor(), + match.getMenuName(), + match.getLocation(), + match.isLinkDisabled()); return true; } return false; diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index 80be8fcbf7..6fec1d3e10 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -610,5 +610,13 @@ namespace tut testRegex("invalid .net URL", r, "foo.netty", ""); + + testRegex("XML tags around URL [1]", r, + "secondlife.com", + "secondlife.com"); + + testRegex("XML tags around URL [2]", r, + "secondlife.com/status?bar=1", + "secondlife.com/status?bar=1"); } } diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index e8cf135346..f9dfee931b 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -53,7 +53,7 @@ namespace tut LLUrlMatch match; ensure("empty()", match.empty()); - match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLUIColor(), "", ""); + match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLUIColor(), "", "", false); ensure("! empty()", ! match.empty()); } @@ -66,7 +66,7 @@ namespace tut LLUrlMatch match; ensure_equals("getStart() == 0", match.getStart(), 0); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getStart() == 10", match.getStart(), 10); } @@ -79,7 +79,7 @@ namespace tut LLUrlMatch match; ensure_equals("getEnd() == 0", match.getEnd(), 0); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getEnd() == 20", match.getEnd(), 20); } @@ -92,10 +92,10 @@ namespace tut LLUrlMatch match; ensure_equals("getUrl() == ''", match.getUrl(), ""); - match.setValues(10, 20, "http://slurl.com/", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "http://slurl.com/", "", "", "", LLUIColor(), "", "", false); ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getUrl() == '' (2)", match.getUrl(), ""); } @@ -108,10 +108,10 @@ namespace tut LLUrlMatch match; ensure_equals("getLabel() == ''", match.getLabel(), ""); - match.setValues(10, 20, "", "Label", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "Label", "", "", LLUIColor(), "", "", false); ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getLabel() == '' (2)", match.getLabel(), ""); } @@ -124,10 +124,10 @@ namespace tut LLUrlMatch match; ensure_equals("getTooltip() == ''", match.getTooltip(), ""); - match.setValues(10, 20, "", "", "Info", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "Info", "", LLUIColor(), "", "", false); ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getTooltip() == '' (2)", match.getTooltip(), ""); } @@ -140,10 +140,10 @@ namespace tut LLUrlMatch match; ensure_equals("getIcon() == ''", match.getIcon(), ""); - match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "", "", false); ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure_equals("getIcon() == '' (2)", match.getIcon(), ""); } @@ -156,10 +156,10 @@ namespace tut LLUrlMatch match; ensure("getMenuName() empty", match.getMenuName().empty()); - match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "xui_file.xml", ""); + match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "xui_file.xml", "", false); ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure("getMenuName() empty (2)", match.getMenuName().empty()); } @@ -172,10 +172,10 @@ namespace tut LLUrlMatch match; ensure("getLocation() empty", match.getLocation().empty()); - match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "xui_file.xml", "Paris"); + match.setValues(10, 20, "", "", "", "Icon", LLUIColor(), "xui_file.xml", "Paris", false); ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris"); - match.setValues(10, 20, "", "", "", "", LLUIColor(), "", ""); + match.setValues(10, 20, "", "", "", "", LLUIColor(), "", "", false); ensure("getLocation() empty (2)", match.getLocation().empty()); } } -- cgit v1.2.3 From 2ec69d6d71e18c60a81d55f79e291e366d05eacd Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 14:56:39 +0000 Subject: EXT-4678: Revert URL black list support from LLTextBase. The new URL provides a more flexible solution that can be specified in XUI (as we now do to disabled hyperlinking for the sim hostname in the About floater). --- indra/llui/lltextbase.cpp | 19 ------------------- indra/llui/lltextbase.h | 7 ------- indra/newview/llfloaterabout.cpp | 6 ------ indra/newview/skins/default/xui/en/floater_about.xml | 2 +- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 2ee2023875..978bd317e2 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1512,25 +1512,6 @@ void LLTextBase::setText(const LLStringExplicit &utf8str, const LLStyle::Params& onValueChange(0, getLength()); } -void LLTextBase::addBlackListUrl(const std::string &url) -{ - mBlackListUrls.push_back(url); -} - -bool LLTextBase::isBlackListUrl(const std::string &url) const -{ - std::vector::const_iterator it; - for (it = mBlackListUrls.begin(); it != mBlackListUrls.end(); ++it) - { - const std::string &blacklist_url = *it; - if (url.find(blacklist_url) != std::string::npos) - { - return true; - } - } - return false; -} - //virtual std::string LLTextBase::getText() const { diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index e1c6cc36ab..dc3671eab1 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -187,9 +187,6 @@ public: const LLFontGL* getDefaultFont() const { return mDefaultFont; } LLStyle::Params getDefaultStyle(); - // tell the text object to suppress auto highlighting of a specific URL - void addBlackListUrl(const std::string &url); - public: // Fired when a URL link is clicked commit_signal_t mURLClickSignal; @@ -312,7 +309,6 @@ protected: void updateRects(); void needsScroll() { mScrollNeeded = TRUE; } void replaceUrlLabel(const std::string &url, const std::string &label); - bool isBlackListUrl(const std::string &url) const; protected: // text segmentation and flow @@ -364,9 +360,6 @@ protected: LLView* mDocumentView; class LLScrollContainer* mScroller; - // list of URLs to suppress from automatic hyperlinking - std::vector mBlackListUrls; - // transient state bool mReflowNeeded; // need to reflow text because of change to text contents or display region bool mScrollNeeded; // need to change scroll region because of change to cursor position diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 04f4ddf996..ef69f39ad2 100644 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -187,12 +187,6 @@ BOOL LLFloaterAbout::postBuild() support << '\n' << getString("AboutTraffic", args); } - // don't make the sim hostname be a hyperlink - if (info.has("HOSTNAME")) - { - support_widget->addBlackListUrl(info["HOSTNAME"].asString()); - } - support_widget->appendText(support.str(), FALSE, LLStyle::Params() diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index b6443c4c21..bfdd48e2f4 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -21,7 +21,7 @@ Built with [COMPILER] version [COMPILER_VERSION] -You are at [POSITION_0,number,1], [POSITION_1,number,1], [POSITION_2,number,1] in [REGION] located at [HOSTNAME] ([HOSTIP]) +You are at [POSITION_0,number,1], [POSITION_1,number,1], [POSITION_2,number,1] in [REGION] located at <nolink>[HOSTNAME]</nolink> ([HOSTIP]) [SERVER_VERSION] [[SERVER_RELEASE_NOTES_URL] [ReleaseNotes]] -- cgit v1.2.3 From 303c379a18630fbbc2c4a86714ebd9627c03ec9e Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 14:57:41 +0000 Subject: EXT-4763: Use syntax to disable linking of landmark names. --- indra/newview/skins/default/xui/en/notifications.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index fc535205f1..d3e08cad3a 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3088,7 +3088,7 @@ Join me in [REGION] icon="alertmodal.tga" name="TeleportFromLandmark" type="alertmodal"> -Are you sure you want to teleport to [LOCATION]? +Are you sure you want to teleport to <nolink>[LOCATION]</nolink>? Date: Fri, 29 Jan 2010 17:01:01 +0200 Subject: Fixed normal bug EXT-4355 (Preferences: Location of logs does not show full path) - changed "control_name" for view with log path to the "InstantMessageLogPath" - also changed a line editor state from "disabled" to "readonly" to have a chance to scroll text to see full path in this field. --HG-- branch : product-engine --- indra/newview/llfloaterpreference.cpp | 2 +- indra/newview/skins/default/xui/en/panel_preferences_privacy.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index e77c93b5f8..ef444c8ba4 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1207,7 +1207,7 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im childEnable("log_nearby_chat"); childEnable("log_instant_messages"); childEnable("show_timestamps_check_im"); - childEnable("log_path_string"); + childDisable("log_path_string");// LineEditor becomes readonly in this case. childEnable("log_path_button"); std::string display_email(email); diff --git a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml index 0aaeb6114e..f7e3ede93c 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml @@ -174,8 +174,7 @@ Date: Fri, 29 Jan 2010 17:04:17 +0200 Subject: fixed EXT-4736 There's an ability to block system notifications from nearby chat --HG-- branch : product-engine --- indra/newview/llchathistory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index f1e7e622b3..8cfcca31ce 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -310,7 +310,7 @@ protected: showSystemContextMenu(x,y); if(mSourceType == CHAT_SOURCE_AGENT) showAvatarContextMenu(x,y); - if(mSourceType == CHAT_SOURCE_OBJECT) + if(mSourceType == CHAT_SOURCE_OBJECT && SYSTEM_FROM != mFrom) showObjectContextMenu(x,y); } -- cgit v1.2.3 From 0524e91aae36d87d8e0944fd294e02f145d5d547 Mon Sep 17 00:00:00 2001 From: Denis Serdjuk Date: Fri, 29 Jan 2010 17:22:36 +0200 Subject: fixed bug EXT-4122 [BSI] Notification about \"maximum number of groups\" returns redundant information The hardcoded and unlocalized dataserver response has been removed from the message of notification. --HG-- branch : product-engine --- indra/newview/llviewermessage.cpp | 1 - indra/newview/skins/default/xui/en/notifications.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 55b0d6fa8b..9240833632 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -630,7 +630,6 @@ bool join_group_response(const LLSD& notification, const LLSD& response) delete_context_data = FALSE; LLSD args; args["NAME"] = name; - args["INVITE"] = message; LLNotificationsUtil::add("JoinedTooManyGroupsMember", args, notification["payload"]); } } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index fc535205f1..787346f7cd 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -2941,7 +2941,6 @@ Chat and instant messages will be hidden. Instant messages will get your Busy mo type="alert"> You have reached your maximum number of groups. Please leave another group before joining this one, or decline the offer. [NAME] has invited you to join a group as a member. -[INVITE] Date: Fri, 29 Jan 2010 17:48:10 +0200 Subject: =?UTF-8?q?fixed=20major=20EXT-3643=20=E2=80=9CEmbed=20friendship?= =?UTF-8?q?=20offer=20into=20IM=20window=E2=80=9D;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : product-engine --- indra/llcommon/llchat.h | 2 + indra/llui/llnotificationsutil.cpp | 5 ++ indra/llui/llnotificationsutil.h | 2 + indra/newview/llchathistory.cpp | 35 +++++++++- indra/newview/llimfloater.cpp | 19 +++++- indra/newview/llimfloater.h | 1 + indra/newview/llnotificationhandler.h | 22 +++++- indra/newview/llnotificationhandlerutil.cpp | 78 ++++++++++++++++++++-- indra/newview/llnotificationofferhandler.cpp | 19 +++++- indra/newview/lltoastnotifypanel.cpp | 5 ++ .../skins/default/xui/en/floater_im_session.xml | 10 +-- .../newview/skins/default/xui/en/notifications.xml | 6 +- 12 files changed, 183 insertions(+), 21 deletions(-) diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h index 46456882ba..a77bd211f3 100644 --- a/indra/llcommon/llchat.h +++ b/indra/llcommon/llchat.h @@ -79,6 +79,7 @@ public: : mText(text), mFromName(), mFromID(), + mNotifId(), mSourceType(CHAT_SOURCE_AGENT), mChatType(CHAT_TYPE_NORMAL), mAudible(CHAT_AUDIBLE_FULLY), @@ -94,6 +95,7 @@ public: std::string mText; // UTF-8 line of text std::string mFromName; // agent or object name LLUUID mFromID; // agent id or object id + LLUUID mNotifId; EChatSourceType mSourceType; EChatType mChatType; EChatAudible mAudible; diff --git a/indra/llui/llnotificationsutil.cpp b/indra/llui/llnotificationsutil.cpp index f343d27cb4..54bdb4bd66 100644 --- a/indra/llui/llnotificationsutil.cpp +++ b/indra/llui/llnotificationsutil.cpp @@ -94,3 +94,8 @@ void LLNotificationsUtil::cancel(LLNotificationPtr pNotif) { LLNotifications::instance().cancel(pNotif); } + +LLNotificationPtr LLNotificationsUtil::find(LLUUID uuid) +{ + return LLNotifications::instance().find(uuid); +} diff --git a/indra/llui/llnotificationsutil.h b/indra/llui/llnotificationsutil.h index d552fa915b..338204924a 100644 --- a/indra/llui/llnotificationsutil.h +++ b/indra/llui/llnotificationsutil.h @@ -65,6 +65,8 @@ namespace LLNotificationsUtil S32 getSelectedOption(const LLSD& notification, const LLSD& response); void cancel(LLNotificationPtr pNotif); + + LLNotificationPtr find(LLUUID uuid); } #endif diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index f1e7e622b3..acbd0db868 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -51,9 +51,12 @@ #include "llslurl.h" #include "lllayoutstack.h" #include "llagent.h" +#include "llnotificationsutil.h" +#include "lltoastnotifypanel.h" #include "llviewerregion.h" #include "llworld.h" + #include "llsidetray.h"//for blocked objects panel static LLDefaultChildRegistry::Register r("chat_history"); @@ -654,8 +657,36 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL mLastMessageTimeStr = chat.mTimeStr; } - std::string message = irc_me ? chat.mText.substr(3) : chat.mText; - mEditor->appendText(message, FALSE, style_params); + if (chat.mNotifId.notNull()) + { + LLNotificationPtr notification = LLNotificationsUtil::find(chat.mNotifId); + if (notification != NULL) + { + LLToastNotifyPanel* notify_box = new LLToastNotifyPanel( + notification); + notify_box->setFollowsLeft(); + notify_box->setFollowsRight(); + //Prepare the rect for the view + LLRect target_rect = mEditor->getDocumentView()->getRect(); + // squeeze down the widget by subtracting padding off left and right + target_rect.mLeft += mLeftWidgetPad + mEditor->getHPad(); + target_rect.mRight -= mRightWidgetPad; + notify_box->reshape(target_rect.getWidth(), + notify_box->getRect().getHeight()); + notify_box->setOrigin(target_rect.mLeft, notify_box->getRect().mBottom); + + LLInlineViewSegment::Params params; + params.view = notify_box; + params.left_pad = mLeftWidgetPad; + params.right_pad = mRightWidgetPad; + mEditor->appendWidget(params, "\n", false); + } + } + else + { + std::string message = irc_me ? chat.mText.substr(3) : chat.mText; + mEditor->appendText(message, FALSE, style_params); + } mEditor->blockUndo(); // automatically scroll to end when receiving chat from myself diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index c0f22fcea2..c2bcb1cdf9 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -601,8 +601,18 @@ void LLIMFloater::updateMessages() chat.mFromID = from_id; chat.mSessionID = mSessionID; chat.mFromName = from; - chat.mText = message; chat.mTimeStr = time; + + // process offer notification + if (msg.has("notifiaction_id")) + { + chat.mNotifId = msg["notifiaction_id"].asUUID(); + } + //process text message + else + { + chat.mText = message; + } mChatHistory->appendMessage(chat, use_plain_text_chat_history); mLastMessageIndex = msg["index"].asInteger(); @@ -610,6 +620,13 @@ void LLIMFloater::updateMessages() } } +void LLIMFloater::reloadMessages() +{ + mChatHistory->clear(); + mLastMessageIndex = -1; + updateMessages(); +} + // static void LLIMFloater::onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ) { diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h index 0ca0325451..9552b30737 100644 --- a/indra/newview/llimfloater.h +++ b/indra/newview/llimfloater.h @@ -80,6 +80,7 @@ public: // get new messages from LLIMModel void updateMessages(); + void reloadMessages(); static void onSendMsg( LLUICtrl*, void*); void sendMsg(); diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h index e57674d31c..5f4768e321 100644 --- a/indra/newview/llnotificationhandler.h +++ b/indra/newview/llnotificationhandler.h @@ -276,6 +276,11 @@ public: */ static bool canSpawnIMSession(const LLNotificationPtr& notification); + /** + * Checks sufficient conditions to add notification toast panel IM floater. + */ + static bool canAddNotifPanelToIM(const LLNotificationPtr& notification); + /** * Checks if passed notification can create IM session and be written into it. * @@ -296,6 +301,11 @@ public: */ static void logToIMP2P(const LLNotificationPtr& notification); + /** + * Writes notification message to IM p2p session. + */ + static void logToIMP2P(const LLNotificationPtr& notification, bool to_file_only); + /** * Writes group notice notification message to IM group session. */ @@ -309,7 +319,7 @@ public: /** * Spawns IM session. */ - static void spawnIMSession(const std::string& name, const LLUUID& from_id); + static LLUUID spawnIMSession(const std::string& name, const LLUUID& from_id); /** * Returns name from the notification's substitution. @@ -319,6 +329,16 @@ public: * @param notification - Notification which substitution's name will be returned. */ static std::string getSubstitutionName(const LLNotificationPtr& notification); + + /** + * Adds notification panel to the IM floater. + */ + static void addNotifPanelToIM(const LLNotificationPtr& notification); + + /** + * Reloads IM floater messages. + */ + static void reloadIMFloaterMessages(const LLNotificationPtr& notification); }; } diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 02f948eca9..f9b3b7187a 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -39,6 +39,7 @@ #include "llagent.h" #include "llfloaterreg.h" #include "llnearbychat.h" +#include "llimfloater.h" using namespace LLNotificationsUI; @@ -90,6 +91,13 @@ bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification) || INVENTORY_DECLINED == notification->getName(); } +// static +bool LLHandlerUtil::canAddNotifPanelToIM(const LLNotificationPtr& notification) +{ + return OFFER_FRIENDSHIP == notification->getName(); +} + + // static bool LLHandlerUtil::canSpawnSessionAndLogToIM(const LLNotificationPtr& notification) { @@ -136,6 +144,12 @@ void LLHandlerUtil::logToIM(const EInstantMessage& session_type, // static void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) +{ + logToIMP2P(notification, false); +} + +// static +void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_file_only) { const std::string name = LLHandlerUtil::getSubstitutionName(notification); @@ -148,8 +162,16 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) { LLUUID from_id = notification->getPayload()["from_id"]; - logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(), - from_id, from_id); + if(to_file_only) + { + logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(), + LLUUID(), LLUUID()); + } + else + { + logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(), + from_id, from_id); + } } } @@ -191,7 +213,7 @@ void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChat } // static -void LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_id) +LLUUID LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_id) { LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id); @@ -199,8 +221,10 @@ void LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_i session_id); if (session == NULL) { - LLIMMgr::instance().addSession(name, IM_NOTHING_SPECIAL, from_id); + session_id = LLIMMgr::instance().addSession(name, IM_NOTHING_SPECIAL, from_id); } + + return session_id; } // static @@ -210,3 +234,49 @@ std::string LLHandlerUtil::getSubstitutionName(const LLNotificationPtr& notifica ? notification->getSubstitutions()["NAME"] : notification->getSubstitutions()["[NAME]"]; } + +// static +void LLHandlerUtil::addNotifPanelToIM(const LLNotificationPtr& notification) +{ + const std::string name = LLHandlerUtil::getSubstitutionName(notification); + LLUUID from_id = notification->getPayload()["from_id"]; + + LLUUID session_id = spawnIMSession(name, from_id); + // add offer to session + LLIMModel::LLIMSession * session = LLIMModel::getInstance()->findIMSession( + session_id); + llassert_always(session != NULL); + + LLSD offer; + offer["notifiaction_id"] = notification->getID(); + offer["from_id"] = notification->getPayload()["from_id"]; + offer["from"] = name; + offer["time"] = LLLogChat::timestamp(true); + session->mMsgs.push_front(offer); + + LLIMFloater::show(session_id); +} + +// static +void LLHandlerUtil::reloadIMFloaterMessages( + const LLNotificationPtr& notification) +{ + LLUUID from_id = notification->getPayload()["from_id"]; + LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id); + LLIMFloater* im_floater = LLFloaterReg::findTypedInstance( + "impanel", session_id); + if (im_floater != NULL) + { + LLIMModel::LLIMSession * session = LLIMModel::getInstance()->findIMSession( + session_id); + if(session != NULL) + { + session->mMsgs.clear(); + std::list chat_history; + LLLogChat::loadAllHistory(session->mHistoryFileName, chat_history); + session->addMessagesFromHistory(chat_history); + } + + im_floater->reloadMessages(); + } +} diff --git a/indra/newview/llnotificationofferhandler.cpp b/indra/newview/llnotificationofferhandler.cpp index fad0c6a91e..8c13b0fafa 100644 --- a/indra/newview/llnotificationofferhandler.cpp +++ b/indra/newview/llnotificationofferhandler.cpp @@ -93,7 +93,7 @@ bool LLOfferHandler::processNotification(const LLSD& notify) if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change") { - LLHandlerUtil::logToIMP2P(notification); + if( notification->getPayload().has("give_inventory_notification") && !notification->getPayload()["give_inventory_notification"] ) @@ -103,18 +103,25 @@ bool LLOfferHandler::processNotification(const LLSD& notify) } else { + LLUUID session_id; if (LLHandlerUtil::canSpawnIMSession(notification)) { const std::string name = LLHandlerUtil::getSubstitutionName(notification); LLUUID from_id = notification->getPayload()["from_id"]; - LLHandlerUtil::spawnIMSession(name, from_id); + session_id = LLHandlerUtil::spawnIMSession(name, from_id); } - if (notification->getPayload().has("SUPPRESS_TOAST") + if (LLHandlerUtil::canAddNotifPanelToIM(notification)) + { + LLHandlerUtil::addNotifPanelToIM(notification); + LLHandlerUtil::logToIMP2P(notification, true); + } + else if (notification->getPayload().has("SUPPRESS_TOAST") && notification->getPayload()["SUPPRESS_TOAST"]) { + LLHandlerUtil::logToIMP2P(notification); LLNotificationsUtil::cancel(notification); } else @@ -131,6 +138,8 @@ bool LLOfferHandler::processNotification(const LLSD& notify) if(channel) channel->addToast(p); + LLHandlerUtil::logToIMP2P(notification); + // send a signal to the counter manager mNewNotificationSignal(); } @@ -146,6 +155,10 @@ bool LLOfferHandler::processNotification(const LLSD& notify) } else { + if (LLHandlerUtil::canAddNotifPanelToIM(notification)) + { + LLHandlerUtil::reloadIMFloaterMessages(notification); + } mChannel->killToastByNotificationID(notification->getID()); } } diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp index 94acb2ae8c..4d741456c4 100644 --- a/indra/newview/lltoastnotifypanel.cpp +++ b/indra/newview/lltoastnotifypanel.cpp @@ -43,6 +43,7 @@ #include "lluiconstants.h" #include "llrect.h" #include "lltrans.h" +#include "llnotificationsutil.h" const S32 BOTTOM_PAD = VPAD * 3; S32 BUTTON_WIDTH = 90; @@ -235,6 +236,10 @@ LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_opt LLToastNotifyPanel::~LLToastNotifyPanel() { std::for_each(mBtnCallbackData.begin(), mBtnCallbackData.end(), DeletePointer()); + if (LLNotificationsUtil::find(mNotification->getID()) != NULL) + { + LLNotifications::getInstance()->cancel(mNotification); + } } void LLToastNotifyPanel::updateButtonsLayout(const std::vector& buttons, S32 left_pad, S32 top) { diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml index d2e5473157..9aaa660574 100644 --- a/indra/newview/skins/default/xui/en/floater_im_session.xml +++ b/indra/newview/skins/default/xui/en/floater_im_session.xml @@ -12,7 +12,7 @@ can_minimize="true" can_close="true" visible="false" - width="360" + width="440" can_resize="true" min_width="250" min_height="190"> @@ -20,7 +20,7 @@ animate="false" follows="all" height="320" - width="360" + width="440" layout="topleft" orientation="horizontal" name="im_panels" @@ -38,7 +38,7 @@ left="0" top="0" height="200" - width="245" + width="325" user_resize="true"> -- cgit v1.2.3 From 81451696f1de85e235818517c01b8d255d1bb661 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Fri, 29 Jan 2010 18:03:11 +0200 Subject: fixed EXT-4187 "X" does not close client after idle timeout / log off when "Confirm before I quit" is enabled --HG-- branch : product-engine --- indra/newview/llappviewer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 9bb0977c1a..2d694eefd3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2891,7 +2891,14 @@ static LLNotificationFunctorRegistration finish_quit_reg("ConfirmQuit", finish_q void LLAppViewer::userQuit() { - LLNotificationsUtil::add("ConfirmQuit"); + if (gDisconnected) + { + requestQuit(); + } + else + { + LLNotificationsUtil::add("ConfirmQuit"); + } } static bool finish_early_exit(const LLSD& notification, const LLSD& response) -- cgit v1.2.3 From 09c2f013623797a165a1cccd539a3a86f8a0027f Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Fri, 29 Jan 2010 19:20:33 +0200 Subject: Fixed bug EXT-4170 ([BSI] Object picker in "Report Abuse" floater fails to identify owner when object is an attachment). Reason: The floater attempted to render avatar name from the attached object ID. Of course, the attempt failed. Fix: Changed to use the avatar ID. --HG-- branch : product-engine --- indra/newview/llfloaterreporter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 4a1eb51dbe..0f3c176cea 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -248,6 +248,7 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) if ( objectp->isAttachment() ) { objectp = (LLViewerObject*)objectp->getRoot(); + mObjectID = objectp->getID(); } // correct the region and position information @@ -278,7 +279,7 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) object_owner.append("Unknown"); } - setFromAvatar(object_id, object_owner); + setFromAvatar(mObjectID, object_owner); } else { -- cgit v1.2.3 From fe90c259daab3a222a80e84db7b8a328d505a5a2 Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Fri, 29 Jan 2010 19:32:42 +0200 Subject: Fixed major bug EXT-4767 (Any docked/undocked window overlaps Gesture menu). - Changed adding of gestures scrolllist from NonSideTrayView to FloaterViewHolder. --HG-- branch : product-engine --- indra/newview/llnearbychatbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index 6cf8bcb417..ad98a29fb2 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -97,9 +97,9 @@ LLGestureComboList::LLGestureComboList(const LLGestureComboList::Params& p) mList = LLUICtrlFactory::create(params); - // *HACK: adding list as a child to NonSideTrayView to make it fully visible without + // *HACK: adding list as a child to FloaterViewHolder to make it fully visible without // making it top control (because it would cause problems). - gViewerWindow->getNonSideTrayView()->addChild(mList); + gViewerWindow->getFloaterViewHolder()->addChild(mList); mList->setVisible(FALSE); //****************************Gesture Part********************************/ -- cgit v1.2.3 From ea7915c2aee486dfb3b7e29016c67a0c4a49cb0f Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Fri, 29 Jan 2010 19:52:52 +0200 Subject: Fixed bug EXT-4437 ([BSI] console warning flood when viewing profile) by suppressing duplicated warnings. --HG-- branch : product-engine --- indra/newview/llviewerparcelmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index c537865937..9d7ccd99c6 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1814,7 +1814,7 @@ void LLViewerParcelMgr::processParcelAccessListReply(LLMessageSystem *msg, void if (parcel_id != parcel->getLocalID()) { - llwarns << "processParcelAccessListReply for parcel " << parcel_id + LL_WARNS_ONCE("") << "processParcelAccessListReply for parcel " << parcel_id << " which isn't the selected parcel " << parcel->getLocalID()<< llendl; return; } -- cgit v1.2.3 From 3b34147ceafa02849fa3275e11ac2ae6a55c33a3 Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 29 Jan 2010 19:55:41 +0200 Subject: Fixed low bug EXT-4721(Green border around multi-selected people) --HG-- branch : product-engine --- indra/llui/llflatlistview.cpp | 35 +++++++++-------------------------- indra/llui/llflatlistview.h | 2 -- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 3694ecd4f4..92993650a7 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -289,8 +289,8 @@ void LLFlatListView::resetSelection(bool no_commit_on_deselection /*= false*/) onCommit(); } - // Stretch selected items rect to ensure it won't be clipped - mSelectedItemsBorder->setRect(getSelectedItemsRect().stretch(-1)); + // Stretch selected item rect to ensure it won't be clipped + mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); } void LLFlatListView::setNoItemsCommentText(const std::string& comment_text) @@ -393,7 +393,7 @@ LLFlatListView::LLFlatListView(const LLFlatListView::Params& p) LLViewBorder::Params params; params.name("scroll border"); - params.rect(getSelectedItemsRect()); + params.rect(getLastSelectedItemRect()); params.visible(false); params.bevel_style(LLViewBorder::BEVEL_IN); mSelectedItemsBorder = LLUICtrlFactory::create (params); @@ -480,8 +480,8 @@ void LLFlatListView::rearrangeItems() item_new_top -= (rc.getHeight() + mItemPad); } - // Stretch selected items rect to ensure it won't be clipped - mSelectedItemsBorder->setRect(getSelectedItemsRect().stretch(-1)); + // Stretch selected item rect to ensure it won't be clipped + mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); } void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask) @@ -664,8 +664,8 @@ bool LLFlatListView::selectItemPair(item_pair_t* item_pair, bool select) onCommit(); } - // Stretch selected items rect to ensure it won't be clipped - mSelectedItemsBorder->setRect(getSelectedItemsRect().stretch(-1)); + // Stretch selected item rect to ensure it won't be clipped + mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); return true; } @@ -680,23 +680,6 @@ LLRect LLFlatListView::getLastSelectedItemRect() return mSelectedItemPairs.back()->first->getRect(); } -LLRect LLFlatListView::getSelectedItemsRect() -{ - if (!mSelectedItemPairs.size()) - { - return LLRect::null; - } - LLRect rc = getLastSelectedItemRect(); - for ( pairs_const_iterator_t - it = mSelectedItemPairs.begin(), - it_end = mSelectedItemPairs.end(); - it != it_end; ++it ) - { - rc.unionWith((*it)->first->getRect()); - } - return rc; -} - void LLFlatListView::selectFirstItem () { selectItemPair(mItemPairs.front(), true); @@ -819,8 +802,8 @@ bool LLFlatListView::selectAll() onCommit(); } - // Stretch selected items rect to ensure it won't be clipped - mSelectedItemsBorder->setRect(getSelectedItemsRect().stretch(-1)); + // Stretch selected item rect to ensure it won't be clipped + mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); return true; } diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index 5999e79f61..949a731507 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -368,8 +368,6 @@ protected: LLRect getLastSelectedItemRect(); - LLRect getSelectedItemsRect(); - void ensureSelectedVisible(); private: -- cgit v1.2.3 From d3eb0e9765460801829419b15693b1b00ee5d369 Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 29 Jan 2010 19:55:41 +0200 Subject: Fixed normal bug EXT-4697 (Buttons in bottom bar are compressed after quitting mouselook mode) and low bug EXT-4723 (Not all buttons are displayed on the bottom bar after leaving mouse look): - implemented the LLBottomTrayLite, which appears only in mouselook mode. --HG-- branch : product-engine --- indra/newview/llagent.cpp | 2 - indra/newview/llbottomtray.cpp | 173 +++++++++++---------- indra/newview/llbottomtray.h | 18 +-- .../skins/default/xui/en/panel_bottomtray.xml | 9 +- .../skins/default/xui/en/panel_bottomtray_lite.xml | 95 +++++++++++ 5 files changed, 199 insertions(+), 98 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/panel_bottomtray_lite.xml diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index da0e9238d6..2354323a66 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2805,7 +2805,6 @@ void LLAgent::endAnimationUpdateUI() LLNavigationBar::getInstance()->setVisible(TRUE); gStatusBar->setVisibleForMouselook(true); - LLBottomTray::getInstance()->setVisible(TRUE); LLBottomTray::getInstance()->onMouselookModeOut(); LLSideTray::getInstance()->getButtonsPanel()->setVisible(TRUE); @@ -2906,7 +2905,6 @@ void LLAgent::endAnimationUpdateUI() gStatusBar->setVisibleForMouselook(false); LLBottomTray::getInstance()->onMouselookModeIn(); - LLBottomTray::getInstance()->setVisible(FALSE); LLSideTray::getInstance()->getButtonsPanel()->setVisible(FALSE); LLSideTray::getInstance()->updateSidetrayVisibility(); diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index bd68d52868..a2d594cfa2 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -62,6 +62,39 @@ namespace const std::string& PANEL_GESTURE_NAME = "gesture_panel"; } +class LLBottomTrayLite + : public LLPanel +{ +public: + LLBottomTrayLite() + : mNearbyChatBar(NULL), + mGesturePanel(NULL) + { + mFactoryMap["chat_bar"] = LLCallbackMap(LLBottomTray::createNearbyChatBar, NULL); + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_bottomtray_lite.xml"); + // Necessary for focus movement among child controls + setFocusRoot(TRUE); + } + + BOOL postBuild() + { + mNearbyChatBar = getChild("chat_bar"); + mGesturePanel = getChild("gesture_panel"); + return TRUE; + } + + void onFocusLost() + { + if (gAgent.cameraMouselook()) + { + LLBottomTray::getInstance()->setVisible(FALSE); + } + } + + LLNearbyChatBar* mNearbyChatBar; + LLPanel* mGesturePanel; +}; + LLBottomTray::LLBottomTray(const LLSD&) : mChicletPanel(NULL), mSpeakPanel(NULL), @@ -76,6 +109,8 @@ LLBottomTray::LLBottomTray(const LLSD&) , mSnapshotPanel(NULL) , mGesturePanel(NULL) , mCamButton(NULL) +, mBottomTrayLite(NULL) +, mIsInLiteMode(false) { // Firstly add ourself to IMSession observers, so we catch session events // before chiclets do that. @@ -100,6 +135,12 @@ LLBottomTray::LLBottomTray(const LLSD&) // Necessary for focus movement among child controls setFocusRoot(TRUE); + + { + mBottomTrayLite = new LLBottomTrayLite(); + mBottomTrayLite->setFollowsAll(); + mBottomTrayLite->setVisible(FALSE); + } } LLBottomTray::~LLBottomTray() @@ -134,6 +175,11 @@ void* LLBottomTray::createNearbyChatBar(void* userdata) return new LLNearbyChatBar(); } +LLNearbyChatBar* LLBottomTray::getNearbyChatBar() +{ + return mIsInLiteMode ? mBottomTrayLite->mNearbyChatBar : mNearbyChatBar; +} + LLIMChiclet* LLBottomTray::createIMChiclet(const LLUUID& session_id) { LLIMChiclet::EType im_chiclet_type = LLIMChiclet::getIMSessionType(session_id); @@ -237,68 +283,27 @@ void LLBottomTray::onChange(EStatusType status, const std::string &channelURI, b mSpeakBtn->setEnabled(enable); } -//virtual -void LLBottomTray::onFocusLost() +void LLBottomTray::onMouselookModeOut() { - if (gAgent.cameraMouselook()) - { - setVisible(FALSE); - } + mIsInLiteMode = false; + mBottomTrayLite->setVisible(FALSE); + mNearbyChatBar->getChatBox()->setText(mBottomTrayLite->mNearbyChatBar->getChatBox()->getText()); + setVisible(TRUE); } -void LLBottomTray::savePanelsShape() +void LLBottomTray::onMouselookModeIn() { - mSavedShapeList.clear(); - for (child_list_const_iter_t - child_it = mToolbarStack->beginChild(), - child_it_end = mToolbarStack->endChild(); - child_it != child_it_end; ++child_it) - { - mSavedShapeList.push_back( (*child_it)->getRect() ); - } -} + setVisible(FALSE); -void LLBottomTray::restorePanelsShape() -{ - if (mSavedShapeList.size() != mToolbarStack->getChildCount()) - return; - int i = 0; - for (child_list_const_iter_t - child_it = mToolbarStack->beginChild(), - child_it_end = mToolbarStack->endChild(); - child_it != child_it_end; ++child_it) - { - (*child_it)->setShape(mSavedShapeList[i++]); - } -} + // Attach the lite bottom tray + if (getParent() && mBottomTrayLite->getParent() != getParent()) + getParent()->addChild(mBottomTrayLite); -void LLBottomTray::onMouselookModeOut() -{ - // Apply the saved settings when we are not in mouselook mode, see EXT-3988. - { - setTrayButtonVisibleIfPossible (RS_BUTTON_GESTURES, gSavedSettings.getBOOL("ShowGestureButton"), false); - setTrayButtonVisibleIfPossible (RS_BUTTON_MOVEMENT, gSavedSettings.getBOOL("ShowMoveButton"), false); - setTrayButtonVisibleIfPossible (RS_BUTTON_CAMERA, gSavedSettings.getBOOL("ShowCameraButton"), false); - setTrayButtonVisibleIfPossible (RS_BUTTON_SNAPSHOT, gSavedSettings.getBOOL("ShowSnapshotButton"),false); - } - // HACK: To avoid usage the LLLayoutStack logic of resizing, we force the updateLayout - // and then restore children saved shapes. See EXT-4309. - BOOL saved_anim = mToolbarStack->getAnimate(); - mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, FALSE); - // Disable animation to prevent layout updating in several frames. - mToolbarStack->setAnimate(FALSE); - // Force the updating of layout to reset panels collapse factor. - mToolbarStack->updateLayout(); - // Restore animate state. - mToolbarStack->setAnimate(saved_anim); - // Restore saved shapes. - restorePanelsShape(); -} + mBottomTrayLite->setShape(getLocalRect()); + mBottomTrayLite->mNearbyChatBar->getChatBox()->setText(mNearbyChatBar->getChatBox()->getText()); + mBottomTrayLite->mGesturePanel->setVisible(gSavedSettings.getBOOL("ShowGestureButton")); -void LLBottomTray::onMouselookModeIn() -{ - savePanelsShape(); - mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, TRUE); + mIsInLiteMode = true; } //virtual @@ -306,31 +311,14 @@ void LLBottomTray::onMouselookModeIn() // If bottom tray is already visible in mouselook mode, then onVisibilityChange will not be called from setVisible(true), void LLBottomTray::setVisible(BOOL visible) { - LLPanel::setVisible(visible); - - // *NOTE: we must check mToolbarStack against NULL because setVisible is called from the - // LLPanel::initFromParams BEFORE postBuild is called and child controls are not exist yet - if (NULL != mToolbarStack) + if (mIsInLiteMode) { - BOOL visibility = gAgent.cameraMouselook() ? false : true; - - for ( child_list_const_iter_t child_it = mToolbarStack->getChildList()->begin(); - child_it != mToolbarStack->getChildList()->end(); child_it++) - { - LLView* viewp = *child_it; - std::string name = viewp->getName(); - - // Chat bar and gesture button are shown even in mouselook mode. - // But the move, camera and snapshot buttons shouldn't be displayed. See EXT-3988. - if ("chat_bar" == name || "gesture_panel" == name || (visibility && ("movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name))) - continue; - else - { - viewp->setVisible(visibility); - } - } + mBottomTrayLite->setVisible(visible); + } + else + { + LLPanel::setVisible(visible); } - if(visible) gFloaterView->setSnapOffsetBottom(getRect().getHeight()); else @@ -535,7 +523,18 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) if (mChicletPanel && mToolbarStack && mNearbyChatBar) { - mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); + // Firstly, update layout stack to ensure we deal with correct panel sizes. + { + BOOL saved_anim = mToolbarStack->getAnimate(); + // Set chiclet panel to be autoresized by default. + mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); + // Disable animation to prevent layout updating in several frames. + mToolbarStack->setAnimate(FALSE); + // Force the updating of layout to reset panels collapse factor. + mToolbarStack->updateLayout(); + // Restore animate state. + mToolbarStack->setAnimate(saved_anim); + } // bottom tray is narrowed if (delta_width < 0) @@ -637,7 +636,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mNearbyChatBar->getRect().getHeight()); - log(mChicletPanel, "after processing panel decreasing via nearby chatbar panel"); + log(mNearbyChatBar, "after processing panel decreasing via nearby chatbar panel"); lldebugs << "RS_CHATBAR_INPUT" << ", delta_panel: " << delta_panel @@ -1057,6 +1056,11 @@ void LLBottomTray::initStateProcessedObjectMap() mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_MOVEMENT, mMovementPanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_CAMERA, mCamPanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_SNAPSHOT, mSnapshotPanel)); + + mDummiesMap.insert(std::make_pair(RS_BUTTON_GESTURES, getChild("after_gesture_panel"))); + mDummiesMap.insert(std::make_pair(RS_BUTTON_MOVEMENT, getChild("after_movement_panel"))); + mDummiesMap.insert(std::make_pair(RS_BUTTON_CAMERA, getChild("after_cam_panel"))); + mDummiesMap.insert(std::make_pair(RS_BUTTON_SPEAK, getChild("after_speak_panel"))); } void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible) @@ -1069,6 +1073,11 @@ void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool vis } panel->setVisible(visible); + + if (mDummiesMap.count(shown_object_type)) + { + mDummiesMap[shown_object_type]->setVisible(visible); + } } void LLBottomTray::setTrayButtonVisibleIfPossible(EResizeState shown_object_type, bool visible, bool raise_notification) @@ -1084,6 +1093,8 @@ void LLBottomTray::setTrayButtonVisibleIfPossible(EResizeState shown_object_type return; } + const S32 dummy_width = mDummiesMap.count(shown_object_type) ? mDummiesMap[shown_object_type]->getRect().getWidth() : 0; + const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); @@ -1093,7 +1104,7 @@ void LLBottomTray::setTrayButtonVisibleIfPossible(EResizeState shown_object_type const S32 available_width = (chatbar_panel_width - chatbar_panel_min_width) + (chiclet_panel_width - chiclet_panel_min_width); - const S32 required_width = panel->getRect().getWidth(); + const S32 required_width = panel->getRect().getWidth() + dummy_width; can_be_set = available_width >= required_width; } diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 562ee56912..ee0eb13218 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -46,6 +46,7 @@ class LLNotificationChiclet; class LLSpeakButton; class LLNearbyChatBar; class LLIMChiclet; +class LLBottomTrayLite; // Build time optimization, generate once in .cpp file #ifndef LLBOTTOMTRAY_CPP @@ -60,13 +61,14 @@ class LLBottomTray { LOG_CLASS(LLBottomTray); friend class LLSingleton; + friend class LLBottomTrayLite; public: ~LLBottomTray(); BOOL postBuild(); LLChicletPanel* getChicletPanel() {return mChicletPanel;} - LLNearbyChatBar* getNearbyChatBar() {return mNearbyChatBar;} + LLNearbyChatBar* getNearbyChatBar(); void onCommitGesture(LLUICtrl* ctrl); @@ -79,7 +81,6 @@ public: virtual void reshape(S32 width, S32 height, BOOL called_from_parent); - virtual void onFocusLost(); virtual void setVisible(BOOL visible); // Implements LLVoiceClientStatusObserver::onChange() to enable the speak @@ -172,13 +173,6 @@ private: */ void setTrayButtonVisibleIfPossible(EResizeState shown_object_type, bool visible, bool raise_notification = true); - /** - * Save and restore children shapes. - * Used to avoid the LLLayoutStack resizing logic between mouse look mode switching. - */ - void savePanelsShape(); - void restorePanelsShape(); - MASK mResizeState; typedef std::map state_object_map_t; @@ -187,8 +181,8 @@ private: typedef std::map state_object_width_map_t; state_object_width_map_t mObjectDefaultWidthMap; - typedef std::vector shape_list_t; - shape_list_t mSavedShapeList; + typedef std::map dummies_map_t; + dummies_map_t mDummiesMap; protected: @@ -214,6 +208,8 @@ protected: LLPanel* mGesturePanel; LLButton* mCamButton; LLButton* mMovementButton; + LLBottomTrayLite* mBottomTrayLite; + bool mIsInLiteMode; }; #endif // LL_LLBOTTOMPANEL_H diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index 09ec2137b7..aad55685d2 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -87,7 +87,7 @@ image_name="spacer24.tga" layout="topleft" left="0" - name="DUMMY" + name="after_speak_panel" min_width="3" top="0" width="3"/> @@ -127,7 +127,7 @@ layout="topleft" left="0" min_width="3" - name="DUMMY" + name="after_gesture_panel" top="0" width="3"/> + + + + + + + + + + + + -- cgit v1.2.3 From 4fa3577b04e7a02b549ef8375c658632aecf630f Mon Sep 17 00:00:00 2001 From: Dmitry Zaporozhan Date: Fri, 29 Jan 2010 18:51:51 +0200 Subject: Fixed LLGroupIcon to receive LLGroupManager callbacks. --HG-- branch : product-engine --- indra/newview/llgroupiconctrl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp index 0b03d49cbc..5760242bc8 100644 --- a/indra/newview/llgroupiconctrl.cpp +++ b/indra/newview/llgroupiconctrl.cpp @@ -94,6 +94,7 @@ void LLGroupIconCtrl::setValue(const LLSD& value) if (mGroupId != value.asUUID()) { mGroupId = value.asUUID(); + mID = mGroupId; // set LLGroupMgrObserver::mID to make callbacks work // Check if cache already contains image_id for that group if (!updateFromCache()) -- cgit v1.2.3 From a328cdc83015a46a87377ad3c822c730c03026a3 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 29 Jan 2010 17:34:44 +0000 Subject: EXT-4493: Mark snapshot as dirty when changing quality slider. --- indra/newview/llfloatersnapshot.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 94c7ff6f94..a0031f0193 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -378,6 +378,7 @@ void LLSnapshotLivePreview::setSnapshotQuality(S32 quality) { mSnapshotQuality = quality; gSavedSettings.setS32("SnapshotQuality", quality); + mSnapshotUpToDate = FALSE; } } -- cgit v1.2.3 From 092f93b0c1084edf68fc0536aa03a3c7b816505b Mon Sep 17 00:00:00 2001 From: Dmitry Zaporozhan Date: Fri, 29 Jan 2010 19:40:46 +0200 Subject: Fixed normal bug EXT-2124 - [BSI] New notifications of group chat messages do not identify the destination group chat of message. --HG-- branch : product-engine --- indra/newview/lltoastimpanel.cpp | 88 ++++++++++++++++++---- indra/newview/lltoastimpanel.h | 6 ++ .../skins/default/xui/en/panel_instant_message.xml | 10 +++ 3 files changed, 91 insertions(+), 13 deletions(-) diff --git a/indra/newview/lltoastimpanel.cpp b/indra/newview/lltoastimpanel.cpp index 89a58cd736..a436dc0546 100644 --- a/indra/newview/lltoastimpanel.cpp +++ b/indra/newview/lltoastimpanel.cpp @@ -33,7 +33,10 @@ #include "llviewerprecompiledheaders.h" #include "lltoastimpanel.h" +#include "llagent.h" #include "llfloaterreg.h" +#include "llgroupactions.h" +#include "llgroupiconctrl.h" #include "llnotifications.h" #include "llinstantmessage.h" #include "lltooltip.h" @@ -45,11 +48,12 @@ const S32 LLToastIMPanel::DEFAULT_MESSAGE_MAX_LINE_COUNT = 6; //-------------------------------------------------------------------------- LLToastIMPanel::LLToastIMPanel(LLToastIMPanel::Params &p) : LLToastPanel(p.notification), mAvatarIcon(NULL), mAvatarName(NULL), - mTime(NULL), mMessage(NULL) + mTime(NULL), mMessage(NULL), mGroupIcon(NULL) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_instant_message.xml"); LLIconCtrl* sys_msg_icon = getChild("sys_msg_icon"); + mGroupIcon = getChild("group_icon"); mAvatarIcon = getChild("avatar_icon"); mAvatarName = getChild("user_name"); mTime = getChild("time_box"); @@ -86,17 +90,26 @@ LLToastIMPanel::LLToastIMPanel(LLToastIMPanel::Params &p) : LLToastPanel(p.notif mAvatarID = p.avatar_id; mNotification = p.notification; + mAvatarIcon->setVisible(FALSE); + mGroupIcon->setVisible(FALSE); + sys_msg_icon->setVisible(FALSE); + if(p.from == SYSTEM_FROM) { - mAvatarIcon->setVisible(FALSE); sys_msg_icon->setVisible(TRUE); } else { - mAvatarIcon->setVisible(TRUE); - sys_msg_icon->setVisible(FALSE); - - mAvatarIcon->setValue(p.avatar_id); + if(LLGroupActions::isInGroup(mSessionID)) + { + mGroupIcon->setVisible(TRUE); + mGroupIcon->setValue(p.session_id); + } + else + { + mAvatarIcon->setVisible(TRUE); + mAvatarIcon->setValue(p.avatar_id); + } } S32 maxLinesCount; @@ -128,11 +141,39 @@ BOOL LLToastIMPanel::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLToastIMPanel::handleToolTip(S32 x, S32 y, MASK mask) { // It's not our direct child, so parentPointInView() doesn't work. - LLRect name_rect; - mAvatarName->localRectToOtherView(mAvatarName->getLocalRect(), &name_rect, this); - if (!name_rect.pointInRect(x, y)) - return LLToastPanel::handleToolTip(x, y, mask); + LLRect ctrl_rect; + + mAvatarName->localRectToOtherView(mAvatarName->getLocalRect(), &ctrl_rect, this); + if (ctrl_rect.pointInRect(x, y)) + { + spawnNameToolTip(); + return TRUE; + } + + mGroupIcon->localRectToOtherView(mGroupIcon->getLocalRect(), &ctrl_rect, this); + if(mGroupIcon->getVisible() && ctrl_rect.pointInRect(x, y)) + { + spawnGroupIconToolTip(); + return TRUE; + } + + return LLToastPanel::handleToolTip(x, y, mask); +} + +void LLToastIMPanel::showInspector() +{ + if(LLGroupActions::isInGroup(mSessionID)) + { + LLFloaterReg::showInstance("inspect_group", LLSD().with("group_id", mSessionID)); + } + else + { + LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mAvatarID)); + } +} +void LLToastIMPanel::spawnNameToolTip() +{ // Spawn at right side of the name textbox. LLRect sticky_rect = mAvatarName->calcScreenRect(); S32 icon_x = llmin(sticky_rect.mLeft + mAvatarName->getTextPixelWidth() + 3, sticky_rect.mRight - 16); @@ -149,10 +190,31 @@ BOOL LLToastIMPanel::handleToolTip(S32 x, S32 y, MASK mask) params.sticky_rect(sticky_rect); LLToolTipMgr::getInstance()->show(params); - return TRUE; } -void LLToastIMPanel::showInspector() +void LLToastIMPanel::spawnGroupIconToolTip() { - LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mAvatarID)); + // Spawn at right bottom side of group icon. + LLRect sticky_rect = mGroupIcon->calcScreenRect(); + LLCoordGL pos(sticky_rect.mRight, sticky_rect.mBottom); + + LLGroupData g_data; + if(!gAgent.getGroupData(mSessionID, g_data)) + { + llwarns << "Error getting group data" << llendl; + } + + LLInspector::Params params; + params.fillFrom(LLUICtrlFactory::instance().getDefaultParams()); + params.click_callback(boost::bind(&LLToastIMPanel::showInspector, this)); + params.delay_time(0.100f); + params.image(LLUI::getUIImage("Info_Small")); + params.message(g_data.mName); + params.padding(3); + params.pos(pos); + params.max_width(300); + + LLToolTipMgr::getInstance()->show(params); } + +// EOF diff --git a/indra/newview/lltoastimpanel.h b/indra/newview/lltoastimpanel.h index 154e6dae16..444c0af144 100644 --- a/indra/newview/lltoastimpanel.h +++ b/indra/newview/lltoastimpanel.h @@ -39,6 +39,7 @@ #include "llbutton.h" #include "llavatariconctrl.h" +class LLGroupIconCtrl; class LLToastIMPanel: public LLToastPanel { @@ -61,12 +62,17 @@ public: /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask); private: void showInspector(); + + void spawnNameToolTip(); + void spawnGroupIconToolTip(); + static const S32 DEFAULT_MESSAGE_MAX_LINE_COUNT; LLNotificationPtr mNotification; LLUUID mSessionID; LLUUID mAvatarID; LLAvatarIconCtrl* mAvatarIcon; + LLGroupIconCtrl* mGroupIcon; LLTextBox* mAvatarName; LLTextBox* mTime; LLTextBox* mMessage; diff --git a/indra/newview/skins/default/xui/en/panel_instant_message.xml b/indra/newview/skins/default/xui/en/panel_instant_message.xml index 7204e57479..5a1bc32db0 100644 --- a/indra/newview/skins/default/xui/en/panel_instant_message.xml +++ b/indra/newview/skins/default/xui/en/panel_instant_message.xml @@ -35,6 +35,16 @@ name="avatar_icon" top="3" width="18" /> + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_attachment_self.xml b/indra/newview/skins/default/xui/fr/menu_attachment_self.xml new file mode 100644 index 0000000000..999a1c156c --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_attachment_self.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_avatar_icon.xml b/indra/newview/skins/default/xui/fr/menu_avatar_icon.xml index 8f3dfae86e..3bac25c79b 100644 --- a/indra/newview/skins/default/xui/fr/menu_avatar_icon.xml +++ b/indra/newview/skins/default/xui/fr/menu_avatar_icon.xml @@ -1,6 +1,6 @@ - + diff --git a/indra/newview/skins/default/xui/fr/menu_avatar_other.xml b/indra/newview/skins/default/xui/fr/menu_avatar_other.xml new file mode 100644 index 0000000000..289912cd05 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_avatar_other.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_avatar_self.xml b/indra/newview/skins/default/xui/fr/menu_avatar_self.xml new file mode 100644 index 0000000000..82945cf96e --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_avatar_self.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_bottomtray.xml b/indra/newview/skins/default/xui/fr/menu_bottomtray.xml index 46db635afd..3229940980 100644 --- a/indra/newview/skins/default/xui/fr/menu_bottomtray.xml +++ b/indra/newview/skins/default/xui/fr/menu_bottomtray.xml @@ -4,4 +4,9 @@ + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_im_well_button.xml b/indra/newview/skins/default/xui/fr/menu_im_well_button.xml new file mode 100644 index 0000000000..8ef1529e6b --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_im_well_button.xml @@ -0,0 +1,4 @@ + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_imchiclet_adhoc.xml b/indra/newview/skins/default/xui/fr/menu_imchiclet_adhoc.xml new file mode 100644 index 0000000000..4d9a103058 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_imchiclet_adhoc.xml @@ -0,0 +1,4 @@ + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_imchiclet_p2p.xml b/indra/newview/skins/default/xui/fr/menu_imchiclet_p2p.xml index b1683ffcd0..ecc8cee413 100644 --- a/indra/newview/skins/default/xui/fr/menu_imchiclet_p2p.xml +++ b/indra/newview/skins/default/xui/fr/menu_imchiclet_p2p.xml @@ -1,6 +1,6 @@ - + diff --git a/indra/newview/skins/default/xui/fr/menu_inspect_avatar_gear.xml b/indra/newview/skins/default/xui/fr/menu_inspect_avatar_gear.xml index 9a4926b678..39ba4b1074 100644 --- a/indra/newview/skins/default/xui/fr/menu_inspect_avatar_gear.xml +++ b/indra/newview/skins/default/xui/fr/menu_inspect_avatar_gear.xml @@ -7,6 +7,7 @@ + diff --git a/indra/newview/skins/default/xui/fr/menu_inventory.xml b/indra/newview/skins/default/xui/fr/menu_inventory.xml index d6da4b5557..5276aa5b7e 100644 --- a/indra/newview/skins/default/xui/fr/menu_inventory.xml +++ b/indra/newview/skins/default/xui/fr/menu_inventory.xml @@ -46,6 +46,9 @@ + + + @@ -56,10 +59,9 @@ + - - - + diff --git a/indra/newview/skins/default/xui/fr/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/fr/menu_inventory_gear_default.xml index 5fe7a215a4..91bccfd699 100644 --- a/indra/newview/skins/default/xui/fr/menu_inventory_gear_default.xml +++ b/indra/newview/skins/default/xui/fr/menu_inventory_gear_default.xml @@ -9,4 +9,6 @@ + + diff --git a/indra/newview/skins/default/xui/fr/menu_land.xml b/indra/newview/skins/default/xui/fr/menu_land.xml new file mode 100644 index 0000000000..80cc49aa42 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_land.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_login.xml b/indra/newview/skins/default/xui/fr/menu_login.xml index ac262a75e6..fc42b02908 100644 --- a/indra/newview/skins/default/xui/fr/menu_login.xml +++ b/indra/newview/skins/default/xui/fr/menu_login.xml @@ -23,10 +23,8 @@ - - - - + + diff --git a/indra/newview/skins/default/xui/fr/menu_notification_well_button.xml b/indra/newview/skins/default/xui/fr/menu_notification_well_button.xml new file mode 100644 index 0000000000..323bfdbf16 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_notification_well_button.xml @@ -0,0 +1,4 @@ + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_object.xml b/indra/newview/skins/default/xui/fr/menu_object.xml new file mode 100644 index 0000000000..b6775661ad --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_object.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_participant_list.xml b/indra/newview/skins/default/xui/fr/menu_participant_list.xml index 96d9a003cd..c8f5b5f1ad 100644 --- a/indra/newview/skins/default/xui/fr/menu_participant_list.xml +++ b/indra/newview/skins/default/xui/fr/menu_participant_list.xml @@ -1,5 +1,20 @@ + + + + + + + + + - + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_people_groups.xml b/indra/newview/skins/default/xui/fr/menu_people_groups.xml new file mode 100644 index 0000000000..eb51b4cf7e --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_people_groups.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_people_nearby.xml b/indra/newview/skins/default/xui/fr/menu_people_nearby.xml index 946063dda2..d48be969f4 100644 --- a/indra/newview/skins/default/xui/fr/menu_people_nearby.xml +++ b/indra/newview/skins/default/xui/fr/menu_people_nearby.xml @@ -7,4 +7,5 @@ + diff --git a/indra/newview/skins/default/xui/fr/menu_profile_overflow.xml b/indra/newview/skins/default/xui/fr/menu_profile_overflow.xml index 61a346c6af..4bb9fa19a8 100644 --- a/indra/newview/skins/default/xui/fr/menu_profile_overflow.xml +++ b/indra/newview/skins/default/xui/fr/menu_profile_overflow.xml @@ -2,4 +2,8 @@ + + + + diff --git a/indra/newview/skins/default/xui/fr/menu_viewer.xml b/indra/newview/skins/default/xui/fr/menu_viewer.xml index 9639e8415d..272fcfdae6 100644 --- a/indra/newview/skins/default/xui/fr/menu_viewer.xml +++ b/indra/newview/skins/default/xui/fr/menu_viewer.xml @@ -9,7 +9,7 @@ - + @@ -25,36 +25,30 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + @@ -125,21 +119,20 @@ - + - + - @@ -333,7 +326,6 @@ - @@ -366,6 +358,7 @@ + @@ -383,7 +376,7 @@ - + @@ -410,7 +403,6 @@ - diff --git a/indra/newview/skins/default/xui/fr/mime_types_linux.xml b/indra/newview/skins/default/xui/fr/mime_types_linux.xml new file mode 100644 index 0000000000..fc5e7ad659 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/mime_types_linux.xml @@ -0,0 +1,217 @@ + + + + + + Cette parcelle propose du contenu web + + + Afficher le contenu web + + + + + + Vous pouvez jouer un film ici + + + Jouer le film + + + + + + Cette parcelle contient une image + + + Afficher l'image qui se trouve ici + + + + + + Cette parcelle propose du contenu audio + + + Jouer le contenu audio qui se trouve ici + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/mime_types_mac.xml b/indra/newview/skins/default/xui/fr/mime_types_mac.xml new file mode 100644 index 0000000000..fc5e7ad659 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/mime_types_mac.xml @@ -0,0 +1,217 @@ + + + + + + Cette parcelle propose du contenu web + + + Afficher le contenu web + + + + + + Vous pouvez jouer un film ici + + + Jouer le film + + + + + + Cette parcelle contient une image + + + Afficher l'image qui se trouve ici + + + + + + Cette parcelle propose du contenu audio + + + Jouer le contenu audio qui se trouve ici + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml index dd277c9d37..6d7aef6389 100644 --- a/indra/newview/skins/default/xui/fr/notifications.xml +++ b/indra/newview/skins/default/xui/fr/notifications.xml @@ -32,10 +32,10 @@ @@ -105,7 +105,7 @@ - Show IMs in: (Requires restart) + Show IMs in: + + (requires restart) + @@ -365,7 +366,7 @@ name="device_settings_panel" class="panel_voice_device_settings" width="501" - top="285"> + top="280"> Default -- cgit v1.2.3 From 0bbb95c84be891f95be1c4c1ce7ea5aa14bed815 Mon Sep 17 00:00:00 2001 From: Eli Linden Date: Fri, 29 Jan 2010 17:46:35 -0800 Subject: DEV-43688 Cycle3 JA (correct version) --- .../skins/default/xui/ja/floater_buy_currency.xml | 388 ++++----------------- 1 file changed, 65 insertions(+), 323 deletions(-) diff --git a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml index d202bf1b9f..ffdcf838d3 100644 --- a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml +++ b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml @@ -1,324 +1,66 @@ - - - - Buy L$ [LINDENS] for approx. [LOCALAMOUNT] - - - - You need more L$ - - - Contacting LindeX... - - - Buy L$ - - - I have - - - L$ [AMT] - - - I want to buy - - - L$ - - - 1234 - - - For the price - - - approx. [LOCALAMOUNT] - - - Estimating... - - - [NAME] L$ [PRICE] - - - My new balance will be - - - L$ [AMT] - - - [http://www.secondlife.com/my/account/payment_method_management.php payment method] | [http://www.secondlife.com/my/account/currency.php currency] | [http://www.secondlife.com/my/account/exchange_rates.php exchange rate] - - -Re-enter amount to see the latest exchange rate. - - - Confirming this purchase only buys L$, not the object. - - - You aren't buying enough L$. Please increase the amount. - - - + -