summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-17 07:24:23 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-17 07:24:23 +0300
commit115602cf34dfb2f151846673468a41f16712eb49 (patch)
treed6f4330d55799fdb18df2bcd5d96e2c04c8d51f5 /src/ui/documentwidget.c
parenta48aa018640b2d631f318585da23e4ec7f8e8bdc (diff)
DocumentWidget: Permanent images
A dynamically generated page showing nothing but an image should not be treated the same way as an inline image. I.e., disallow hiding the image on an image page.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index ab8af9b8..84ad1139 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -363,6 +363,10 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) {
363 if (isHover_Widget(w) && !contains_Widget(constAs_Widget(d->scroll), mouse)) { 363 if (isHover_Widget(w) && !contains_Widget(constAs_Widget(d->scroll), mouse)) {
364 setCursor_Window(get_Window(), 364 setCursor_Window(get_Window(),
365 d->hoverLink ? SDL_SYSTEM_CURSOR_HAND : SDL_SYSTEM_CURSOR_IBEAM); 365 d->hoverLink ? SDL_SYSTEM_CURSOR_HAND : SDL_SYSTEM_CURSOR_IBEAM);
366 if (d->hoverLink &&
367 linkFlags_GmDocument(d->doc, d->hoverLink->linkId) & permanent_GmLinkFlag) {
368 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); /* not dismissable */
369 }
366 } 370 }
367} 371}
368 372
@@ -575,7 +579,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse
575 } 579 }
576 format_String( 580 format_String(
577 &str, "=> %s %s\n", cstr_String(d->mod.url), imageTitle); 581 &str, "=> %s %s\n", cstr_String(d->mod.url), imageTitle);
578 setImage_GmDocument(d->doc, 1, mimeStr, &response->body); 582 setImage_GmDocument(d->doc, 1, mimeStr, &response->body, iFalse /* it's fixed */);
579 } 583 }
580 else { 584 else {
581 clear_String(&str); 585 clear_String(&str);
@@ -974,7 +978,7 @@ static iBool handleMediaCommand_DocumentWidget_(iDocumentWidget *d, const char *
974// cstr_String(meta_GmRequest(req->req))); 978// cstr_String(meta_GmRequest(req->req)));
975 if (startsWith_String(meta_GmRequest(req->req), "image/")) { 979 if (startsWith_String(meta_GmRequest(req->req), "image/")) {
976 setImage_GmDocument(d->doc, req->linkId, meta_GmRequest(req->req), 980 setImage_GmDocument(d->doc, req->linkId, meta_GmRequest(req->req),
977 body_GmRequest(req->req)); 981 body_GmRequest(req->req), iTrue);
978 updateVisible_DocumentWidget_(d); 982 updateVisible_DocumentWidget_(d);
979 invalidate_DocumentWidget_(d); 983 invalidate_DocumentWidget_(d);
980 refresh_Widget(as_Widget(d)); 984 refresh_Widget(as_Widget(d));
@@ -1489,10 +1493,16 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1489 iAssert(linkId); 1493 iAssert(linkId);
1490 /* Media links are opened inline by default. */ 1494 /* Media links are opened inline by default. */
1491 if (isMediaLink_GmDocument(d->doc, linkId)) { 1495 if (isMediaLink_GmDocument(d->doc, linkId)) {
1496 const int linkFlags = linkFlags_GmDocument(d->doc, linkId);
1497 if (linkFlags & content_GmLinkFlag && linkFlags & permanent_GmLinkFlag) {
1498 /* We have the image and it cannot be dismissed, so nothing
1499 further to do. */
1500 return iTrue;
1501 }
1492 if (!requestMedia_DocumentWidget_(d, linkId)) { 1502 if (!requestMedia_DocumentWidget_(d, linkId)) {
1493 if (linkFlags_GmDocument(d->doc, linkId) & content_GmLinkFlag) { 1503 if (linkFlags & content_GmLinkFlag) {
1494 /* Dismiss shown content on click. */ 1504 /* Dismiss shown content on click. */
1495 setImage_GmDocument(d->doc, linkId, NULL, NULL); 1505 setImage_GmDocument(d->doc, linkId, NULL, NULL, iTrue);
1496 d->hoverLink = NULL; 1506 d->hoverLink = NULL;
1497 scroll_DocumentWidget_(d, 0); 1507 scroll_DocumentWidget_(d, 0);
1498 updateVisible_DocumentWidget_(d); 1508 updateVisible_DocumentWidget_(d);
@@ -1505,7 +1515,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1505 iMediaRequest *req = findMediaRequest_DocumentWidget_(d, linkId); 1515 iMediaRequest *req = findMediaRequest_DocumentWidget_(d, linkId);
1506 if (req) { 1516 if (req) {
1507 setImage_GmDocument(d->doc, linkId, meta_GmRequest(req->req), 1517 setImage_GmDocument(d->doc, linkId, meta_GmRequest(req->req),
1508 body_GmRequest(req->req)); 1518 body_GmRequest(req->req), iTrue);
1509 updateVisible_DocumentWidget_(d); 1519 updateVisible_DocumentWidget_(d);
1510 invalidate_DocumentWidget_(d); 1520 invalidate_DocumentWidget_(d);
1511 refresh_Widget(w); 1521 refresh_Widget(w);