diff options
-rw-r--r-- | !NetSurf/Resources/Pointers,ff9 | bin | 0 -> 540 bytes | |||
-rw-r--r-- | desktop/browser.c | 38 | ||||
-rw-r--r-- | desktop/gui.h | 3 | ||||
-rw-r--r-- | riscos/gui.c | 62 |
4 files changed, 101 insertions, 2 deletions
diff --git a/!NetSurf/Resources/Pointers,ff9 b/!NetSurf/Resources/Pointers,ff9 Binary files differnew file mode 100644 index 000000000..5c68403c7 --- /dev/null +++ b/!NetSurf/Resources/Pointers,ff9 diff --git a/desktop/browser.c b/desktop/browser.c index 305f7186f..00cf88129 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -45,6 +45,7 @@ static void browser_window_update(struct browser_window *bw, bool scroll_to_top); static void browser_window_set_status(struct browser_window *bw, const char *text); +static void browser_window_set_pointer(gui_pointer_shape shape); static void download_window_callback(content_msg msg, struct content *c, void *p1, void *p2, const char *error); @@ -424,6 +425,17 @@ void browser_window_set_status(struct browser_window *bw, const char *text) gui_window_set_status(bw->window, text); } +/** + * Change the shape of the mouse pointer + * + * \param shape shape to use + */ + +void browser_window_set_pointer(gui_pointer_shape shape) +{ + gui_window_set_pointer(shape); +} + /** * Close and destroy a browser window. @@ -1358,6 +1370,7 @@ void browser_window_follow_link(struct browser_window *bw, browser_window_create(url); } else if (click_type == 0) { browser_window_set_status(bw, url); + browser_window_set_pointer(GUI_POINTER_POINT); done = 1; } free(url); @@ -1386,29 +1399,50 @@ void browser_window_follow_link(struct browser_window *bw, browser_window_create(url); } else if (click_type == 0) { browser_window_set_status(bw, url); + browser_window_set_pointer(GUI_POINTER_POINT); done = 1; } free(url); break; } + if (click_type == 0 && click_boxes[i].box->gadget != NULL) { + if (click_boxes[i].box->gadget->type == GADGET_TEXTBOX || + click_boxes[i].box->gadget->type == GADGET_TEXTAREA || + click_boxes[i].box->gadget->type == GADGET_PASSWORD || + click_boxes[i].box->gadget->type == GADGET_FILE) { + browser_window_set_pointer(GUI_POINTER_CARET); + done = 1; + break; + } + else if (click_boxes[i].box->gadget->type == GADGET_SELECT) { + browser_window_set_pointer(GUI_POINTER_MENU); + done = 1; + break; + } + } if (click_type == 0 && click_boxes[i].box->title != NULL) { browser_window_set_status(bw, click_boxes[i].box-> title); + browser_window_set_pointer(GUI_POINTER_DEFAULT); done = 1; break; } } if (click_type == 0 && done == 0) { - if (bw->loading_content != 0) + if (bw->loading_content != 0) { browser_window_set_status(bw, bw->loading_content-> status_message); - else + browser_window_set_pointer(GUI_POINTER_DEFAULT); + } + else { browser_window_set_status(bw, bw->current_content-> status_message); + browser_window_set_pointer(GUI_POINTER_DEFAULT); + } } free(click_boxes); diff --git a/desktop/gui.h b/desktop/gui.h index 62dcf27a7..684332c56 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -15,6 +15,8 @@ struct gui_window; typedef struct gui_window gui_window; +typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET, + GUI_POINTER_MENU } gui_pointer_shape; #include <stdbool.h> #include "netsurf/desktop/browser.h" @@ -33,6 +35,7 @@ void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy); unsigned long gui_window_get_width(gui_window* g); void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long height); void gui_window_set_status(gui_window* g, const char* text); +void gui_window_set_pointer(gui_pointer_shape shape); void gui_window_set_title(gui_window* g, char* title); void gui_window_set_url(gui_window *g, char *url); diff --git a/riscos/gui.c b/riscos/gui.c index 4c7bfb8ac..dee2320a0 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -21,8 +21,10 @@ #include "oslib/osbyte.h" #include "oslib/osfile.h" #include "oslib/osfscontrol.h" +#include "oslib/osspriteop.h" #include "oslib/plugin.h" #include "oslib/wimp.h" +#include "oslib/wimpspriteop.h" #include "oslib/uri.h" #include "netsurf/utils/config.h" #include "netsurf/desktop/gui.h" @@ -61,6 +63,8 @@ bool gui_reformat_pending = false; /**< Some windows have been resized, gui_drag_type gui_current_drag_type; static wimp_t task_handle; /**< RISC OS wimp task handle. */ static clock_t gui_last_poll; /**< Time of last wimp_poll. */ +osspriteop_area *pointers; /**< Sprite area containing pointer data */ +gui_pointer_shape curr_pointer; /**< Current shape of the pointer */ /** Accepted wimp user messages. */ static const wimp_MESSAGE_LIST(26) task_messages = { { message_DATA_SAVE, @@ -106,6 +110,7 @@ struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0; static void ro_gui_choose_language(void); +static void ro_gui_pointers_init(const char *filename); static void ro_gui_icon_bar_create(void); static void ro_gui_handle_event(wimp_event_no event, wimp_block *block); static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block); @@ -193,6 +198,7 @@ void gui_init(int argc, char** argv) #endif ro_gui_history_init(); wimp_close_template(); + ro_gui_pointers_init("<NetSurf$Dir>.Resources.Pointers"); ro_gui_icon_bar_create(); } @@ -251,6 +257,31 @@ void ro_gui_choose_language(void) option_accept_language = strdup(option_language); } +/** + * Initialise pointer sprite area + */ +void ro_gui_pointers_init(const char *filename) +{ + FILE *fp; + unsigned int len; + os_error *e; + + fp = fopen(filename, "rb"); + if (!fp) return; + fseek(fp, 0, SEEK_END); + len = ftell(fp); + fclose(fp); + pointers = xcalloc(len+4, sizeof(char)); + + pointers->size = len+4; + pointers->sprite_count = 0; + pointers->first = 16; + pointers->used = 16; + + e = xosspriteop_load_sprite_file(osspriteop_USER_AREA, + pointers, filename); + if (e) xfree(pointers); +} /** * Create an iconbar icon. @@ -275,6 +306,7 @@ void ro_gui_icon_bar_create(void) void gui_quit(void) { ro_gui_history_quit(); + xfree(pointers); wimp_close_down(task_handle); xhourglass_off(); } @@ -368,6 +400,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) case wimp_POINTER_LEAVING_WINDOW: over_window = 0; + gui_window_set_pointer(GUI_POINTER_DEFAULT); break; case wimp_POINTER_ENTERING_WINDOW: @@ -482,6 +515,35 @@ void ro_gui_null_reason_code(void) } } +/** + * Change mouse pointer shape + */ +void gui_window_set_pointer(gui_pointer_shape shape) +{ + if (shape == curr_pointer) return; + + switch (shape) { + case GUI_POINTER_DEFAULT: + xwimpspriteop_set_pointer_shape("ptr_default", + 1, 0, 0, 0, 0); + break; + case GUI_POINTER_POINT: + xosspriteop_set_pointer_shape(0x100, pointers, + (osspriteop_id)"ptr_point", 1, 6, 0, 0, 0); + break; + case GUI_POINTER_CARET: + xosspriteop_set_pointer_shape(0x100, pointers, + (osspriteop_id)"ptr_caret", 1, 5, 0, 0, 0); + break; + case GUI_POINTER_MENU: + xosspriteop_set_pointer_shape(0x100, pointers, + (osspriteop_id)"ptr_menu", 1, 6, 4, 0, 0); + break; + } + + curr_pointer = shape; +} + /** * Handle Redraw_Window_Request events. |