aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Brush <matthewbrush@gmail.com>2011-03-28 18:39:37 -0700
committerMatthew Brush <matthewbrush@gmail.com>2011-03-28 18:39:37 -0700
commit176aacfd488b45e198bb88c219f3193515bbd822 (patch)
tree8a1ca56fd5407d9c64e663ef756affca0f27598d
parentf88ad3864ccdf534e46cc004b377b2c08d318a04 (diff)
downloadscintilla-mirror-176aacfd488b45e198bb88c219f3193515bbd822.tar.gz
Fix X PRIMARY selection issue when Scintilla widget is unrealized/re-realized.
When the widget is unrealized (for ex. with gtk_container_remove), the GdkWindows used in the widget are destroyed and when the widget is realized again (for ex. with gtk_container_add), the GdkWindows are re-created. This commit moves the gtk_selection_add_targets() calls into the RealizeThis function, so that when the widget is realized again, the selection targets are re-added on the new GdkWindow. Also add gtk_selection_clear_targets() into UnRealizeThis to remove the registered targets before the GdkWindow is destroyed. References: http://mail.gnome.org/archives/gtk-devel-list/2002-March/msg00078.html http://mail.gnome.org/archives/anjuta-devel-list/2002-March/msg00066.html http://git.geany.org/geany/tree/plugins/splitwindow.c#n310
-rw-r--r--gtk/ScintillaGTK.cxx24
1 files changed, 16 insertions, 8 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 55ce3f7d1..42f9bc756 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -420,6 +420,14 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
gtk_widget_realize(widtxt);
gtk_widget_realize(PWidget(scrollbarv));
gtk_widget_realize(PWidget(scrollbarh));
+
+ gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY,
+ clipboardCopyTargets, nClipboardCopyTargets);
+
+#ifndef USE_GTK_CLIPBOARD
+ gtk_selection_add_targets(widget, atomClipboard,
+ clipboardPasteTargets, nClipboardPasteTargets);
+#endif
}
void ScintillaGTK::Realize(GtkWidget *widget) {
@@ -429,6 +437,14 @@ void ScintillaGTK::Realize(GtkWidget *widget) {
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
try {
+
+ gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY);
+
+#ifndef USE_GTK_CLIPBOARD
+ gtk_selection_clear_targets(widget, atomClipboard);
+#endif
+
+
if (IS_WIDGET_MAPPED(widget)) {
gtk_widget_unmap(widget);
}
@@ -670,14 +686,6 @@ void ScintillaGTK::Initialise() {
gtk_widget_grab_focus(PWidget(wMain));
- gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
- clipboardCopyTargets, nClipboardCopyTargets);
-
-#ifndef USE_GTK_CLIPBOARD
- gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), atomClipboard,
- clipboardPasteTargets, nClipboardPasteTargets);
-#endif
-
gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)),
GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE));