diff --git a/common/utils/T/tracer/gui/container.c b/common/utils/T/tracer/gui/container.c index d3ce2a110bcfde184591abed34395b1cc25ef9c0..8de43479332390a91294c62ff71ca8bd9ef5db9f 100644 --- a/common/utils/T/tracer/gui/container.c +++ b/common/utils/T/tracer/gui/container.c @@ -227,7 +227,7 @@ static void horizontal_hints(gui *_gui, widget *_w, int *width, int *height) } static void horizontal_button(gui *_g, widget *_this, int x, int y, - int button, int up) + int key_modifiers, int button, int up) { LOGD("BUTTON container horizontal %p xy %d %d button %d up %d\n", _this, x, y, button, up); struct gui *g = _g; @@ -237,7 +237,7 @@ static void horizontal_button(gui *_g, widget *_this, int x, int y, l = this->common.children; while (l) { if (l->item->x <= x && x < l->item->x + l->item->width) { - l->item->button(g, l->item, x, y, button, up); + l->item->button(g, l->item, x, y, key_modifiers, button, up); break; } l = l->next; @@ -245,7 +245,7 @@ static void horizontal_button(gui *_g, widget *_this, int x, int y, } static void vertical_button(gui *_g, widget *_this, int x, int y, - int button, int up) + int key_modifiers, int button, int up) { LOGD("BUTTON container vertical %p xy %d %d button %d up %d\n", _this, x, y, button, up); struct gui *g = _g; @@ -255,7 +255,7 @@ static void vertical_button(gui *_g, widget *_this, int x, int y, l = this->common.children; while (l) { if (l->item->y <= y && y < l->item->y + l->item->height) { - l->item->button(g, l->item, x, y, button, up); + l->item->button(g, l->item, x, y, key_modifiers, button, up); break; } l = l->next; diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h index e470d2d3667115f860be1bf40b4af89dcc7a1295..5ae623f559bc57455b863b523cca233c7799efa7 100644 --- a/common/utils/T/tracer/gui/gui.h +++ b/common/utils/T/tracer/gui/gui.h @@ -12,6 +12,11 @@ typedef void widget; #define BACKGROUND_COLOR 0 #define FOREGROUND_COLOR 1 +/* key modifiers */ +#define KEY_SHIFT (1<<0) +#define KEY_CONTROL (1<<1) +#define KEY_ALT (1<<2) + gui *gui_init(void); /* position = -1 to put at the end */ diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h index 8f15747490f727521fce9483aaa64b7459ade86f..5b8469ad9a3da9437cdb3a21a6813e7825778744 100644 --- a/common/utils/T/tracer/gui/gui_defs.h +++ b/common/utils/T/tracer/gui/gui_defs.h @@ -53,7 +53,8 @@ struct widget { void (*paint)(gui *g, widget *this); void (*clear)(gui *g, widget *this); /* user input */ - void (*button)(gui *g, widget *this, int x, int y, int button, int up); + void (*button)(gui *g, widget *this, int x, int y, int key_modifiers, + int button, int up); }; struct widget_list { diff --git a/common/utils/T/tracer/gui/label.c b/common/utils/T/tracer/gui/label.c index 80d885f1d21e23ab224c747ee1edce2f266b10eb..bbe6e98eaf807747fdc9d2a3c2cc9cb7b5522ee9 100644 --- a/common/utils/T/tracer/gui/label.c +++ b/common/utils/T/tracer/gui/label.c @@ -45,7 +45,8 @@ widget *new_label(gui *_gui, const char *label) return w; } -static void button(gui *gui, widget *_this, int x, int y, int button, int up) +static void button(gui *gui, widget *_this, int x, int y, + int key_modifiers, int button, int up) { LOGD("BUTTON label %p xy %d %d button %d up %d\n", _this, x, y, button, up); @@ -55,7 +56,8 @@ static void button(gui *gui, widget *_this, int x, int y, int button, int up) } /* we could use default_button, but it's in widget.c, so, well... */ -static void no_button(gui *gui, widget *_this, int x,int y,int button,int up) +static void no_button(gui *gui, widget *_this, int x, int y, + int key_modifiers, int button, int up) { /* do nothing */ } diff --git a/common/utils/T/tracer/gui/positioner.c b/common/utils/T/tracer/gui/positioner.c index 5bd23e147e900550e27c70dc3a940534aafb611d..673ffb32ded28295032e76e96626a179f11d8d23 100644 --- a/common/utils/T/tracer/gui/positioner.c +++ b/common/utils/T/tracer/gui/positioner.c @@ -50,14 +50,15 @@ static void hints(gui *_gui, widget *_w, int *width, int *height) else { *width = *height = 1; } } -static void button(gui *_g, widget *_this, int x, int y, int button, int up) +static void button(gui *_g, widget *_this, int x, int y, + int key_modifiers, int button, int up) { LOGD("BUTTON positioner %p xy %d %d button %d up %d\n", _this, x, y, button, up); struct gui *g = _g; struct positioner_widget *this = _this; struct widget_list *l = this->common.children; if (l != NULL) - l->item->button(g, l->item, x, y, button, up); + l->item->button(g, l->item, x, y, key_modifiers, button, up); } static void paint(gui *_gui, widget *_this) diff --git a/common/utils/T/tracer/gui/textlist.c b/common/utils/T/tracer/gui/textlist.c index 50a21cd45984c0666b98e158b4250d5238ccb9b3..6803d2301da689ebece2c47bcb1f6e9d06f8439b 100644 --- a/common/utils/T/tracer/gui/textlist.c +++ b/common/utils/T/tracer/gui/textlist.c @@ -44,7 +44,8 @@ static void allocate( LOGD("ALLOCATE textlist %p xywh %d %d %d %d nlines %d\n", this, x, y, width, height, this->allocated_nlines); } -static void button(gui *_g, widget *_this, int x, int y, int button, int up) +static void button(gui *_g, widget *_this, int x, int y, + int key_modifiers, int button, int up) { struct gui *g = _g; struct textlist_widget *this = _this; diff --git a/common/utils/T/tracer/gui/timeline.c b/common/utils/T/tracer/gui/timeline.c index e627567aaf32490b6e6f64e9597ccdd8d1b81af8..43cbcc525f74841e9ef3450c48a8de1f17b167d2 100644 --- a/common/utils/T/tracer/gui/timeline.c +++ b/common/utils/T/tracer/gui/timeline.c @@ -54,7 +54,8 @@ static void allocate(gui *_gui, widget *_this, gui_notify(_gui, "resize", _this, &width); } -static void button(gui *_g, widget *_this, int x, int y, int button, int up) +static void button(gui *_g, widget *_this, int x, int y, + int key_modifiers, int button, int up) { struct gui *g = _g; struct timeline_widget *this = _this; diff --git a/common/utils/T/tracer/gui/toplevel_window.c b/common/utils/T/tracer/gui/toplevel_window.c index 03d5091bc7f75b759ccc3333912876242b726981..d2436c84f9a0b2dcea2442d07c2ba528d294bd57 100644 --- a/common/utils/T/tracer/gui/toplevel_window.c +++ b/common/utils/T/tracer/gui/toplevel_window.c @@ -55,13 +55,14 @@ static void paint(gui *_gui, widget *_this) g->xwin = NULL; /* TODO: remove? it's just in case */ } -static void button(gui *_g, widget *_this, int x, int y, int button, int up) +static void button(gui *_g, widget *_this, int x, int y, + int key_modifiers, int button, int up) { struct gui *g = _g; struct toplevel_window_widget *this = _this; g->xwin = this->x; this->common.children->item->button(_g, this->common.children->item, - x, y, button, up); + x, y, key_modifiers, button, up); g->xwin = NULL; /* TODO: remove? it's just in case */ } diff --git a/common/utils/T/tracer/gui/widget.c b/common/utils/T/tracer/gui/widget.c index 944d27548fbcde7c8a978b224141d96f00e99f8e..1d2b03a25f935aa3960c640cde248795f7fb353b 100644 --- a/common/utils/T/tracer/gui/widget.c +++ b/common/utils/T/tracer/gui/widget.c @@ -14,8 +14,8 @@ static void default_add_child( gui *_gui, widget *_this, widget *child, int position); static void default_del_child(gui *_gui, widget *_this, widget *child); static void default_hints(gui *g, widget *this, int *width, int *height); -static void default_button(gui *gui, widget *_this, int x, int y, int button, - int up); +static void default_button(gui *gui, widget *_this, int x, int y, + int key_modifiers, int button, int up); static void toplevel_list_append(struct gui *g, struct widget *e) { @@ -228,8 +228,8 @@ static void default_hints(gui *g, widget *this, int *width, int *height) *height = 1; } -static void default_button(gui *gui, widget *_this, int x, int y, int button, - int up) +static void default_button(gui *gui, widget *_this, int x, int y, + int key_modifiers, int button, int up) { /* nothing */ } diff --git a/common/utils/T/tracer/gui/x.c b/common/utils/T/tracer/gui/x.c index bbc51e8a947015697a590e142332bfe586efaca8..0a2d1450398ac58220026e96b5c13ee97dc766f2 100644 --- a/common/utils/T/tracer/gui/x.c +++ b/common/utils/T/tracer/gui/x.c @@ -171,13 +171,21 @@ void x_events(gui *_gui) break; case ButtonPress: if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, + int key_modifiers = 0; + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, ev.xbutton.button, 0); } break; case ButtonRelease: if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, + int key_modifiers = 0; + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, ev.xbutton.button, 1); } break;