summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-01-06 02:15:06 +0000
committercorvid <corvid@lavabit.com>2011-01-06 02:15:06 +0000
commit64d3ecbb49ca39a39fda0fe77732cb09a43a401c (patch)
tree697318ded5c627f634c3875989077ae3b3e6b37c /src
parent006e1bd1bd9f9e076f31232950a134c75026f0cf (diff)
keys and mouse buttons
Diffstat (limited to 'src')
-rw-r--r--src/findbar.cc22
-rw-r--r--src/keys.cc140
-rw-r--r--src/menu.cc4
-rw-r--r--src/ui.cc22
-rw-r--r--src/uicmd.cc12
5 files changed, 100 insertions, 100 deletions
diff --git a/src/findbar.cc b/src/findbar.cc
index 8cca52ba..915d355a 100644
--- a/src/findbar.cc
+++ b/src/findbar.cc
@@ -35,15 +35,15 @@ int MyInput::handle(int e)
{
_MSG("findbar MyInput::handle()\n");
int ret = 1, k = event_key();
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
+ unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
if (e == KEY) {
- if (k == LeftKey || k == RightKey) {
- if (modifier == SHIFT) {
+ if (k == FL_Left || k == FL_Right) {
+ if (modifier == FL_SHIFT) {
a_UIcmd_send_event_to_tabs_by_wid(e, this);
return 1;
}
- } else if (k == EscapeKey && modifier == 0) {
+ } else if (k == FL_Escape && modifier == 0) {
// Avoid clearing the text with Esc, just hide the findbar.
return 0;
}
@@ -92,7 +92,7 @@ void Findbar::search_cb2(Widget *widget, void *vfb)
* Somehow fltk even regards the first loss of focus for the
* window as a WHEN_ENTER_KEY_ALWAYS event.
*/
- if (event_key() == ReturnKey)
+ if (event_key() == FL_Enter)
search_cb(widget, vfb);
}
@@ -139,13 +139,13 @@ Findbar::Findbar(int width, int height) :
next_btn = new HighlightButton(x, border, button_width, height, "Next");
x += button_width + gap;
- next_btn->add_shortcut(ReturnKey);
- next_btn->add_shortcut(KeypadEnter);
+ next_btn->add_shortcut(FL_Enter);
+ next_btn->add_shortcut(FL_KP_Enter);
next_btn->callback(search_cb, this);
next_btn->clear_tab_to_focus();
prev_btn= new HighlightButton(x, border, button_width, height, "Previous");
- prev_btn->add_shortcut(SHIFT+ReturnKey);
+ prev_btn->add_shortcut(FL_SHIFT+FL_Enter);
prev_btn->callback(searchBackwards_cb, this);
prev_btn->clear_tab_to_focus();
x += button_width + gap;
@@ -172,15 +172,15 @@ Findbar::~Findbar()
}
/*
- * Handle events. Used to catch EscapeKey events.
+ * Handle events. Used to catch FL_Escape events.
*/
int Findbar::handle(int event)
{
int ret = 0;
int k = event_key();
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
+ unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
- if (event == KEY && modifier == 0 && k == EscapeKey) {
+ if (event == KEY && modifier == 0 && k == FL_Escape) {
hide();
ret = 1;
}
diff --git a/src/keys.cc b/src/keys.cc
index 1a39f4c8..a3430c72 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -38,80 +38,80 @@ typedef struct {
* Local data
*/
static const Mapping_t keyNames[] = {
- { "Backspace", fltk::BackSpaceKey },
- { "Delete", fltk::DeleteKey },
- { "Down", fltk::DownKey },
- { "End", fltk::EndKey },
- { "Esc", fltk::EscapeKey },
- { "F1", fltk::F1Key },
- { "F2", fltk::F2Key },
- { "F3", fltk::F3Key },
- { "F4", fltk::F4Key },
- { "F5", fltk::F5Key },
- { "F6", fltk::F6Key },
- { "F7", fltk::F7Key },
- { "F8", fltk::F8Key },
- { "F9", fltk::F9Key },
- { "F10", fltk::F10Key },
- { "F11", fltk::F11Key },
- { "F12", fltk::F12Key },
- { "Home", fltk::HomeKey },
- { "Insert", fltk::InsertKey },
- { "Left", fltk::LeftKey },
- { "PageDown", fltk::PageDownKey },
- { "PageUp", fltk::PageUpKey },
- { "Print", fltk::PrintKey },
- { "Return", fltk::ReturnKey },
- { "Right", fltk::RightKey },
- { "Space", fltk::SpaceKey },
- { "Tab", fltk::TabKey },
- { "Up", fltk::UpKey }
+ { "Backspace", FL_BackSpace },
+ { "Delete", FL_Delete },
+ { "Down", FL_Down },
+ { "End", FL_End },
+ { "Esc", FL_Escape },
+ { "F1", FL_F1 },
+ { "F2", FL_F2 },
+ { "F3", FL_F3 },
+ { "F4", FL_F4 },
+ { "F5", FL_F5 },
+ { "F6", FL_F6 },
+ { "F7", FL_F7 },
+ { "F8", FL_F8 },
+ { "F9", FL_F9 },
+ { "F10", FL_F10 },
+ { "F11", FL_F11 },
+ { "F12", FL_F12 },
+ { "Home", FL_Home },
+ { "Insert", FL_Insert },
+ { "Left", FL_Left },
+ { "PageDown", FL_Page_Down },
+ { "PageUp", FL_Page_Up },
+ { "Print", FL_Print },
+ { "Return", FL_Enter },
+ { "Right", FL_Right },
+ { "Space", ' ' },
+ { "Tab", FL_Tab },
+ { "Up", FL_Up }
};
static const Mapping_t modifierNames[] = {
- { "Shift", fltk::SHIFT },
- { "Ctrl", fltk::CTRL },
- { "Alt", fltk::ALT },
- { "Meta", fltk::META },
- { "Button1", fltk::BUTTON1 },
- { "Button2", fltk::BUTTON2 },
- { "Button3", fltk::BUTTON3 }
+ { "Shift", FL_SHIFT },
+ { "Ctrl", FL_CTRL },
+ { "Alt", FL_ALT },
+ { "Meta", FL_META },
+ { "Button1", FL_BUTTON1 },
+ { "Button2", FL_BUTTON2 },
+ { "Button3", FL_BUTTON3 }
};
static const KeyBinding_t default_keys[] = {
- { "nop" , KEYS_NOP , 0 , 0 },
- { "open" , KEYS_OPEN , fltk::CTRL , 'o' },
- { "new-window" , KEYS_NEW_WINDOW , fltk::CTRL , 'n' },
- { "new-tab" , KEYS_NEW_TAB , fltk::CTRL , 't' },
- { "left-tab" , KEYS_LEFT_TAB , fltk::SHIFT , fltk::TabKey },
- { "right-tab" , KEYS_RIGHT_TAB , fltk::CTRL , fltk::TabKey },
- { "close-tab" , KEYS_CLOSE_TAB , fltk::CTRL , 'q' },
- { "find" , KEYS_FIND , fltk::CTRL , 'f' },
- { "websearch" , KEYS_WEBSEARCH , fltk::CTRL , 's' },
- { "bookmarks" , KEYS_BOOKMARKS , fltk::CTRL , 'b' },
- { "fullscreen" , KEYS_FULLSCREEN , fltk::CTRL , fltk::SpaceKey },
- { "reload" , KEYS_RELOAD , fltk::CTRL , 'r' },
- { "stop" , KEYS_STOP , 0 , 0 },
- { "save" , KEYS_SAVE , 0 , 0 },
- { "hide-panels" , KEYS_HIDE_PANELS , 0 , fltk::EscapeKey },
- { "file-menu" , KEYS_FILE_MENU , fltk::ALT , 'f' },
- { "close-all" , KEYS_CLOSE_ALL , fltk::ALT , 'q' },
- { "back" , KEYS_BACK , 0 , fltk::BackSpaceKey },
- { "back" , KEYS_BACK , 0 , ',' },
- { "forward" , KEYS_FORWARD , fltk::SHIFT , fltk::BackSpaceKey },
- { "forward" , KEYS_FORWARD , 0 , '.' },
- { "goto" , KEYS_GOTO , fltk::CTRL , 'l' },
- { "home" , KEYS_HOME , fltk::CTRL , 'h' },
- { "screen-up" , KEYS_SCREEN_UP , 0 , fltk::PageUpKey },
- { "screen-up" , KEYS_SCREEN_UP , 0 , 'b' },
- { "screen-down" , KEYS_SCREEN_DOWN , 0 , fltk::PageDownKey },
- { "screen-down" , KEYS_SCREEN_DOWN , 0 , fltk::SpaceKey },
- { "line-up" , KEYS_LINE_UP , 0 , fltk::UpKey },
- { "line-down" , KEYS_LINE_DOWN , 0 , fltk::DownKey },
- { "left" , KEYS_LEFT , 0 , fltk::LeftKey },
- { "right" , KEYS_RIGHT , 0 , fltk::RightKey },
- { "top" , KEYS_TOP , 0 , fltk::HomeKey },
- { "bottom" , KEYS_BOTTOM , 0 , fltk::EndKey },
+ { "nop" , KEYS_NOP , 0 , 0 },
+ { "open" , KEYS_OPEN , FL_CTRL , 'o' },
+ { "new-window" , KEYS_NEW_WINDOW , FL_CTRL , 'n' },
+ { "new-tab" , KEYS_NEW_TAB , FL_CTRL , 't' },
+ { "left-tab" , KEYS_LEFT_TAB , FL_SHIFT , FL_Tab },
+ { "right-tab" , KEYS_RIGHT_TAB , FL_CTRL , FL_Tab },
+ { "close-tab" , KEYS_CLOSE_TAB , FL_CTRL , 'q' },
+ { "find" , KEYS_FIND , FL_CTRL , 'f' },
+ { "websearch" , KEYS_WEBSEARCH , FL_CTRL , 's' },
+ { "bookmarks" , KEYS_BOOKMARKS , FL_CTRL , 'b' },
+ { "fullscreen" , KEYS_FULLSCREEN , FL_CTRL , ' ' },
+ { "reload" , KEYS_RELOAD , FL_CTRL , 'r' },
+ { "stop" , KEYS_STOP , 0 , 0 },
+ { "save" , KEYS_SAVE , 0 , 0 },
+ { "hide-panels" , KEYS_HIDE_PANELS , 0 , FL_Escape },
+ { "file-menu" , KEYS_FILE_MENU , FL_ALT , 'f' },
+ { "close-all" , KEYS_CLOSE_ALL , FL_ALT , 'q' },
+ { "back" , KEYS_BACK , 0 , FL_BackSpace },
+ { "back" , KEYS_BACK , 0 , ',' },
+ { "forward" , KEYS_FORWARD , FL_SHIFT , FL_BackSpace },
+ { "forward" , KEYS_FORWARD , 0 , '.' },
+ { "goto" , KEYS_GOTO , FL_CTRL , 'l' },
+ { "home" , KEYS_HOME , FL_CTRL , 'h' },
+ { "screen-up" , KEYS_SCREEN_UP , 0 , FL_Page_Up },
+ { "screen-up" , KEYS_SCREEN_UP , 0 , 'b' },
+ { "screen-down" , KEYS_SCREEN_DOWN , 0 , FL_Page_Down },
+ { "screen-down" , KEYS_SCREEN_DOWN , 0 , ' ' },
+ { "line-up" , KEYS_LINE_UP , 0 , FL_Up },
+ { "line-down" , KEYS_LINE_DOWN , 0 , FL_Down },
+ { "left" , KEYS_LEFT , 0 , FL_Left },
+ { "right" , KEYS_RIGHT , 0 , FL_Right },
+ { "top" , KEYS_TOP , 0 , FL_Home },
+ { "bottom" , KEYS_BOTTOM , 0 , FL_End },
};
static Dlist *bindings;
@@ -174,9 +174,9 @@ KeysCommand_t Keys::getKeyCmd()
KeyBinding_t keyNode;
// We're only interested in some flags
keyNode.modifier = fltk::event_state() &
- (fltk::SHIFT | fltk::CTRL | fltk::ALT | fltk::META);
+ (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
- if (keyNode.modifier == fltk::SHIFT &&
+ if (keyNode.modifier == FL_SHIFT &&
ispunct(fltk::event_text()[0])) {
// Get key code for a shifted character
keyNode.key = fltk::event_text()[0];
diff --git a/src/menu.cc b/src/menu.cc
index d802bddb..e032c189 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -139,7 +139,7 @@ static void Menu_open_url_nw_cb(Widget* )
static void Menu_open_url_nt_cb(Widget* )
{
int focus = prefs.focus_new_tab ? 1 : 0;
- if (event_state(SHIFT)) focus = !focus;
+ if (event_state(FL_SHIFT)) focus = !focus;
a_UIcmd_open_url_nt(popup_bw, popup_url, focus);
}
@@ -293,7 +293,7 @@ static void Menu_history_cb(Widget *wid, void *data)
// Middle button, open in a new window/tab
if (prefs.middle_click_opens_new_tab) {
int focus = prefs.focus_new_tab ? 1 : 0;
- if (event_state(SHIFT)) focus = !focus;
+ if (event_state(FL_SHIFT)) focus = !focus;
a_UIcmd_open_url_nt(popup_bw, url, focus);
} else {
a_UIcmd_open_url_nw(popup_bw, url);
diff --git a/src/ui.cc b/src/ui.cc
index fac78604..c6ee971d 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -103,8 +103,8 @@ public:
};
/*
- * Disable: UpKey, DownKey, PageUpKey, PageDownKey and
- * CTRL+{o,r,HomeKey,EndKey}
+ * Disable keys: Up, Down, Page_Up, Page_Down and
+ * CTRL+{o,r,Home,End}
*/
int CustInput::handle(int e)
{
@@ -113,23 +113,23 @@ int CustInput::handle(int e)
_MSG("CustInput::handle event=%d\n", e);
// We're only interested in some flags
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
+ unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
// Don't focus with arrow keys
if (e == FOCUS &&
- (k == UpKey || k == DownKey || k == LeftKey || k == RightKey)) {
+ (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
return 0;
} else if (e == KEY) {
- if (modifier == CTRL) {
+ if (modifier == FL_CTRL) {
if (k == 'l') {
// Make text selected when already focused.
position(size(), 0);
return 1;
- } else if (k == 'o' || k == 'r' || k == HomeKey || k == EndKey)
+ } else if (k == 'o' || k == 'r' || k == FL_Home || k == FL_End)
return 0;
- } else if (modifier == SHIFT) {
- if (k == LeftKey || k == RightKey) {
- _MSG(" CustInput::handle > SHIFT+RightKey\n");
+ } else if (modifier == FL_SHIFT) {
+ if (k == FL_Left || k == FL_Right) {
+ _MSG(" CustInput::handle > FL_SHIFT+FL_Right\n");
a_UIcmd_send_event_to_tabs_by_wid(e, this);
return 1;
}
@@ -288,7 +288,7 @@ static void location_cb(Widget *wid, void *data)
* other events we're not interested in. For instance pressing
* The Back or Forward, buttons, or the first click on a rendered
* page. BUG: this must be investigated and reported to FLTK2 team */
- if (event_key() == ReturnKey) {
+ if (event_key() == FL_Enter) {
a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
}
if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) {
@@ -853,7 +853,7 @@ int UI::handle(int event)
}
} else if (event == PUSH) {
if (prefs.middle_click_drags_page == 0 &&
- event_button() == MiddleButton &&
+ event_button() == FL_MIDDLE_MOUSE &&
!a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) {
if (Main->Rectangle::contains (event_x (), event_y ())) {
/* Offer the event to Main's children (form widgets) */
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 001165d6..6b3287a6 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -249,13 +249,13 @@ public:
if (e == KEY) {
int k = event_key();
// We're only interested in some flags
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
- if (k == UpKey || k == DownKey || k == TabKey) {
+ unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
+ if (k == FL_Up || k == FL_Down || k == FL_Tab) {
return 0;
- } else if (k == LeftKey || k == RightKey) {
- if (modifier == SHIFT) {
+ } else if (k == FL_Left || k == FL_Right) {
+ if (modifier == FL_SHIFT) {
int i = value();
- if (k == LeftKey) {i = i ? i-1 : children()-1;}
+ if (k == FL_Left) {i = i ? i-1 : children()-1;}
else {i++; if (i >= children()) i = 0;}
selected_child(child(i));
return 1;
@@ -383,7 +383,7 @@ BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid)
}
/*
- * FLTK regards SHIFT + {LeftKey, Right} as navigation keys.
+ * FLTK regards SHIFT + {Left, Right} as navigation keys.
* Special handling is required to override it. Here we route
* these events directly to the recipient.
* TODO: focus is not remembered correctly.