Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3034 from jhsrennie/win_paste

Move paste code to g_Windowing
  • Loading branch information...
commit 8bc7c1a9019f24d98db23413d41311878e2c911e 2 parents df91888 + 30f8944
John Rennie authored
View
21 xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
@@ -753,26 +753,7 @@ void CGUIDialogKeyboardGeneric::OnPasteClipboard(void)
CStdStringW pasted_text;
// Get text from the clipboard
-#if defined(TARGET_DARWIN_OSX)
- const char *szStr = Cocoa_Paste();
- if (szStr)
- pasted_text = szStr;
-#elif defined TARGET_WINDOWS
- if (OpenClipboard(NULL))
- {
- HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
- if (hglb != NULL)
- {
- LPWSTR lpwstr = (LPWSTR) GlobalLock(hglb);
- if (lpwstr != NULL)
- {
- pasted_text = lpwstr;
- GlobalUnlock(hglb);
- }
- }
- CloseClipboard();
- }
-#endif
+ pasted_text = g_Windowing.GetClipboard();
// Insert the pasted text at the current cursor position.
if (pasted_text.length() > 0)
View
37 xbmc/guilib/GUIEditControl.cpp
@@ -27,6 +27,7 @@
#include "Key.h"
#include "LocalizeStrings.h"
#include "XBDateTime.h"
+#include "windowing/WindowingFactory.h"
#include "utils/md5.h"
#if defined(TARGET_DARWIN)
@@ -577,29 +578,21 @@ void CGUIEditControl::OnSMSCharacter(unsigned int key)
void CGUIEditControl::OnPasteClipboard()
{
-#if defined(TARGET_DARWIN_OSX)
- const char *szStr = Cocoa_Paste();
- if (szStr)
- {
- m_text2 += szStr;
- m_cursorPos+=strlen(szStr);
- UpdateText();
- }
-#elif defined TARGET_WINDOWS
- if (OpenClipboard(g_hWnd))
+ CStdStringW pasted_text;
+
+// Get text from the clipboard
+ pasted_text = g_Windowing.GetClipboard();
+
+ // Insert the pasted text at the current cursor position.
+ if (pasted_text.length() > 0)
{
- HGLOBAL hglb = GetClipboardData(CF_TEXT);
- if (hglb != NULL)
- {
- LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
- if (lptstr != NULL)
- {
- m_text2 = (char*)lptstr;
- GlobalUnlock(hglb);
- }
- }
- CloseClipboard();
+ CStdStringW left_end = m_text2.Left(m_cursorPos);
+ CStdStringW right_end = m_text2.Right(m_text2.length() - m_cursorPos);
+
+ m_text2 = left_end;
+ m_text2.append(pasted_text);
+ m_text2.append(right_end);
+ m_cursorPos += pasted_text.length();
UpdateText();
}
-#endif
}
View
5 xbmc/windowing/WinSystem.cpp
@@ -235,3 +235,8 @@ bool CWinSystemBase::UseLimitedColor()
return false;
#endif
}
+
+CStdStringW CWinSystemBase::GetClipboard(void)
+{
+ return "";
+}
View
2  xbmc/windowing/WinSystem.h
@@ -108,6 +108,8 @@ class CWinSystemBase
virtual void EnableTextInput(bool bEnable) {}
virtual bool IsTextInputEnabled() { return false; }
+ CStdStringW GetClipboard(void);
+
protected:
void UpdateDesktopResolution(RESOLUTION_INFO& newRes, int screen, int width, int height, float refreshRate, uint32_t dwFlags = 0);
View
2  xbmc/windowing/osx/WinSystemOSX.h
@@ -69,6 +69,8 @@ class CWinSystemOSX : public CWinSystemBase
void* GetCGLContextObj();
+ CStdStringW GetClipboard(void);
+
protected:
void* CreateWindowedContext(void* shareCtx);
void* CreateFullScreenContext(int screen_index, void* shareCtx);
View
11 xbmc/windowing/osx/WinSystemOSX.mm
@@ -1626,4 +1626,15 @@ static void DisplayReconfigured(CGDirectDisplayID display,
return [(NSOpenGLContext*)m_glContext CGLContextObj];
}
+CStdStringW CWinSystemOSX::GetClipboard(void)
+{
+ CStdStringW pasted_text;
+
+ const char *szStr = Cocoa_Paste();
+ if (szStr)
+ pasted_text = szStr;
+
+ return pasted_text;
+}
+
#endif
View
22 xbmc/windowing/windows/WinSystemWin32DX.cpp
@@ -98,4 +98,26 @@ bool CWinSystemWin32DX::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, boo
return true;
}
+CStdStringW CWinSystemWin32DX::GetClipboard(void)
+{
+ CStdStringW pasted_text;
+
+ if (OpenClipboard(NULL))
+ {
+ HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
+ if (hglb != NULL)
+ {
+ LPWSTR lpwstr = (LPWSTR) GlobalLock(hglb);
+ if (lpwstr != NULL)
+ {
+ pasted_text = lpwstr;
+ GlobalUnlock(hglb);
+ }
+ }
+ CloseClipboard();
+ }
+
+ return pasted_text;
+}
+
#endif
View
2  xbmc/windowing/windows/WinSystemWin32DX.h
@@ -45,6 +45,8 @@ class CWinSystemWin32DX : public CWinSystemWin32, public CRenderSystemDX
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays);
virtual bool WindowedMode() { return CRenderSystemDX::m_useWindowedDX; }
+ CStdStringW GetClipboard(void);
+
protected:
virtual void UpdateMonitor();
bool UseWindowedDX(bool fullScreen);
Please sign in to comment.
Something went wrong with that request. Please try again.