Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorDiego Borghetti <bdiego@gmail.com>2009-05-08 23:37:14 +0400
committerDiego Borghetti <bdiego@gmail.com>2009-05-08 23:37:14 +0400
commitcf8a37a3bb142a4ed8b7c7125092a408eea9fb10 (patch)
tree37090cc8845765bf19f954178f7cf445440d4720 /intern
parent1d11df17085bd4f1231a892089a0771887d155bb (diff)
Fix Copy & Paste not working inside Blender.
My last patch remove the code that check if Blender is the owner of the selection, that is why stop working.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp91
1 files changed, 55 insertions, 36 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 0fb4b735f97..e7e47a6bf38 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1182,49 +1182,68 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(int flag) const
//0 = Regular clipboard 1 = selection
// Options for where to get the selection from
- Atom sseln= flag ? m_clipboard : m_primary;
+ Atom sseln= flag ? m_primary : m_clipboard;
Atom target= m_string;
+ Window owner;
// from xclip.c doOut() v0.11
- unsigned char *sel_buf; /* buffer for selection data */
- unsigned long sel_len= 0; /* length of sel_buf */
- XEvent evt; /* X Event Structures */
+ unsigned char *sel_buf;
+ unsigned long sel_len= 0;
+ XEvent evt;
unsigned int context= XCLIB_XCOUT_NONE;
- if (sseln == m_string)
- sel_buf= (unsigned char *)XFetchBuffer(m_display, (int *)&sel_len, 0);
- else {
- while (1) {
- /* only get an event if xcout() is doing something */
- if (context != XCLIB_XCOUT_NONE)
- XNextEvent(m_display, &evt);
-
- /* fetch the selection, or part of it */
- getClipboard_xcout(evt, sseln, target, &sel_buf, &sel_len, &context);
-
- /* fallback is needed. set XA_STRING to target and restart the loop. */
- if (context == XCLIB_XCOUT_FALLBACK) {
- context= XCLIB_XCOUT_NONE;
- target= m_string;
- continue;
- }
- else if (context == XCLIB_XCOUT_FALLBACK_UTF8) {
- /* utf8 fail, move to compouned text. */
- context= XCLIB_XCOUT_NONE;
- target= m_compound_text;
- continue;
- }
- else if (context == XCLIB_XCOUT_FALLBACK_COMP) {
- /* compouned text faile, move to text. */
- context= XCLIB_XCOUT_NONE;
- target= m_text;
- continue;
- }
+ vector<GHOST_IWindow *> & win_vec = m_windowManager->getWindows();
+ vector<GHOST_IWindow *>::iterator win_it = win_vec.begin();
+ GHOST_WindowX11 * window = static_cast<GHOST_WindowX11 *>(*win_it);
+ Window win = window->getXWindow();
- /* only continue if xcout() is doing something */
- if (context == XCLIB_XCOUT_NONE)
- break;
+ /* check if we are the owner. */
+ owner= XGetSelectionOwner(m_display, sseln);
+ if (owner == win) {
+ if (sseln == m_clipboard) {
+ sel_buf= (unsigned char *)malloc(strlen(txt_cut_buffer)+1);
+ strcpy((char *)sel_buf, txt_cut_buffer);
+ return((GHOST_TUns8*)sel_buf);
}
+ else {
+ sel_buf= (unsigned char *)malloc(strlen(txt_select_buffer)+1);
+ strcpy((char *)sel_buf, txt_select_buffer);
+ return((GHOST_TUns8*)sel_buf);
+ }
+ }
+ else if (owner == None)
+ return(NULL);
+
+ while (1) {
+ /* only get an event if xcout() is doing something */
+ if (context != XCLIB_XCOUT_NONE)
+ XNextEvent(m_display, &evt);
+
+ /* fetch the selection, or part of it */
+ getClipboard_xcout(evt, sseln, target, &sel_buf, &sel_len, &context);
+
+ /* fallback is needed. set XA_STRING to target and restart the loop. */
+ if (context == XCLIB_XCOUT_FALLBACK) {
+ context= XCLIB_XCOUT_NONE;
+ target= m_string;
+ continue;
+ }
+ else if (context == XCLIB_XCOUT_FALLBACK_UTF8) {
+ /* utf8 fail, move to compouned text. */
+ context= XCLIB_XCOUT_NONE;
+ target= m_compound_text;
+ continue;
+ }
+ else if (context == XCLIB_XCOUT_FALLBACK_COMP) {
+ /* compouned text faile, move to text. */
+ context= XCLIB_XCOUT_NONE;
+ target= m_text;
+ continue;
+ }
+
+ /* only continue if xcout() is doing something */
+ if (context == XCLIB_XCOUT_NONE)
+ break;
}
if (sel_len) {