From 5603491b0b61c379b0e62987be32c3631e31dcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sun, 11 Jan 1998 09:01:34 +0100 Subject: [PATCH] * Types.pmod (Window->event_callbacks): Use an array of handlers for each event-type. (Window->GrabButton): New function. Rev: lib/modules/Protocols.pmod/X.pmod/Types.pmod:1.12 --- lib/modules/Protocols.pmod/X.pmod/Types.pmod | 27 +++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/modules/Protocols.pmod/X.pmod/Types.pmod b/lib/modules/Protocols.pmod/X.pmod/Types.pmod index e70cf700db..2734d0b158 100644 --- a/lib/modules/Protocols.pmod/X.pmod/Types.pmod +++ b/lib/modules/Protocols.pmod/X.pmod/Types.pmod @@ -234,7 +234,7 @@ class Window object visual, colortable, parent; int currentInputMask; - mapping(string:function) event_callbacks = ([ ]); + mapping(string:array(function)) event_callbacks = ([ ]); int alt_gr, num_lock, shift, control, caps_lock; int meta, alt, super, hyper; @@ -484,15 +484,18 @@ class Window void set_event_callback(string type, function f) { - event_callbacks[type] = f; + event_callbacks[type] = (event_callbacks[type] || ({ }) ) + + ({ f }); } +#if 0 function remove_event_callback(string type) { function f = event_callbacks[type]; m_delete(event_callbacks, type); } - +#endif + object SelectInput_req() { object req = Requests.ChangeWindowAttributes(); @@ -528,6 +531,24 @@ class Window return currentInputMask; } + object GrabButton_req(int button, int modifiers, array(string) types) + { + object req = Requests.GrabButton(); + req->ownerEvents = 1; + req->grabWindow = id; + req->eventMask = event_mask_to_int(types); + req->button = button; + req->modifiers = modifiers || 0x8000; + + return req; + } + + void GrabButton(int button, int modifiers, string ... types) + { + object req = GrabButton_req(button, modifiers, types); + display->send_request(req); + } + object Map_req() { object req = Requests.MapWindow(); -- GitLab