1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 14:56:39 +02:00

core: add "/input grab_mouse" and "/input grab_mouse_area" (default: right click on input bar)

This commit is contained in:
Sebastien Helleu
2011-07-30 15:44:55 +02:00
parent ca3c1e2636
commit 95b179dd08
27 changed files with 227 additions and 62 deletions
+2
View File
@@ -304,6 +304,8 @@ list of actions:
hotlist_clear: clear hotlist
grab_key: grab a key (optional argument: delay for end of grab, default is 500 milliseconds)
grab_key_command: grab a key with its associated command (optional argument: delay for end of grab, default is 500 milliseconds)
grab_mouse: grab mouse event code
grab_mouse_area: grab mouse event code with area
scroll_unread: scroll to unread marker
set_unread: set unread marker for all buffers
set_unread_current_buffer: set unread marker for current buffer
+1
View File
@@ -586,6 +586,7 @@ These keys are used in context "mouse", namely when a mouse event occurs.
| ◾◽◽ | left | nicklist | Kick nick | /window ${_window_number};/kick ${nick}
| ◾◽◽ | left (long) | nicklist | Kick and ban nick | /window ${_window_number};/kickban ${nick}
| ◽◽◾ | left | nicklist | Ban nick | /window ${_window_number};/ban ${nick}
| ◽◽◾ | - | input | Grab a mouse event and insert its code in command line | /input grab_mouse_area
| wheel ⇑ | - | any bar | Scroll bar by -10% | /bar scroll ${_bar_name} ${_window_number} -10%
| wheel ⇓ | - | any bar | Scroll bar by +10% | /bar scroll ${_bar_name} ${_window_number} +10%
| ◽◾◽ | - | anywhere | Start cursor mode at this point | /cursor go ${_x},${_y}
+2
View File
@@ -304,6 +304,8 @@ list of actions:
hotlist_clear: clear hotlist
grab_key: grab a key (optional argument: delay for end of grab, default is 500 milliseconds)
grab_key_command: grab a key with its associated command (optional argument: delay for end of grab, default is 500 milliseconds)
grab_mouse: grab mouse event code
grab_mouse_area: grab mouse event code with area
scroll_unread: scroll to unread marker
set_unread: set unread marker for all buffers
set_unread_current_buffer: set unread marker for current buffer
+1
View File
@@ -584,6 +584,7 @@ These keys are used in context "mouse", namely when a mouse event occurs.
| ◾◽◽ | left | nicklist | Kick nick | /window ${_window_number};/kick ${nick}
| ◾◽◽ | left (long) | nicklist | Kick and ban nick | /window ${_window_number};/kickban ${nick}
| ◽◽◾ | left | nicklist | Ban nick | /window ${_window_number};/ban ${nick}
| ◽◽◾ | - | input | Grab a mouse event and insert its code in command line | /input grab_mouse_area
| wheel ⇑ | - | any bar | Scroll bar by -10% | /bar scroll ${_bar_name} ${_window_number} -10%
| wheel ⇓ | - | any bar | Scroll bar by +10% | /bar scroll ${_bar_name} ${_window_number} +10%
| ◽◾◽ | - | anywhere | Start cursor mode at this point | /cursor go ${_x},${_y}
+2
View File
@@ -304,6 +304,8 @@ list des actions:
hotlist_clear: effacer la hotlist
grab_key: capturer une touche (paramètre facultatif: délai pour la fin de la capture, par défaut 500 millisecondes)
grab_key_command: capturer une touche avec sa commande associée (paramètre facultatif: délai pour la fin de la capture, par défaut 500 millisecondes)
grab_mouse: capturer un évènement de la souris
grab_mouse_area: capturer un évènement de la souris avec la zone
scroll_unread: faire défiler jusqu'au marqueur de données non lues
set_unread: définir le marqueur de données non lues pour tous les tampons
set_unread_current_buffer: définir le marqueur de données non lues pour le tampon courant
+1
View File
@@ -594,6 +594,7 @@ Ces touches sont utilisées dans le contexte "mouse", c'est-à-dire lorsqu'un
| ◾◽◽ | left | liste des pseudos | Retirer par la force le pseudo | /window ${_window_number};/kick ${nick}
| ◾◽◽ | left (long) | liste des pseudos | Retirer par la force et bannir le pseudo | /window ${_window_number};/kickban ${nick}
| ◽◽◾ | left | liste des pseudos | Bannir le pseudo | /window ${_window_number};/ban ${nick}
| ◽◽◾ | - | ligne de commande | Capturer un évènement de la souris et insérer son code sur la ligne de commande | /input grab_mouse_area
| roulette ⇑ | - | toute barre | Faire défiler la barre de -10% | /bar scroll ${_bar_name} ${_window_number} -10%
| roulette ⇓ | - | toute barre | Faire défiler la barre de +10% | /bar scroll ${_bar_name} ${_window_number} +10%
| ◽◾◽ | - | n'importe où | Démarrer le mode curseur ("cursor") à ce point | /cursor go ${_x},${_y}
+2
View File
@@ -304,6 +304,8 @@ list of actions:
hotlist_clear: clear hotlist
grab_key: grab a key (optional argument: delay for end of grab, default is 500 milliseconds)
grab_key_command: grab a key with its associated command (optional argument: delay for end of grab, default is 500 milliseconds)
grab_mouse: grab mouse event code
grab_mouse_area: grab mouse event code with area
scroll_unread: scroll to unread marker
set_unread: set unread marker for all buffers
set_unread_current_buffer: set unread marker for current buffer
+1
View File
@@ -594,6 +594,7 @@ These keys are used in context "mouse", namely when a mouse event occurs.
| ◾◽◽ | left | nicklist | Kick nick | /window ${_window_number};/kick ${nick}
| ◾◽◽ | left (long) | nicklist | Kick and ban nick | /window ${_window_number};/kickban ${nick}
| ◽◽◾ | left | nicklist | Ban nick | /window ${_window_number};/ban ${nick}
| ◽◽◾ | - | input | Grab a mouse event and insert its code in command line | /input grab_mouse_area
| wheel ⇑ | - | any bar | Scroll bar by -10% | /bar scroll ${_bar_name} ${_window_number} -10%
| wheel ⇓ | - | any bar | Scroll bar by +10% | /bar scroll ${_bar_name} ${_window_number} +10%
| ◽◾◽ | - | anywhere | Start cursor mode at this point | /cursor go ${_x},${_y}
+3 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-05 15:37+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1360,6 +1360,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-14 20:53+0100\n"
"Last-Translator: Nils Görs\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1395,6 +1395,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-05 15:37+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1368,6 +1368,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+6 -2
View File
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"PO-Revision-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-30 14:38+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@@ -1390,6 +1390,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
@@ -1442,6 +1444,8 @@ msgstr ""
"la capture, par défaut 500 millisecondes)\n"
" grab_key_command: capturer une touche avec sa commande associée (paramètre "
"facultatif: délai pour la fin de la capture, par défaut 500 millisecondes)\n"
" grab_mouse: capturer un évènement de la souris\n"
" grab_mouse_area: capturer un évènement de la souris avec la zone\n"
" scroll_unread: faire défiler jusqu'au marqueur de données non lues\n"
" set_unread: définir le marqueur de données non lues pour tous les tampons\n"
" set_unread_current_buffer: définir le marqueur de données non lues pour le "
+3 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1239,6 +1239,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-16 11:32+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1367,6 +1367,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-07-05 15:38+0200\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1371,6 +1371,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1367,6 +1367,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1247,6 +1247,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+3 -1
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-07-30 08:54+0200\n"
"POT-Creation-Date: 2011-07-30 14:37+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1095,6 +1095,8 @@ msgid ""
"500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
"argument: delay for end of grab, default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for current buffer\n"
+13 -4
View File
@@ -2287,9 +2287,13 @@ COMMAND_CALLBACK(input)
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
gui_input_hotlist_clear (buffer);
else if (string_strcasecmp (argv[1], "grab_key") == 0)
gui_input_grab_key (buffer, (argc > 2) ? argv[2] : NULL);
gui_input_grab_key (buffer, 0, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_key_command") == 0)
gui_input_grab_key_command (buffer, (argc > 2) ? argv[2] : NULL);
gui_input_grab_key (buffer, 1, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_mouse") == 0)
gui_input_grab_mouse (buffer, 0);
else if (string_strcasecmp (argv[1], "grab_mouse_area") == 0)
gui_input_grab_mouse (buffer, 1);
else if (string_strcasecmp (argv[1], "scroll_unread") == 0)
gui_input_scroll_unread (buffer);
else if (string_strcasecmp (argv[1], "set_unread") == 0)
@@ -3093,6 +3097,7 @@ COMMAND_CALLBACK(mouse)
return WEECHAT_RC_OK;
}
/* enable mouse */
if (string_strcasecmp (argv[1], "enable") == 0)
{
gui_mouse_enable ();
@@ -3101,6 +3106,7 @@ COMMAND_CALLBACK(mouse)
return WEECHAT_RC_OK;
}
/* disable mouse */
if (string_strcasecmp (argv[1], "disable") == 0)
{
gui_mouse_disable ();
@@ -3109,6 +3115,7 @@ COMMAND_CALLBACK(mouse)
return WEECHAT_RC_OK;
}
/* toggle mouse */
if (string_strcasecmp (argv[1], "toggle") == 0)
{
if (gui_mouse_enabled)
@@ -5460,6 +5467,8 @@ command_init ()
" grab_key_command: grab a key with its associated "
"command (optional argument: delay for end of grab, "
"default is 500 milliseconds)\n"
" grab_mouse: grab mouse event code\n"
" grab_mouse_area: grab mouse event code with area\n"
" scroll_unread: scroll to unread marker\n"
" set_unread: set unread marker for all buffers\n"
" set_unread_current_buffer: set unread marker for "
@@ -5481,8 +5490,8 @@ command_init ()
"history_global_previous|history_global_next|"
"jump_smart|jump_last_buffer|jump_previously_visited_buffer|"
"jump_next_visited_buffer|hotlist_clear|grab_key|"
"grab_key_command|scroll_unread|set_unread|"
"set_unread_current_buffer|switch_active_buffer|"
"grab_key_command|grab_mouse|grab_mouse_area|scroll_unread|"
"set_unread|set_unread_current_buffer|switch_active_buffer|"
"switch_active_buffer_previous|insert",
&command_input, NULL);
hook_command (NULL, "key",
+3 -1
View File
@@ -263,6 +263,8 @@ gui_key_default_bindings (int context)
BIND("@item(buffer_nicklist):button1-gesture-left", "/window ${_window_number};/kick ${nick}");
BIND("@item(buffer_nicklist):button1-gesture-left-long", "/window ${_window_number};/kickban ${nick}");
BIND("@item(buffer_nicklist):button2-gesture-left", "/window ${_window_number};/ban ${nick}");
/* mouse events on input */
BIND("@bar(input):button2", "/input grab_mouse_area");
/* mouse wheel on any bar */
BIND("@bar(*):wheelup", "/bar scroll ${_bar_name} ${_window_number} -10%");
BIND("@bar(*):wheeldown", "/bar scroll ${_bar_name} ${_window_number} +10%");
@@ -296,7 +298,7 @@ gui_key_flush ()
insert_ok = 1;
if (gui_mouse_grab)
if (gui_mouse_event_pending)
{
insert_ok = 0;
key_str[0] = (char) key;
+122 -20
View File
@@ -34,9 +34,16 @@
#include "../../core/wee-hook.h"
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-bar.h"
#include "../gui-bar-window.h"
#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-completion.h"
#include "../gui-cursor.h"
#include "../gui-input.h"
#include "../gui-key.h"
#include "../gui-mouse.h"
#include "../gui-window.h"
/*
@@ -74,29 +81,116 @@ gui_mouse_display_state ()
}
/*
* gui_mouse_grab_timer_cb: timer for grabbing mouse code
* gui_mouse_grab_init: init "grab mode"
*/
void
gui_mouse_grab_init (int area)
{
gui_mouse_grab = (area) ? 2 : 1;
}
/*
* gui_mouse_grab_event2input: get area for input, according to (x,y) of mouse
* event
* for example: @item(buffer_nicklist)
* @bar(title)
* @chat
* @*
*/
char *
gui_mouse_grab_event2input ()
{
struct t_gui_cursor_info cursor_info;
static char area[256];
gui_cursor_get_info (gui_mouse_event_x[0],
gui_mouse_event_y[0],
&cursor_info);
if (cursor_info.bar_item)
{
snprintf (area, sizeof (area),
"@item(%s)", cursor_info.bar_item);
}
else if (cursor_info.bar_window)
{
snprintf (area, sizeof (area),
"@bar(%s)", ((cursor_info.bar_window)->bar)->name);
}
else if (cursor_info.chat)
{
snprintf (area, sizeof (area), "@chat");
}
else
{
snprintf (area, sizeof (area), "@*");
}
return area;
}
/*
* gui_mouse_grab_end: end "grab mode"
*/
void
gui_mouse_grab_end (const char *mouse_key)
{
char mouse_key_input[256];
/* insert mouse key in input */
if (gui_current_window->buffer->input)
{
if (gui_mouse_grab == 2)
{
/* mouse key with area */
snprintf (mouse_key_input, sizeof (mouse_key_input),
"%s:%s",
gui_mouse_grab_event2input (),
mouse_key);
}
else
{
/* mouse key without area */
snprintf (mouse_key_input, sizeof (mouse_key_input),
"%s", mouse_key);
}
gui_input_insert_string (gui_current_window->buffer,
mouse_key_input, -1);
if (gui_current_window->buffer->completion)
gui_completion_stop (gui_current_window->buffer->completion, 1);
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
}
gui_mouse_grab = 0;
}
/*
* gui_mouse_event_timer_cb: timer for grabbing mouse code
*/
int
gui_mouse_grab_timer_cb (void *data, int remaining_calls)
gui_mouse_event_timer_cb (void *data, int remaining_calls)
{
/* make C compiler happy */
(void) data;
(void) remaining_calls;
gui_mouse_grab_end ();
gui_mouse_event_end ();
return WEECHAT_RC_OK;
}
/*
* gui_mouse_grab_init: init "grab mouse" mode
* gui_mouse_event_init: init mouse event
*/
void
gui_mouse_grab_init ()
gui_mouse_event_init ()
{
gui_mouse_grab = 1;
gui_mouse_event_pending = 1;
if (gui_mouse_event_timer)
unhook (gui_mouse_event_timer);
@@ -104,18 +198,18 @@ gui_mouse_grab_init ()
gui_mouse_event_timer = hook_timer (NULL,
CONFIG_INTEGER(config_look_mouse_timer_delay),
0, 1,
&gui_mouse_grab_timer_cb, NULL);
&gui_mouse_event_timer_cb, NULL);
}
/*
* gui_mouse_grab_code2key: get key name with a mouse code
* *extra_chars is set with first char following the
* end of mouse code (this can point to the '\0' or
* other chars)
* gui_mouse_event_code2key: get key name with a mouse code
* *extra_chars is set with first char following the
* end of mouse code (this can point to the '\0' or
* other chars)
*/
const char *
gui_mouse_grab_code2key (const char *code, char **extra_chars)
gui_mouse_event_code2key (const char *code, char **extra_chars)
{
int x, y, code_utf8, length;
double diff_x, diff_y, distance, angle, pi4;
@@ -288,17 +382,17 @@ gui_mouse_grab_code2key (const char *code, char **extra_chars)
}
/*
* gui_mouse_grab_end: end "grab mouse" mode
* gui_mouse_event_end: end mouse event
*/
void
gui_mouse_grab_end ()
gui_mouse_event_end ()
{
const char *mouse_key;
char *extra_chars;
int i;
gui_mouse_grab = 0;
gui_mouse_event_pending = 0;
/* end mouse event timer */
if (gui_mouse_event_timer)
@@ -307,13 +401,21 @@ gui_mouse_grab_end ()
gui_mouse_event_timer = NULL;
}
/* get key from mouse code and execute command (if found) */
mouse_key = gui_mouse_grab_code2key (gui_key_combo_buffer, &extra_chars);
/* get key from mouse code */
mouse_key = gui_mouse_event_code2key (gui_key_combo_buffer, &extra_chars);
if (mouse_key && mouse_key[0])
{
(void) gui_key_focus (mouse_key,
GUI_KEY_CONTEXT_MOUSE);
gui_mouse_reset_event ();
if (gui_mouse_grab)
{
gui_mouse_grab_end (mouse_key);
}
else
{
/* execute command (if found) */
(void) gui_key_focus (mouse_key,
GUI_KEY_CONTEXT_MOUSE);
}
gui_mouse_event_reset ();
}
gui_key_combo_buffer[0] = '\0';
+18 -6
View File
@@ -60,21 +60,33 @@ gui_mouse_display_state ()
}
/*
* gui_mouse_grab_init: init "grab mouse" mode
* gui_mouse_grab_init: init "grab mode"
*/
void
gui_mouse_grab_init ()
gui_mouse_grab_init (int area)
{
(void) area;
/* This function does nothing in Gtk GUI */
}
/*
* gui_mouse_event_init: init mouse event
*/
void
gui_mouse_event_init ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_mouse_grab_code2key: get key name with a mouse code
* gui_mouse_event_code2key: get key name with a mouse code
*/
const char *
gui_mouse_grab_code2key (const char *code)
gui_mouse_event_code2key (const char *code)
{
(void) code;
@@ -84,11 +96,11 @@ gui_mouse_grab_code2key (const char *code)
}
/*
* gui_mouse_grab_end: end "grab mouse" mode
* gui_mouse_event_end: end mouse event
*/
void
gui_mouse_grab_end ()
gui_mouse_event_end ()
{
/* This function does nothing in Gtk GUI */
}
+8 -6
View File
@@ -43,6 +43,7 @@
#include "gui-hotlist.h"
#include "gui-key.h"
#include "gui-line.h"
#include "gui-mouse.h"
#include "gui-window.h"
@@ -1343,22 +1344,23 @@ gui_input_hotlist_clear (struct t_gui_buffer *buffer)
*/
void
gui_input_grab_key (struct t_gui_buffer *buffer, const char *delay)
gui_input_grab_key (struct t_gui_buffer *buffer, int command, const char *delay)
{
if (buffer->input)
gui_key_grab_init (0, delay);
gui_key_grab_init (command, delay);
}
/*
* gui_input_grab_key_command: init "grab key mode" (next key and command
* bound will be inserted into input buffer)
* gui_input_grab_mouse: init "grab mouse mode" (next mouse event will be
* inserted into input buffer) (default key: button2 of
* mouse in input bar)
*/
void
gui_input_grab_key_command (struct t_gui_buffer *buffer, const char *delay)
gui_input_grab_mouse (struct t_gui_buffer *buffer, int area)
{
if (buffer->input)
gui_key_grab_init (1, delay);
gui_mouse_grab_init (area);
}
/*
+2 -3
View File
@@ -70,10 +70,9 @@ extern void gui_input_jump_last_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer);
extern void gui_input_grab_key (struct t_gui_buffer *buffer,
extern void gui_input_grab_key (struct t_gui_buffer *buffer, int command,
const char *delay);
extern void gui_input_grab_key_command (struct t_gui_buffer *buffer,
const char *delay);
extern void gui_input_grab_mouse (struct t_gui_buffer *buffer, int area);
extern void gui_input_scroll_unread (struct t_gui_buffer *buffer);
extern void gui_input_set_unread ();
extern void gui_input_set_unread_current (struct t_gui_buffer *buffer);
+5 -5
View File
@@ -820,15 +820,15 @@ gui_key_pressed (const char *key_str)
return 0;
}
/* mode "mouse grab" (mouse event pending) */
if (gui_mouse_grab)
/* mouse event pending */
if (gui_mouse_event_pending)
{
pos = strstr (gui_key_combo_buffer, "\x1B[M");
if (pos)
{
pos[0] = '\0';
gui_mouse_grab_end ();
gui_mouse_grab_init ();
gui_mouse_event_end ();
gui_mouse_event_init ();
}
return 0;
}
@@ -836,7 +836,7 @@ gui_key_pressed (const char *key_str)
if (strcmp (gui_key_combo_buffer, "\x01[[M") == 0)
{
gui_key_combo_buffer[0] = '\0';
gui_mouse_grab_init ();
gui_mouse_event_init ();
return 0;
}
+6 -3
View File
@@ -34,7 +34,10 @@
int gui_mouse_enabled = 0; /* 1 if mouse support is enabled */
int gui_mouse_debug = 0; /* debug mode for mouse */
int gui_mouse_grab = 0; /* 1 if grab mouse code enabled */
int gui_mouse_grab = 0; /* 1 if grab mode enabled */
/* mouse event */
int gui_mouse_event_pending = 0; /* 1 if mouse event has started */
struct t_hook *gui_mouse_event_timer = NULL; /* timer to detect entire */
/* mouse event */
int gui_mouse_event_index = 0; /* index for x/y in array (0 or 1) */
@@ -61,11 +64,11 @@ gui_mouse_debug_toggle ()
}
/*
* gui_mouse_reset_event: reset event values
* gui_mouse_event_reset: reset event values
*/
void
gui_mouse_reset_event ()
gui_mouse_event_reset ()
{
gui_mouse_event_index = 0;
gui_mouse_event_x[0] = 0;
+5 -3
View File
@@ -25,6 +25,7 @@
extern int gui_mouse_enabled;
extern int gui_mouse_debug;
extern int gui_mouse_grab;
extern int gui_mouse_event_pending;
extern struct t_hook *gui_mouse_event_timer;
extern int gui_mouse_event_index;
extern int gui_mouse_event_x[2];
@@ -34,14 +35,15 @@ extern char gui_mouse_event_button;
/* mouse functions */
extern void gui_mouse_debug_toggle ();
extern void gui_mouse_reset_event ();
extern void gui_mouse_event_reset ();
/* mouse functions (GUI dependent) */
extern void gui_mouse_enable ();
extern void gui_mouse_disable ();
extern void gui_mouse_display_state ();
extern void gui_mouse_grab_init ();
extern void gui_mouse_grab_end ();
extern void gui_mouse_grab_init (int area);
extern void gui_mouse_event_init ();
extern void gui_mouse_event_end ();
#endif /* __WEECHAT_GUI_MOUSE_H */