diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2011-06-06 17:50:35 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2011-06-06 17:55:28 -0400 |
commit | 4b90a77794aa4b8904e360bed865ff88c15777c0 (patch) | |
tree | a99a187bd36538de2dca504e3f5525e5c6fa8cc5 | |
parent | 579e321edc54452d991d0bfd9041b94858116f32 (diff) |
Improved mouse label handling.
Fixes mouse label related issues that were present, including mouse
label being wrong after switching to a new display but before moving
the mouse, and having the mouse label change while in the switcher.
-rw-r--r-- | src/bclient.c | 21 | ||||
-rw-r--r-- | src/dclient.c | 21 | ||||
-rw-r--r-- | src/display.c | 25 | ||||
-rw-r--r-- | src/display.h | 4 | ||||
-rw-r--r-- | src/sclient.c | 7 |
5 files changed, 63 insertions, 15 deletions
diff --git a/src/bclient.c b/src/bclient.c index 121eb64..ba9caf4 100644 --- a/src/bclient.c +++ b/src/bclient.c @@ -40,15 +40,14 @@ bclient_key(struct display *d, bool down, int keycode) } static int -bclient_mouse(struct display *d, struct mouse_event *m) +bclient_position(struct display *d, int x, int y) { struct view *v; - struct buffer *b = LIST_FIRST(&d->buffers); struct client *c; TAILQ_FOREACH(v, &d->views, display_next) - if (m->x >= v->spos.x && m->x < (v->spos.x + v->spos.w) && - m->y >= v->spos.y && m->y < (v->spos.y + v->spos.h)) + if (x >= v->spos.x && x < (v->spos.x + v->spos.w) && + y >= v->spos.y && y < (v->spos.y + v->spos.h)) break; /* What client is the mouse over? */ @@ -58,9 +57,20 @@ bclient_mouse(struct display *d, struct mouse_event *m) if (c != d->mouse_client) { d->mouse_client = c; - display_update_mouselabel(c); + display_update_mouselabel(d, c); } + return 0; +} + +static int +bclient_mouse(struct display *d, struct mouse_event *m) +{ + struct buffer *b = LIST_FIRST(&d->buffers); + + /* Update position */ + bclient_position(d, m->x, m->y); + /* Remove the buffer offset */ /* Clamp the position to the buffer bounds */ /* Scale the position to the dimensions the frontend expects */ @@ -84,6 +94,7 @@ bclient_new(struct buffer *b) /* Set up input methods */ d->send_key = bclient_key; d->send_mouse = bclient_mouse; + d->update_position = bclient_position; d->type = DISPLAY_BUFFER; d->client = b->client; diff --git a/src/dclient.c b/src/dclient.c index df3abf1..374a8a4 100644 --- a/src/dclient.c +++ b/src/dclient.c @@ -74,15 +74,14 @@ dclient_key(struct display *d, bool down, int keycode) } static int -dclient_mouse(struct display *d, struct mouse_event *m) +dclient_position(struct display *d, int x, int y) { struct view *v; - struct buffer *b; struct client *c; TAILQ_FOREACH(v, &d->views, display_next) - if (m->x >= v->spos.x && m->x < (v->spos.x + v->spos.w) && - m->y >= v->spos.y && m->y < (v->spos.y + v->spos.h) && + if (x >= v->spos.x && x < (v->spos.x + v->spos.w) && + y >= v->spos.y && y < (v->spos.y + v->spos.h) && v->mapped) break; @@ -101,9 +100,20 @@ dclient_mouse(struct display *d, struct mouse_event *m) if (c != d->mouse_client && nkeys == 0) { d->mouse_client = c; - display_update_mouselabel(c); + display_update_mouselabel(d, c); } + return 0; +} + +static int +dclient_mouse(struct display *d, struct mouse_event *m) +{ + struct buffer *b; + + /* Update position */ + dclient_position(d, m->x, m->y); + /* Forward the actual motion event. */ if (d->mouse_client && d->mouse_client->input) { b = LIST_FIRST(&d->mouse_client->buffers); @@ -170,6 +180,7 @@ dclient_new(void) /* Set up input methods */ sd.send_key = dclient_key; sd.send_mouse = dclient_mouse; + sd.update_position = dclient_position; sd.type = DISPLAY_DESKTOP; sd.client = c; diff --git a/src/display.c b/src/display.c index b72a919..3542ad1 100644 --- a/src/display.c +++ b/src/display.c @@ -109,10 +109,16 @@ display_update_seclabel(struct display *d) } void -display_update_mouselabel(struct client *c) +display_update_mouselabel(struct display *d, struct client *c) { IDirectFBSurface *surf; - c = c ? c : server_display->client; + + if (!d) + c = server_display->client; + else if (d != active_display) + return; + else + c = c ? c : server_display->client; mouselabel->GetSurface(mouselabel, &surf); surf->Clear(surf, 0, 0, 0, 0); @@ -258,7 +264,10 @@ display_switch(struct display *d) view_show(v); } - display_update_mouselabel(d->mouse_client); + if (is_switcher) + display_update_mouselabel(NULL, NULL); + else + display_update_mouselabel(d, d->mouse_client); } void @@ -268,6 +277,7 @@ display_secure_enter(int keycode) case LINPICK_SWITCH_SAK: server_display->focus_client = active_display->client; display_update_seclabel(server_display); + display_update_mouselabel(NULL, NULL); attention_indicator = 0; is_switcher = 1; show_switcher(); @@ -286,6 +296,7 @@ display_secure_leave(void) hide_switcher(); server_display->focus_client = NULL; display_update_seclabel(active_display); + display_update_mouselabel(active_display, active_display->mouse_client); } } @@ -384,7 +395,7 @@ display_view_remove(struct view *v) /* XXX find new view? */ d->mouse_view = NULL; d->mouse_client = NULL; - display_update_mouselabel(NULL); + display_update_mouselabel(d, NULL); } if (v == d->focus_view) { d->focus_view = NULL; @@ -467,6 +478,12 @@ display_key_event(struct input_event *e) void display_position_event(int x, int y) { + struct display *d; + + CIRCLEQ_FOREACH(d, &displays, display_next) + if (d != active_display) + d->update_position(d, x, y); + mouselabel->MoveTo(mouselabel, x + MOUSELABEL_OFFSET, y + MOUSELABEL_OFFSET); } diff --git a/src/display.h b/src/display.h index 7bcd3b2..fe69629 100644 --- a/src/display.h +++ b/src/display.h @@ -45,6 +45,7 @@ struct display; typedef int (*key_func)(struct display *, bool down, int keycode); typedef int (*mouse_func)(struct display *, struct mouse_event *m); +typedef int (*position_func)(struct display *, int x, int y); struct display { unsigned int type; @@ -59,6 +60,7 @@ struct display { struct view *mouse_view; key_func send_key; /* keyboard function */ mouse_func send_mouse; /* mouse function */ + position_func update_position; /* track mouse position */ }; CIRCLEQ_HEAD(display_cirq, display); @@ -80,7 +82,7 @@ void display_secure_leave(void); void -display_update_mouselabel(struct client *client); +display_update_mouselabel(struct display *d, struct client *client); void display_update_seclabel(struct display *display); diff --git a/src/sclient.c b/src/sclient.c index 2500247..fcbce5a 100644 --- a/src/sclient.c +++ b/src/sclient.c @@ -42,6 +42,12 @@ sclient_key(struct display *d, bool down, int keycode) } static int +sclient_position(struct display *d, int x, int y) +{ + return 0; +} + +static int sclient_mouse(struct display *d, struct mouse_event *m) { return 0; @@ -139,6 +145,7 @@ sclient_new(void) /* Set up input methods */ sd.send_key = sclient_key; sd.send_mouse = sclient_mouse; + sd.update_position = sclient_position; sd.type = DISPLAY_SERVER; sd.client = c; |