From cc321d5f63a526aab5a93bc3269736ac14bd92f7 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 6 Jan 2013 00:21:15 +0000 Subject: Track the mouse pointer on a per-window basis --- amiga/arexx.c | 8 ++------ amiga/download.c | 8 ++------ amiga/drag.c | 11 ++++++----- amiga/file.c | 4 ++-- amiga/gui.c | 20 ++++++-------------- amiga/gui.h | 1 + amiga/gui_options.c | 9 ++------- amiga/menu.c | 8 ++++---- amiga/search.c | 11 ++++++----- amiga/theme.c | 42 +++++++++++++++++++++--------------------- amiga/theme.h | 8 ++++++-- amiga/tree.c | 14 ++++---------- 12 files changed, 62 insertions(+), 82 deletions(-) (limited to 'amiga') diff --git a/amiga/arexx.c b/amiga/arexx.c index 154f69703..7048c0673 100755 --- a/amiga/arexx.c +++ b/amiga/arexx.c @@ -275,11 +275,7 @@ STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu if(!bw) return; - /* Set the busy pointer. We intentionally don't use ami_update_pointer here. */ - SetWindowPointer(bw->window->shared->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_set_pointer(bw->window->shared, GUI_POINTER_WAIT, false); if(fh = FOpen((char *)cmd->ac_ArgList[0], MODE_NEWFILE, 0)) { @@ -290,7 +286,7 @@ STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu SetComment((char *)cmd->ac_ArgList[0], nsurl_access(hlcache_handle_get_url(bw->current_content))); } - ami_reset_pointer(bw->window->shared->win); + ami_reset_pointer(bw->window->shared); } STATIC VOID rx_quit(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused))) diff --git a/amiga/download.c b/amiga/download.c index 37fc79e28..c49bd8554 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -357,11 +357,7 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title) strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname,savereq->fr_File,1024); - /* Set the busy pointer. We intentionally don't use ami_update_pointer here. */ - SetWindowPointer(g->shared->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_set_pointer(g->shared, GUI_POINTER_WAIT, false); if(ami_download_check_overwrite(fname, g->shared->win, 0)) { @@ -388,7 +384,7 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title) } FreeVec(linkname); } - ami_reset_pointer(g->shared->win); + ami_reset_pointer(g->shared); } } diff --git a/amiga/drag.c b/amiga/drag.c index 20dbc78e3..addc4b3cf 100644 --- a/amiga/drag.c +++ b/amiga/drag.c @@ -142,7 +142,7 @@ void ami_drag_save(struct Window *win) return; } - ami_update_pointer(win, GUI_POINTER_WAIT, false); + ami_update_pointer(win, GUI_POINTER_WAIT); switch(drag_save) { @@ -189,7 +189,8 @@ void ami_drag_save(struct Window *win) drag_save = 0; drag_save_data = NULL; - ami_update_pointer(win, GUI_POINTER_DEFAULT, false); + + ami_update_pointer(win, GUI_POINTER_DEFAULT); } void ami_drag_icon_show(struct Window *win, const char *type) @@ -205,12 +206,12 @@ void ami_drag_icon_show(struct Window *win, const char *type) if(nsoption_bool(drag_save_icons) == false) { - ami_update_pointer(win, AMI_GUI_POINTER_DRAG, false); + ami_update_pointer(win, AMI_GUI_POINTER_DRAG); return; } else { - ami_update_pointer(win, GUI_POINTER_DEFAULT, false); + ami_update_pointer(win, GUI_POINTER_DEFAULT); } if(!strcmp(type, "drawer")) deftype = WBDRAWER; @@ -266,7 +267,7 @@ void ami_drag_icon_move(void) void ami_drag_icon_close(struct Window *win) { if(drag_icon) CloseWindow(drag_icon); - if(win) ami_update_pointer(win, GUI_POINTER_DEFAULT, false); + if(win) ami_update_pointer(win, GUI_POINTER_DEFAULT); drag_icon = NULL; drag_in_progress = FALSE; } diff --git a/amiga/file.c b/amiga/file.c index 161aabdf3..30a63b615 100644 --- a/amiga/file.c +++ b/amiga/file.c @@ -141,7 +141,7 @@ void ami_file_save(int type, char *fname, struct Window *win, struct bitmap *bm; BPTR fh=0; - ami_update_pointer(win, GUI_POINTER_WAIT, false); + ami_update_pointer(win, GUI_POINTER_WAIT); if(ami_download_check_overwrite(fname, win, 0)) { @@ -200,7 +200,7 @@ void ami_file_save(int type, char *fname, struct Window *win, if(object) SetComment(fname, nsurl_access(hlcache_handle_get_url(object))); } - ami_update_pointer(win, GUI_POINTER_DEFAULT, false); + ami_update_pointer(win, GUI_POINTER_DEFAULT); } void ami_file_save_req(int type, struct gui_window_2 *gwin, diff --git a/amiga/gui.c b/amiga/gui.c index 0c31c7f68..2bf9dde70 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1435,7 +1435,7 @@ void ami_handle_msg(void) { ami_context_menu_mouse_trap(gwin, FALSE); - if(!gwin->mouse_state) ami_update_pointer(gwin->win, GUI_POINTER_DEFAULT, false); + if(!gwin->mouse_state) ami_set_pointer(gwin, GUI_POINTER_DEFAULT, true); } break; @@ -3600,11 +3600,7 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->bw->scale); int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->bw->scale); - /* Set the busy pointer. We intentionally don't use ami_update_pointer here. */ - SetWindowPointer(gwin->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_set_pointer(gwin, GUI_POINTER_WAIT, false); browserglob.shared_pens = &gwin->shared_pens; @@ -3674,7 +3670,7 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, } } - ami_reset_pointer(gwin->win); + ami_reset_pointer(gwin); } @@ -3852,19 +3848,15 @@ void ami_do_redraw(struct gui_window_2 *gwin) clip.x1 = bbox->Left + bbox->Width; clip.y1 = bbox->Top + bbox->Height; - /* Set the busy pointer. We intentionally don't use ami_update_pointer here. */ - SetWindowPointer(gwin->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); - + ami_set_pointer(gwin, GUI_POINTER_WAIT, false); + if(browser_window_redraw(gwin->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip, &ctx)) { ami_clearclipreg(&browserglob); browserglob.rp = temprp; } - ami_reset_pointer(gwin->win); + ami_reset_pointer(gwin); } } diff --git a/amiga/gui.h b/amiga/gui.h index 1dff5d3c0..ff467977a 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -120,6 +120,7 @@ struct gui_window_2 { struct IBox *ptr_lock; struct AppWindow *appwin; struct MinList shared_pens; + gui_pointer_shape mouse_pointer; }; struct gui_window diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 66e47d8ad..e54ad15a6 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -1502,10 +1502,7 @@ void ami_gui_opts_use(bool save) bool rescan_fonts = false; bool old_tab_always_show; - SetWindowPointer(gow->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_update_pointer(gow->win, GUI_POINTER_WAIT); GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_HOMEPAGE],(ULONG *)&data); nsoption_set_charp(homepage_url, (char *)strdup((char *)data)); @@ -1863,9 +1860,7 @@ void ami_gui_opts_use(bool save) ami_menu_check_toggled = true; - SetWindowPointer(gow->win, - WA_Pointer, NULL, - TAG_DONE); + ami_update_pointer(gow->win, GUI_POINTER_DEFAULT); } void ami_gui_opts_close(void) diff --git a/amiga/menu.c b/amiga/menu.c index c3b191e40..496400dfb 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -753,9 +753,9 @@ static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct I struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_update_pointer(gwin->win, GUI_POINTER_WAIT, false); + ami_set_pointer(gwin, GUI_POINTER_WAIT, false); ami_print_ui(gwin->bw->current_content); - ami_update_pointer(gwin->win, GUI_POINTER_DEFAULT, false); + ami_reset_pointer(gwin); } static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct IntuiMessage *msg) @@ -766,7 +766,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_update_pointer(gwin->win, GUI_POINTER_WAIT, false); + ami_set_pointer(gwin, GUI_POINTER_WAIT, false); temp = ASPrintf("%s|%s|%s", messages_get("OK"), messages_get("HelpCredits"), @@ -800,7 +800,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I else if(sel == 0) browser_window_create("about:licence", NULL, 0, true, false); - ami_update_pointer(gwin->win, GUI_POINTER_DEFAULT, false); + ami_reset_pointer(gwin); } static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg) diff --git a/amiga/search.c b/amiga/search.c index 6f8ebd414..1148f6d77 100755 --- a/amiga/search.c +++ b/amiga/search.c @@ -36,9 +36,10 @@ #include "amiga/os3support.h" #include "amiga/search.h" #include "amiga/object.h" +#include "amiga/theme.h" + #include #include - #include #include #include @@ -277,10 +278,10 @@ void ami_search_set_status(bool found, void *p) void ami_search_set_hourglass(bool active, void *p) { - SetWindowPointer(fwin->win, - WA_BusyPointer,active, - WA_PointerDelay,active, - TAG_DONE); + if(active) + ami_update_pointer(fwin->win, GUI_POINTER_WAIT); + else + ami_update_pointer(fwin->win, GUI_POINTER_DEFAULT); } /** diff --git a/amiga/theme.c b/amiga/theme.c index 52462c03c..6e3336746 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -174,18 +174,24 @@ void ami_get_theme_filename(char *filename, char *themestring, bool protocol) void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) { - ami_update_pointer(g->shared->win, shape, false); + ami_set_pointer(g->shared, shape, true); +} + +void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update) +{ + if(gwin->mouse_pointer == shape) return; + ami_update_pointer(gwin->win, shape); + if(update == true) gwin->mouse_pointer = shape; } /* reset the mouse pointer back to what NetSurf last set it as */ -void ami_reset_pointer(struct Window *win) +void ami_reset_pointer(struct gui_window_2 *gwin) { - ami_update_pointer(win, mouseptrcurrent, true); + ami_update_pointer(gwin->win, gwin->mouse_pointer); } -void ami_update_pointer(struct Window *win, gui_pointer_shape shape, bool reapply) +void ami_update_pointer(struct Window *win, gui_pointer_shape shape) { - if((mouseptrcurrent == shape) && (reapply == false)) return; if(drag_save_data) return; if(nsoption_bool(use_os_pointers)) @@ -193,24 +199,24 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape, bool reappl switch(shape) { case GUI_POINTER_DEFAULT: - SetWindowPointer(win,TAG_DONE); + SetWindowPointer(win, TAG_DONE); break; case GUI_POINTER_WAIT: SetWindowPointer(win, - WA_BusyPointer,TRUE, - WA_PointerDelay,TRUE, + WA_BusyPointer, TRUE, + WA_PointerDelay, TRUE, TAG_DONE); break; default: if(mouseptrobj[shape]) { - SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); + SetWindowPointer(win, WA_Pointer, mouseptrobj[shape], TAG_DONE); } else { - SetWindowPointer(win,TAG_DONE); + SetWindowPointer(win, TAG_DONE); } break; } @@ -219,34 +225,28 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape, bool reappl { if(mouseptrobj[shape]) { - SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); + SetWindowPointer(win, WA_Pointer, mouseptrobj[shape], TAG_DONE); } else { if(shape == GUI_POINTER_WAIT) { SetWindowPointer(win, - WA_BusyPointer,TRUE, - WA_PointerDelay,TRUE, + WA_BusyPointer, TRUE, + WA_PointerDelay, TRUE, TAG_DONE); } else { - SetWindowPointer(win,TAG_DONE); + SetWindowPointer(win, TAG_DONE); } } } - - mouseptrcurrent = shape; } void gui_window_hide_pointer(struct gui_window *g) { - if(mouseptrcurrent != AMI_GUI_POINTER_BLANK) - { - SetWindowPointer(g->shared->win,WA_Pointer,mouseptrobj[AMI_GUI_POINTER_BLANK],TAG_DONE); - mouseptrcurrent = AMI_GUI_POINTER_BLANK; - } + ami_set_pointer(g->shared, AMI_GUI_POINTER_BLANK, true); } void ami_init_mouse_pointers(void) diff --git a/amiga/theme.h b/amiga/theme.h index 52a21bb1a..3c3931c12 100644 --- a/amiga/theme.h +++ b/amiga/theme.h @@ -35,6 +35,10 @@ void ami_update_throbber(struct gui_window_2 *g,bool redraw); void ami_init_mouse_pointers(void); void ami_mouse_pointers_free(void); -void ami_update_pointer(struct Window *win, gui_pointer_shape shape, bool reapply); -void ami_reset_pointer(struct Window *win); +void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update); +void ami_reset_pointer(struct gui_window_2 *gwin); +/* Use the following ONLY if nothing other than the Intuition window pointer is available, + * and ALWAYS in preference to SetWindowPointer(), as it features more pointers and uses + * the correct ones specified in user preferences. */ +void ami_update_pointer(struct Window *win, gui_pointer_shape shape); #endif diff --git a/amiga/tree.c b/amiga/tree.c index e3224ff53..9f53d4be8 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -991,15 +991,12 @@ BOOL ami_tree_event(struct treeview_window *twin) { strlcpy(fname,savereq->fr_Drawer,1024); AddPart(fname,savereq->fr_File,1024); - SetWindowPointer(twin->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_update_pointer(twin->win, GUI_POINTER_WAIT); if(twin->type == AMI_TREE_HISTORY) history_global_export(fname); else if(twin->type == AMI_TREE_HOTLIST) hotlist_export(fname); - SetWindowPointer(twin->win, TAG_DONE); + ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); } break; @@ -1241,10 +1238,7 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data) if(!twin->win) return; - SetWindowPointer(twin->win, - WA_BusyPointer, TRUE, - WA_PointerDelay, TRUE, - TAG_DONE); + ami_update_pointer(twin->win, GUI_POINTER_WAIT); glob = &twin->globals; @@ -1292,6 +1286,6 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data) } } - SetWindowPointer(twin->win, TAG_DONE); + ami_update_pointer(twin->win, GUI_POINTER_WAIT); glob = &browserglob; } -- cgit v1.2.3