]> git.lyx.org Git - features.git/commitdiff
better mouse pointer handling, actualy makes sense now
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 14 Apr 2000 19:20:33 +0000 (19:20 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 14 Apr 2000 19:20:33 +0000 (19:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@658 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/WorkArea.C
src/bufferview_funcs.C

index 49851cc60081da52f3b8bbba024d233ea77704bf..b1eef145062d8b2c875ad840d352654da4fce804 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2000-04-14  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * src/WorkArea.C (work_area_handler): call BufferView::enterView
+       and Buffer::leaveView when FL_ENTER and FL_LEAVE.
+
+       * src/BufferView.C (enterView): new func
+       (leaveView): new func
+
+       * src/BufferView_pimpl.C (enterView): new func, sets xterm cursor
+       when approp.
+       (leaveView): new func, undefines xterm cursor when approp.
+
+       * src/bufferview_funcs.C: moved SetXCursor to BufferView_pimp.C
+       (AllowInput): delete the Workarea cursor handling from this func.
+
        * src/Painter.C (underline): draw a slimer underline in most cases.
 
        * src/lyx_main.C (error_handler): use extern "C"
index 148c7bbd44b9fe86831b341405d7c697b99dc493..a8db202cfa1ee19e03e79b3b51f5c81cdf8558b4 100644 (file)
@@ -148,6 +148,18 @@ void BufferView::upCB(long time, int button)
 }
 
 
+void BufferView::enterView()
+{
+       pimpl_->enterView();
+}
+
+
+void BufferView::leaveView()
+{
+       pimpl_->leaveView();
+}
+
+
 // Callback for scrollbar slider
 void BufferView::scrollCB(double value)
 {
index d9d92636aa89d14a4449620918c76ed2569e140a..cc44535382886183b7d5ba430f3c76f79f61df42 100644 (file)
@@ -218,6 +218,10 @@ public:
        ///
        void tripleClick(int x, int y, unsigned int button);
        ///
+       void enterView();
+       ///
+       void leaveView();
+       ///
        void workAreaSelectionNotify(Window win, XEvent * event);
 private:
        struct Pimpl;
index 8ca4cc9a05e141d0992a5b7693d51116ad5deea3..7c5689c8cf6e68f6c6d17b1f5447db91a3456926 100644 (file)
@@ -51,6 +51,21 @@ void waitForX()
 }
 
 
+static
+void SetXtermCursor(Window win)
+{
+       static Cursor cursor;
+       static bool cursor_undefined = true;
+       if (cursor_undefined){
+               cursor = XCreateFontCursor(fl_display, XC_xterm);
+               XFlush(fl_display);
+               cursor_undefined = false;
+       }
+       XDefineCursor(fl_display, win, cursor);
+       XFlush(fl_display);
+}
+
+
 BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
             int xpos, int ypos, int width, int height)
        : bv_(b), owner_(o)
@@ -65,6 +80,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
        workarea->setFocus();
        work_area_focus = true;
        lyx_focus = false;
+       using_xterm_cursor = false;
 }
 
 
@@ -747,6 +763,24 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
 }
 
 
+void BufferView::Pimpl::enterView()
+{
+       if (active() && available()) {
+               SetXtermCursor(workarea->getWin());
+               using_xterm_cursor = true;
+       }
+}
+
+
+void BufferView::Pimpl::leaveView()
+{
+       if (using_xterm_cursor) {
+               XUndefineCursor(fl_display, workarea->getWin());
+               using_xterm_cursor = false;
+       }
+}
+
+
 void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button)
 {
        if (buffer_ == 0 || screen == 0) return;
index c0d09c806bec4eb67dfdda84c9134a88b61d5477..60ae84c7438c40577e48e245fc3e296bb8c6c92a 100644 (file)
@@ -77,6 +77,10 @@ struct BufferView::Pimpl {
        ///
        void tripleClick(int x, int y, unsigned int button);
        ///
+       void enterView();
+       ///
+       void leaveView();
+       ///
        void cursorToggle();
        ///
        void cursorPrevious();
@@ -142,5 +146,7 @@ struct BufferView::Pimpl {
        WorkArea * workarea;
        ///
        UpdateInset updatelist;
+private:
+       bool using_xterm_cursor;
 };
 #endif
index f306e63550926dc83ef5027793d833b696261ed0..5b71a2a692279d6227a9c8c6d79680cda1df3fb4 100644 (file)
@@ -428,9 +428,11 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
                break;
        case FL_ENTER:
                lyxerr.debug() << "Workarea event: ENTER" << endl;
+               area->owner->enterView();
                break;
        case FL_LEAVE:
                lyxerr.debug() << "Workarea event: LEAVE" << endl;
+               area->owner->leaveView();
                break;
        case FL_DBLCLICK:
                if (!ev) break;
index e3f9f0a73422101a54d68cc99e5b6b2e565773cf..e4d2f5205e14440a4cb84067aca69180b605a796 100644 (file)
@@ -17,21 +17,6 @@ extern FD_form_paragraph * fd_form_paragraph;
 extern FD_form_character * fd_form_character;
 
 
-static
-void SetXtermCursor(Window win)
-{
-       static Cursor cursor;
-       static bool cursor_undefined = true;
-       if (cursor_undefined){
-               cursor = XCreateFontCursor(fl_display, XC_xterm);
-               XFlush(fl_display);
-               cursor_undefined = false;
-       }
-       XDefineCursor(fl_display, win, cursor);
-       XFlush(fl_display);
-}
-
-
 void Foot(BufferView * bv)
 {
        if (!bv->available()) 
@@ -190,10 +175,6 @@ void AllowInput(BufferView * bv)
                XUndefineCursor(fl_display,
                                fd_form_character->form_character->window);
 
-       // What to do about this? (Lgb)
-       if (bv->belowMouse())
-               SetXtermCursor(bv->owner()->getForm()->window);
-
        XFlush(fl_display);
        fl_activate_all_forms();
 }
@@ -258,8 +239,10 @@ string CurrentState(BufferView * bv)
                // font. (Asger)
                Buffer * buffer = bv->buffer();
                LyXFont font = bv->text->real_current_font;
-               LyXFont defaultfont = textclasslist.TextClass(buffer->
-                                                             params.textclass).defaultfont();
+               LyXFont const & defaultfont =
+                       textclasslist
+                       .TextClass(buffer->params.textclass)
+                       .defaultfont();
                font.reduce(defaultfont);
                state = _("Font: ") + font.stateText();
                // The paragraph depth
@@ -297,7 +280,6 @@ string CurrentState(BufferView * bv)
 }
 
 
-// candidate for move to BufferView
 /* -------> Does the actual toggle job of the XxxCB() calls above.
  * Also shows the current font state.
  */