On 03/30/11 05:03, Nick Treleaven wrote:
On Tue, 29 Mar 2011 18:39:37 -0700
Matthew Brush<mbr...@codebrainz.ca>  wrote:

The patches were committed[1][2].

So now, can we patch our copy of Scintilla, or do we need to wait until
their next release and then until we update to that version?

We can patch our copy now.

Now that we have all our ducks in a row, I've attached two patches to re-add Windows support to the Split Window plugin.

#0001
Applies the patches merged upstream and puts copies of the two patches in the scintilla/ directory (not sure if this is needed).

#0002
The patch that was applied and removed previously on SVN, but I recommitted on my local (up to date) Git copy and re-worded the commit message a bit. Probably any of the older versions of this patch will work just the same.

In the meantime, I'll keep testing...at least in Linux.

Cheers,
Matthew Brush
>From 4711211ba80a6d88f5bf8a4be8b2216df275d1b2 Mon Sep 17 00:00:00 2001
From: Matthew Brush <matthewbr...@gmail.com>
Date: Wed, 30 Mar 2011 19:48:02 -0700
Subject: [PATCH 1/2] Apply patches needed to support re-releazing Scintilla widgets.

Patches needed to support unrealizing and re-realizing Scintilla
widgets in the Split Window plugin.  These changes were merged
upstream and will not be required in the future.
---
 .../0001-Fix-PRIMARY-selection-on-realize.patch    |   70 ++++++++++++++++++++
 scintilla/0002-Fix-cursors-on-realize.patch        |   40 +++++++++++
 scintilla/gtk/ScintillaGTK.cxx                     |   36 ++++++++--
 3 files changed, 138 insertions(+), 8 deletions(-)
 create mode 100644 scintilla/0001-Fix-PRIMARY-selection-on-realize.patch
 create mode 100644 scintilla/0002-Fix-cursors-on-realize.patch

diff --git a/scintilla/0001-Fix-PRIMARY-selection-on-realize.patch b/scintilla/0001-Fix-PRIMARY-selection-on-realize.patch
new file mode 100644
index 0000000..fe8a1e3
--- /dev/null
+++ b/scintilla/0001-Fix-PRIMARY-selection-on-realize.patch
@@ -0,0 +1,70 @@
+# HG changeset patch
+# User Matthew Brush <matthewbr...@gmail.com>
+# Date 1301362777 25200
+# Node ID f4b6785eea540df855dda717f1886d59758d1cc3
+# Parent  b4b219312338521cd5afd3f92c2cb314cd498727
+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
+
+diff -r b4b219312338 -r f4b6785eea54 gtk/ScintillaGTK.cxx
+--- a/gtk/ScintillaGTK.cxx	Sun Mar 27 12:57:55 2011 +1100
++++ b/gtk/ScintillaGTK.cxx	Mon Mar 28 18:39:37 2011 -0700
+@@ -420,6 +420,14 @@
+ 	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::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 @@
+ 
+ 	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));
diff --git a/scintilla/0002-Fix-cursors-on-realize.patch b/scintilla/0002-Fix-cursors-on-realize.patch
new file mode 100644
index 0000000..1502484
--- /dev/null
+++ b/scintilla/0002-Fix-cursors-on-realize.patch
@@ -0,0 +1,40 @@
+# HG changeset patch
+# User Matthew Brush <matthewbr...@gmail.com>
+# Date 1301379167 25200
+# Node ID b3677caa0e3e606346bbcd1a44988fee37bac254
+# Parent  f4b6785eea540df855dda717f1886d59758d1cc3
+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
+
+diff -r f4b6785eea54 -r b3677caa0e3e gtk/ScintillaGTK.cxx
+--- a/gtk/ScintillaGTK.cxx	Mon Mar 28 18:39:37 2011 -0700
++++ b/gtk/ScintillaGTK.cxx	Mon Mar 28 23:12:47 2011 -0700
+@@ -421,6 +421,18 @@
+ 	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);
+ 
diff --git a/scintilla/gtk/ScintillaGTK.cxx b/scintilla/gtk/ScintillaGTK.cxx
index c288488..1cf96b8 100644
--- a/scintilla/gtk/ScintillaGTK.cxx
+++ b/scintilla/gtk/ScintillaGTK.cxx
@@ -416,6 +416,26 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
 	gtk_widget_realize(widtxt);
 	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);
+
+#ifndef USE_GTK_CLIPBOARD
+	gtk_selection_add_targets(widget, atomClipboard,
+	                          clipboardPasteTargets, nClipboardPasteTargets);
+#endif
 }
 
 void ScintillaGTK::Realize(GtkWidget *widget) {
@@ -425,6 +445,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);
 		}
@@ -668,14 +696,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));
-- 
1.7.1

>From 386ea0d035d96f47ee3844ea86be9fad73afadcc Mon Sep 17 00:00:00 2001
From: Matthew Brush <matthewbr...@gmail.com>
Date: Wed, 30 Mar 2011 20:07:12 -0700
Subject: [PATCH 2/2] Remove widget reparenting in Split Window plugin.

Instead of reparenting the documents notebook full of
ScintillaObjects, ref it, remove it from the old parent, add
it to the new parent, and then unref it.  This should fix issues
using the Split Window plugin on Windows where the Scintilla
widget was leaving its windows in the wrong place after
reparenting.
---
 plugins/splitwindow.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c
index 561ae54..0852197 100644
--- a/plugins/splitwindow.c
+++ b/plugins/splitwindow.c
@@ -292,7 +292,6 @@ static GtkWidget *create_toolbar(void)
 	return toolbar;
 }
 
-
 static void split_view(gboolean horizontal)
 {
 	GtkWidget *notebook = geany_data->main_widgets->notebook;
@@ -307,14 +306,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();
@@ -358,10 +357,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)
 	{
@@ -372,7 +369,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

_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to