From 4e75a5cdfd897af12af8c0e927ada7315da81de8 Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Mon, 28 Mar 2011 18:39:37 -0700 Subject: 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 --- gtk/ScintillaGTK.cxx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'gtk') 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(GDK_ACTION_COPY | GDK_ACTION_MOVE)); -- cgit v1.2.3 From 37e46c39ed8edf42f438719963d2cf2bc84439cb Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Mon, 28 Mar 2011 23:12:47 -0700 Subject: Reset cursors when Scintilla widget is realized. Solves problem which occurs when Scintilla widget is unrealized and then re-realized and the cursor is left at GDK_XTERM even over the scrollbars. When the Scintilla widget is unrealized it's GdkWindows are destroyed and so the previous cursors are lost. This commit forces default cursors on the text and scrollbar windows when the widget is realized. References: http://www.mail-archive.com/scintilla-interest@lyra.org/msg01364.html http://git.geany.org/geany/tree/plugins/splitwindow.c#n310 http://www.mail-archive.com/geany@uvena.de/msg00821.html --- gtk/ScintillaGTK.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gtk') diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 42f9bc756..f36af2760 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -421,6 +421,18 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gtk_widget_realize(PWidget(scrollbarv)); gtk_widget_realize(PWidget(scrollbarh)); + cursor = gdk_cursor_new(GDK_XTERM); + gdk_window_set_cursor(PWidget(wText)->window, cursor); + gdk_cursor_unref(cursor); + + cursor = gdk_cursor_new(GDK_LEFT_PTR); + gdk_window_set_cursor(PWidget(scrollbarv)->window, cursor); + gdk_cursor_unref(cursor); + + cursor = gdk_cursor_new(GDK_LEFT_PTR); + gdk_window_set_cursor(PWidget(scrollbarh)->window, cursor); + gdk_cursor_unref(cursor); + gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); -- cgit v1.2.3 From f74871bda66e68fa8300e1cd7950671cb28e0605 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 30 Mar 2011 10:58:37 +1100 Subject: Removing empty lines. --- gtk/ScintillaGTK.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gtk') diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index f36af2760..117357668 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -435,7 +435,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); - #ifndef USE_GTK_CLIPBOARD gtk_selection_add_targets(widget, atomClipboard, clipboardPasteTargets, nClipboardPasteTargets); @@ -449,14 +448,11 @@ 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); } -- cgit v1.2.3