diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2011-07-27 15:32:53 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2011-07-27 15:44:28 -0400 |
commit | 03a9a10a4575f002b32bc7ad80e32aaeca75d1d6 (patch) | |
tree | 2bb9c0b728831d412165a0ba62d67c2fa24265bc | |
parent | 8e918a6ef68665a9d5ab18abaef86374ea255f8a (diff) |
Support client-settable view names in the track protocol.
A new NAME message type is added to the track protocol, with the name
carried in the lower 24 bytes of the message. The view_set_name()
interface, which previously existed as view_set_title(), has been
re-introduced.
-rw-r--r-- | doc/track_protocol.txt | 6 | ||||
-rw-r--r-- | src/comm.c | 19 | ||||
-rw-r--r-- | src/comm_structs.h | 7 | ||||
-rw-r--r-- | src/view.c | 9 | ||||
-rw-r--r-- | src/view.h | 14 |
5 files changed, 47 insertions, 8 deletions
diff --git a/doc/track_protocol.txt b/doc/track_protocol.txt index dfe079e..76a77c9 100644 --- a/doc/track_protocol.txt +++ b/doc/track_protocol.txt @@ -44,6 +44,12 @@ set in the message: LINPICKER_DESTROY The view specified in the view field should be removed. +LINPICKER_NAME +The 24 lower bytes of the message contain an informational character string +to be associated with the view specified the view field. The string may be +up to 24 characters in length; if less, the remaining space should be filled +with NUL characters. + 2. Messages sent from linpicker-server to linpicker-track: there is currently only one such message, consisting of a single byte type field. @@ -127,6 +127,22 @@ comm_destroy(struct client *c, struct buffer *b, struct lin_message *m) } static void +comm_name(struct client *c, struct buffer *b, struct lin_message *m) +{ + char name[25]; + struct view *v = view_lookup(c, m->view); + if (!v) { + FD_LOG(1, "Warning: view %x does not exist.\n", m->view); + return; + } + + /* XXX check for control chars, newlines, bad UTF-8, etc. */ + memcpy(name, &m->flags, 24); + name[24] = '\0'; + view_set_name(v, name); +} + +static void comm_destroy_all(struct client *c, struct buffer *b) { struct view *v; @@ -162,6 +178,9 @@ comm_process(struct client *c, struct buffer *b, struct lin_message *m) case LINPICKER_DESTROY: comm_destroy(c, b, m); break; + case LINPICKER_NAME: + comm_name(c, b, m); + break; default: break; } diff --git a/src/comm_structs.h b/src/comm_structs.h index efa72f2..b17a598 100644 --- a/src/comm_structs.h +++ b/src/comm_structs.h @@ -31,10 +31,11 @@ #define LINPICKER_REQUEST_UPDATE 0 /* Messages sent by client */ -#define LINPICKER_RESET 0 -#define LINPICKER_CREATE 1 -#define LINPICKER_UPDATE 2 +#define LINPICKER_RESET 0 +#define LINPICKER_CREATE 1 +#define LINPICKER_UPDATE 2 #define LINPICKER_DESTROY 3 +#define LINPICKER_NAME 4 #define LINPICKER_FLAG_POSITION 1 #define LINPICKER_FLAG_TOPMOST 2 @@ -172,6 +172,7 @@ view_free(struct view *v) v->window->Release(v->window); v->vsurface->Release(v->vsurface); + free(v->name); free(v); } @@ -428,6 +429,14 @@ out: return 0; } +int +view_set_name(struct view *v, const char *name) +{ + free(v->name); + v->name = strdup(name); + return v->name ? 0 : -1; +} + void view_toggle_labeling(void) { @@ -51,7 +51,8 @@ struct buffer; struct view { int id; /* view ID */ int flags; /* properties of the view */ - struct sec_label *label; /* security label */ + struct sec_label *label; /* security label */ + char *name; /* client-defined string */ DFBRectangle bpos; /* view location within its buffer */ DFBRectangle spos; /* view position and size on screen */ struct client *client; /* client owner */ @@ -84,10 +85,10 @@ struct view * view_new(struct client *c, struct buffer *b, int id, unsigned int flags); void -view_remove(struct view *view); +view_remove(struct view *v); int -view_show(struct view *view); +view_show(struct view *v); int view_update_surface(struct view *v); @@ -104,10 +105,13 @@ int view_translate(struct view *v, int dx, int dy); void -view_refresh(struct view *view); +view_refresh(struct view *v); int -view_stack(struct view *view, unsigned op, struct view *sibling); +view_stack(struct view *v, unsigned op, struct view *sibling); + +int +view_set_name(struct view *v, const char *name); void view_toggle_labeling(void); |