static_cast-based key/mouse-state. Kill insetKeyPress.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4210 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-05-26 17:33:14 +00:00
parent 6352b88f9f
commit 97ef9131ba
57 changed files with 446 additions and 277 deletions

View File

@ -541,16 +541,16 @@ int BufferView::Pimpl::scrollDown(long time)
} }
void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state) void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, key_modifier::state state)
{ {
bv_->owner()->getLyXFunc()->processKeySym(keysym, state); bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
} }
void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state state)
{ {
// Only use motion with button 1 // Only use motion with button 1
if (!(state & Button1MotionMask)) if (!(state & mouse_button::button1))
return; return;
if (!buffer_ || !screen_.get()) return; if (!buffer_ || !screen_.get()) return;
@ -613,28 +613,27 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
// Single-click on work area // Single-click on work area
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
unsigned int button) mouse_button::state button)
{ {
if (!buffer_ || !screen_.get()) if (!buffer_ || !screen_.get())
return; return;
// ok ok, this is a hack. // ok ok, this is a hack.
// Why??? (Jug20020424)
if (button == 4 || button == 5) { if (button == mouse_button::button4) {
switch (button) { scrollUp(lyxrc.wheel_jump);
case 4: // We shouldn't go further down as we really should only do the
scrollUp(lyxrc.wheel_jump); // default 100, set in lyxrc // scrolling and be done with this. Otherwise we may open some
break; // dialogs (Jug 20020424).
case 5: return;
scrollDown(lyxrc.wheel_jump); } else if (button == mouse_button::button5) {
break; scrollDown(lyxrc.wheel_jump);
}
// We shouldn't go further down as we really should only do the // We shouldn't go further down as we really should only do the
// scrolling and be done with this. Otherwise we may open some // scrolling and be done with this. Otherwise we may open some
// dialogs (Jug 20020424). // dialogs (Jug 20020424).
return; return;
} }
Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos); Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos);
// Middle button press pastes if we have a selection // Middle button press pastes if we have a selection
@ -642,7 +641,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// it could get cleared on the unlocking of the inset so // it could get cleared on the unlocking of the inset so
// we have to check this first // we have to check this first
bool paste_internally = false; bool paste_internally = false;
if (button == 2 && bv_->getLyXText()->selection.set()) { if (button == mouse_button::button2 && bv_->getLyXText()->selection.set()) {
owner_->getLyXFunc()->dispatch(LFUN_COPY); owner_->getLyXFunc()->dispatch(LFUN_COPY);
paste_internally = true; paste_internally = true;
} }
@ -693,7 +692,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// I'm not sure we should continue here if we hit an inset (Jug20020403) // I'm not sure we should continue here if we hit an inset (Jug20020403)
// Right click on a footnote flag opens float menu // Right click on a footnote flag opens float menu
if (button == 3) { if (button == mouse_button::button3) {
selection_possible = false; selection_possible = false;
return; return;
} }
@ -712,7 +711,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// Insert primary selection with middle mouse // Insert primary selection with middle mouse
// if there is a local selection in the current buffer, // if there is a local selection in the current buffer,
// insert this // insert this
if (button == 2) { if (button == mouse_button::button2) {
if (paste_internally) if (paste_internally)
owner_->getLyXFunc()->dispatch(LFUN_PASTE); owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else else
@ -724,9 +723,8 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
} }
void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state button)
{ {
// select a word
if (!buffer_) if (!buffer_)
return; return;
@ -735,7 +733,7 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
if (text->bv_owner && bv_->theLockingInset()) if (text->bv_owner && bv_->theLockingInset())
return; return;
if (screen_.get() && button == 1) { if (screen_.get() && button == mouse_button::button1) {
if (text->bv_owner) { if (text->bv_owner) {
screen_->hideCursor(); screen_->hideCursor();
screen_->toggleSelection(text, bv_); screen_->toggleSelection(text, bv_);
@ -751,9 +749,8 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
} }
void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button) void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state button)
{ {
// select a line
if (!buffer_) if (!buffer_)
return; return;
@ -762,7 +759,7 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
if (text->bv_owner && bv_->theLockingInset()) if (text->bv_owner && bv_->theLockingInset())
return; return;
if (screen_.get() && (button == 1)) { if (screen_.get() && (button == mouse_button::button1)) {
if (text->bv_owner) { if (text->bv_owner) {
screen_->hideCursor(); screen_->hideCursor();
screen_->toggleSelection(text, bv_); screen_->toggleSelection(text, bv_);
@ -838,10 +835,10 @@ void BufferView::Pimpl::leaveView()
void BufferView::Pimpl::workAreaButtonRelease(int x, int y, void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
unsigned int button) mouse_button::state button)
{ {
// do nothing if we used the mouse wheel // do nothing if we used the mouse wheel
if (!buffer_ || !screen_.get() || button == 4 || button == 5) if (!buffer_ || !screen_.get() || button == mouse_button::button4 || button == mouse_button::button5)
return; return;
// If we hit an inset, we have the inset coordinates in these // If we hit an inset, we have the inset coordinates in these
@ -862,11 +859,11 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
selection_possible = false; selection_possible = false;
if (button == 2) if (button == mouse_button::button2)
return; return;
// finish selection // finish selection
if (button == 1) { if (button == mouse_button::button1) {
workarea_.haveSelection(bv_->getLyXText()->selection.set()); workarea_.haveSelection(bv_->getLyXText()->selection.set());
} }
@ -932,7 +929,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
// Maybe we want to edit a bibitem ale970302 // Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 + if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) { bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) {
bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0); bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, mouse_button::none);
} }
return; return;

View File

@ -5,6 +5,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "commandtags.h" #include "commandtags.h"
#include "frontends/mouse_state.h"
#include "frontends/Timeout.h" #include "frontends/Timeout.h"
// FIXME remove me // FIXME remove me
#include "frontends/WorkArea.h" #include "frontends/WorkArea.h"
@ -66,17 +67,17 @@ struct BufferView::Pimpl : public SigC::Object {
/// ///
int scrollDown(long time); int scrollDown(long time);
/// ///
void workAreaKeyPress(KeySym, unsigned int state); void workAreaKeyPress(KeySym, key_modifier::state state);
/// ///
void workAreaMotionNotify(int x, int y, unsigned int state); void workAreaMotionNotify(int x, int y, mouse_button::state state);
/// ///
void workAreaButtonPress(int x, int y, unsigned int button); void workAreaButtonPress(int x, int y, mouse_button::state button);
/// ///
void workAreaButtonRelease(int x, int y, unsigned int button); void workAreaButtonRelease(int x, int y, mouse_button::state button);
/// ///
void doubleClick(int x, int y, unsigned int button); void doubleClick(int x, int y, mouse_button::state button);
/// ///
void tripleClick(int x, int y, unsigned int button); void tripleClick(int x, int y, mouse_button::state button);
/// ///
void selectionRequested(); void selectionRequested();
/// ///

View File

@ -1,3 +1,15 @@
2002-05-26 John Levon <moz@compsoc.man.ac.uk>
* BufferView_pimpl.h:
* BufferView_pimpl.C:
* kbmap.h:
* kbmap.C:
* kbsequence.h:
* kbsequence.C:
* lyxfunc.h:
* lyxfunc.C:
* text2.C: use key_state/mouse_state
2002-05-25 Lars Gullik Bjønnes <larsbj@birdstep.com> 2002-05-25 Lars Gullik Bjønnes <larsbj@birdstep.com>
* vc-backend.C (scanMaster): use boost regex and get rid of LRegex * vc-backend.C (scanMaster): use boost regex and get rid of LRegex

View File

@ -1,3 +1,12 @@
2002-05-26 John Levon <moz@compsoc.man.ac.uk>
* key_state.h:
* mouse_state.h: add
* Makefile.am:
* WorkArea.h:
* WorkArea.C: use above
2002-05-24 John Levon <moz@compsoc.man.ac.uk> 2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am: * Makefile.am:

View File

@ -38,5 +38,7 @@ libfrontends_la_SOURCES = \
WorkArea.h \ WorkArea.h \
font_loader.h \ font_loader.h \
font_metrics.h \ font_metrics.h \
key_state.h \
mouse_state.h \
screen.C \ screen.C \
screen.h screen.h

View File

@ -47,6 +47,64 @@ void waitForX()
XSync(fl_get_display(), 0); XSync(fl_get_display(), 0);
} }
// FIXME !
mouse_button::state x_button_state(unsigned int button)
{
mouse_button::state b = mouse_button::none;
switch (button) {
case Button1:
b = mouse_button::button1;
break;
case Button2:
b = mouse_button::button2;
break;
case Button3:
b = mouse_button::button3;
break;
case Button4:
b = mouse_button::button4;
break;
case Button5:
b = mouse_button::button5;
break;
default: // FIXME
break;
}
return b;
}
// FIXME
mouse_button::state x_motion_state(unsigned int state)
{
mouse_button::state b = mouse_button::none;
if (state & Button1MotionMask)
b |= mouse_button::button1;
if (state & Button2MotionMask)
b |= mouse_button::button2;
if (state & Button3MotionMask)
b |= mouse_button::button3;
if (state & Button4MotionMask)
b |= mouse_button::button4;
if (state & Button5MotionMask)
b |= mouse_button::button5;
return b;
}
key_modifier::state x_key_state(unsigned int state)
{
key_modifier::state k = key_modifier::none;
if (state & ControlMask)
k |= key_modifier::ctrl;
if (state & ShiftMask)
k |= key_modifier::shift;
if (state & Mod1Mask)
k |= key_modifier::alt;
return k;
}
} // anon namespace } // anon namespace
@ -357,8 +415,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
area->workAreaButtonPress(ev->xbutton.x - ob->x, area->workAreaButtonPress(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y, ev->xbutton.y - ob->y,
ev->xbutton.button); x_button_state(ev->xbutton.button));
//area->workAreaKeyPress(XK_Pointer_Button1, ev->xbutton.state);
break; break;
case FL_RELEASE: case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break; if (!ev || ev->xbutton.button == 0) break;
@ -366,7 +423,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
area->workAreaButtonRelease(ev->xbutton.x - ob->x, area->workAreaButtonRelease(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y, ev->xbutton.y - ob->y,
ev->xbutton.button); x_button_state(ev->xbutton.button));
break; break;
#if FL_REVISION < 89 #if FL_REVISION < 89
case FL_MOUSE: case FL_MOUSE:
@ -381,7 +438,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl;
area->workAreaMotionNotify(ev->xmotion.x - ob->x, area->workAreaMotionNotify(ev->xmotion.x - ob->x,
ev->xmotion.y - ob->y, ev->xmotion.y - ob->y,
ev->xbutton.state); x_motion_state(ev->xbutton.state));
} }
break; break;
#if FL_REVISION < 89 #if FL_REVISION < 89
@ -490,7 +547,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
last_key_pressed = xke->keycode; last_key_pressed = xke->keycode;
last_state_pressed = ret_state; last_state_pressed = ret_state;
area->workAreaKeyPress(ret_key, ret_state); area->workAreaKeyPress(ret_key, x_key_state(ret_state));
} }
break; break;
@ -521,14 +578,14 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
area->workAreaDoubleClick(ev->xbutton.x - ob->x, area->workAreaDoubleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y, ev->xbutton.y - ob->y,
ev->xbutton.button); x_button_state(ev->xbutton.button));
break; break;
case FL_TRPLCLICK: case FL_TRPLCLICK:
if (!ev) break; if (!ev) break;
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
area->workAreaTripleClick(ev->xbutton.x - ob->x, area->workAreaTripleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y, ev->xbutton.y - ob->y,
ev->xbutton.button); x_button_state(ev->xbutton.button));
break; break;
case FL_OTHER: case FL_OTHER:
if (!ev) break; if (!ev) break;

View File

@ -22,6 +22,8 @@
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/mouse_state.h"
#include "frontends/key_state.h"
/// ///
class WorkArea { class WorkArea {
@ -107,13 +109,13 @@ public:
/// ///
SigC::Signal1<void, double> scrollCB; SigC::Signal1<void, double> scrollCB;
/// ///
SigC::Signal2<void, KeySym, unsigned int> workAreaKeyPress; SigC::Signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
/// ///
SigC::Signal3<void, int, int, unsigned int> workAreaButtonPress; SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonPress;
/// ///
SigC::Signal3<void, int, int, unsigned int> workAreaButtonRelease; SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
/// ///
SigC::Signal3<void, int, int, unsigned int> workAreaMotionNotify; SigC::Signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
/// ///
SigC::Signal0<void> workAreaFocus; SigC::Signal0<void> workAreaFocus;
/// ///
@ -123,9 +125,9 @@ public:
/// ///
SigC::Signal0<void> workAreaLeave; SigC::Signal0<void> workAreaLeave;
/// ///
SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick; SigC::Signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
/// ///
SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick; SigC::Signal3<void, int, int, mouse_button::state> workAreaTripleClick;
/// emitted when an X client has requested our selection /// emitted when an X client has requested our selection
SigC::Signal0<void> selectionRequested; SigC::Signal0<void> selectionRequested;
/// emitted when another X client has stolen our selection /// emitted when another X client has stolen our selection

39
src/frontends/key_state.h Normal file
View File

@ -0,0 +1,39 @@
/**
* \file key_state.h
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* Keyboard modifier state representation.
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef KEY_STATE_H
#define KEY_STATE_H
/// modifier key states
namespace key_modifier {
enum state {
none = 0, //< no modifiers held
ctrl = 1, //< control button held
alt = 2, //< alt/meta key held
shift = 4 //< shift key held
};
inline state operator|(state const & s1, state const & s2)
{
int const i1(static_cast<int>(s1));
int const i2(static_cast<int>(s2));
return static_cast<state>(i1 | i2);
}
inline void operator|=(state & s1, state s2)
{
s1 = static_cast<state>(s1 | s2);
}
} // namespace key_modifier
#endif // KEY_STATE_H

View File

@ -0,0 +1,34 @@
/**
* \file mouse_state.h
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* GUII representation of mouse presses and
* mouse button states
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef MOUSE_STATE_H
#define MOUSE_STATE_H
/// used both for presses and held during motion
namespace mouse_button {
enum state {
none = 0, //< no buttons held
button1 = 1, //< mouse button 1 pressed
button2 = 2,
button3 = 4,
button4 = 8,
button5 = 16
};
inline void operator|=(state & s1, state s2)
{
s1 = static_cast<state>(s1 | s2);
}
} // namespace mouse_button
#endif // MOUSE_STATE_H

View File

@ -1,3 +1,42 @@
2002-05-26 John Levon <moz@compsoc.man.ac.uk>
* inset.C:
* inset.h:
* insetbib.C:
* insetbib.h:
* insetcite.h:
* insetcite.C:
* insetcollapsable.C:
* insetcollapsable.h:
* inseterror.C:
* inseterror.h:
* insetert.C:
* insetert.h:
* insetexternal.C:
* insetexternal.h:
* insetfloatlist.C:
* insetfloatlist.h:
* insetgraphics.C:
* insetgraphics.h:
* insetinclude.C:
* insetinclude.h:
* insetindex.C:
* insetindex.h:
* insetlabel.C:
* insetlabel.h:
* insetparent.C:
* insetparent.h:
* insetref.C:
* insetref.h:
* insettabular.C:
* insettabular.h:
* insettext.C:
* insettext.h:
* insettoc.C:
* insettoc.h:
* inseturl.C:
* inseturl.h: use mouse_state. Kill insetKeyPress
2002-05-24 John Levon <moz@compsoc.man.ac.uk> 2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* insetbib.C: * insetbib.C:

View File

@ -19,6 +19,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/mouse_state.h"
#include "commandtags.h" #include "commandtags.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "gettext.h" #include "gettext.h"
@ -79,7 +80,7 @@ bool Inset::autoDelete() const
} }
void Inset::edit(BufferView *, int, int, unsigned int) void Inset::edit(BufferView *, int, int, mouse_button::state)
{} {}
@ -172,14 +173,14 @@ UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
{} {}
void UpdatableInset::insetButtonPress(BufferView *, int x, int y, int button) void UpdatableInset::insetButtonPress(BufferView *, int x, int y, mouse_button::state button)
{ {
lyxerr[Debug::INFO] << "Inset Button Press x=" << x lyxerr[Debug::INFO] << "Inset Button Press x=" << x
<< ", y=" << y << ", button=" << button << endl; << ", y=" << y << ", button=" << button << endl;
} }
bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button) bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, mouse_button::state button)
{ {
lyxerr[Debug::INFO] << "Inset Button Release x=" << x lyxerr[Debug::INFO] << "Inset Button Release x=" << x
<< ", y=" << y << ", button=" << button << endl; << ", y=" << y << ", button=" << button << endl;
@ -187,13 +188,7 @@ bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button)
} }
void UpdatableInset::insetKeyPress(XKeyEvent *) void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, mouse_button::state state)
{
lyxerr[Debug::INFO] << "Inset Keypress" << endl;
}
void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, int state)
{ {
lyxerr[Debug::INFO] << "Inset Motion Notify x=" << x lyxerr[Debug::INFO] << "Inset Motion Notify x=" << x
<< ", y=" << y << ", state=" << state << endl; << ", y=" << y << ", state=" << state << endl;
@ -229,7 +224,7 @@ void UpdatableInset::fitInsetCursor(BufferView *) const
{} {}
void UpdatableInset::edit(BufferView *, int, int, unsigned int) void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
{} {}

View File

@ -17,8 +17,8 @@
#include <vector> #include <vector>
#include "LString.h" #include "LString.h"
#include <X11/Xlib.h>
#include "commandtags.h" #include "commandtags.h"
#include "frontends/mouse_state.h"
#include "LColor.h" #include "LColor.h"
class LyXFont; class LyXFont;
@ -151,21 +151,21 @@ public:
/// what appears in the minibuffer when opening /// what appears in the minibuffer when opening
virtual string const editMessage() const; virtual string const editMessage() const;
/// ///
virtual void edit(BufferView *, int x, int y, unsigned int button); virtual void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual void edit(BufferView *, bool front = true); virtual void edit(BufferView *, bool front = true);
/// ///
virtual EDITABLE editable() const; virtual EDITABLE editable() const;
/// This is called when the user clicks inside an inset /// This is called when the user clicks inside an inset
virtual void insetButtonPress(BufferView *, int, int, int) {} virtual void insetButtonPress(BufferView *, int, int, mouse_button::state) {}
/// This is called when the user releases the button inside an inset /// This is called when the user releases the button inside an inset
// the bool return is used to see if we opened a dialog so that we can // the bool return is used to see if we opened a dialog so that we can
// check this from an outer inset and open the dialog of the // check this from an outer inset and open the dialog of the
// outer inset if that one has one! // outer inset if that one has one!
virtual bool insetButtonRelease(BufferView *, int, int, int) virtual bool insetButtonRelease(BufferView *, int, int, mouse_button::state)
{ return editable() == IS_EDITABLE; } { return editable() == IS_EDITABLE; }
/// This is called when the user moves the mouse inside an inset /// This is called when the user moves the mouse inside an inset
virtual void insetMotionNotify(BufferView *, int , int , int) {} virtual void insetMotionNotify(BufferView *, int , int, mouse_button::state) {}
/// ///
virtual bool isTextInset() const { return false; } virtual bool isTextInset() const { return false; }
/// ///
@ -447,22 +447,20 @@ public:
/// ///
virtual void getCursorPos(BufferView *, int &, int &) const {} virtual void getCursorPos(BufferView *, int &, int &) const {}
/// ///
virtual void insetButtonPress(BufferView *, int x, int y, int button); virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
/// ///
// the bool return is used to see if we opened a dialog so that we can // the bool return is used to see if we opened a dialog so that we can
// check this from an outer inset and open the dialog of the outer inset // check this from an outer inset and open the dialog of the outer inset
// if that one has one! // if that one has one!
/// ///
virtual bool insetButtonRelease(BufferView *, virtual bool insetButtonRelease(BufferView *,
int x, int y, int button); int x, int y, mouse_button::state button);
/// ///
virtual void insetKeyPress(XKeyEvent * ev); virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
///
virtual void insetMotionNotify(BufferView *, int x, int y, int state);
/// ///
virtual void insetUnlock(BufferView *); virtual void insetUnlock(BufferView *);
/// ///
virtual void edit(BufferView *, int x, int y, unsigned int button); virtual void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual void edit(BufferView *, bool front = true); virtual void edit(BufferView *, bool front = true);
/// ///

View File

@ -110,7 +110,7 @@ string const InsetBibKey::getScreenLabel(Buffer const *) const
} }
void InsetBibKey::edit(BufferView * bv, int, int, unsigned int) void InsetBibKey::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showBibitem(this); bv->owner()->getDialogs()->showBibitem(this);
} }
@ -118,7 +118,7 @@ void InsetBibKey::edit(BufferView * bv, int, int, unsigned int)
void InsetBibKey::edit(BufferView * bv, bool) void InsetBibKey::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }
@ -278,7 +278,7 @@ vector<pair<string, string> > const InsetBibtex::getKeys(Buffer const * buffer)
} }
void InsetBibtex::edit(BufferView * bv, int, int, unsigned int) void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showBibtex(this); bv->owner()->getDialogs()->showBibtex(this);
} }
@ -286,7 +286,7 @@ void InsetBibtex::edit(BufferView * bv, int, int, unsigned int)
void InsetBibtex::edit(BufferView * bv, bool) void InsetBibtex::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -43,7 +43,7 @@ public:
/// ///
virtual string const getScreenLabel(Buffer const *) const; virtual string const getScreenLabel(Buffer const *) const;
/// ///
void edit(BufferView *, int x, int y, unsigned int button); void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///
@ -93,7 +93,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; } Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
/// ///
void edit(BufferView *, int x, int y, unsigned int button); void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -307,7 +307,7 @@ string const InsetCitation::getScreenLabel(Buffer const * buffer) const
} }
void InsetCitation::edit(BufferView * bv, int, int, unsigned int) void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state)
{ {
// A call to edit() indicates that we're no longer loading the // A call to edit() indicates that we're no longer loading the
// buffer but doing some real work. // buffer but doing some real work.
@ -320,7 +320,7 @@ void InsetCitation::edit(BufferView * bv, int, int, unsigned int)
void InsetCitation::edit(BufferView * bv, bool) void InsetCitation::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -34,7 +34,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::CITE_CODE; } Inset::Code lyxCode() const { return Inset::CITE_CODE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -235,7 +235,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
void InsetCollapsable::edit(BufferView * bv, int xp, int yp, void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
unsigned int button) mouse_button::state button)
{ {
UpdatableInset::edit(bv, xp, yp, button); UpdatableInset::edit(bv, xp, yp, button);
@ -313,7 +313,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
void InsetCollapsable::insetButtonPress(BufferView * bv, void InsetCollapsable::insetButtonPress(BufferView * bv,
int x, int y, int button) int x, int y, mouse_button::state button)
{ {
if (!collapsed_ && (y > button_bottom_y)) { if (!collapsed_ && (y > button_bottom_y)) {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
@ -327,10 +327,10 @@ void InsetCollapsable::insetButtonPress(BufferView * bv,
bool InsetCollapsable::insetButtonRelease(BufferView * bv, bool InsetCollapsable::insetButtonRelease(BufferView * bv,
int x, int y, int button) int x, int y, mouse_button::state button)
{ {
bool ret = false; bool ret = false;
if ((button != 3) && (x >= 0) && (x < button_length) && if ((button != mouse_button::button3) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y)) (y >= button_top_y) && (y <= button_bottom_y))
{ {
if (collapsed_) { if (collapsed_) {
@ -352,7 +352,7 @@ bool InsetCollapsable::insetButtonRelease(BufferView * bv,
inset.ascent(bv, font)); inset.ascent(bv, font));
ret = inset.insetButtonRelease(bv, x, yy, button); ret = inset.insetButtonRelease(bv, x, yy, button);
} }
if ((button == 3) && !ret) { if ((button == mouse_button::button3) && !ret) {
return showInsetDialog(bv); return showInsetDialog(bv);
} }
return ret; return ret;
@ -360,7 +360,7 @@ bool InsetCollapsable::insetButtonRelease(BufferView * bv,
void InsetCollapsable::insetMotionNotify(BufferView * bv, void InsetCollapsable::insetMotionNotify(BufferView * bv,
int x, int y, int state) int x, int y, mouse_button::state state)
{ {
if (y > button_bottom_y) { if (y > button_bottom_y) {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
@ -373,12 +373,6 @@ void InsetCollapsable::insetMotionNotify(BufferView * bv,
} }
void InsetCollapsable::insetKeyPress(XKeyEvent * xke)
{
inset.insetKeyPress(xke);
}
int InsetCollapsable::latex(Buffer const * buf, ostream & os, int InsetCollapsable::latex(Buffer const * buf, ostream & os,
bool fragile, bool free_spc) const bool fragile, bool free_spc) const
{ {

View File

@ -60,7 +60,7 @@ public:
/// ///
void update(BufferView *, LyXFont const &, bool =false); void update(BufferView *, LyXFont const &, bool =false);
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView *, bool front = true); void edit(BufferView *, bool front = true);
/// ///
@ -89,13 +89,11 @@ public:
/// ///
int insetInInsetY() const; int insetInInsetY() const;
/// ///
bool insetButtonRelease(BufferView *, int, int, int); bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
/// ///
void insetButtonPress(BufferView *, int, int, int); void insetButtonPress(BufferView *, int, int, mouse_button::state);
/// ///
void insetMotionNotify(BufferView *, int, int, int); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
void insetKeyPress(XKeyEvent *);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action, UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
string const &); string const &);

View File

@ -86,7 +86,7 @@ string const InsetError::editMessage() const
} }
void InsetError::edit(BufferView * bv, int, int, unsigned int) void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showError(this); bv->owner()->getDialogs()->showError(this);
} }
@ -94,5 +94,5 @@ void InsetError::edit(BufferView * bv, int, int, unsigned int)
void InsetError::edit(BufferView * bv, bool) void InsetError::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -57,7 +57,7 @@ public:
/// what appears in the minibuffer when opening /// what appears in the minibuffer when opening
string const editMessage() const; string const editMessage() const;
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -263,10 +263,9 @@ void InsetERT::updateStatus(BufferView * bv, bool swap) const
} }
} }
void InsetERT::edit(BufferView * bv, int x, int y, mouse_button::state button)
void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
{ {
if (button == 3) if (button == mouse_button::button3)
return; return;
if (status_ == Inlined) { if (status_ == Inlined) {
@ -300,7 +299,7 @@ void InsetERT::edit(BufferView * bv, bool front)
void InsetERT::insetButtonPress(BufferView * bv, void InsetERT::insetButtonPress(BufferView * bv,
int x, int y, int button) int x, int y, mouse_button::state button)
{ {
if (status_ == Inlined) { if (status_ == Inlined) {
inset.insetButtonPress(bv, x, y, button); inset.insetButtonPress(bv, x, y, button);
@ -310,9 +309,10 @@ void InsetERT::insetButtonPress(BufferView * bv,
} }
bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y,
mouse_button::state button)
{ {
if (button == 3) { if (button == mouse_button::button3) {
showInsetDialog(bv); showInsetDialog(bv);
return true; return true;
} }
@ -338,7 +338,7 @@ bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button)
void InsetERT::insetMotionNotify(BufferView * bv, void InsetERT::insetMotionNotify(BufferView * bv,
int x, int y, int state) int x, int y, mouse_button::state state)
{ {
if (status_ == Inlined) { if (status_ == Inlined) {
inset.insetMotionNotify(bv, x, y, state); inset.insetMotionNotify(bv, x, y, state);

View File

@ -67,7 +67,7 @@ public:
void setFont(BufferView *, LyXFont const &, void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false); bool toggleall = false, bool selectall = false);
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///
@ -75,11 +75,11 @@ public:
/// ///
SigC::Signal0<void> hideDialog; SigC::Signal0<void> hideDialog;
/// ///
void insetButtonPress(BufferView *, int x, int y, int button); void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
/// ///
bool insetButtonRelease(BufferView * bv, int x, int y, int button); bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
/// ///
void insetMotionNotify(BufferView *, int x, int y, int state); void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
/// ///
int latex(Buffer const *, std::ostream &, bool fragile, int latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const; bool free_spc) const;

View File

@ -77,7 +77,7 @@ string const InsetExternal::editMessage() const
void InsetExternal::edit(BufferView * bv, void InsetExternal::edit(BufferView * bv,
int /*x*/, int /*y*/, unsigned int /*button*/) int /*x*/, int /*y*/, mouse_button::state)
{ {
view_ = bv; view_ = bv;
view_->owner()->getDialogs()->showExternal(this); view_->owner()->getDialogs()->showExternal(this);
@ -86,7 +86,7 @@ void InsetExternal::edit(BufferView * bv,
void InsetExternal::edit(BufferView * bv, bool) void InsetExternal::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -44,7 +44,7 @@ public:
/// what appears in the minibuffer when opening /// what appears in the minibuffer when opening
virtual string const editMessage() const; virtual string const editMessage() const;
/// ///
virtual void edit(BufferView *, int x, int y, unsigned int button); virtual void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual void edit(BufferView * bv, bool front = true); virtual void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -78,7 +78,7 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex)
} }
void InsetFloatList::edit(BufferView * bv, int, int, unsigned int) void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showTOC(this); bv->owner()->getDialogs()->showTOC(this);
} }
@ -86,7 +86,7 @@ void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
void InsetFloatList::edit(BufferView * bv, bool) void InsetFloatList::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -33,7 +33,7 @@ public:
/// ///
string const getScreenLabel(Buffer const *) const; string const getScreenLabel(Buffer const *) const;
/// ///
void edit(BufferView * bv, int, int, unsigned int); void edit(BufferView * bv, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -364,7 +364,7 @@ void InsetGraphics::updateInset(string const & filepath) const
} }
void InsetGraphics::edit(BufferView *bv, int, int, unsigned int) void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showGraphics(this); bv->owner()->getDialogs()->showGraphics(this);
} }
@ -372,7 +372,7 @@ void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
void InsetGraphics::edit(BufferView * bv, bool) void InsetGraphics::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -47,7 +47,7 @@ public:
/// ///
void draw(BufferView *, LyXFont const &, int, float &, bool) const; void draw(BufferView *, LyXFont const &, int, float &, bool) const;
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -123,7 +123,7 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const
} }
void InsetInclude::edit(BufferView * bv, int, int, unsigned int) void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showInclude(this); bv->owner()->getDialogs()->showInclude(this);
} }
@ -131,7 +131,7 @@ void InsetInclude::edit(BufferView * bv, int, int, unsigned int)
void InsetInclude::edit(BufferView * bv, bool) void InsetInclude::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -77,7 +77,7 @@ public:
/// This returns the list of bibkeys on the child buffer /// This returns the list of bibkeys on the child buffer
std::vector< std::pair<string,string> > const getKeys() const; std::vector< std::pair<string,string> > const getKeys() const;
/// ///
void edit(BufferView *, int x, int y, unsigned int button); void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -25,7 +25,7 @@ string const InsetIndex::getScreenLabel(Buffer const *) const
} }
void InsetIndex::edit(BufferView * bv, int, int, unsigned int) void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showIndex(this); bv->owner()->getDialogs()->showIndex(this);
} }
@ -33,7 +33,7 @@ void InsetIndex::edit(BufferView * bv, int, int, unsigned int)
void InsetIndex::edit(BufferView * bv, bool) void InsetIndex::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -35,7 +35,7 @@ public:
/// ///
EDITABLE editable() const { return IS_EDITABLE; } EDITABLE editable() const { return IS_EDITABLE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///
@ -56,7 +56,7 @@ public:
/// Updates needed features for this inset. /// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// ///
void edit(BufferView *, int, int, unsigned int) {} void edit(BufferView *, int, int, mouse_button::state) {}
/// ///
void edit(BufferView *, bool = true) {} void edit(BufferView *, bool = true) {}
/// ///

View File

@ -42,7 +42,7 @@ vector<string> const InsetLabel::getLabelList() const
} }
void InsetLabel::edit(BufferView * bv, int, int, unsigned int) void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
{ {
pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents()); pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
if (result.first) { if (result.first) {
@ -70,7 +70,7 @@ void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
void InsetLabel::edit(BufferView * bv, bool) void InsetLabel::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -33,7 +33,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::LABEL_CODE; } Inset::Code lyxCode() const { return Inset::LABEL_CODE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -44,8 +44,8 @@ string const InsetParent::getScreenLabel(Buffer const *) const
} }
void InsetParent::edit(BufferView * bv, int, int, unsigned int) void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
dispatch(LFUN_CHILDOPEN, getContents()); dispatch(LFUN_CHILDOPEN, getContents());
} }
@ -53,7 +53,7 @@ void InsetParent::edit(BufferView * bv, int, int, unsigned int)
void InsetParent::edit(BufferView * bv, bool) void InsetParent::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -39,7 +39,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::PARENT_CODE; } Inset::Code lyxCode() const { return Inset::PARENT_CODE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -22,13 +22,13 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
: InsetCommand(p), isLatex(buf.isLatex()) : InsetCommand(p), isLatex(buf.isLatex())
{} {}
void InsetRef::edit(BufferView * bv, int, int, unsigned int button) void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
{ {
// Eventually trigger dialog with button 3 not 1 // Eventually trigger dialog with button 3 not 1
if (button == 3) if (button == mouse_button::button3)
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
dispatch(LFUN_REF_GOTO, getContents()); dispatch(LFUN_REF_GOTO, getContents());
else if (button == 1) else if (button == mouse_button::button1)
bv->owner()->getDialogs()->showRef(this); bv->owner()->getDialogs()->showRef(this);
} }

View File

@ -50,7 +50,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::REF_CODE; } Inset::Code lyxCode() const { return Inset::REF_CODE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -551,7 +551,7 @@ string const InsetTabular::editMessage() const
} }
void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button) void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
{ {
UpdatableInset::edit(bv, x, y, button); UpdatableInset::edit(bv, x, y, button);
@ -566,7 +566,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
setPos(bv, x, y); setPos(bv, x, y);
clearSelection(); clearSelection();
finishUndo(); finishUndo();
if (insetHit(bv, x, y) && (button != 3)) { if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
activateCellInsetAbs(bv, x, y, button); activateCellInsetAbs(bv, x, y, button);
} }
} }
@ -766,9 +766,9 @@ bool InsetTabular::insertInset(BufferView * bv, Inset * inset)
} }
void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
{ {
if (hasSelection() && (button == 3)) if (hasSelection() && (button == mouse_button::button3))
return; return;
if (hasSelection()) { if (hasSelection()) {
@ -815,7 +815,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
updateLocal(bv, CELL, false); updateLocal(bv, CELL, false);
the_locking_inset = 0; the_locking_inset = 0;
} }
if (button == 2) { if (button == mouse_button::button2) {
localDispatch(bv, LFUN_PASTESELECTION, "paragraph"); localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
return; return;
} }
@ -833,13 +833,13 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
bool InsetTabular::insetButtonRelease(BufferView * bv, bool InsetTabular::insetButtonRelease(BufferView * bv,
int x, int y, int button) int x, int y, mouse_button::state button)
{ {
bool ret = false; bool ret = false;
if (the_locking_inset) if (the_locking_inset)
ret = the_locking_inset->insetButtonRelease(bv, x - inset_x, ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button); y - inset_y, button);
if (button == 3 && !ret) { if (button == mouse_button::button3 && !ret) {
bv->owner()->getDialogs()->showTabular(this); bv->owner()->getDialogs()->showTabular(this);
return true; return true;
} }
@ -847,7 +847,7 @@ bool InsetTabular::insetButtonRelease(BufferView * bv,
} }
void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button) void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button)
{ {
if (the_locking_inset) { if (the_locking_inset) {
the_locking_inset->insetMotionNotify(bv, the_locking_inset->insetMotionNotify(bv,
@ -871,15 +871,6 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
} }
void InsetTabular::insetKeyPress(XKeyEvent * xke)
{
if (the_locking_inset) {
the_locking_inset->insetKeyPress(xke);
return;
}
}
UpdatableInset::RESULT UpdatableInset::RESULT
InsetTabular::localDispatch(BufferView * bv, kb_action action, InsetTabular::localDispatch(BufferView * bv, kb_action action,
string const & arg) string const & arg)
@ -1635,7 +1626,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
if (!moved) if (!moved)
return FINISHED; return FINISHED;
if (lock) { // behind the inset if (lock) { // behind the inset
if (activateCellInset(bv, 0, 0, 0, true)) if (activateCellInset(bv, 0, 0, mouse_button::none, true))
return DISPATCHED; return DISPATCHED;
} }
resetPos(bv); resetPos(bv);
@ -1707,7 +1698,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
if (lock) { if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()-> bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params); isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, 0, !rtl); activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
} }
resetPos(bv); resetPos(bv);
return true; return true;
@ -1736,7 +1727,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
if (lock) { if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()-> bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params); isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, 0, !rtl); activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
} }
resetPos(bv); resetPos(bv);
return true; return true;
@ -2170,7 +2161,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
} }
bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button, bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button,
bool behind) bool behind)
{ {
UpdatableInset * inset = UpdatableInset * inset =
@ -2191,7 +2182,7 @@ bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y, bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
int button) mouse_button::state button)
{ {
inset_x = cursor_.x() inset_x = cursor_.x()
- top_x + tabular->GetBeginningOfTextInCell(actcell); - top_x + tabular->GetBeginningOfTextInCell(actcell);
@ -2695,7 +2686,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
// otherwise we have to lock the next inset and ask for it's selecttion // otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)); static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
inset->edit(bv, 0, 0, 0); inset->edit(bv, 0, 0, mouse_button::none);
string const str(selectNextWordInt(bv, value)); string const str(selectNextWordInt(bv, value));
nodraw(false); nodraw(false);
if (!str.empty()) if (!str.empty())

View File

@ -101,7 +101,7 @@ public:
/// ///
string const editMessage() const; string const editMessage() const;
/// ///
void edit(BufferView *, int x, int y, unsigned int); void edit(BufferView *, int x, int y, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///
@ -132,13 +132,11 @@ public:
/// ///
bool display() const { return tabular->IsLongTabular(); } bool display() const { return tabular->IsLongTabular(); }
/// ///
bool insetButtonRelease(BufferView *, int, int, int); bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
/// ///
void insetButtonPress(BufferView *, int, int, int); void insetButtonPress(BufferView *, int, int, mouse_button::state);
/// ///
void insetMotionNotify(BufferView *, int, int, int); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
void insetKeyPress(XKeyEvent *);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action, UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
string const &); string const &);
@ -288,11 +286,11 @@ private:
} }
/// ///
bool activateCellInset(BufferView *, int x = 0, int y = 0, bool activateCellInset(BufferView *, int x = 0, int y = 0,
int button = 0, mouse_button::state button = mouse_button::none,
bool behind = false); bool behind = false);
/// ///
bool activateCellInsetAbs(BufferView *, int x = 0, int y = 0, bool activateCellInsetAbs(BufferView *, int x = 0, int y = 0,
int button = 0); mouse_button::state button = mouse_button::none);
/// ///
bool insetHit(BufferView * bv, int x, int y) const; bool insetHit(BufferView * bv, int x, int y) const;
/// ///

View File

@ -675,7 +675,7 @@ string const InsetText::editMessage() const
} }
void InsetText::edit(BufferView * bv, int x, int y, unsigned int button) void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button)
{ {
UpdatableInset::edit(bv, x, y, button); UpdatableInset::edit(bv, x, y, button);
@ -698,7 +698,8 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
// we put here -1 and not button as now the button in the // we put here -1 and not button as now the button in the
// edit call should not be needed we will fix this in 1.3.x // edit call should not be needed we will fix this in 1.3.x
// cycle hopefully (Jug 20020509) // cycle hopefully (Jug 20020509)
if (!checkAndActivateInset(bv, x, tmp_y, -1)) { // FIXME: GUII I've changed this to none: probably WRONG
if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) {
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent); y + insetAscent);
lt->cursor.x_fix(lt->cursor.x()); lt->cursor.x_fix(lt->cursor.x());
@ -994,7 +995,8 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
} }
void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) void InsetText::insetButtonPress(BufferView * bv,
int x, int y, mouse_button::state button)
{ {
no_selection = true; no_selection = true;
@ -1054,9 +1056,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
return; return;
} }
} }
if (!inset) { // && (button == 2)) { if (!inset) { // && (button == mouse_button::button2)) {
bool paste_internally = false; bool paste_internally = false;
if ((button == 2) && getLyXText(bv)->selection.set()) { if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) {
localDispatch(bv, LFUN_COPY, ""); localDispatch(bv, LFUN_COPY, "");
paste_internally = true; paste_internally = true;
} }
@ -1092,7 +1094,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
// Insert primary selection with middle mouse // Insert primary selection with middle mouse
// if there is a local selection in the current buffer, // if there is a local selection in the current buffer,
// insert this // insert this
if (button == 2) { if (button == mouse_button::button2) {
if (paste_internally) if (paste_internally)
localDispatch(bv, LFUN_PASTE, ""); localDispatch(bv, LFUN_PASTE, "");
else else
@ -1106,7 +1108,8 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
} }
bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) bool InsetText::insetButtonRelease(BufferView * bv,
int x, int y, mouse_button::state button)
{ {
no_selection = true; no_selection = true;
if (the_locking_inset) { if (the_locking_inset) {
@ -1136,7 +1139,7 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
} }
void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state) void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state state)
{ {
if (the_locking_inset) { if (the_locking_inset) {
the_locking_inset->insetMotionNotify(bv, x - inset_x, the_locking_inset->insetMotionNotify(bv, x - inset_x,
@ -1173,15 +1176,6 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
} }
void InsetText::insetKeyPress(XKeyEvent * xke)
{
if (the_locking_inset) {
the_locking_inset->insetKeyPress(xke);
return;
}
}
UpdatableInset::RESULT UpdatableInset::RESULT
InsetText::localDispatch(BufferView * bv, InsetText::localDispatch(BufferView * bv,
kb_action action, string const & arg) kb_action action, string const & arg)
@ -2069,7 +2063,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool front)
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int button) mouse_button::state button)
{ {
x -= drawTextXOffset; x -= drawTextXOffset;
int dummyx = x; int dummyx = x;
@ -2078,7 +2072,9 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
// we only do the edit() call if the inset was hit by the mouse // we only do the edit() call if the inset was hit by the mouse
// or if it is a highly editable inset. So we should call this // or if it is a highly editable inset. So we should call this
// function from our own edit with button < 0. // function from our own edit with button < 0.
if (button < 0 && !isHighlyEditableInset(inset)) // FIXME: GUII jbl. I've changed this to ::none for now which is probably
// WRONG
if (button == mouse_button::none && !isHighlyEditableInset(inset))
return false; return false;
if (inset) { if (inset) {

View File

@ -107,7 +107,7 @@ public:
/// ///
string const editMessage() const; string const editMessage() const;
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView *, bool front = true); void edit(BufferView *, bool front = true);
/// ///
@ -124,13 +124,11 @@ public:
/// ///
bool updateInsetInInset(BufferView *, Inset *); bool updateInsetInInset(BufferView *, Inset *);
/// ///
bool insetButtonRelease(BufferView *, int, int, int); bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
/// ///
void insetButtonPress(BufferView *, int, int, int); void insetButtonPress(BufferView *, int, int, mouse_button::state);
/// ///
void insetMotionNotify(BufferView *, int, int, int); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
void insetKeyPress(XKeyEvent *);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, UpdatableInset::RESULT localDispatch(BufferView *,
kb_action, string const &); kb_action, string const &);
@ -317,7 +315,7 @@ private:
bool checkAndActivateInset(BufferView * bv, bool front); bool checkAndActivateInset(BufferView * bv, bool front);
/// ///
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0, bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
int button = 0); mouse_button::state button = mouse_button::none);
/// ///
void removeNewlines(); void removeNewlines();
/// ///

View File

@ -36,7 +36,7 @@ Inset::Code InsetTOC::lyxCode() const
} }
void InsetTOC::edit(BufferView * bv, int, int, unsigned int) void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showTOC(this); bv->owner()->getDialogs()->showTOC(this);
} }
@ -44,7 +44,7 @@ void InsetTOC::edit(BufferView * bv, int, int, unsigned int)
void InsetTOC::edit(BufferView * bv, bool) void InsetTOC::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -32,7 +32,7 @@ public:
/// ///
string const getScreenLabel(Buffer const *) const; string const getScreenLabel(Buffer const *) const;
/// ///
void edit(BufferView * bv, int, int, unsigned int); void edit(BufferView * bv, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -21,7 +21,7 @@ InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
{} {}
void InsetUrl::edit(BufferView * bv, int, int, unsigned int) void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs()->showUrl(this); bv->owner()->getDialogs()->showUrl(this);
} }
@ -29,7 +29,7 @@ void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
void InsetUrl::edit(BufferView * bv, bool) void InsetUrl::edit(BufferView * bv, bool)
{ {
edit(bv, 0, 0, 0); edit(bv, 0, 0, mouse_button::none);
} }

View File

@ -39,7 +39,7 @@ public:
/// ///
EDITABLE editable() const { return IS_EDITABLE; } EDITABLE editable() const { return IS_EDITABLE; }
/// ///
void edit(BufferView *, int, int, unsigned int); void edit(BufferView *, int, int, mouse_button::state);
/// ///
void edit(BufferView * bv, bool front = true); void edit(BufferView * bv, bool front = true);
/// ///

View File

@ -28,16 +28,15 @@ using std::endl;
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask }; enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
string const kb_keymap::printKeysym(unsigned int key, unsigned int mod) string const kb_keymap::printKeysym(unsigned int key, key_modifier::state mod)
{ {
string buf; string buf;
mod &= ModsMask;
char const * const s = XKeysymToString(key); char const * const s = XKeysymToString(key);
if (mod & ShiftMask) buf += "S-"; if (mod & key_modifier::shift) buf += "S-";
if (mod & ControlMask) buf += "C-"; if (mod & key_modifier::ctrl) buf += "C-";
if (mod & Mod1Mask) buf += "M-"; if (mod & key_modifier::alt) buf += "M-";
if (s) buf += s; if (s) buf += s;
return buf; return buf;
} }
@ -68,7 +67,7 @@ char kb_keymap::getiso(unsigned int c)
string const kb_keymap::printKey(kb_key const & key) const string const kb_keymap::printKey(kb_key const & key) const
{ {
return printKeysym(key.code, key.mod & 0xffff); return printKeysym(key.code, key.mod.first);
} }
@ -96,7 +95,7 @@ string::size_type kb_keymap::bind(string const & seq, int action)
int kb_keymap::lookup(unsigned int key, int kb_keymap::lookup(unsigned int key,
unsigned int mod, kb_sequence * seq) const key_modifier::state mod, kb_sequence * seq) const
{ {
if (table.empty()) { if (table.empty()) {
seq->curmap = seq->stdmap; seq->curmap = seq->stdmap;
@ -104,14 +103,13 @@ int kb_keymap::lookup(unsigned int key,
return LFUN_UNKNOWN_ACTION; return LFUN_UNKNOWN_ACTION;
} }
//suppress modifier bits we do not handle
mod &= ModsMask;
for (Table::const_iterator cit = table.begin(); for (Table::const_iterator cit = table.begin();
cit != table.end(); ++cit) { cit != table.end(); ++cit) {
unsigned int const msk1 = cit->mod & 0xffff; key_modifier::state mask(cit->mod.second);
unsigned int const msk0 = (cit->mod >> 16) & 0xffff; key_modifier::state check =
if (cit->code == key && (mod & ~msk0) == msk1) { static_cast<key_modifier::state>(mod & ~mask);
if (cit->code == key && cit->mod.first == check) {
// match found // match found
if (cit->table.get()) { if (cit->table.get()) {
// this is a prefix key - set new map // this is a prefix key - set new map
@ -150,11 +148,12 @@ void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
unsigned int const code = seq->sequence[r]; unsigned int const code = seq->sequence[r];
if (code == NoSymbol) return; if (code == NoSymbol) return;
unsigned int const modmsk = seq->modifiers[r]; key_modifier::state const mod1 = seq->modifiers[r].first;
key_modifier::state const mod2 = seq->modifiers[r].second;
// check if key is already there // check if key is already there
for (Table::iterator it = table.begin(); it != table.end(); ++it) { for (Table::iterator it = table.begin(); it != table.end(); ++it) {
if (code == it->code && modmsk == it->mod) { if (code == it->code && mod1 == it->mod.first && mod2 == it->mod.second) {
// overwrite binding // overwrite binding
if (r + 1 == seq->length()) { if (r + 1 == seq->length()) {
lyxerr[Debug::KBMAP] lyxerr[Debug::KBMAP]
@ -181,7 +180,7 @@ void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
Table::iterator newone = table.insert(table.end(), kb_key()); Table::iterator newone = table.insert(table.end(), kb_key());
newone->code = code; newone->code = code;
newone->mod = modmsk; newone->mod = seq->modifiers[r];
if (r + 1 == seq->length()) { if (r + 1 == seq->length()) {
newone->action = action; newone->action = action;
newone->table.reset(); newone->table.reset();

View File

@ -16,6 +16,7 @@
#endif #endif
#include "LString.h" #include "LString.h"
#include "frontends/key_state.h"
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@ -44,7 +45,7 @@ public:
* @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
*/ */
int lookup(unsigned int key, int lookup(unsigned int key,
unsigned int mod, kb_sequence * seq) const; key_modifier::state mod, kb_sequence * seq) const;
/// Given an action, find all keybindings. /// Given an action, find all keybindings.
string const findbinding(int action, string const findbinding(int action,
@ -55,19 +56,21 @@ public:
* @param key the key * @param key the key
* @param mod the modifiers * @param mod the modifiers
*/ */
static string const printKeysym(unsigned int key, unsigned int mod); static string const printKeysym(unsigned int key, key_modifier::state mod);
/// return the ISO value of a keysym /// return the ISO value of a keysym
static char getiso(unsigned int i); static char getiso(unsigned int i);
private: private:
typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
/// ///
struct kb_key { struct kb_key {
/// Keysym /// Keysym
unsigned int code; unsigned int code;
/// Modifier masks /// Modifier masks
unsigned int mod; modifier_pair mod;
/// Keymap for prefix keys /// Keymap for prefix keys
boost::shared_ptr<kb_keymap> table; boost::shared_ptr<kb_keymap> table;

View File

@ -18,12 +18,14 @@
#pragma implementation #pragma implementation
#endif #endif
#include "frontends/mouse_state.h"
#include "kbsequence.h" #include "kbsequence.h"
#include "kbmap.h" #include "kbmap.h"
#include "commandtags.h" #include "commandtags.h"
#include "debug.h" #include "debug.h"
using std::make_pair;
using std::vector; using std::vector;
using std::endl; using std::endl;
using std::hex; using std::hex;
@ -35,7 +37,7 @@ using std::dec;
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask }; enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod) int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod)
{ {
// adding a key to a deleted sequence // adding a key to a deleted sequence
// starts a new sequence // starts a new sequence
@ -46,7 +48,7 @@ int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
modifiers.clear(); modifiers.clear();
} }
modifiers.push_back(mod + (nmod << 16)); modifiers.push_back(make_pair(mod, nmod));
sequence.push_back(key); sequence.push_back(key);
++length_; ++length_;
@ -63,8 +65,8 @@ string::size_type kb_sequence::parse(string const & s)
if (s.empty()) return 1; if (s.empty()) return 1;
string::size_type i = 0; string::size_type i = 0;
unsigned int mod = 0; key_modifier::state mod = key_modifier::none;
unsigned int nmod = 0; key_modifier::state nmod = key_modifier::none;
while (i < s.length()) { while (i < s.length()) {
if (s[i] == ' ') if (s[i] == ' ')
++i; ++i;
@ -74,15 +76,15 @@ string::size_type kb_sequence::parse(string const & s)
if (i + 1 < s.length() && s[i + 1] == '-') { if (i + 1 < s.length() && s[i + 1] == '-') {
switch (s[i]) { switch (s[i]) {
case 's': case 'S': case 's': case 'S':
mod |= ShiftMask; mod |= key_modifier::shift;
i += 2; i += 2;
continue; continue;
case 'c': case 'C': case 'c': case 'C':
mod |= ControlMask; mod |= key_modifier::ctrl;
i += 2; i += 2;
continue; continue;
case 'm': case 'M': case 'm': case 'M':
mod |= Mod1Mask; mod |= key_modifier::alt;
i += 2; i += 2;
continue; continue;
default: default:
@ -92,15 +94,15 @@ string::size_type kb_sequence::parse(string const & s)
&& s[i + 2] == '-') { && s[i + 2] == '-') {
switch (s[i + 1]) { switch (s[i + 1]) {
case 's': case 'S': case 's': case 'S':
nmod |= ShiftMask; nmod |= key_modifier::shift;
i += 3; i += 3;
continue; continue;
case 'c': case 'C': case 'c': case 'C':
nmod |= ControlMask; nmod |= key_modifier::ctrl;
i += 3; i += 3;
continue; continue;
case 'm': case 'M': case 'm': case 'M':
nmod |= Mod1Mask; nmod |= key_modifier::alt;
i += 3; i += 3;
continue; continue;
default: default:
@ -122,7 +124,7 @@ string::size_type kb_sequence::parse(string const & s)
i = j; i = j;
addkey(key, mod, nmod); addkey(key, mod, nmod);
mod = 0; mod = key_modifier::none;
} }
} }
@ -143,7 +145,7 @@ string const kb_sequence::print() const
// return buf; // return buf;
for (vector<unsigned int>::size_type i = 0; i < length_; ++i) { for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff); buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
// append a blank // append a blank
if (i + 1 < length_) { if (i + 1 < length_) {

View File

@ -12,9 +12,13 @@
#pragma interface #pragma interface
#endif #endif
#include <vector> #include <config.h>
#include "frontends/key_state.h"
#include "LString.h" #include "LString.h"
#include <vector>
class kb_keymap; class kb_keymap;
/// Holds a key sequence and the current and standard keymaps /// Holds a key sequence and the current and standard keymaps
@ -31,11 +35,13 @@ public:
/** /**
* Add a key to the key sequence and look it up in the curmap * Add a key to the key sequence and look it up in the curmap
* if the latter is defined. * if the latter is defined.
* @param text the text from the key event
* @param mod modifier mask * @param mod modifier mask
* @param nmod which modifiers to mask out for equality test * @param nmod which modifiers to mask out for equality test
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
*/ */
int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0); int addkey(unsigned int text, key_modifier::state mod,
key_modifier::state nmod = key_modifier::none);
/** /**
* Add a sequence of keys from a string to the sequence * Add a sequence of keys from a string to the sequence
@ -96,8 +102,9 @@ private:
*/ */
std::vector<unsigned int> sequence; std::vector<unsigned int> sequence;
typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
/// modifiers for keys in the sequence /// modifiers for keys in the sequence
std::vector<unsigned int> modifiers; std::vector<modifier_pair> modifiers;
/// Current length of key sequence /// Current length of key sequence
std::vector<unsigned int>::size_type length_; std::vector<unsigned int>::size_type length_;

View File

@ -165,7 +165,7 @@ LyXFunc::LyXFunc(LyXView * o)
keyseq(toplevel_keymap.get(), toplevel_keymap.get()), keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()) cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
{ {
meta_fake_bit = 0; meta_fake_bit = key_modifier::none;
lyx_dead_action = LFUN_NOACTION; lyx_dead_action = LFUN_NOACTION;
lyx_calling_dead_action = LFUN_NOACTION; lyx_calling_dead_action = LFUN_NOACTION;
} }
@ -222,7 +222,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
} }
void LyXFunc::processKeySym(KeySym keysym, unsigned int state) void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state)
{ {
string argument; string argument;
@ -232,8 +232,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
lyxerr << "KeySym is " lyxerr << "KeySym is "
<< stm << stm
<< "[" << "["
<< keysym << "] State is [" << keysym
<< state << "]"
<< endl; << endl;
} }
// Do nothing if we have nothing (JMarc) // Do nothing if we have nothing (JMarc)
@ -256,33 +255,30 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
// cancel and meta-fake keys. RVDK_PATCH_5 // cancel and meta-fake keys. RVDK_PATCH_5
cancel_meta_seq.reset(); cancel_meta_seq.reset();
int action = cancel_meta_seq.addkey(keysym, state int action = cancel_meta_seq.addkey(keysym, state);
&(ShiftMask|ControlMask
|Mod1Mask));
if (lyxerr.debugging(Debug::KEY)) { if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "action first set to [" << action << "]" << endl; lyxerr << "action first set to [" << action << "]" << endl;
} }
// When not cancel or meta-fake, do the normal lookup. // When not cancel or meta-fake, do the normal lookup.
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
// Mostly, meta_fake_bit = 0. RVDK_PATCH_5. // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) { if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
#if 0
if (lyxerr.debugging(Debug::KEY)) { if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "meta_fake_bit is [" lyxerr << "meta_fake_bit is ["
<< meta_fake_bit << "]" << endl; << meta_fake_bit << "]" << endl;
} }
#endif
// remove Caps Lock and Mod2 as a modifiers // remove Caps Lock and Mod2 as a modifiers
action = keyseq.addkey(keysym, action = keyseq.addkey(keysym, (state | meta_fake_bit));
(state | meta_fake_bit)
&(ShiftMask|ControlMask
|Mod1Mask));
if (lyxerr.debugging(Debug::KEY)) { if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "action now set to [" lyxerr << "action now set to ["
<< action << "]" << endl; << action << "]" << endl;
} }
} }
// Dont remove this unless you know what you are doing. // Dont remove this unless you know what you are doing.
meta_fake_bit = 0; meta_fake_bit = key_modifier::none;
// can this happen now ? // can this happen now ?
if (action == LFUN_NOACTION) { if (action == LFUN_NOACTION) {
@ -307,7 +303,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
if (action == LFUN_UNKNOWN_ACTION) { if (action == LFUN_UNKNOWN_ACTION) {
// It is unknown, but what if we remove all // It is unknown, but what if we remove all
// the modifiers? (Lgb) // the modifiers? (Lgb)
action = keyseq.addkey(keysym, 0); action = keyseq.addkey(keysym, key_modifier::none);
if (lyxerr.debugging(Debug::KEY)) { if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "Removing modifiers...\n" lyxerr << "Removing modifiers...\n"
@ -1075,7 +1071,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
case LFUN_CANCEL: // RVDK_PATCH_5 case LFUN_CANCEL: // RVDK_PATCH_5
keyseq.reset(); keyseq.reset();
meta_fake_bit = 0; meta_fake_bit = key_modifier::none;
if (owner->view()->available()) if (owner->view()->available())
// cancel any selection // cancel any selection
dispatch(LFUN_MARK_OFF); dispatch(LFUN_MARK_OFF);
@ -1084,7 +1080,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
case LFUN_META_FAKE: // RVDK_PATCH_5 case LFUN_META_FAKE: // RVDK_PATCH_5
{ {
meta_fake_bit = Mod1Mask; meta_fake_bit = key_modifier::alt;
setMessage(keyseq.print()); setMessage(keyseq.print());
} }
break; break;

View File

@ -9,6 +9,8 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <sigc++/signal_system.h> #include <sigc++/signal_system.h>
#include "frontends/mouse_state.h"
#include "frontends/key_state.h"
#include "commandtags.h" // for kb_action enum #include "commandtags.h" // for kb_action enum
#include "FuncStatus.h" #include "FuncStatus.h"
#include "kbsequence.h" #include "kbsequence.h"
@ -52,7 +54,7 @@ public:
void initMiniBuffer(); void initMiniBuffer();
/// ///
void processKeySym(KeySym k, unsigned int state); void processKeySym(KeySym key, key_modifier::state state);
/// we need one internal which is called from inside LyXAction and /// we need one internal which is called from inside LyXAction and
/// can contain the string argument. /// can contain the string argument.
@ -89,7 +91,7 @@ private:
/// ///
kb_sequence cancel_meta_seq; kb_sequence cancel_meta_seq;
/// ///
unsigned meta_fake_bit; key_modifier::state meta_fake_bit;
/// ///
void moveCursorUpdate(bool flag = true, bool selecting = false); void moveCursorUpdate(bool flag = true, bool selecting = false);
/// ///
@ -139,7 +141,7 @@ private:
inline inline
bool LyXFunc::wasMetaKey() const bool LyXFunc::wasMetaKey() const
{ {
return (meta_fake_bit != 0); return (meta_fake_bit != key_modifier::none);
} }

View File

@ -1,3 +1,9 @@
2002-05-26 John Levon <moz@compsoc.man.ac.uk>
* formulabase.C:
* formulabase.h:
* math_inset.h: use mouse_state. Kill insetKeyPress
2002-05-24 John Levon <moz@compsoc.man.ac.uk> 2002-05-24 John Levon <moz@compsoc.man.ac.uk>
* math_support.C: font loader moved * math_support.C: font loader moved

View File

@ -34,8 +34,8 @@
#include "math_support.h" #include "math_support.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
#include "frontends/mouse_state.h"
#include "Lsstream.h" #include "Lsstream.h"
#include "math_arrayinset.h" #include "math_arrayinset.h"
#include "math_charinset.h" #include "math_charinset.h"
@ -73,7 +73,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
delete new_inset; delete new_inset;
return false; return false;
} }
new_inset->edit(bv, 0, 0, 0); new_inset->edit(bv, 0, 0, mouse_button::none);
return true; return true;
} }
@ -142,7 +142,7 @@ string const InsetFormulaBase::editMessage() const
} }
void InsetFormulaBase::edit(BufferView * bv, int x, int y, unsigned int) void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
{ {
if (!bv->lockInset(this)) if (!bv->lockInset(this))
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
@ -278,7 +278,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
bool InsetFormulaBase::insetButtonRelease(BufferView * bv, bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
int /*x*/, int /*y*/, int button) int /*x*/, int /*y*/, mouse_button::state button)
{ {
//lyxerr << "insetButtonRelease: " << x << " " << y << "\n"; //lyxerr << "insetButtonRelease: " << x << " " << y << "\n";
@ -288,7 +288,7 @@ bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
showInsetCursor(bv); showInsetCursor(bv);
bv->updateInset(this, false); bv->updateInset(this, false);
if (button == 3) { if (button == mouse_button::button3) {
// launch math panel for right mouse button // launch math panel for right mouse button
bv->owner()->getDialogs()->showMathPanel(); bv->owner()->getDialogs()->showMathPanel();
return true; return true;
@ -298,7 +298,7 @@ bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
void InsetFormulaBase::insetButtonPress(BufferView * bv, void InsetFormulaBase::insetButtonPress(BufferView * bv,
int x, int y, int button) int x, int y, mouse_button::state button)
{ {
//lyxerr << "insetButtonPress: " //lyxerr << "insetButtonPress: "
// << x << " " << y << " but: " << button << "\n"; // << x << " " << y << " but: " << button << "\n";
@ -337,7 +337,7 @@ void InsetFormulaBase::insetButtonPress(BufferView * bv,
break; break;
} }
#else #else
if (button == 1 || !mathcursor) { if (button == mouse_button::button1 || !mathcursor) {
delete mathcursor; delete mathcursor;
mathcursor = new MathCursor(this, x == 0); mathcursor = new MathCursor(this, x == 0);
metrics(bv); metrics(bv);
@ -359,7 +359,7 @@ void InsetFormulaBase::insetButtonPress(BufferView * bv,
void InsetFormulaBase::insetMotionNotify(BufferView * bv, void InsetFormulaBase::insetMotionNotify(BufferView * bv,
int x, int y, int /*button*/) int x, int y, mouse_button::state)
{ {
if (!mathcursor) if (!mathcursor)
return; return;
@ -383,12 +383,6 @@ void InsetFormulaBase::insetMotionNotify(BufferView * bv,
} }
void InsetFormulaBase::insetKeyPress(XKeyEvent *)
{
lyxerr[Debug::MATHED] << "Used InsetFormulaBase::InsetKeyPress." << endl;
}
UpdatableInset::RESULT UpdatableInset::RESULT
InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
string const & arg) string const & arg)

View File

@ -21,6 +21,7 @@
#include <iosfwd> #include <iosfwd>
#include "insets/inset.h" #include "insets/inset.h"
#include "frontends/mouse_state.h"
#include "lyxfont.h" #include "lyxfont.h"
// only for getType(): // only for getType():
@ -64,7 +65,7 @@ public:
/// what appears in the minibuffer when opening /// what appears in the minibuffer when opening
virtual string const editMessage() const; virtual string const editMessage() const;
/// ///
virtual void edit(BufferView *, int x, int y, unsigned int button); virtual void edit(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual void edit(BufferView *, bool front = true); virtual void edit(BufferView *, bool front = true);
/// ///
@ -78,13 +79,11 @@ public:
/// ///
virtual void toggleInsetSelection(BufferView * bv); virtual void toggleInsetSelection(BufferView * bv);
/// ///
virtual void insetButtonPress(BufferView *, int x, int y, int button); virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual bool insetButtonRelease(BufferView *, int x, int y, int button); virtual bool insetButtonRelease(BufferView *, int x, int y, mouse_button::state button);
/// ///
virtual void insetKeyPress(XKeyEvent * ev); virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
///
virtual void insetMotionNotify(BufferView *, int x, int y, int state);
/// ///
virtual void insetUnlock(BufferView *); virtual void insetUnlock(BufferView *);

View File

@ -28,6 +28,7 @@
#pragma interface #pragma interface
#endif #endif
#include "frontends/mouse_state.h"
#include "math_xdata.h" #include "math_xdata.h"
#include "math_defs.h" #include "math_defs.h"
@ -224,7 +225,7 @@ public:
virtual bool needsBraces() const { return true; } virtual bool needsBraces() const { return true; }
/// ///
virtual void edit(BufferView *, int, int, unsigned int) {} virtual void edit(BufferView *, int, int, mouse_button::state) {}
/// request "external features" /// request "external features"
virtual void validate(LaTeXFeatures & features) const; virtual void validate(LaTeXFeatures & features) const;

View File

@ -2332,7 +2332,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const
Inset * inset_hit = Inset * inset_hit =
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1); bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) { if (inset_hit && isHighlyEditableInset(inset_hit)) {
inset_hit->edit(bview, x, y - (y2 - y1), 0); inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
} }
} }
#else #else
@ -2356,7 +2356,7 @@ void LyXText::cursorDown(BufferView * bview, bool selecting) const
Inset * inset_hit = Inset * inset_hit =
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1); bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) { if (inset_hit && isHighlyEditableInset(inset_hit)) {
inset_hit->edit(bview, x, y - (y2 - y1), 0); inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
} }
} }
#else #else