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
This commit is contained in:
Lars Gullik Bjønnes 2000-04-14 19:20:33 +00:00
parent 36e819ef14
commit f2044aeec7
7 changed files with 75 additions and 22 deletions

View File

@ -1,5 +1,18 @@
2000-04-14 Lars Gullik Bjønnes <larsbj@lyx.org> 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/Painter.C (underline): draw a slimer underline in most cases.
* src/lyx_main.C (error_handler): use extern "C" * src/lyx_main.C (error_handler): use extern "C"

View 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 // Callback for scrollbar slider
void BufferView::scrollCB(double value) void BufferView::scrollCB(double value)
{ {

View File

@ -218,6 +218,10 @@ public:
/// ///
void tripleClick(int x, int y, unsigned int button); void tripleClick(int x, int y, unsigned int button);
/// ///
void enterView();
///
void leaveView();
///
void workAreaSelectionNotify(Window win, XEvent * event); void workAreaSelectionNotify(Window win, XEvent * event);
private: private:
struct Pimpl; struct Pimpl;

View 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, BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
int xpos, int ypos, int width, int height) int xpos, int ypos, int width, int height)
: bv_(b), owner_(o) : bv_(b), owner_(o)
@ -65,6 +80,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
workarea->setFocus(); workarea->setFocus();
work_area_focus = true; work_area_focus = true;
lyx_focus = false; 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) void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button)
{ {
if (buffer_ == 0 || screen == 0) return; if (buffer_ == 0 || screen == 0) return;

View File

@ -77,6 +77,10 @@ struct BufferView::Pimpl {
/// ///
void tripleClick(int x, int y, unsigned int button); void tripleClick(int x, int y, unsigned int button);
/// ///
void enterView();
///
void leaveView();
///
void cursorToggle(); void cursorToggle();
/// ///
void cursorPrevious(); void cursorPrevious();
@ -142,5 +146,7 @@ struct BufferView::Pimpl {
WorkArea * workarea; WorkArea * workarea;
/// ///
UpdateInset updatelist; UpdateInset updatelist;
private:
bool using_xterm_cursor;
}; };
#endif #endif

View File

@ -428,9 +428,11 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
break; break;
case FL_ENTER: case FL_ENTER:
lyxerr.debug() << "Workarea event: ENTER" << endl; lyxerr.debug() << "Workarea event: ENTER" << endl;
area->owner->enterView();
break; break;
case FL_LEAVE: case FL_LEAVE:
lyxerr.debug() << "Workarea event: LEAVE" << endl; lyxerr.debug() << "Workarea event: LEAVE" << endl;
area->owner->leaveView();
break; break;
case FL_DBLCLICK: case FL_DBLCLICK:
if (!ev) break; if (!ev) break;

View File

@ -17,21 +17,6 @@ extern FD_form_paragraph * fd_form_paragraph;
extern FD_form_character * fd_form_character; 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) void Foot(BufferView * bv)
{ {
if (!bv->available()) if (!bv->available())
@ -190,10 +175,6 @@ void AllowInput(BufferView * bv)
XUndefineCursor(fl_display, XUndefineCursor(fl_display,
fd_form_character->form_character->window); fd_form_character->form_character->window);
// What to do about this? (Lgb)
if (bv->belowMouse())
SetXtermCursor(bv->owner()->getForm()->window);
XFlush(fl_display); XFlush(fl_display);
fl_activate_all_forms(); fl_activate_all_forms();
} }
@ -258,8 +239,10 @@ string CurrentState(BufferView * bv)
// font. (Asger) // font. (Asger)
Buffer * buffer = bv->buffer(); Buffer * buffer = bv->buffer();
LyXFont font = bv->text->real_current_font; LyXFont font = bv->text->real_current_font;
LyXFont defaultfont = textclasslist.TextClass(buffer-> LyXFont const & defaultfont =
params.textclass).defaultfont(); textclasslist
.TextClass(buffer->params.textclass)
.defaultfont();
font.reduce(defaultfont); font.reduce(defaultfont);
state = _("Font: ") + font.stateText(); state = _("Font: ") + font.stateText();
// The paragraph depth // 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. /* -------> Does the actual toggle job of the XxxCB() calls above.
* Also shows the current font state. * Also shows the current font state.
*/ */