On Thursday 05 December 2002 2:48 pm, John Levon wrote:
> On Thu, Dec 05, 2002 at 03:47:28PM +0100, Lars Gullik Bjønnes wrote:
> > | Then the code can stay as it is too, except XWorkArea sets I-beam
> > | cursor.
> >
> > I can live with that as well.
>
> OK. This should work just fine. Unfortunately I made the aI changes in
> my tree too, so we'll have to wait for a full compile until I can make
> you a patch for just this :)

Did you mean to attach a patch?

While your preparing your suggestion, here's mine. It does exactly the right 
thing and has the added benefit that we get a correctly coloured pointer for 
free (by using the xforms toolkit rather than raw X).

I'm very happy to use your approach, but would like to see the code so I can 
compare/contrast ;-)

Regards,
Angus
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.321
diff -u -p -r1.321 BufferView_pimpl.C
--- src/BufferView_pimpl.C	27 Nov 2002 10:30:03 -0000	1.321
+++ src/BufferView_pimpl.C	5 Dec 2002 14:41:15 -0000
@@ -933,6 +933,14 @@ bool BufferView::Pimpl::dispatch(FuncReq
 
 	switch (ev.action) {
 
+	case LFUN_MOUSE_ENTER:
+		owner_->setCursor(true);
+		break;
+
+	case LFUN_MOUSE_LEAVE:
+		owner_->setCursor(false);
+		break;
+
 	case LFUN_SCROLL_INSET:
 		// this is not handled here as this function is only active
 		// if we have a locking_inset and that one is (or contains)
Index: src/commandtags.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/commandtags.h,v
retrieving revision 1.104
diff -u -p -r1.104 commandtags.h
--- src/commandtags.h	29 Nov 2002 13:22:38 -0000	1.104
+++ src/commandtags.h	5 Dec 2002 14:41:15 -0000
@@ -283,6 +283,8 @@ enum kb_action {
 	LFUN_FORKS_KILL,                // Angus 16 Feb 2002
 	LFUN_TOOLTIPS_TOGGLE,           // Angus 8 Mar 2002
 	LFUN_INSET_OPTARG,				// Martin 12 Aug 2002
+	LFUN_MOUSE_ENTER,               // Angus 5 Dec 2002
+	LFUN_MOUSE_LEAVE,               // Angus 5 Dec 2002
 	LFUN_MOUSE_PRESS,               // André 9 Aug 2002
 	LFUN_MOUSE_MOTION,              // André 9 Aug 2002
 	LFUN_MOUSE_RELEASE,             // André 9 Aug 2002
Index: src/frontends/LyXView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.h,v
retrieving revision 1.18
diff -u -p -r1.18 LyXView.h
--- src/frontends/LyXView.h	1 Dec 2002 22:59:18 -0000	1.18
+++ src/frontends/LyXView.h	5 Dec 2002 14:41:15 -0000
@@ -71,6 +71,8 @@ public:
 	virtual void prohibitInput() const = 0;
 	/// end modal operation
 	virtual void allowInput() const = 0;
+	/// Toggles the cursor as we enter/leave the Work Area
+	virtual void setCursor(bool editing) const = 0;
 
 	//@{ generic accessor functions
 
Index: src/frontends/qt2/QtView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QtView.h,v
retrieving revision 1.7
diff -u -p -r1.7 QtView.h
--- src/frontends/qt2/QtView.h	20 Oct 2002 01:48:28 -0000	1.7
+++ src/frontends/qt2/QtView.h	5 Dec 2002 14:41:16 -0000
@@ -49,6 +49,8 @@ public:
 	virtual void prohibitInput() const;
 	/// end modal operation
 	virtual void allowInput() const;
+	/// FIXME. Not yet implemented.
+	virtual void setCursor(bool editing) const {}
 
 	/// display a status message
 	virtual void message(string const & str);
Index: src/frontends/xforms/XFormsView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsView.C,v
retrieving revision 1.26
diff -u -p -r1.26 XFormsView.C
--- src/frontends/xforms/XFormsView.C	30 Sep 2002 20:00:42 -0000	1.26
+++ src/frontends/xforms/XFormsView.C	5 Dec 2002 14:41:16 -0000
@@ -58,7 +58,8 @@ int C_XFormsView_atCloseMainFormCB(FL_FO
 
 XFormsView::XFormsView(int width, int height)
 	: LyXView(),
-	  icon_pixmap_(0), icon_mask_(0)
+	  icon_pixmap_(0), icon_mask_(0),
+	  editing_(false), input_prohibited_(false)
 {
 	create_form_form_main(width, height);
 	fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0);
@@ -121,6 +122,7 @@ void XFormsView::show(int x, int y, stri
 	}
 
 	fl_show_form(form, placement, FL_FULLBORDER, title.c_str());
+	fl_set_cursor(getForm()->window, FL_DEFAULT_CURSOR);
 
 	show_view_state();
 #if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
@@ -205,6 +207,16 @@ void XFormsView::show_view_state()
 }
 
 
+void  XFormsView::setCursor(bool editing) const
+{
+	editing_ = editing;
+	if (input_prohibited_)
+		return;
+	int const cursor = editing_ ? XC_xterm : FL_DEFAULT_CURSOR;
+	fl_set_cursor(getForm()->window, cursor);
+}
+
+
 // How should this actually work? Should it prohibit input in all BufferViews,
 // or just in the current one? If "just the current one", then it should be
 // placed in BufferView. If "all BufferViews" then LyXGUI (I think) should
@@ -214,20 +226,8 @@ void XFormsView::show_view_state()
 // "allowInput" as well.)
 void XFormsView::prohibitInput() const
 {
-	view()->hideCursor();
-
-	static Cursor cursor;
-	static bool cursor_undefined = true;
-
-	if (cursor_undefined) {
-		cursor = XCreateFontCursor(fl_get_display(), XC_watch);
-		XFlush(fl_get_display());
-		cursor_undefined = false;
-	}
-
-	/* set the cursor to the watch for all forms and the canvas */
-	XDefineCursor(fl_get_display(), getForm()->window, cursor);
-
+	input_prohibited_ = true;
+	fl_set_cursor(getForm()->window, XC_watch);
 	XFlush(fl_get_display());
 	fl_deactivate_all_forms();
 }
@@ -235,10 +235,10 @@ void XFormsView::prohibitInput() const
 
 void XFormsView::allowInput() const
 {
-	/* reset the cursor from the watch for all forms and the canvas */
-
-	XUndefineCursor(fl_get_display(), getForm()->window);
-
+	input_prohibited_ = false;
+	// Reset the cursor from the watch for all forms and the canvas
+	int const cursor = editing_ ? XC_xterm : FL_DEFAULT_CURSOR;
+	fl_set_cursor(getForm()->window, cursor);
 	XFlush(fl_get_display());
 	fl_activate_all_forms();
 }
Index: src/frontends/xforms/XFormsView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsView.h,v
retrieving revision 1.15
diff -u -p -r1.15 XFormsView.h
--- src/frontends/xforms/XFormsView.h	30 Sep 2002 20:00:42 -0000	1.15
+++ src/frontends/xforms/XFormsView.h	5 Dec 2002 14:41:16 -0000
@@ -51,6 +51,8 @@ public:
 	virtual void prohibitInput() const;
 	///
 	virtual void allowInput() const;
+	///
+	virtual void setCursor(bool editing) const;
 
 	/// callback for close event from window manager
 	static int atCloseMainFormCB(FL_FORM *, void *);
@@ -86,5 +88,9 @@ private:
 	Pixmap icon_pixmap_;
 	///
 	Pixmap icon_mask_;
+	/// Set by setCursor
+	mutable bool editing_;
+	/// Set by prohibitInput, allowInput
+	mutable bool input_prohibited_;
 };
 #endif
Index: src/frontends/xforms/XWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XWorkArea.C,v
retrieving revision 1.29
diff -u -p -r1.29 XWorkArea.C
--- src/frontends/xforms/XWorkArea.C	5 Dec 2002 12:26:08 -0000	1.29
+++ src/frontends/xforms/XWorkArea.C	5 Dec 2002 14:41:16 -0000
@@ -498,9 +498,11 @@ int XWorkArea::work_area_handler(FL_OBJE
 
 	case FL_ENTER:
 		lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl;
+		area->dispatch(FuncRequest(LFUN_MOUSE_ENTER));
 		break;
 	case FL_LEAVE:
 		lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl;
+		area->dispatch(FuncRequest(LFUN_MOUSE_LEAVE));
 		break;
 	case FL_DBLCLICK:
 		if (ev) {

Reply via email to