texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Patch: Qt mouse copy-on-select


From: Gubinelli Massimiliano
Subject: Re: [Texmacs-dev] Patch: Qt mouse copy-on-select
Date: Wed, 14 Oct 2009 12:20:31 +0200

Committed.

max


On 13 oct. 09, at 22:27, Norbert Nemec wrote:

Hi there,

attached is a patch that fixes the Qt mouse selection mechanism. The member variable "selection" is also removed as it is unnecessary.

(Btw: I checked for the problem that Joris encountered in the X11 code where clear_selection was always called right after set_selection if the application had been the owner already. Does not seem to be a problem in the Qt code. For me, the code works perfectly as it is now.)

Greetings,
Norbert
From b9a673eac0bbb75e31ef3213ddbd0b5e8bf3c69e Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Tue, 13 Oct 2009 21:22:08 +0100
Subject: [PATCH] Fix Qt mouse selection.

---
src/src/Plugins/Qt/qt_gui.cpp | 29 ++++++++++++ +----------------
src/src/Plugins/Qt/qt_gui.hpp         |    1 -
2 files changed, 13 insertions(+), 17 deletions(-)
mode change 100644 => 100755 src/plugins/asymptote/bin/perl-tm_asy

diff --git a/src/plugins/asymptote/bin/perl-tm_asy b/src/plugins/ asymptote/bin/perl-tm_asy
old mode 100644
new mode 100755
diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/ qt_gui.cpp
index 15b3ff0..0446e74 100755
--- a/src/src/Plugins/Qt/qt_gui.cpp
+++ b/src/src/Plugins/Qt/qt_gui.cpp
@@ -42,7 +42,7 @@ int timeout_time;
******************************************************************************/

qt_gui_rep::qt_gui_rep(int &argc, char **argv):
-  interrupted (false), selection (NULL)
+  interrupted (false)
{
  (void) argc; (void) argv;
  // argc= argc2;
@@ -146,19 +146,21 @@ bool
qt_gui_rep::set_selection (string key, tree t, string s) {
  selection_t (key)= copy (t);
  selection_s (key)= copy (s);
-  if (key == "primary") {
-    //if (is_nil (windows_l)) return false;
-    //Window win= windows_l->item;
-    if (selection != NULL) tm_delete_array (selection);
-    //XSetSelectionOwner (dpy, XA_PRIMARY, win, CurrentTime);
-    //if (XGetSelectionOwner(dpy, XA_PRIMARY)==None) return false;
-    selection= as_charp (s);

-    QClipboard *clipboard = QApplication::clipboard();
-    QString originalText = clipboard->text();

-    clipboard->setText(selection);
+  QClipboard *cb = QApplication::clipboard();
+  QClipboard::Mode mode;
+  if (key == "primary") {
+    mode= QClipboard::Clipboard;
+  } else if (key == "mouse" && cb->supportsSelection()) {
+    mode= QClipboard::Selection;
+  } else {
+    return true;
  }
+
+  char *selection = as_charp (s);
+  cb->setText(selection,mode);
+  tm_delete_array (selection);
  return true;
}

@@ -166,11 +168,6 @@ void
qt_gui_rep::clear_selection (string key) {
  selection_t->reset (key);
  selection_s->reset (key);
-  if ((key == "primary") && (selection != NULL)) {
-    tm_delete_array (selection);
-    // FIXME: should we do something with the pasteboard?
-    selection= NULL;
-  }
}

/ ****************************************************************************** diff --git a/src/src/Plugins/Qt/qt_gui.hpp b/src/src/Plugins/Qt/ qt_gui.hpp
index e0bb219..796be09 100755
--- a/src/src/Plugins/Qt/qt_gui.hpp
+++ b/src/src/Plugins/Qt/qt_gui.hpp
@@ -39,7 +39,6 @@ public:
  QTMGuiHelper *gui_helper;
  QTimer *updatetimer;

-  char*                  selection;
  hashmap<string,tree>   selection_t;
  hashmap<string,string> selection_s;

--
1.6.3.3

_______________________________________________
Texmacs-dev mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/texmacs-dev





reply via email to

[Prev in Thread] Current Thread [Next in Thread]