From f2044aeec772031b8e0d5ab5b26b3e810d93b0dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 14 Apr 2000 19:20:33 +0000 Subject: [PATCH] better mouse pointer handling, actualy makes sense now git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@658 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 13 +++++++++++++ src/BufferView.C | 12 ++++++++++++ src/BufferView.h | 4 ++++ src/BufferView_pimpl.C | 34 ++++++++++++++++++++++++++++++++++ src/BufferView_pimpl.h | 6 ++++++ src/WorkArea.C | 2 ++ src/bufferview_funcs.C | 26 ++++---------------------- 7 files changed, 75 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49851cc600..b1eef14506 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2000-04-14 Lars Gullik Bjønnes + * 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" diff --git a/src/BufferView.C b/src/BufferView.C index 148c7bbd44..a8db202cfa 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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) { diff --git a/src/BufferView.h b/src/BufferView.h index d9d92636aa..cc44535382 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -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; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 8ca4cc9a05..7c5689c8cf 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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; diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index c0d09c806b..60ae84c743 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -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 diff --git a/src/WorkArea.C b/src/WorkArea.C index f306e63550..5b71a2a692 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -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; diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index e3f9f0a734..e4d2f5205e 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -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. */ -- 2.39.2