summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAilin Nemui <ailin@esf51.localdomain>2012-11-02 17:26:52 +0100
committerSebastien Helleu <flashcode@flashtux.org>2012-11-02 17:26:52 +0100
commit8b52fc90d52f6656366dcedcbbd3dff48a4e2024 (patch)
tree1533608b5322d3261248b275e3bddbad26fd4fee
parent4d436e3ac653b9face748afbe4d3c96b797469b4 (diff)
downloadweechat-8b52fc90d52f6656366dcedcbbd3dff48a4e2024.zip
core: add incomplete mouse events "event-down" and "event-drag" (task #11840)
-rw-r--r--ChangeLog1
-rw-r--r--doc/de/weechat_user.de.txt30
-rw-r--r--doc/en/weechat_user.en.txt11
-rw-r--r--doc/fr/weechat_user.fr.txt14
-rw-r--r--doc/it/weechat_user.it.txt12
-rw-r--r--doc/ja/weechat_user.ja.txt12
-rw-r--r--src/gui/curses/gui-curses-mouse.c27
-rw-r--r--src/gui/gui-key.c5
8 files changed, 97 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 78ff73987..db50bb8ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ v0.4.0-dev, 2012-11-02
Version 0.4.0 (under dev!)
--------------------------
+* core: add incomplete mouse events "event-down" and "event-drag" (task #11840)
* core: add command /eval, use expression in conditions for bars
* core: add option "-quit" for command /upgrade (save session and quit without
restarting WeeChat, for delayed restoration)
diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt
index c857ca784..e6c47ea5d 100644
--- a/doc/de/weechat_user.de.txt
+++ b/doc/de/weechat_user.de.txt
@@ -1101,15 +1101,25 @@ Liste der Mausgesten (nur für Maustasten, nicht für das Mausrad, anwendbar):
[width="50%",cols="3m,4",options="header"]
|========================================
-| Mausgeste | Distanz
-| Bewegung hoch | 3 ... 19
-| Bewegung hoch (lang) | ≥ 20
-| Bewegung runter | 3 ... 19
-| Bewegung runter (lang) | ≥ 20
-| Bewegung links | 3 ... 39
-| Bewegung links (lang) | ≥ 40
-| Bewegung rechts | 3 ... 39
-| Bewegung rechts (lang) | ≥ 40
+| Mausgeste | Distanz
+| gesture-up | 3 ... 19
+| gesture-up-long | ≥ 20
+| gesture-down | 3 ... 19
+| gesture-down-long | ≥ 20
+| gesture-left | 3 ... 39
+| gesture-left-long | ≥ 40
+| gesture-right | 3 ... 39
+| gesture-right-long | ≥ 40
+|========================================
+
+// TRANSLATION MISSING
+List of incomplete events (only for buttons, useful for plugins/scripts):
+
+[width="50%",cols="3m,4",options="header"]
+|========================================
+| Event | Description
+| event-down | button was pressed but not released yet
+| event-drag | mouse was moved with button pressed down
|========================================
Bespiele von Ereignissen:
@@ -1117,6 +1127,8 @@ Bespiele von Ereignissen:
* `button1`
* `ctrl-button1`
* `button1-gesture-right`
+* `button1-event-down`
+* `button1-event-drag`
* `alt-button2-gesture-down-long`
* `wheelup`
* `ctrl-alt-wheeldown`
diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt
index 0d2514bd4..9da126350 100644
--- a/doc/en/weechat_user.en.txt
+++ b/doc/en/weechat_user.en.txt
@@ -1103,11 +1103,22 @@ List of gestures (only for buttons, not wheel):
| gesture-right-long | ≥ 40
|========================================
+List of incomplete events (only for buttons, useful for plugins/scripts):
+
+[width="50%",cols="3m,4",options="header"]
+|========================================
+| Event | Description
+| event-down | button was pressed but not released yet
+| event-drag | mouse was moved with button pressed down
+|========================================
+
Example of events:
* `button1`
* `ctrl-button1`
* `button1-gesture-right`
+* `button1-event-down`
+* `button1-event-drag`
* `alt-button2-gesture-down-long`
* `wheelup`
* `ctrl-alt-wheeldown`
diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt
index 7db404f4f..b54e4c828 100644
--- a/doc/fr/weechat_user.fr.txt
+++ b/doc/fr/weechat_user.fr.txt
@@ -1133,11 +1133,23 @@ Liste des gestes (seulement pour les boutons, pas la roulette) :
| gesture-right-long | ≥ 40
|========================================
-Exemple d'évènements :
+Liste des évènements incomplets (seulement pour les boutons, pratique pour les
+extensions/scripts) :
+
+[width="50%",cols="3m,4",options="header"]
+|========================================
+| Evènement | Description
+| event-down | le bouton a été pressé mais pas encore relâché
+| event-drag | la souris a bougé avec le bouton pressé
+|========================================
+
+Exemples d'évènements :
* `button1`
* `ctrl-button1`
* `button1-gesture-right`
+* `button1-event-down`
+* `button1-event-drag`
* `alt-button2-gesture-down-long`
* `wheelup`
* `ctrl-alt-wheeldown`
diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt
index c45cba988..94f344e4d 100644
--- a/doc/it/weechat_user.it.txt
+++ b/doc/it/weechat_user.it.txt
@@ -1126,11 +1126,23 @@ Elenco di azioni (solo per i pulsanti, non la rotellina):
| gesture-right-long | ≥ 40
|========================================
+// TRANSLATION MISSING
+List of incomplete events (only for buttons, useful for plugins/scripts):
+
+[width="50%",cols="3m,4",options="header"]
+|========================================
+| Event | Description
+| event-down | button was pressed but not released yet
+| event-drag | mouse was moved with button pressed down
+|========================================
+
Esempio di eventi:
* `button1`
* `ctrl-button1`
* `button1-gesture-right`
+* `button1-event-down`
+* `button1-event-drag`
* `alt-button2-gesture-down-long`
* `wheelup`
* `ctrl-alt-wheeldown`
diff --git a/doc/ja/weechat_user.ja.txt b/doc/ja/weechat_user.ja.txt
index 7b295d269..b6e85f47a 100644
--- a/doc/ja/weechat_user.ja.txt
+++ b/doc/ja/weechat_user.ja.txt
@@ -1074,11 +1074,23 @@ WeeChat はデフォルトマウスイベントの多くを定義しています
| gesture-right-long | ≥ 40
|========================================
+// TRANSLATION MISSING
+List of incomplete events (only for buttons, useful for plugins/scripts):
+
+[width="50%",cols="3m,4",options="header"]
+|========================================
+| Event | Description
+| event-down | button was pressed but not released yet
+| event-drag | mouse was moved with button pressed down
+|========================================
+
イベントの表記例:
* `button1`
* `ctrl-button1`
* `button1-gesture-right`
+* `button1-event-down`
+* `button1-event-drag`
* `alt-button2-gesture-down-long`
* `wheelup`
* `ctrl-alt-wheeldown`
diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c
index 759a2a9f0..73264665d 100644
--- a/src/gui/curses/gui-curses-mouse.c
+++ b/src/gui/curses/gui-curses-mouse.c
@@ -32,6 +32,7 @@
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-hook.h"
+#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-bar.h"
@@ -314,9 +315,6 @@ gui_mouse_event_code2key (const char *code)
}
}
- if (!MOUSE_CODE_END(code[0]))
- return NULL;
-
/* add name of button event */
for (i = 0; gui_mouse_button_codes[i][0]; i++)
{
@@ -327,6 +325,21 @@ gui_mouse_event_code2key (const char *code)
}
}
+ if (!MOUSE_CODE_END(code[0]))
+ {
+ strcat (key, "-event-");
+ if (MOUSE_CODE_MOTION(code[0])) {
+ strcat (key, "drag");
+ }
+ else
+ {
+ gui_mouse_event_x[1] = gui_mouse_event_x[0];
+ gui_mouse_event_y[1] = gui_mouse_event_y[0];
+ strcat (key, "down");
+ }
+ return key;
+ }
+
/*
* Mouse gesture: if (x,y) on release is different from (x,y) on click,
* compute distance and angle between 2 points.
@@ -412,6 +425,7 @@ void
gui_mouse_event_end ()
{
const char *mouse_key;
+ int bare_event;
gui_mouse_event_pending = 0;
@@ -426,9 +440,11 @@ gui_mouse_event_end ()
mouse_key = gui_mouse_event_code2key (gui_key_combo_buffer);
if (mouse_key && mouse_key[0])
{
+ bare_event = string_match (mouse_key, "*-event-*", 1);
if (gui_mouse_grab)
{
- gui_mouse_grab_end (mouse_key);
+ if (!bare_event)
+ gui_mouse_grab_end (mouse_key);
}
else
{
@@ -436,7 +452,8 @@ gui_mouse_event_end ()
(void) gui_key_focus (mouse_key,
GUI_KEY_CONTEXT_MOUSE);
}
- gui_mouse_event_reset ();
+ if (!bare_event)
+ gui_mouse_event_reset ();
}
gui_key_combo_buffer[0] = '\0';
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 93938ec2a..6c338eabf 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -1009,6 +1009,11 @@ gui_key_focus_command (const char *key, int context,
if (gui_key_cmp (key, ptr_key->area_key, context) != 0)
continue;
+ /* ignore mouse event if not explicit requested */
+ if ((context == GUI_KEY_CONTEXT_MOUSE) &&
+ (string_match (key, "*-event-*", 1) != string_match (ptr_key->area_key, "*-event-*", 1)))
+ continue;
+
/* check if focus is matching with key */
matching = gui_key_focus_matching (ptr_key, hashtable_focus);
if (!matching)