Re: Selection bug/feature



Roy Wood wrote:

I think the problem is a little more straight forward: if you unrealize the window (destroying the window), you lose the X selection. Roy: is the Anjuta code actually unmapping/unrealizing the window, like you described in your email? If so, then that is your problem.


What happens is that Anjuta takes the notebook widget containing the Scintilla widgets, does a gtk_container_remove() to remove the notebook from the current window, creates an hpaned widget, and then does a gtk_container_add() to add the notebook back into the new hpaned widget. I've traced through the code, and the Scintilla widgets have their unmap and unrealize handlers called, which is not surprising. And when they are added to the hpaned widget, the map/realize handlers are also called. Note that the widget itself isn't destroyed-- it just changes containers.

Tracing through the gtk/gdk selection code, it appears to use some combination of the widget pointer as well as the associated window, which is where things break. For example, if I try to do a new copy and claim the clipboard, gtk/gdk notices that I am still the same widget, and still own the clipboard, so it doesn't modify its internal data structures. However, when I request the clipboard, gtk/gdk uses the window reference to try to find me, which doesn't work.

Any thoughts there then?

The X selection is used for clipboard handling, and X selections are held by a particular window (in this case, the GdkWindow corresponding to the Scintilla widget, which gets destroyed when it gets unrealized). When porting to 2.0, Scintilla can probably be converted to use the new GtkClipboard code, which manages a selection for you (so the selection doesn't die when you window dies) and is easier to use. For now, would it be possible for you to use gtk_widget_reparent() instead? If the hpaned is already shown, you reparenting the scintilla widget shouldn't destroy its GdkWindow.

James.





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