diff options
author | John Tytgat <joty@netsurf-browser.org> | 2004-05-06 21:18:26 +0000 |
---|---|---|
committer | John Tytgat <joty@netsurf-browser.org> | 2004-05-06 21:18:26 +0000 |
commit | 255bf8f1edc480b85d0aa7e499d7b027749717e0 (patch) | |
tree | d7fbf6870a55ab15f1e77efffa9c52ea19e75be5 /riscos | |
parent | 7cb9b4d79b078040967e5326615779d7c073b23d (diff) | |
download | netsurf-255bf8f1edc480b85d0aa7e499d7b027749717e0.tar.gz netsurf-255bf8f1edc480b85d0aa7e499d7b027749717e0.tar.bz2 |
[project @ 2004-05-06 21:18:26 by joty]
[ Again, the same commit of 2004-05-03 ]
ro_gui_set_icon_string() :
- anti-flicker test didn't work when string is longer than icon text
buffer length.
- make sure we have a NUL char terminated string when new icon text is
longer than icon buffer.
svn path=/import/netsurf/; revision=837
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/wimp.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/riscos/wimp.c b/riscos/wimp.c index da87cbd8a..baa9d1fa0 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -106,28 +106,34 @@ char *ro_gui_get_icon_string(wimp_w w, wimp_i i) { * \param text string (copied) */ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) { - wimp_caret caret; + wimp_caret caret; wimp_icon_state ic; int old_len, len; - + /* Get the icon data */ ic.w = w; ic.i = i; - if (xwimp_get_icon_state(&ic)) return; - + if (xwimp_get_icon_state(&ic)) + return; + /* Check that the existing text is not the same as the updated text to stop flicker */ - if (!strncmp(ic.icon.data.indirected_text.text, text, - (unsigned int)ic.icon.data.indirected_text.size)) return; - + if (ic.icon.data.indirected_text.size + && !strncmp(ic.icon.data.indirected_text.text, text, + (unsigned int)ic.icon.data.indirected_text.size - 1)) + return; + /* Copy the text across */ old_len = strlen(ic.icon.data.indirected_text.text); - strncpy(ic.icon.data.indirected_text.text, text, - (unsigned int)ic.icon.data.indirected_text.size); - + if (ic.icon.data.indirected_text.size) { + strncpy(ic.icon.data.indirected_text.text, text, + (unsigned int)ic.icon.data.indirected_text.size - 1); + ic.icon.data.indirected_text.text[ic.icon.data.indirected_text.size - 1] = '\0'; + } + /* Handle the caret being in the icon */ if (!xwimp_get_caret_position(&caret)) { @@ -137,7 +143,7 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) { xwimp_set_caret_position(w, i, caret.pos.x, caret.pos.y, -1, caret.index); } } - + /* Redraw the icon */ ro_gui_redraw_icon(w, i); |