start on image maps (dw-part)
Hi, just to let you know, I just started with client side image maps (the dw-part). Below is an initial implementation of ImageMapsList. This is not yet ready at all, but perhaps someone might want have a look. Cheers, Johannes diff -r 877bbc03146b -r ebc6de688732 dw/image.cc --- a/dw/image.cc Thu Apr 17 22:14:42 2008 +0200 +++ b/dw/image.cc Mon Apr 21 21:03:51 2008 +0200 @@ -25,12 +25,44 @@ namespace dw { +ImageMapsList::ImageMap::ImageMap () +{ + shapesAndLinks = new container::typed::List <ShapeAndLink> (true); +} + +void ImageMapsList::ImageMap::add (core::Shape *shape, int link) { + ShapeAndLink *shapeAndLink = new ShapeAndLink (); + shapeAndLink->shape = shape; + shapeAndLink->link = link; + shapesAndLinks->append (shapeAndLink); +} + +int ImageMapsList::ImageMap::link (int x, int y) { + container::typed::Iterator <ShapeAndLink> it; + int link = -1; + + for (it = shapesAndLinks->iterator (); it.hasNext (); ) { + ShapeAndLink *shapeAndLink = it.getNext (); + + if (shapeAndLink->shape->isPointWithin (x, y)) { + link = shapeAndLink->link; + break; + } + } + + return link; +} + ImageMapsList::ImageMapsList () { + imageMaps = new container::typed::HashTable <object::Object, ImageMap> + (true, true); + currentMap = NULL; } ImageMapsList::~ImageMapsList () { + delete imageMaps; } /** @@ -42,6 +74,8 @@ ImageMapsList::~ImageMapsList () */ void ImageMapsList::startNewMap (object::Object *key) { + currentMap = new ImageMap (); + imageMaps->put (key, currentMap); } /** @@ -52,6 +86,7 @@ void ImageMapsList::startNewMap (object: */ void ImageMapsList::addShapeToCurrentMap (core::Shape *shape, int link) { + currentMap->add (shape, link); } // ---------------------------------------------------------------------- diff -r 877bbc03146b -r ebc6de688732 dw/image.hh --- a/dw/image.hh Thu Apr 17 22:14:42 2008 +0200 +++ b/dw/image.hh Mon Apr 21 21:03:51 2008 +0200 @@ -22,6 +22,27 @@ namespace dw { */ class ImageMapsList { +private: + class ImageMap: public object::Object { + private: + class ShapeAndLink: public object::Object { + public: + core::Shape *shape; + int link; + }; + + container::typed::List <ShapeAndLink> *shapesAndLinks; + public: + ImageMap (); + ~ImageMap (); + + void add (core::Shape *shape, int link); + int link (int x, int y); + }; + + container::typed::HashTable <object::Object, ImageMap> *imageMaps; + ImageMap *currentMap; + public: ImageMapsList (); ~ImageMapsList ();
Hi - again, it went smoother than expected. The design was well thought out and documented by Sebastian in image.hh. Here comes the dw-part of client side image maps. I could need some help to hook this up in html.cc so I can start testing it. Also the linkEmitter stuff in image.cc needs to be looked at by someone who knows how this works :-) Cheers, Johannes
Johannes wrote:
Here comes the dw-part of client side image maps. I could need some help to hook this up in html.cc so I can start testing it. Also the linkEmitter stuff in image.cc needs to be looked at by someone who knows how this works :-)
Okay, I recognize my cue here :) I now have the dillo side working with it in a look-my-one-testcase-works! sense, but still have to go through and look at the spec more closely and make it robust and all that...
dw: I added motionNotifyImpl() and currLink dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dw: I added motionNotifyImpl() and currLink
Wow, that was fast! Works fine so far :-)
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
What about deleting coords earlier? I think they are no longer needed once the shape has been constructed. Regarding your comment in Image::enterNotifyImpl(). I noticed that too, but enterNotifyImpl() simply notifies about the enter event, so no coordinates are needed. Don't you think that implementing map aware Image::motionNotifyImpl() is enough? Cheers, Johannes
diff -pur dw2/dw/image.cc dw2-cur/dw/image.cc --- dw2/dw/image.cc 2008-03-13 14:56:16.000000000 +0000 +++ dw2-cur/dw/image.cc 2008-04-22 04:16:21.000000000 +0000 @@ -25,12 +25,49 @@
namespace dw {
+ImageMapsList::ImageMap::ImageMap () +{ + shapesAndLinks = new container::typed::List <ShapeAndLink> (true); +} + +ImageMapsList::ImageMap::~ImageMap () +{ + delete shapesAndLinks; +} + +void ImageMapsList::ImageMap::add (core::Shape *shape, int link) { + ShapeAndLink *shapeAndLink = new ShapeAndLink (); + shapeAndLink->shape = shape; + shapeAndLink->link = link; + shapesAndLinks->append (shapeAndLink); +} + +int ImageMapsList::ImageMap::link (int x, int y) { + container::typed::Iterator <ShapeAndLink> it; + int link = -1; + + for (it = shapesAndLinks->iterator (); it.hasNext (); ) { + ShapeAndLink *shapeAndLink = it.getNext (); + + if (shapeAndLink->shape->isPointWithin (x, y)) { + link = shapeAndLink->link; + break; + } + } + + return link; +} + ImageMapsList::ImageMapsList () { + imageMaps = new container::typed::HashTable <object::Object, ImageMap> + (true, true); + currentMap = NULL; }
ImageMapsList::~ImageMapsList () { + delete imageMaps; }
/** @@ -38,20 +75,34 @@ ImageMapsList::~ImageMapsList () * * This has to be called before dw::ImageMapsList::addShapeToCurrentMap. * "key" is owned by the image map list, so a copy should be passed, when - * nessary. + * necessary. */ void ImageMapsList::startNewMap (object::Object *key) { + currentMap = new ImageMap (); + imageMaps->put (key, currentMap); }
/** * \brief Add a shape to the current map- * * "shape" is owned by the image map list, so a copy should be passed, when - * nessary. + * necessary. */ void ImageMapsList::addShapeToCurrentMap (core::Shape *shape, int link) { + currentMap->add (shape, link); +} + +int ImageMapsList::link (object::Object *key, int x, int y) +{ + int link = -1; + ImageMap *map = imageMaps->get (key); + + if (map) + link = map->link (x, y); + + return link; }
// ---------------------------------------------------------------------- @@ -65,6 +116,9 @@ Image::Image(const char *altText) altTextWidth = -1; // not yet calculated buffer = NULL; clicking = false; + currLink = -1; + mapList = NULL; + mapKey = NULL; }
Image::~Image() @@ -139,10 +193,11 @@ void Image::sizeAllocateImpl (core::Allo
void Image::enterNotifyImpl (core::EventCrossing *event) { - int link = getStyle()->x_link; + // BUG: this is wrong for image maps, but the cursor position is unknown. + currLink = getStyle()->x_link;
- if (link != -1) { - (void) emitLinkEnter (link, -1, -1, -1); + if (currLink != -1) { + (void) emitLinkEnter (currLink, -1, -1, -1); } }
@@ -150,18 +205,36 @@ void Image::leaveNotifyImpl (core::Event { clicking = false;
- if (getStyle()->x_link != -1) { + if (currLink != -1) { + currLink = -1; (void) emitLinkEnter (-1, -1, -1, -1); } }
+bool Image::motionNotifyImpl (core::EventMotion *event) +{ + if (mapList) { + int newLink = mapList->link (mapKey, event->xWidget, event->yWidget); + if (newLink != currLink) { + currLink = newLink; + clicking = false; + setCursor(newLink == -1 ? core::style::CURSOR_DEFAULT : + core::style::CURSOR_POINTER); + (void) emitLinkEnter (newLink, -1, -1, -1); + } + } + return true; +} + bool Image::buttonPressImpl (core::EventButton *event) { bool ret = false; + currLink = mapList ? mapList->link (mapKey, event->xWidget, event->yWidget): + getStyle()->x_link; if (event->button == 3){ - (void)emitLinkPress(getStyle()->x_link, getStyle()->x_img, -1,-1,event); + (void)emitLinkPress(currLink, getStyle()->x_img, -1,-1,event); ret = true; - } else if (event->button == 1 || getStyle()->x_link != -1){ + } else if (event->button == 1 || currLink != -1){ clicking = true; ret = true; } @@ -170,9 +243,11 @@ bool Image::buttonPressImpl (core::Event
bool Image::buttonReleaseImpl (core::EventButton *event) { + currLink = mapList ? mapList->link (mapKey, event->xWidget, event->yWidget): + getStyle()->x_link; if (clicking) { clicking = false; - emitLinkClick (getStyle()->x_link, getStyle()->x_img, -1, -1, event); + emitLinkClick (currLink, getStyle()->x_img, -1, -1, event); return true; } return false; @@ -290,8 +365,10 @@ void Image::setIsMap () * is owned by the image, if it is used by the caller afterwards, a copy * should be passed. */ -void setUseMap (ImageMapsList *list, object::Object *key) +void Image::setUseMap (ImageMapsList *list, object::Object *key) { + mapList = list; + mapKey = key; }
} // namespace dw diff -pur dw2/dw/image.hh dw2-cur/dw/image.hh --- dw2/dw/image.hh 2008-02-08 18:06:56.000000000 +0000 +++ dw2-cur/dw/image.hh 2008-04-21 23:39:03.000000000 +0000 @@ -22,12 +22,36 @@ namespace dw { */ class ImageMapsList { +private: + class ImageMap: public object::Object { + private: + class ShapeAndLink: public object::Object { + public: + core::Shape *shape; + int link; + + ~ShapeAndLink () { if (shape) delete shape; }; + }; + + container::typed::List <ShapeAndLink> *shapesAndLinks; + public: + ImageMap (); + ~ImageMap (); + + void add (core::Shape *shape, int link); + int link (int x, int y); + }; + + container::typed::HashTable <object::Object, ImageMap> *imageMaps; + ImageMap *currentMap; + public: ImageMapsList (); ~ImageMapsList ();
void startNewMap (object::Object *key); void addShapeToCurrentMap (core::Shape *shape, int link); + int link (object::Object *key, int x, int y); };
/** @@ -92,6 +116,9 @@ private: core::Imgbuf *buffer; int altTextWidth; bool clicking; + int currLink; + ImageMapsList *mapList; + Object *mapKey;
protected: void sizeRequestImpl (core::Requisition *requisition); @@ -103,7 +130,7 @@ protected: bool buttonReleaseImpl (core::EventButton *event); void enterNotifyImpl (core::EventCrossing *event); void leaveNotifyImpl (core::EventCrossing *event); - //bool motionNotifyImpl (core::EventMotion *event); + bool motionNotifyImpl (core::EventMotion *event);
//core::Iterator *iterator (Content::Type mask, bool atEnd);
--- dillo2/src/html.cc 2008-04-17 22:18:33.000000000 +0000 +++ dillo2-cur/src/html.cc 2008-04-22 04:39:08.000000000 +0000 @@ -323,7 +323,7 @@ public: //BUG: for now everything is pu misc::SimpleVector<DilloHtmlForm> *forms; misc::SimpleVector<DilloUrl*> *links; misc::SimpleVector<DilloLinkImage*> *images; - //DwImageMapList maps; + ImageMapsList maps;
int32_t link_color; int32_t visited_color; @@ -2905,7 +2905,6 @@ static void Html_tag_open_img(DilloHtml if (load_now) Html_load_image(html->bw, url, Image);
-#if 0 /* Image maps */ if (Html_get_attr(html, tag, tagsize, "ismap")) { /* BUG: if several ISMAP images follow each other without @@ -2914,17 +2913,17 @@ static void Html_tag_open_img(DilloHtml // a_Dw_image_set_ismap (Image->dw); _MSG(" Html_tag_open_img: server-side map (ISMAP)\n"); } else if (S_TOP(html)->style->x_link != -1 && - usemap_url == NULL) + usemap_url == NULL) { /* For simple links, we have to suppress the "image_pressed" signal. * This is overridden for USEMAP images. */ // a_Dw_widget_set_button_sensitive (IM2DW(Image->dw), FALSE); + }
if (usemap_url) { -// a_Dw_image_set_usemap (Image->dw, &html->maps, usemap_url); + ((::dw::Image*)Image->dw)->setUseMap(&html->maps, + new ::object::String(usemap_url->url_string->str)); a_Url_free (usemap_url); } -#endif - html->connectSignals((Widget*)Image->dw); }
@@ -2943,7 +2942,7 @@ static void Html_tag_open_map(DilloHtml if ((attrbuf = Html_get_attr(html, tag, tagsize, "name"))) { hash_name = dStrconcat("#", attrbuf, NULL); url = Html_url_new(html, hash_name, NULL, 0, 0, 0, 0); - //a_Dw_image_map_list_add_map (&html->maps, url); + html->maps.startNewMap(new ::object::String(url->url_string->str)); a_Url_free (url); dFree(hash_name); } @@ -2961,56 +2960,111 @@ static void Html_tag_close_map(DilloHtml }
/* + * Read coords in a string, returning a vector of ints. + */ +static +misc::SimpleVector<int> *Html_read_coords(DilloHtml *html, const char *str) +{ + int i, coord; + const char *tail = str; + char *newtail = NULL; + misc::SimpleVector<int> *coords = new misc::SimpleVector<int> (4); + + i = 0; + while (1) { + coord = strtol(tail, &newtail, 10); + if (coord == 0 && newtail == tail) + break; + coords->increase(); + coords->set(coords->size() - 1, coord); + while (isspace(*newtail)) + newtail++; + if (!*newtail) + break; + if (*newtail != ',') { + MSG_HTML("usemap coords MUST be separated by commas.\n"); + } + tail = newtail + 1; + } + + return coords; +} + +/* * <AREA> */ static void Html_tag_open_area(DilloHtml *html, const char *tag, int tagsize) { -// // AL -// /* todo: point must be a dynamic array */ -// GdkPoint point[1024]; -// DilloUrl* url; -// const char *attrbuf; -// int type = DW_IMAGE_MAP_SHAPE_RECT; -// int nbpoints, link = -1; -// -// if ((attrbuf = Html_get_attr(html, tag, tagsize, "shape"))) { -// if (dStrcasecmp(attrbuf, "rect") == 0) -// type = DW_IMAGE_MAP_SHAPE_RECT; -// else if (dStrcasecmp(attrbuf, "circle") == 0) -// type = DW_IMAGE_MAP_SHAPE_CIRCLE; -// else if (dStrncasecmp(attrbuf, "poly", 4) == 0) -// type = DW_IMAGE_MAP_SHAPE_POLY; -// else -// type = DW_IMAGE_MAP_SHAPE_RECT; -// } -// /* todo: add support for coords in % */ -// if ((attrbuf = Html_get_attr(html, tag, tagsize, "coords"))) { -// /* Is this a valid poly ? -// * rect = x0,y0,x1,y1 => 2 -// * circle = x,y,r => 2 -// * poly = x0,y0,x1,y1,x2,y2 minimum => 3 */ -// nbpoints = Html_read_coords(html, attrbuf, point); -// } else -// return; -// -// if (Html_get_attr(html, tag, tagsize, "nohref")) { -// link = -1; -// _MSG("nohref"); -// } -// -// if ((attrbuf = Html_get_attr(html, tag, tagsize, "href"))) { -// url = Html_url_new(html, attrbuf, NULL, 0, 0, 0, 0); -// dReturn_if_fail ( url != NULL ); -// if ((attrbuf = Html_get_attr(html, tag, tagsize, "alt"))) -// a_Url_set_alt(url, attrbuf); -// -// link = Html_set_new_link(html, &url); -// } -// -// a_Dw_image_map_list_add_shape(&html->maps, type, link, -// point, nbpoints); -} + misc::SimpleVector<int> *coords; + DilloUrl* url; + const char *attrbuf; + int link = -1; + Shape *shape = NULL; + + if (!(html->InFlags & IN_MAP)) { + MSG_HTML("<area> element not inside <map>\n"); + return; + } + + /* todo: add support for coords in % */ + if ((attrbuf = Html_get_attr(html, tag, tagsize, "coords"))) { + coords = Html_read_coords(html, attrbuf); + } else + return; + + attrbuf = Html_get_attr(html, tag, tagsize, "shape");
+ if (!attrbuf || !*attrbuf || !dStrcasecmp(attrbuf, "rect")) { + /* the default shape is a rectangle */ + if (coords->size() != 4) + MSG_HTML("<area> rectangle must have four coordinate values\n"); + if (coords->size() >= 4) + shape = new Rectangle(coords->get(0), + coords->get(1), + coords->get(2) - coords->get(0), + coords->get(3) - coords->get(1)); + } else if (dStrcasecmp(attrbuf, "default") == 0) { + /* "Specifies the entire region." "default" is not the default shape. */ + MSG("<area> shape=default not implemented.\n"); + } else if (dStrcasecmp(attrbuf, "circle") == 0) { + if (coords->size() != 3) + MSG_HTML("<area> circle must have three coordinate values\n"); + if (coords->size() >= 3) + shape = new Circle(coords->get(0), coords->get(1), coords->get(2)); + } else if (dStrncasecmp(attrbuf, "poly", 4) == 0) { + Polygon *poly; + int i; + if (coords->size() % 2) + MSG_HTML("<area> polygon with odd number of coordinates\n"); + shape = poly = new Polygon(); + for (i = 0; i < (coords->size() / 2); i++) + poly->addPoint(coords->get(2*i), coords->get(2*i + 1)); + if (i) { + /* be sure to close it */ + poly->addPoint(coords->get(0), coords->get(1)); + } + } else { + MSG_HTML("<area> unknown shape: \"%s\"\n", attrbuf); + } + + if (shape) { + if (Html_get_attr(html, tag, tagsize, "nohref")) { + link = -1; + _MSG("nohref"); + } + if ((attrbuf = Html_get_attr(html, tag, tagsize, "href"))) { + url = Html_url_new(html, attrbuf, NULL, 0, 0, 0, 0); + dReturn_if_fail ( url != NULL ); + if ((attrbuf = Html_get_attr(html, tag, tagsize, "alt"))) + a_Url_set_alt(url, attrbuf); + + link = Html_set_new_link(html, &url); + } + html->maps.addShapeToCurrentMap(shape, link); + } + if (coords) + delete(coords); +}
/* * Test and extract the link from a javascript instruction. @@ -3064,7 +3118,8 @@ static void Html_tag_open_a(DilloHtml *h const char *attrbuf;
/* todo: add support for MAP with A HREF */ - Html_tag_open_area(html, tag, tagsize); + if (html->InFlags & IN_MAP) + Html_tag_open_area(html, tag, tagsize);
if ((attrbuf = Html_get_attr(html, tag, tagsize, "href"))) { /* if it's a javascript link, extract the reference. */
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
Johannes wrote:
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
What about deleting coords earlier? I think they are no longer needed once the shape has been constructed.
That's true. I had just reached a point where the code was already tested and I didn't want to mess with anything for fear of introducing some error at the last moment ("this doesn't work at all! did you even compile it?" :))
Regarding your comment in Image::enterNotifyImpl(). I noticed that too, but enterNotifyImpl() simply notifies about the enter event, so no coordinates are needed. Don't you think that implementing map aware Image::motionNotifyImpl() is enough?
You're probably right. I wasn't sure whether it would get a motionNotify when it first entered the image. Speaking of motionNotify, the other day I was looking into getting the link in the status bar to change when scrolling. I'd gotten as far as figuring out that maybe *checks notes* Layout::scrollPosChanged could call Layout::motionNotify, but then I got stuck because I didn't know where to get current cursor coordinates from.
On Tue, Apr 22, 2008 at 02:05:43PM +0000, corvid wrote:
Johannes wrote:
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
What about deleting coords earlier? I think they are no longer needed once the shape has been constructed.
That's true. I had just reached a point where the code was already tested and I didn't want to mess with anything for fear of introducing some error at the last moment ("this doesn't work at all! did you even compile it?" :))
Regarding your comment in Image::enterNotifyImpl(). I noticed that too, but enterNotifyImpl() simply notifies about the enter event, so no coordinates are needed. Don't you think that implementing map aware Image::motionNotifyImpl() is enough?
You're probably right. I wasn't sure whether it would get a motionNotify when it first entered the image.
Speaking of motionNotify, the other day I was looking into getting the link in the status bar to change when scrolling. I'd gotten as far as figuring out that maybe *checks notes* Layout::scrollPosChanged could call Layout::motionNotify, but then I got stuck because I didn't know where to get current cursor coordinates from.
In fltk one can call get_mouse(int &x, int &y). But I'm not sure how to wrap this properly. Perhaps adding a similar method to Platform? What about different views, can they all have separate pointer devices? Just checked dillo1. It handles at least the scrolling case properly.
Johannes wrote:
On Tue, Apr 22, 2008 at 02:05:43PM +0000, corvid wrote:
Speaking of motionNotify, the other day I was looking into getting the link in the status bar to change when scrolling. I'd gotten as far as figuring out that maybe *checks notes* Layout::scrollPosChanged could call Layout::motionNotify, but then I got stuck because I didn't know where to get current cursor coordinates from.
In fltk one can call get_mouse(int &x, int &y). But I'm not sure how to wrap this properly. Perhaps adding a similar method to Platform? What about different views, can they all have separate pointer devices? Just checked dillo1. It handles at least the scrolling case properly.
Ah, indeed. It turns out that old dillo sets viewport->mouse_[xy] in Dw_gtk_viewport_motion_notify() and then has a static void Dw_gtk_viewport_adj_changed (GtkAdjustment *adj, GtkDwViewport *viewport) { Dw_gtk_viewport_mouse_event (GTK_WIDGET (viewport), viewport->mouse_x, viewport->mouse_y, NULL); } Attached is a patch similar to this. It works for scrolling and when I close a window that had been obscuring the viewport (it gets ENTER and FOCUS. I chose ENTER). It does not work when I page around with my window manager because the only event the viewport handler sees is KEYUP, and I didn't like the idea of using KEYUP for this.
On Wed, Apr 23, 2008 at 06:08:27AM +0000, corvid wrote:
Johannes wrote:
On Tue, Apr 22, 2008 at 02:05:43PM +0000, corvid wrote:
Speaking of motionNotify, the other day I was looking into getting the link in the status bar to change when scrolling. I'd gotten as far as figuring out that maybe *checks notes* Layout::scrollPosChanged could call Layout::motionNotify, but then I got stuck because I didn't know where to get current cursor coordinates from.
In fltk one can call get_mouse(int &x, int &y). But I'm not sure how to wrap this properly. Perhaps adding a similar method to Platform? What about different views, can they all have separate pointer devices? Just checked dillo1. It handles at least the scrolling case properly.
Ah, indeed. It turns out that old dillo sets viewport->mouse_[xy] in Dw_gtk_viewport_motion_notify() and then has a static void Dw_gtk_viewport_adj_changed (GtkAdjustment *adj, GtkDwViewport *viewport) { Dw_gtk_viewport_mouse_event (GTK_WIDGET (viewport), viewport->mouse_x, viewport->mouse_y, NULL); }
Attached is a patch similar to this.
It works for scrolling and when I close a window that had been obscuring the viewport (it gets ENTER and FOCUS. I chose ENTER). It does not work when I page around with my window manager because the only event the viewport handler sees is KEYUP, and I didn't like the idea of using KEYUP for this.
Nice! But there is still other cases, like going back with <Backspace> such that the cursor ends up over a link. Or incremental rendering such that the cursor ends up over a link ( (to reproduce go to a slow page, move the cursor over a link and press <Ctrl>-r to reload). I'm not sure how to handle these cases where the movement is initiated by the layout rather than the view. I'd like to have a general mechanism like Layout::canvasMousePosChanged () that can be called in all these cases. Johannes
Johannes wrote:
On Wed, Apr 23, 2008 at 06:08:27AM +0000, corvid wrote:
Johannes wrote:
On Tue, Apr 22, 2008 at 02:05:43PM +0000, corvid wrote:
Speaking of motionNotify, the other day I was looking into getting the link in the status bar to change when scrolling. I'd gotten as far as figuring out that maybe *checks notes* Layout::scrollPosChanged could call Layout::motionNotify, but then I got stuck because I didn't know where to get current cursor coordinates from.
In fltk one can call get_mouse(int &x, int &y). But I'm not sure how to wrap this properly. Perhaps adding a similar method to Platform? What about different views, can they all have separate pointer devices? Just checked dillo1. It handles at least the scrolling case properly.
Ah, indeed. It turns out that old dillo sets viewport->mouse_[xy] in Dw_gtk_viewport_motion_notify() and then has a static void Dw_gtk_viewport_adj_changed (GtkAdjustment *adj, GtkDwViewport *viewport) { Dw_gtk_viewport_mouse_event (GTK_WIDGET (viewport), viewport->mouse_x, viewport->mouse_y, NULL); }
Attached is a patch similar to this.
It works for scrolling and when I close a window that had been obscuring the viewport (it gets ENTER and FOCUS. I chose ENTER). It does not work when I page around with my window manager because the only event the viewport handler sees is KEYUP, and I didn't like the idea of using KEYUP for this.
Nice! But there is still other cases, like going back with <Backspace> such that the cursor ends up over a link. Or incremental rendering such that the cursor ends up over a link ( (to reproduce go to a slow page, move the cursor over a link and press <Ctrl>-r to reload).
I'm not sure how to handle these cases where the movement is initiated by the layout rather than the view.
I ignored it at the time because I figured it was probably hard to deal with. It also incorrectly shows links when text searching causes scrolling. I have this case fixed in my copy now. And it could be made to deal with moving into scrollbars, although that's probably for a separate patch at some point (with cursor resetting as well).
I'd like to have a general mechanism like Layout::canvasMousePosChanged () that can be called in all these cases.
I'll at least try to figure out something...
On Sat, Apr 26, 2008 at 07:27:18PM +0000, corvid wrote:
Johannes wrote:
What about deleting coords earlier? I think they are no longer needed once the shape has been constructed.
attached.
Committed. -- Cheers Jorge.-
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dw: I added motionNotifyImpl() and currLink
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
Committed this patch and also scroll_motionNotify.dw2. Shape image-mapped links work so far. Coordinates are not yet being sent. If I missed something, please repost the patch. (I assume this is a work in progress). -- Cheers Jorge.-
Jorge wrote:
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dw: I added motionNotifyImpl() and currLink
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
Committed this patch and also scroll_motionNotify.dw2.
Shape image-mapped links work so far. Coordinates are not yet being sent. If I missed something, please repost the patch. (I assume this is a work in progress).
What's not working exactly? We didn't do ISMAP yet, if that's what you're saying...
On Sat, Apr 26, 2008 at 05:26:58PM +0000, corvid wrote:
Jorge wrote:
On Tue, Apr 22, 2008 at 04:50:32AM +0000, corvid wrote:
dw: I added motionNotifyImpl() and currLink
dillo: - I imagine the setUseMap() in open_img() is probably supposed to be routed through DilloImage. - Html_read_coords() was borrowed from 0.8.6 and modified a fair amount. For one thing, the old code couldn't handle whitespace preceding a comma. - I didn't really like that dReturn_if_fail so far down in open_area() since coords is dynamically allocated now, but I left it there.
Committed this patch and also scroll_motionNotify.dw2.
Shape image-mapped links work so far. Coordinates are not yet being sent. If I missed something, please repost the patch. (I assume this is a work in progress).
What's not working exactly? We didn't do ISMAP yet, if that's what you're saying...
Yes, ISMAP. -- Cheers Jorge.-
/* BUG: if several ISMAP images follow each other without * being separated with a word, only the first one is ISMAPed */
PS I left this old comment in, but if I make a file containing a bunch of ismap images in a row, they certainly _seem_ ismapped. I click on them and dillo tries to go to http://[wherever]?x,y.
On Sun, Apr 27, 2008 at 06:36:31PM +0000, corvid wrote:
/* BUG: if several ISMAP images follow each other without * being separated with a word, only the first one is ISMAPed */
PS I left this old comment in, but if I make a file containing a bunch of ismap images in a row, they certainly _seem_ ismapped. I click on them and dillo tries to go to http://[wherever]?x,y.
Yes, comment was deleted. -- Cheers Jorge.-
On Sun, Apr 27, 2008 at 06:22:48PM +0000, corvid wrote:
Jorge wrote:
Yes, ISMAP.
All right, here you go. It turned out to be a lot of work :)
Committed. It'd be good to hook emitMotionNotify() to have URL feedback for ISMAP in the status box. -- Cheers Jorge.-
participants (3)
-
corvid@lavabit.com
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de