diff options
author | Armin Weatherwax | 2009-06-08 11:10:27 +0200 |
---|---|---|
committer | McCabe Maxsted | 2009-09-04 11:34:24 -0700 |
commit | 3f0082a9dda60432b8b759e09f19b495d9d5275c (patch) | |
tree | 989f5e10f9b9891ec7718b5ee2406582b6c0e352 /linden/indra/llui/lltexteditor.cpp | |
parent | Rebranded startup loading page to Imprudence (diff) | |
download | meta-impy-3f0082a9dda60432b8b759e09f19b495d9d5275c.zip meta-impy-3f0082a9dda60432b8b759e09f19b495d9d5275c.tar.gz meta-impy-3f0082a9dda60432b8b759e09f19b495d9d5275c.tar.bz2 meta-impy-3f0082a9dda60432b8b759e09f19b495d9d5275c.tar.xz |
Linux middle mouse button paste/primary selection support and gtk clipboard handler (fixes crashbug using synergy mouse-keyboard-clipboard-sharing over lan)
modified: linden/doc/contributions.txt
modified: linden/indra/llui/llclipboard.cpp
modified: linden/indra/llui/llclipboard.h
modified: linden/indra/llui/llfloater.cpp
modified: linden/indra/llui/llfloater.h
modified: linden/indra/llui/lllineeditor.cpp
modified: linden/indra/llui/lllineeditor.h
modified: linden/indra/llui/lltexteditor.cpp
modified: linden/indra/llui/lltexteditor.h
modified: linden/indra/llui/llview.cpp
modified: linden/indra/llui/llview.h
modified: linden/indra/llwindow/CMakeLists.txt
new file: linden/indra/llwindow/llmousehandler.cpp
modified: linden/indra/llwindow/llmousehandler.h
modified: linden/indra/llwindow/llwindow.cpp
modified: linden/indra/llwindow/llwindow.h
modified: linden/indra/llwindow/llwindowsdl.cpp
modified: linden/indra/llwindow/llwindowsdl.h
modified: linden/indra/newview/lltool.cpp
modified: linden/indra/newview/lltool.h
modified: linden/indra/newview/llviewertexteditor.cpp
modified: linden/indra/newview/llviewertexteditor.h
modified: linden/indra/newview/llviewerwindow.cpp
modified: linden/indra/newview/llviewerwindow.h
(cherry picked from commit 594f4830922f4294dda432fa748935adffaeed8f)
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 3813e76..95cce60 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -1203,6 +1203,18 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) | |||
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | 1205 | ||
1206 | BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
1207 | { | ||
1208 | setFocus( TRUE ); | ||
1209 | if( canPastePrimary() ) | ||
1210 | { | ||
1211 | setCursorAtLocalPos( x, y, TRUE ); | ||
1212 | pastePrimary(); | ||
1213 | } | ||
1214 | return TRUE; | ||
1215 | } | ||
1216 | |||
1217 | |||
1206 | BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) | 1218 | BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) |
1207 | { | 1219 | { |
1208 | BOOL handled = FALSE; | 1220 | BOOL handled = FALSE; |
@@ -1323,6 +1335,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1323 | 1335 | ||
1324 | setCursorAtLocalPos( x, y, TRUE ); | 1336 | setCursorAtLocalPos( x, y, TRUE ); |
1325 | endSelection(); | 1337 | endSelection(); |
1338 | |||
1339 | // take selection to primary clipboard | ||
1340 | updatePrimary(); | ||
1326 | } | 1341 | } |
1327 | 1342 | ||
1328 | if( !hasSelection() ) | 1343 | if( !hasSelection() ) |
@@ -1330,6 +1345,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1330 | handleMouseUpOverSegment( x, y, mask ); | 1345 | handleMouseUpOverSegment( x, y, mask ); |
1331 | } | 1346 | } |
1332 | 1347 | ||
1348 | // take selection to 'primary' clipboard | ||
1349 | updatePrimary(); | ||
1350 | |||
1333 | handled = TRUE; | 1351 | handled = TRUE; |
1334 | } | 1352 | } |
1335 | 1353 | ||
@@ -1392,8 +1410,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) | |||
1392 | // delay cursor flashing | 1410 | // delay cursor flashing |
1393 | resetKeystrokeTimer(); | 1411 | resetKeystrokeTimer(); |
1394 | 1412 | ||
1413 | // take selection to 'primary' clipboard | ||
1414 | updatePrimary(); | ||
1415 | |||
1395 | handled = TRUE; | 1416 | handled = TRUE; |
1396 | } | 1417 | } |
1418 | |||
1397 | return handled; | 1419 | return handled; |
1398 | } | 1420 | } |
1399 | 1421 | ||
@@ -1689,6 +1711,12 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) | |||
1689 | } | 1711 | } |
1690 | } | 1712 | } |
1691 | 1713 | ||
1714 | if( handled ) | ||
1715 | { | ||
1716 | // take selection to 'primary' clipboard | ||
1717 | updatePrimary(); | ||
1718 | } | ||
1719 | |||
1692 | return handled; | 1720 | return handled; |
1693 | } | 1721 | } |
1694 | 1722 | ||
@@ -1868,22 +1896,46 @@ BOOL LLTextEditor::canPaste() const | |||
1868 | return !mReadOnly && gClipboard.canPasteString(); | 1896 | return !mReadOnly && gClipboard.canPasteString(); |
1869 | } | 1897 | } |
1870 | 1898 | ||
1871 | |||
1872 | // paste from clipboard | 1899 | // paste from clipboard |
1873 | void LLTextEditor::paste() | 1900 | void LLTextEditor::paste() |
1874 | { | 1901 | { |
1875 | if (!canPaste()) | 1902 | bool is_primary = false; |
1903 | pasteHelper(is_primary); | ||
1904 | } | ||
1905 | |||
1906 | // paste from primary | ||
1907 | void LLTextEditor::pastePrimary() | ||
1908 | { | ||
1909 | bool is_primary = true; | ||
1910 | pasteHelper(is_primary); | ||
1911 | } | ||
1912 | |||
1913 | // paste from primary (itsprimary==true) or clipboard (itsprimary==false) | ||
1914 | void LLTextEditor::pasteHelper(bool is_primary) | ||
1915 | { | ||
1916 | bool can_paste_it; | ||
1917 | if (is_primary) | ||
1918 | can_paste_it = canPastePrimary(); | ||
1919 | else | ||
1920 | can_paste_it = canPaste(); | ||
1921 | |||
1922 | if (!can_paste_it) | ||
1876 | { | 1923 | { |
1877 | return; | 1924 | return; |
1878 | } | 1925 | } |
1879 | LLUUID source_id; | 1926 | LLUUID source_id; |
1880 | LLWString paste = gClipboard.getPasteWString(&source_id); | 1927 | LLWString paste; |
1928 | if (is_primary) | ||
1929 | paste = gClipboard.getPastePrimaryWString(&source_id); | ||
1930 | else | ||
1931 | paste = gClipboard.getPasteWString(&source_id); | ||
1932 | |||
1881 | if (paste.empty()) | 1933 | if (paste.empty()) |
1882 | { | 1934 | { |
1883 | return; | 1935 | return; |
1884 | } | 1936 | } |
1885 | // Delete any selected characters (the paste replaces them) | 1937 | // Delete any selected characters (the paste replaces them) |
1886 | if( hasSelection() ) | 1938 | if( (!is_primary) && hasSelection() ) |
1887 | { | 1939 | { |
1888 | deleteSelection(TRUE); | 1940 | deleteSelection(TRUE); |
1889 | } | 1941 | } |
@@ -1917,6 +1969,32 @@ void LLTextEditor::paste() | |||
1917 | } | 1969 | } |
1918 | 1970 | ||
1919 | 1971 | ||
1972 | |||
1973 | // copy selection to primary | ||
1974 | void LLTextEditor::copyPrimary() | ||
1975 | { | ||
1976 | if( !canCopy() ) | ||
1977 | { | ||
1978 | return; | ||
1979 | } | ||
1980 | S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); | ||
1981 | S32 length = abs( mSelectionStart - mSelectionEnd ); | ||
1982 | gClipboard.copyFromPrimarySubstring(mWText, left_pos, length, mSourceID); | ||
1983 | } | ||
1984 | |||
1985 | BOOL LLTextEditor::canPastePrimary() const | ||
1986 | { | ||
1987 | return !mReadOnly && gClipboard.canPastePrimaryString(); | ||
1988 | } | ||
1989 | |||
1990 | void LLTextEditor::updatePrimary() | ||
1991 | { | ||
1992 | if (canCopy()) | ||
1993 | { | ||
1994 | copyPrimary(); | ||
1995 | } | ||
1996 | } | ||
1997 | |||
1920 | BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) | 1998 | BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) |
1921 | { | 1999 | { |
1922 | BOOL handled = FALSE; | 2000 | BOOL handled = FALSE; |
@@ -1992,6 +2070,11 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) | |||
1992 | } | 2070 | } |
1993 | } | 2071 | } |
1994 | 2072 | ||
2073 | if (handled) | ||
2074 | { | ||
2075 | updatePrimary(); | ||
2076 | } | ||
2077 | |||
1995 | return handled; | 2078 | return handled; |
1996 | } | 2079 | } |
1997 | 2080 | ||