Commits (3)
  • ROOL's avatar
    Remove unused error message · 98ddc415
    ROOL authored
    Admin:
      Found during sweep of $Options variables for User Guide.
    
    Version 3.23. Tagged as 'Help2-3_23'
    98ddc415
  • Jeffrey Lee's avatar
    Power saving tweaks & timer fixes · a404ce4c
    Jeffrey Lee authored
    Detail:
      * When help is enabled, use event_poll_idle() (i.e. Wimp_PollIdle) instead of regular event_poll() to limit our update rate to a sensible value
      * Adjust send_help_request() so that it won't send another request if the pointer state hasn't changed since the last request (otherwise constant wimp message activity will prevent the Wimp from entering low power mode)
      * Fix a couple of time value comparisons to not be subject to problems when the monotonic timer wraps around
      Files changed: c/main, h/defines
    Admin:
      Tested on Raspberry Pi 3
      Fixes issue reported on forums with !Help preventing the system from switching to low CPU speed:
      https://www.riscosopen.org/forum/forums/4/topics/9074
    
    
    Version 3.24. Tagged as 'Help2-3_24'
    a404ce4c
  • Robert Sprowson's avatar
    Fix potential memory leak on malloc failure · 1dda9cac
    Robert Sprowson authored
    Do the claim in 1 step, to save time and save leaking if one of them fails.
    Ref https://www.riscosopen.org/forum/forums/4/topics/9503
    
    Version 3.25. Tagged as 'Help2-3_25'
    1dda9cac
......@@ -28,8 +28,7 @@ HelpI14:\TICONISE icon.|M\Siconise the \w.
Error1:Bad inversion
Error2:Illegal character
Error3:Bad interactive option
Error4:in Help$Options
Error5:Insufficient memory to display help message
Error4:Insufficient memory to display help message
Fatal1:Bad substitution in message
Fatal2:Help has suffered a fatal error and must exit immediately
......
/* (3.22)
/* (3.25)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 3.22
#define Module_MajorVersion_CMHG 3.25
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 23 Jul 2014
#define Module_Date_CMHG 08 Oct 2017
#define Module_MajorVersion "3.22"
#define Module_Version 322
#define Module_MajorVersion "3.25"
#define Module_Version 325
#define Module_MinorVersion ""
#define Module_Date "23 Jul 2014"
#define Module_Date "08 Oct 2017"
#define Module_ApplicationDate "23-Jul-14"
#define Module_ApplicationDate "08-Oct-17"
#define Module_ComponentName "Help2"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Help2"
#define Module_FullVersion "3.22"
#define Module_HelpVersion "3.22 (23 Jul 2014)"
#define Module_LibraryVersionInfo "3:22"
#define Module_FullVersion "3.25"
#define Module_HelpVersion "3.25 (08 Oct 2017)"
#define Module_LibraryVersionInfo "3:25"
......@@ -70,8 +70,8 @@ static char fontname[256]; /* the chosen font name */
/* Status variables */
static int screen_w, screen_h; /* Width and height of screen in the current mode */
static int request_handle=0; /* Task handle of app that last help request was sent to */
static int request_x=-1, request_y=-1; /* x and y co-ords of the last help request sent */
static int reply_time=0, reply_x=-1, reply_y=-1; /* The time and position of the last help reply received */
static WimpGetPointerInfoBlock request_pi; /* Pointer location + icon that help request was last sent to */
static int reply_time=-1, reply_x=-1, reply_y=-1;/* The time and position of the last help reply received */
static int check_time=0, check_x=-1, check_y=-1; /* The time & position of the last check */
static int still_time=0; /* How long the pointer has been still for */
static int num_icons=-1; /* Current number of icons in the help box */
......@@ -211,12 +211,13 @@ static _kernel_oserror* update_help_box(char* string, int length)
int x, y, num_strings, lines, i, width_os, height_os;
int width, bullet_size;
if (length>1024) return common_error(messages_lookup("Error5"));
if (length>1024) return common_error(messages_lookup("Error4"));
strcpy(help_box_message, string);
reply_x = request_x;
reply_y = request_y;
reply_x = request_pi.x;
reply_y = request_pi.y;
_swix(OS_ReadMonotonicTime, _OUT(0), &reply_time);
if (reply_time==-1) reply_time = 0; /* Avoid getting confused with the reset value */
/* Find the size of the ' ' in the helpbox font */
_swix(Font_ConverttoOS, _INR(1, 2)|_OUT(1), return_string_length(helpbox_font_handle, " "), 0,
......@@ -226,16 +227,16 @@ static _kernel_oserror* update_help_box(char* string, int length)
error_trap(toolbox_hide_object(0, shadow_id), 0);
/* Get memory to store expanded help message */
expanded_string = malloc(1024);
buffer = malloc(1024);
if ((!expanded_string) || (!buffer)) return common_error(messages_lookup("Error5"));
buffer = malloc(1024 + 1024);
if (!buffer) return common_error(messages_lookup("Error4"));
expanded_string = &buffer[1024];
/* Break the help message down into lines which will be displayed in the box */
num_strings = translate_help_string(help_box_message, expanded_string, length);
width = choose_box_width(helpbox_font_handle, &width_os, &height_os);
lines = break_strings_down(helpbox_font_handle, width, buffer);
/* Set the extent of the help box (and shadow) */
/* Set the extent of the help box (and shadow) */
extent.xmin = 0;
extent.xmax = width_os;
extent.ymin = 0;
......@@ -322,7 +323,6 @@ static _kernel_oserror* update_help_box(char* string, int length)
help_box_showing = 1;
free(buffer);
free(expanded_string);
return NULL;
}
......@@ -404,7 +404,7 @@ static void check_new_help_message(char* message)
* *
* In: gpi -> block returned by Wimp_GetPointerInfo *
* *
* Globals: request_x, request_y *
* Globals: request_pi *
*---------------------------------------------------------------------------*/
static void send_help_request(WimpGetPointerInfoBlock* gpi)
......@@ -414,11 +414,14 @@ static void send_help_request(WimpGetPointerInfoBlock* gpi)
char token[12];
int icon = gpi->icon_handle;
/* Don't bother sendig requests to ourself */
/* Don't bother sending requests to ourself */
if ( (gpi->window_handle == help_box_wimp) || (gpi->window_handle == shadow_wimp) ) return;
request_x = gpi->x;
request_y = gpi->y;
/* Don't bother sending if the mouse state hasn't changed since the last request - otherwise the constant message traffic will prevent the Wimp from lowering the CPU speed
Note that we check the entire state, just in case the window/icon has changed without the mouse moving (e.g. close icon clicked) */
if ( !memcmp(&request_pi,gpi,sizeof(WimpGetPointerInfoBlock)) ) return;
request_pi = *gpi;
if ( (icon<=-2) && (icon>=-14) )
{
......@@ -683,14 +686,14 @@ static int null_event(int event_code, WimpPollBlock *event, IdBlock *id_block, v
_swix(OS_ReadMonotonicTime, _OUT(0), &time);
/* Check for timeout */
if ( (reply_time > -1) && (timeout > 0) && (time > reply_time + timeout) )
if ( (reply_time != -1) && (timeout > 0) && (time - reply_time > timeout) )
{
remove_help_box();
still_time = 0;
}
/* We check the position of the pointer every n centiseconds */
if ( time > check_time + DelayBetweenChecks )
if ( time - check_time > DelayBetweenChecks )
{
/* Have we moved since the last check? */
if ( (check_x >= gpi.x-still_distance) && (check_x <= gpi.x+still_distance)
......@@ -839,7 +842,16 @@ int main(int argc, char **argv)
while (TRUE)
{
error_trap(event_poll(&event_code, &wpb, NULL), 0);
if (help_on)
{
unsigned int time;
_swix(OS_ReadMonotonicTime, _OUT(0), &time);
error_trap(event_poll_idle(&event_code, &wpb, time + NullPollRate, NULL), 0);
}
else
{
error_trap(event_poll(&event_code, &wpb, NULL), 0);
}
}
return 0;
......
......@@ -25,6 +25,9 @@
/* Delay between help requests (cs) */
#define DelayBetweenChecks 10
/* Delay between null poll events (cs), essentially limits our max responsiveness */
#define NullPollRate 4
/* CMOS Double click cancel distance byte */
#define WimpDoubleClickMove 22
......