From acf46e01a8dfeaa03585e7add070cc93677d50bf Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 27 Jul 2010 21:41:21 +0000 Subject: Allow text selection dragging across (NetSurf) windows. DisplayBeep if it is dropped somewhere invalid. svn path=/trunk/netsurf/; revision=10665 --- amiga/clipboard.c | 24 +++++++++++++++++++----- amiga/download.c | 9 +++++++-- amiga/gui.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- amiga/gui.h | 3 ++- 4 files changed, 71 insertions(+), 13 deletions(-) (limited to 'amiga') diff --git a/amiga/clipboard.c b/amiga/clipboard.c index bf09f5f98..d84add7f2 100755 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -257,17 +257,31 @@ bool gui_copy_to_clipboard(struct selection *s) void ami_drag_selection(struct selection *s) { struct box *text_box; - ULONG x = s->bw->window->shared->win->MouseX; - ULONG y = s->bw->window->shared->win->MouseY; + ULONG x; + ULONG y; + struct gui_window_2 *gwin = ami_window_at_pointer(); - if(text_box = ami_text_box_at_point(s->bw->window, &x, &y)) + if(!gwin) + { + DisplayBeep(scrn); + return; + } + + x = gwin->win->MouseX; + y = gwin->win->MouseY; + + if(text_box = ami_text_box_at_point(gwin, &x, &y)) { if(gui_copy_to_clipboard(s)) { - browser_window_mouse_click(s->bw, BROWSER_MOUSE_PRESS_1, x, y); - browser_window_key_press(s->bw, KEY_PASTE); + browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y); + browser_window_key_press(gwin->bw, KEY_PASTE); } } + else + { + DisplayBeep(scrn); + } } bool ami_easy_clipboard(char *text) diff --git a/amiga/download.c b/amiga/download.c index 0edd9c166..2802dca84 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -345,18 +345,21 @@ void gui_drag_save_selection(struct selection *s, struct gui_window *g) void ami_drag_save(struct Window *win) { - ULONG which,type; + ULONG which = WBO_NONE,type; char path[1025],dpath[1025]; char *source_data; ULONG source_size; - which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY, + if(strcmp(option_use_pubscreen,"Workbench") == 0) + { + which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY, WBOBJA_Type,&type, WBOBJA_FullPath,&path, WBOBJA_FullPathSize,1024, WBOBJA_DrawerPath,&dpath, WBOBJA_DrawerPathSize,1024, TAG_DONE); + } if((which == WBO_DRAWER) || ((which == WBO_ICON) && (type > WBDRAWER))) { @@ -366,6 +369,7 @@ void ami_drag_save(struct Window *win) { if(drag_save == GUI_SAVE_TEXT_SELECTION) ami_drag_selection((struct selection *)drag_save_data); + else DisplayBeep(scrn); drag_save = 0; drag_save_data = NULL; @@ -374,6 +378,7 @@ void ami_drag_save(struct Window *win) if(path[0] == '\0') { + DisplayBeep(scrn); drag_save = 0; drag_save_data = NULL; return; diff --git a/amiga/gui.c b/amiga/gui.c index 9609b7a08..0d06efd43 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -3784,7 +3785,7 @@ uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved) /* return the text box at posn x,y in window coordinates x,y are updated to be document co-ordinates */ -struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y) +struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y) { struct IBox *bbox; ULONG xs,ys,width,height; @@ -3792,19 +3793,19 @@ struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y) hlcache_handle *content; int box_x=0,box_y=0; - GetAttr(SPACE_AreaBox, (Object *)g->shared->objects[GID_BROWSER], + GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox); - ami_get_hscroll_pos(g->shared, (ULONG *)&xs); + ami_get_hscroll_pos(gwin, (ULONG *)&xs); *x = *x - (bbox->Left) +xs; - ami_get_vscroll_pos(g->shared, (ULONG *)&ys); + ami_get_vscroll_pos(gwin, (ULONG *)&ys); *y = *y - (bbox->Top) + ys; width=bbox->Width; height=bbox->Height; - content = g->shared->bw->current_content; + content = gwin->bw->current_content; box = html_get_box_tree(content); while ((box = box_at_point(box, *x, *y, &box_x, &box_y, &content))) { @@ -3827,3 +3828,40 @@ struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y) } return text_box; } + +struct gui_window_2 *ami_find_gwin_by_id(struct Window *win) +{ + struct nsObject *node, *nnode; + struct gui_window_2 *gwin; + + if(!IsMinListEmpty(window_list)) + { + node = (struct nsObject *)GetHead((struct List *)window_list); + + do + { + nnode=(struct nsObject *)GetSucc((struct Node *)node); + + if(node->Type == AMINS_WINDOW) // or frame? + { + gwin = node->objstruct; + if(win == gwin->win) return gwin; + } + } while(node = nnode); + } + return NULL; +} + +struct gui_window_2 *ami_window_at_pointer(void) +{ + struct Layer *layer; + + LockLayerInfo(&scrn->LayerInfo); + + layer = WhichLayer(&scrn->LayerInfo, scrn->MouseX, scrn->MouseY); + + UnlockLayerInfo(&scrn->LayerInfo); + + if(layer) return ami_find_gwin_by_id(layer->Window); + else return NULL; +} diff --git a/amiga/gui.h b/amiga/gui.h index 2a961f62c..dce118b89 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -127,7 +127,8 @@ void ami_close_all_tabs(struct gui_window_2 *gwin); void ami_quit_netsurf(void); void ami_do_redraw(struct gui_window_2 *g); STRPTR ami_locale_langs(void); -struct box *ami_text_box_at_point(struct gui_window *g, ULONG *x, ULONG *y); +struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y); +struct gui_window_2 *ami_window_at_pointer(void); struct TextFont *origrpfont; struct MinList *window_list; -- cgit v1.2.3