On 03/27/11 09:11, Colomban Wendling wrote:
We need a better fix then. Maybe you can try to find out why the X clipboard get broken on Scintilla (and fix it :D). If it get fixed, we will probably can re-apply the patch.
When the ScintillaObject gets reparented (unrealized/re-realized), it doesn't re-setup the selection targets again (this is only done in ScintillaGTK::Initialize()).
The first patch #0001 is the same as the previous #0003 patch, which removes the reparenting stuff, to make Split Window work on Windows.
The second patch #0002 fixes the primary selection issue by moving gtk_selection_add_targets() and friends into the ScintillaGTK::RealizeThis() function, and also adds its counter-parts to the ScintillaGTK::UnRealizeThis() function.
The third patch #0003 fixes the issue where the I-Beam cursor is displayed even for the scrollbars when the widget is unrealized/re-realized. I tried a few different ways to do this, including trying to use Scintilla's SetCursor() function, but nothing seemed to work.
Everything *seems* to work now, and it's not hacky, IMO - except maybe #0003 a little bit ;).
Cheers, Matthew Brush
>From 1eb6bc349514ef4446e03b61d9661e33c7cf9499 Mon Sep 17 00:00:00 2001 From: Matthew Brush <matthewbr...@gmail.com> Date: Wed, 16 Mar 2011 14:33:40 -0700 Subject: [PATCH 3/5] Remove widget reparenting in Split Window plugin. Instead of reparenting the documents notebook full of ScintillaObjects, just ref it, remove it from the old parent, add it to the new parent, and then unref it. This might fix issues with Split Window plugin on Windows and seems to have no issues on in Linux. --- plugins/splitwindow.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c index e357198..9117bf4 100644 --- a/plugins/splitwindow.c +++ b/plugins/splitwindow.c @@ -298,7 +298,6 @@ static GtkWidget *create_toolbar(void) return toolbar; } - static void split_view(gboolean horizontal) { GtkWidget *notebook = geany_data->main_widgets->notebook; @@ -313,14 +312,14 @@ static void split_view(gboolean horizontal) set_state(horizontal ? STATE_SPLIT_HORIZONTAL : STATE_SPLIT_VERTICAL); - /* temporarily put document notebook in main vbox (scintilla widgets must stay - * in a visible parent window, otherwise there are X selection and scrollbar issues) */ - gtk_widget_reparent(notebook, - ui_lookup_widget(geany->main_widgets->window, "vbox1")); + gtk_widget_ref(notebook); + gtk_container_remove(GTK_CONTAINER(parent), notebook); pane = horizontal ? gtk_hpaned_new() : gtk_vpaned_new(); gtk_container_add(GTK_CONTAINER(parent), pane); - gtk_widget_reparent(notebook, pane); + + gtk_container_add(GTK_CONTAINER(pane), notebook); + gtk_widget_unref(notebook); box = gtk_vbox_new(FALSE, 0); toolbar = create_toolbar(); @@ -364,10 +363,8 @@ static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data) g_return_if_fail(edit_window.editor); - /* temporarily put document notebook in main vbox (scintilla widgets must stay - * in a visible parent window, otherwise there are X selection and scrollbar issues) */ - gtk_widget_reparent(notebook, - ui_lookup_widget(geany->main_widgets->window, "vbox1")); + gtk_widget_ref(notebook); + gtk_container_remove(GTK_CONTAINER(pane), notebook); if (edit_window.sci != NULL && edit_window.handler_id > 0) { @@ -378,7 +375,9 @@ static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data) gtk_widget_destroy(pane); edit_window.editor = NULL; edit_window.sci = NULL; - gtk_widget_reparent(notebook, parent); + + gtk_container_add(GTK_CONTAINER(parent), notebook); + gtk_widget_unref(notebook); } -- 1.7.1
diff --git a/scintilla/gtk/ScintillaGTK.cxx b/scintilla/gtk/ScintillaGTK.cxx index c288488..1773e61 100644 --- a/scintilla/gtk/ScintillaGTK.cxx +++ b/scintilla/gtk/ScintillaGTK.cxx @@ -416,6 +416,18 @@ 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 + + gtk_drag_dest_set(widget, + GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets, + static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE)); } void ScintillaGTK::Realize(GtkWidget *widget) { @@ -425,6 +437,15 @@ 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 + + gtk_drag_dest_unset(widget); + if (IS_WIDGET_MAPPED(widget)) { gtk_widget_unmap(widget); } @@ -668,18 +689,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)); - // Set caret period based on GTK settings gboolean blinkOn = false; if (g_object_class_find_property(G_OBJECT_GET_CLASS(
diff --git a/scintilla/gtk/ScintillaGTK.cxx b/scintilla/gtk/ScintillaGTK.cxx index 1773e61..f91ce07 100644 --- a/scintilla/gtk/ScintillaGTK.cxx +++ b/scintilla/gtk/ScintillaGTK.cxx @@ -417,6 +417,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);
_______________________________________________ Geany-devel mailing list Geany-devel@uvena.de https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel