Fix DSI when drag saving
Allow selection drags to URL and search gadgets svn path=/trunk/netsurf/; revision=12259
This commit is contained in:
parent
1304964f92
commit
1518543c22
|
@ -21,6 +21,7 @@
|
|||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
|
||||
#include "amiga/clipboard.h"
|
||||
#include "amiga/iff_cset.h"
|
||||
#include "amiga/options.h"
|
||||
#include "amiga/gui.h"
|
||||
|
@ -43,6 +44,9 @@
|
|||
struct IFFHandle *iffh = NULL;
|
||||
|
||||
bool ami_add_to_clipboard(const char *text, size_t length, bool space);
|
||||
static bool ami_copy_selection(const char *text, size_t length,
|
||||
struct box *box, void *handle, const char *whitespace_text,
|
||||
size_t whitespace_length);
|
||||
|
||||
struct IFFHandle *ami_clipboard_init_internal(int unit)
|
||||
{
|
||||
|
@ -275,11 +279,44 @@ bool gui_copy_to_clipboard(struct selection *s)
|
|||
return false;
|
||||
}
|
||||
|
||||
struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
|
||||
{
|
||||
struct ami_text_selection *sel;
|
||||
|
||||
sel = AllocVec(sizeof(struct ami_text_selection),
|
||||
MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if(sel) selection_traverse(gwin->bw->sel, ami_copy_selection, sel);
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
||||
static bool ami_copy_selection(const char *text, size_t length,
|
||||
struct box *box, void *handle, const char *whitespace_text,
|
||||
size_t whitespace_length)
|
||||
{
|
||||
struct ami_text_selection *sel = handle;
|
||||
int len = length;
|
||||
|
||||
if((length + (sel->length)) > (sizeof(sel->text)))
|
||||
len = sizeof(sel->text) - (sel->length);
|
||||
|
||||
if(len <= 0) return false;
|
||||
|
||||
memcpy((sel->text) + (sel->length), text, len);
|
||||
sel->length += len;
|
||||
|
||||
sel->text[sel->length] = '\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ami_drag_selection(struct selection *s)
|
||||
{
|
||||
struct box *text_box;
|
||||
ULONG x;
|
||||
ULONG y;
|
||||
int x;
|
||||
int y;
|
||||
struct ami_text_selection *sel;
|
||||
struct IFFHandle *old_iffh = iffh;
|
||||
struct gui_window_2 *gwin = ami_window_at_pointer();
|
||||
|
||||
|
@ -307,7 +344,31 @@ void ami_drag_selection(struct selection *s)
|
|||
}
|
||||
else
|
||||
{
|
||||
DisplayBeep(scrn);
|
||||
x = gwin->win->MouseX;
|
||||
y = gwin->win->MouseY;
|
||||
|
||||
if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
|
||||
{
|
||||
if(sel = ami_selection_to_text(gwin))
|
||||
{
|
||||
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
|
||||
gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
|
||||
FreeVec(sel);
|
||||
}
|
||||
}
|
||||
else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
|
||||
{
|
||||
if(sel = ami_selection_to_text(gwin))
|
||||
{
|
||||
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
|
||||
gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
|
||||
FreeVec(sel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayBeep(scrn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2008-2009, 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
|
@ -23,12 +23,20 @@
|
|||
struct bitmap;
|
||||
struct hlcache_handle;
|
||||
struct selection;
|
||||
struct gui_window_2;
|
||||
|
||||
struct ami_text_selection
|
||||
{
|
||||
char text[1024];
|
||||
int length;
|
||||
};
|
||||
|
||||
void ami_clipboard_init(void);
|
||||
void ami_clipboard_free(void);
|
||||
void ami_drag_selection(struct selection *s);
|
||||
bool ami_easy_clipboard(char *text);
|
||||
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap);
|
||||
struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin);
|
||||
#ifdef WITH_NS_SVG
|
||||
bool ami_easy_clipboard_svg(struct hlcache_handle *c);
|
||||
#endif
|
||||
|
|
|
@ -48,9 +48,6 @@
|
|||
#include <string.h>
|
||||
|
||||
static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved);
|
||||
static bool ami_context_menu_copy_selection(const char *text, size_t length,
|
||||
struct box *box, void *handle, const char *whitespace_text,
|
||||
size_t whitespace_length);
|
||||
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
|
||||
int x1, int y1, const struct history_entry *entry, void *user_data);
|
||||
|
||||
|
@ -84,12 +81,6 @@ struct Library *PopupMenuBase = NULL;
|
|||
struct PopupMenuIFace *IPopupMenu = NULL;
|
||||
char *ctxmenulab[CMID_LAST];
|
||||
|
||||
struct ami_context_menu_selection
|
||||
{
|
||||
char text[1024];
|
||||
int length;
|
||||
};
|
||||
|
||||
void ami_context_menu_init(void)
|
||||
{
|
||||
if(PopupMenuBase = OpenLibrary("popupmenu.class",0))
|
||||
|
@ -584,16 +575,11 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
|
|||
|
||||
case CMID_SELSEARCH:
|
||||
{
|
||||
struct ami_context_menu_selection *sel;
|
||||
struct ami_text_selection *sel;
|
||||
char *url;
|
||||
|
||||
sel = AllocVec(sizeof(struct ami_context_menu_selection),
|
||||
MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if(sel)
|
||||
if(sel = ami_selection_to_text(gwin))
|
||||
{
|
||||
selection_traverse(gwin->bw->sel, ami_context_menu_copy_selection,
|
||||
sel);
|
||||
url = search_web_from_term(sel->text);
|
||||
browser_window_go(gwin->bw, url, NULL, true);
|
||||
|
||||
|
@ -607,26 +593,6 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
|
|||
return itemid;
|
||||
}
|
||||
|
||||
static bool ami_context_menu_copy_selection(const char *text, size_t length,
|
||||
struct box *box, void *handle, const char *whitespace_text,
|
||||
size_t whitespace_length)
|
||||
{
|
||||
struct ami_context_menu_selection *sel = handle;
|
||||
int len = length;
|
||||
|
||||
if((length + (sel->length)) > (sizeof(sel->text)))
|
||||
len = sizeof(sel->text) - (sel->length);
|
||||
|
||||
if(len <= 0) return false;
|
||||
|
||||
memcpy((sel->text) + (sel->length), text, len);
|
||||
sel->length += len;
|
||||
|
||||
sel->text[sel->length] = '\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
|
||||
int x1, int y1, const struct history_entry *entry, void *user_data)
|
||||
{
|
||||
|
|
|
@ -111,7 +111,7 @@ void ami_drag_save(struct Window *win)
|
|||
ami_drag_icon_close(NULL);
|
||||
ami_autoscroll = FALSE;
|
||||
|
||||
if(strcmp(option_use_pubscreen,"Workbench") == 0)
|
||||
if(option_use_pubscreen && (strcmp(option_use_pubscreen,"Workbench") == 0))
|
||||
{
|
||||
which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY,
|
||||
WBOBJA_Type,&type,
|
||||
|
@ -348,5 +348,5 @@ struct gui_window_2 *ami_window_at_pointer(void)
|
|||
UnlockLayerInfo(&scrn->LayerInfo);
|
||||
|
||||
if(layer) return ami_find_gwin_by_id(layer->Window);
|
||||
else return NULL;
|
||||
else return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue