[EGIT] [legacy/imlib2] master 03/03: image.c: Use the LOAD_... macros to check loader return values

2021-09-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=5512f0a2e3ce9356a7275f17b2898c8e6f983c70

commit 5512f0a2e3ce9356a7275f17b2898c8e6f983c70
Author: Kim Woelders 
Date:   Wed Sep 15 19:17:50 2021 +0200

image.c: Use the LOAD_... macros to check loader return values
---
 src/lib/image.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/lib/image.c b/src/lib/image.c
index 0b962f5..2e2a94c 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -527,10 +527,10 @@ __imlib_LoadImageWrapper(const ImlibLoader * l, 
ImlibImage * im, int load_data)
  }
else
  {
-return 0;
+return LOAD_FAIL;
  }
 
-   if (rc == 0)
+   if (rc <= LOAD_FAIL)
  {
 /* Failed - clean up */
 if (im->w != 0 || im->h != 0)
@@ -711,7 +711,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
 
__imlib_LoadAllLoaders();
 
-   loader_ret = 0;
+   loader_ret = LOAD_FAIL;
 
/* take a guess by extension on the best loader to use */
best_loader = __imlib_FindBestLoaderForFile(im->real_file, 0);
@@ -719,7 +719,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
if (best_loader)
   loader_ret = __imlib_LoadImageWrapper(best_loader, im, immediate_load);
 
-   if (loader_ret > 0)
+   if (loader_ret > LOAD_FAIL)
  {
 im->loader = best_loader;
  }
@@ -738,7 +738,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
  fflush(im->fp);
  rewind(im->fp);
  loader_ret = __imlib_LoadImageWrapper(l, im, immediate_load);
- if (loader_ret > 0)
+ if (loader_ret > LOAD_FAIL)
 break;
   }
 
@@ -765,7 +765,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
 
/* all loaders have been tried and they all failed. free the skeleton */
/* image struct we had and return NULL */
-   if (loader_ret <= 0)
+   if (loader_ret <= LOAD_FAIL)
  {
 /* if the caller wants an error return */
 if (er)
@@ -777,7 +777,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
/* the load succeeded - make sure the image is referenced then add */
/* it to our cache if dont_cache isn't set */
im->references = 1;
-   if (loader_ret == 2)
+   if (loader_ret == LOAD_BREAK)
   dont_cache = 1;
if (!dont_cache)
   __imlib_AddImageToCache(im);
@@ -791,7 +791,7 @@ int
 __imlib_LoadImageData(ImlibImage * im)
 {
if (!im->data && im->loader)
-  if (__imlib_LoadImageWrapper(im->loader, im, 1) == 0)
+  if (__imlib_LoadImageWrapper(im->loader, im, 1) <= LOAD_FAIL)
  return 1;  /* Load failed */
return im->data == NULL;
 }

-- 




[EGIT] [legacy/imlib2] master 01/03: Add script to generate Changelog

2021-09-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=fd2c2ef004329ae22c268c0bcf90723ba19ed56e

commit fd2c2ef004329ae22c268c0bcf90723ba19ed56e
Author: Kim Woelders 
Date:   Thu Sep 16 10:52:13 2021 +0200

Add script to generate Changelog
---
 misc/mkchangelog.sh | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/misc/mkchangelog.sh b/misc/mkchangelog.sh
new file mode 100755
index 000..cba222d
--- /dev/null
+++ b/misc/mkchangelog.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#GLO="git log --format=-%x20%s"
+#GLO="git shortlog -w76,4,6"
+GLO="git shortlog"
+
+VT=`git tag --sort=-version:refname -l`
+VH=""
+if [ "$1" != "" ]; then VH="HEAD"; fi
+V2=""
+for V1 in $1 $VT
+do
+if [ "$V2" != "" ]; then
+if [ "$VH" = "HEAD" ]; then
+VD="$VH"
+else
+VD="$V2"
+VH="$V2"
+fi
+D=$(git show -s --format=%cs $VD^{commit})
+printf "%s - %s\n---\n" "$V2" "$D"
+$GLO $V1..$VH
+VH=""
+fi
+V2="$V1"
+done
+
+D=$(git show -s --format=%cs $VD^{commit})
+printf "\n%s - %s (from dawn of 
time)\n---\n" "$V2" "$D"
+$GLO $V2

-- 




[EGIT] [legacy/imlib2] master 01/02: Revert "GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix"

2021-09-15 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=b71221ce768610418fa58e7bad3d1b34537a4c87

commit b71221ce768610418fa58e7bad3d1b34537a4c87
Author: Kim Woelders 
Date:   Wed Sep 15 19:19:28 2021 +0200

Revert "GIF, TIFF, WEBP loaders: Fix loading if filename does not have 
usual suffix"

This reverts commit 43f82f3bc80324282ec22cb6b7c0e0b3ca2b663f.
---
 src/modules/loaders/loader_gif.c  | 1 -
 src/modules/loaders/loader_tiff.c | 1 -
 src/modules/loaders/loader_webp.c | 2 --
 3 files changed, 4 deletions(-)

diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c
index fbac9cc..cc8baa7 100644
--- a/src/modules/loaders/loader_gif.c
+++ b/src/modules/loaders/loader_gif.c
@@ -18,7 +18,6 @@ load2(ImlibImage * im, int load_data)
DATA32  colormap[256];
 
fd = dup(fileno(im->fp));
-   lseek(fd, 0, SEEK_SET);
 
 #if GIFLIB_MAJOR >= 5
gif = DGifOpenFileHandle(fd, NULL);
diff --git a/src/modules/loaders/loader_tiff.c 
b/src/modules/loaders/loader_tiff.c
index 2cbe6e2..2b76a4c 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -247,7 +247,6 @@ load2(ImlibImage * im, int load_data)
rgba_image.image = NULL;
 
fd = fileno(im->fp);
-   lseek(fd, 0, SEEK_SET);
if (read(fd, _number, sizeof(uint16_t)) != sizeof(uint16_t))
   goto quit;
 
diff --git a/src/modules/loaders/loader_webp.c 
b/src/modules/loaders/loader_webp.c
index 49f8136..de0c13b 100644
--- a/src/modules/loaders/loader_webp.c
+++ b/src/modules/loaders/loader_webp.c
@@ -53,8 +53,6 @@ load2(ImlibImage * im, int load_data)
if (!encoded_data)
   goto quit;
 
-   lseek(fd, 0, SEEK_SET);
-
/* Check signature */
size = 12;
if (read(fd, encoded_data, size) != (long)size)

-- 




[EGIT] [legacy/imlib2] master 02/02: GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix - take 2

2021-09-15 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=adda6d7b9c38eb2fb467f72801ad9856acbd9f02

commit adda6d7b9c38eb2fb467f72801ad9856acbd9f02
Author: Kim Woelders 
Date:   Wed Sep 15 19:24:21 2021 +0200

GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix 
- take 2

Better solution from from Daniel Friesel  / Lars
Stoltenow.
---
 src/lib/image.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lib/image.c b/src/lib/image.c
index c34e48c..0b962f5 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -735,6 +735,7 @@ __imlib_LoadImage(const char *file, FILE * fp, 
ImlibProgressFunction progress,
  /* if its not the best loader that already failed - try load */
  if (l == best_loader)
 continue;
+ fflush(im->fp);
  rewind(im->fp);
  loader_ret = __imlib_LoadImageWrapper(l, im, immediate_load);
  if (loader_ret > 0)

-- 




[EGIT] [legacy/imlib2] master 01/04: WEBP loader: Remove forgotten debug printout

2021-09-13 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=c018a7687c5a83f8464b5ed195583758f2519ed2

commit c018a7687c5a83f8464b5ed195583758f2519ed2
Author: Kim Woelders 
Date:   Sun Sep 12 17:23:02 2021 +0200

WEBP loader: Remove forgotten debug printout
---
 src/modules/loaders/loader_webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/modules/loaders/loader_webp.c 
b/src/modules/loaders/loader_webp.c
index 0cf9ec8..03f80cf 100644
--- a/src/modules/loaders/loader_webp.c
+++ b/src/modules/loaders/loader_webp.c
@@ -126,8 +126,6 @@ save(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity)
uint8_t*encoded_data;
size_t  encoded_size;
 
-   printf("FOO\n");
-
f = fopen(im->real_file, "wb");
if (!f)
   return LOAD_FAIL;

-- 




[EGIT] [legacy/imlib2] master 04/04: GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix

2021-09-13 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=43f82f3bc80324282ec22cb6b7c0e0b3ca2b663f

commit 43f82f3bc80324282ec22cb6b7c0e0b3ca2b663f
Author: Kim Woelders 
Date:   Sun Sep 12 07:04:36 2021 +0200

GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix

Patch from Daniel Friesel :

---
Fix .gif loader if filename does not end in .gif

Imlib2 is currently unable to load gif images if the filename does not end 
in
.gif. This appears to be caused by imlib2 not resetting the file descriptor
back to 0 after trying to open the image with its different loaders.

While imlib2 does call rewind(FILE* im->fp) before invoking each loader, 
this
does not guarantee that the underlying FD is seeked as well. However, the 
GIF
loader uses the FD directly, and therefore tries to read from the middle of 
the
file (unless it is the first loader). This patch adds an explicit seek in 
the
same fashion as implemented in the TIFF loader.

Patch and debugging credits go to Lars Stoltenow.
---

Also fix same issue in TIFF and WEBP loaders.
---
 src/modules/loaders/loader_gif.c  | 1 +
 src/modules/loaders/loader_tiff.c | 1 +
 src/modules/loaders/loader_webp.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c
index cc8baa7..fbac9cc 100644
--- a/src/modules/loaders/loader_gif.c
+++ b/src/modules/loaders/loader_gif.c
@@ -18,6 +18,7 @@ load2(ImlibImage * im, int load_data)
DATA32  colormap[256];
 
fd = dup(fileno(im->fp));
+   lseek(fd, 0, SEEK_SET);
 
 #if GIFLIB_MAJOR >= 5
gif = DGifOpenFileHandle(fd, NULL);
diff --git a/src/modules/loaders/loader_tiff.c 
b/src/modules/loaders/loader_tiff.c
index 2b76a4c..2cbe6e2 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -247,6 +247,7 @@ load2(ImlibImage * im, int load_data)
rgba_image.image = NULL;
 
fd = fileno(im->fp);
+   lseek(fd, 0, SEEK_SET);
if (read(fd, _number, sizeof(uint16_t)) != sizeof(uint16_t))
   goto quit;
 
diff --git a/src/modules/loaders/loader_webp.c 
b/src/modules/loaders/loader_webp.c
index de0c13b..49f8136 100644
--- a/src/modules/loaders/loader_webp.c
+++ b/src/modules/loaders/loader_webp.c
@@ -53,6 +53,8 @@ load2(ImlibImage * im, int load_data)
if (!encoded_data)
   goto quit;
 
+   lseek(fd, 0, SEEK_SET);
+
/* Check signature */
size = 12;
if (read(fd, encoded_data, size) != (long)size)

-- 




[EGIT] [legacy/imlib2] master 03/04: LBM loader: Fix potential out-of-bounds memory access

2021-09-13 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=b78a66195f5c569a154696673d085822a5a411b5

commit b78a66195f5c569a154696673d085822a5a411b5
Author: Kim Woelders 
Date:   Mon Sep 13 11:53:28 2021 +0200

LBM loader: Fix potential out-of-bounds memory access
---
 src/modules/loaders/loader_lbm.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/modules/loaders/loader_lbm.c b/src/modules/loaders/loader_lbm.c
index d8cd1bb..fdf9998 100644
--- a/src/modules/loaders/loader_lbm.c
+++ b/src/modules/loaders/loader_lbm.c
@@ -195,9 +195,12 @@ bodyrow(unsigned char *p, int z, ILBM * ilbm)
 
for (i = 0; i < z; i += w)
  {
-b = ilbm->body.data[ilbm->offset++];
-while (b == 0x80 && ilbm->offset < ilbm->body.size)
-   b = ilbm->body.data[ilbm->offset++];
+if (ilbm->offset < ilbm->body.size)
+  {
+ b = ilbm->body.data[ilbm->offset++];
+ while (b == 0x80 && ilbm->offset < ilbm->body.size)
+b = ilbm->body.data[ilbm->offset++];
+  }
 
 if (ilbm->offset >= ilbm->body.size)
   {

-- 




[EGIT] [legacy/imlib2] master 02/04: WEBP loader: Rename fd variable to be same as everywhere else

2021-09-13 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=dbeb622c7a3df21740206aa2ee442eb2569ee4be

commit dbeb622c7a3df21740206aa2ee442eb2569ee4be
Author: Kim Woelders 
Date:   Sun Sep 12 17:24:56 2021 +0200

WEBP loader: Rename fd variable to be same as everywhere else
---
 src/modules/loaders/loader_webp.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/modules/loaders/loader_webp.c 
b/src/modules/loaders/loader_webp.c
index 03f80cf..de0c13b 100644
--- a/src/modules/loaders/loader_webp.c
+++ b/src/modules/loaders/loader_webp.c
@@ -35,16 +35,16 @@ load2(ImlibImage * im, int load_data)
int rc;
uint8_t*encoded_data;
struct stat stats;
-   int encoded_fd;
+   int fd;
WebPBitstreamFeatures features;
VP8StatusCode   vp8return;
unsigned intsize;
 
-   encoded_fd = fileno(im->fp);
-   if (encoded_fd < 0)
+   fd = fileno(im->fp);
+   if (fd < 0)
   return LOAD_FAIL;
 
-   if (fstat(encoded_fd, ) < 0)
+   if (fstat(fd, ) < 0)
   return LOAD_FAIL;
 
rc = LOAD_FAIL;
@@ -55,7 +55,7 @@ load2(ImlibImage * im, int load_data)
 
/* Check signature */
size = 12;
-   if (read(encoded_fd, encoded_data, size) != (long)size)
+   if (read(fd, encoded_data, size) != (long)size)
   goto quit;
if (memcmp(encoded_data + 0, "RIFF", 4) != 0 ||
memcmp(encoded_data + 8, "WEBP", 4) != 0)
@@ -66,7 +66,7 @@ load2(ImlibImage * im, int load_data)
   goto quit;
 
size -= 12;
-   if (read(encoded_fd, encoded_data + 12, size) != (long)size)
+   if (read(fd, encoded_data + 12, size) != (long)size)
   goto quit;
 
if (WebPGetInfo(encoded_data, stats.st_size, >w, >h) == 0)

-- 




[EGIT] [e16/e16-epplets] master 06/10: Change E[v]snprintf -> [v]snprintf

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=87a3dbceac640b2352d1bbe1a46953e6bc387833

commit 87a3dbceac640b2352d1bbe1a46953e6bc387833
Author: Kim Woelders 
Date:   Tue Aug 31 07:38:38 2021 +0200

Change E[v]snprintf -> [v]snprintf
---
 api/epplet.c   | 78 +++---
 api/epplet.h.in|  3 --
 epplets/ConfigTestEpplet.c |  6 ++--
 epplets/E-Bandwidth.c  |  4 +--
 epplets/E-Biff.c   |  7 ++---
 epplets/E-Cpu.c|  6 ++--
 epplets/E-Disk.c   |  4 +--
 epplets/E-LoadMeter.c  |  6 ++--
 epplets/E-Magic.c  |  2 +-
 epplets/E-MemWatch.c   | 16 +-
 epplets/E-MoonClock.c  |  2 +-
 epplets/E-Mountbox.c   | 30 +-
 epplets/E-Net.c|  4 +--
 epplets/E-NetFlame.c   | 10 +++---
 epplets/E-OpenGL-Demo.c|  8 ++---
 epplets/E-SD.c |  8 ++---
 epplets/E-ScreenSave.c | 12 +++
 epplets/E-ScreenShoot.c| 46 +--
 epplets/E-Slides.c | 38 +++---
 epplets/E-Sys.c|  6 ++--
 epplets/E-Time.c   |  4 +--
 epplets/E-Toolbox.c| 66 +++
 epplets/E-UrlWatch.c   | 24 +++---
 epplets/E-Xss.c| 10 +++---
 24 files changed, 198 insertions(+), 202 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 91fdead..1c9eb35 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -486,7 +486,7 @@ Epplet_Init(const char *name, const char *version, const 
char *info,
/* set the client machine name */
if (!uname())
  {
-   Esnprintf(s, sizeof(s), "%s", ubuf.nodename);
+   snprintf(s, sizeof(s), "%s", ubuf.nodename);
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)s;
@@ -520,11 +520,11 @@ Epplet_Init(const char *name, const char *version, const 
char *info,
win_info = info;
xid_context = XUniqueContext();
CommsSetup();
-   Esnprintf(s, sizeof(s), "set clientname %s", win_name);
+   snprintf(s, sizeof(s), "set clientname %s", win_name);
ECommsSend(s);
-   Esnprintf(s, sizeof(s), "set version %s", win_version);
+   snprintf(s, sizeof(s), "set version %s", win_version);
ECommsSend(s);
-   Esnprintf(s, sizeof(s), "set info %s", win_info);
+   snprintf(s, sizeof(s), "set info %s", win_info);
ECommsSend(s);
ESYNC;
 
@@ -932,7 +932,7 @@ Epplet_cleanup(void)
if (conf_dir)
  {
/* remove lock file */
-   Esnprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, epplet_instance);
+   snprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, epplet_instance);
if (unlink(s) < 0)
  {
 Epplet_dialog_ok("Unable to remove lock file %s -- %s.\n",
@@ -970,7 +970,7 @@ Epplet_remember(void)
 {
chars[1024];
 
-   Esnprintf(s, sizeof(s), "wop %x snap all auto", (unsigned int)mainwin->win);
+   snprintf(s, sizeof(s), "wop %x snap all auto", (unsigned int)mainwin->win);
ECommsSend(s);
 }
 
@@ -979,7 +979,7 @@ Epplet_unremember(void)
 {
chars[1024];
 
-   Esnprintf(s, sizeof(s), "wop %x snap none", (unsigned int)mainwin->win);
+   snprintf(s, sizeof(s), "wop %x snap none", (unsigned int)mainwin->win);
ECommsSend(s);
ESYNC;
 }
@@ -995,8 +995,8 @@ Epplet_imageclass_apply(const char *iclass, const char 
*state, Window ww)
 {
chars[1024];
 
-   Esnprintf(s, sizeof(s), "imageclass %s apply 0x%x %s", iclass,
-(unsigned int)ww, state);
+   snprintf(s, sizeof(s), "imageclass %s apply 0x%x %s", iclass,
+   (unsigned int)ww, state);
ECommsSend(s);
 }
 
@@ -1009,8 +1009,8 @@ Epplet_imageclass_paste(const char *iclass, const char 
*state, Window ww,
GC  gc = 0;
XGCValues   gcv;
 
-   Esnprintf(s, sizeof(s), "imageclass %s apply_copy 0x%x %s %i %i", iclass,
-(unsigned int)ww, state, w, h);
+   snprintf(s, sizeof(s), "imageclass %s apply_copy 0x%x %s %i %i", iclass,
+   (unsigned int)ww, state, w, h);
ECommsSend(s);
msg = ECommsWaitForMessage();
if (msg)
@@ -1021,8 +1021,8 @@ Epplet_imageclass_paste(const char *iclass, const char 
*state, Window ww,
XSetClipMask(disp, gc, m);
XSetClipOrigin(disp, gc, x, y);
XCopyArea(disp, p, context_win->win, gc, 0, 0, w, h, x, y);
-   Esnprintf(s, sizeof(s), "imageclass %s free_pixmap 0x%x", iclass,
- (unsigned int)p);
+   snprintf(s, sizeof(s), "imageclass %s free_pixmap 0x%x", iclass,
+(unsigned int)p);
ECommsSend(s);
XFreeGC(disp, gc);
  }
@@ -1037,8 +1037,8 @@ Epplet_imageclass_get_pixmaps(const cha

[EGIT] [e16/e16-epplets] master 05/10: Indent tweaks, cleanups

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=9cb45612271e8e5161d21a4941715922c48e8f51

commit 9cb45612271e8e5161d21a4941715922c48e8f51
Author: Kim Woelders 
Date:   Thu Aug 26 20:13:56 2021 +0200

Indent tweaks, cleanups
---
 .indent.pro |   2 +-
 api/epplet.c| 195 ++--
 api/epplet.h.in |  49 +--
 epplets/CalcEphem.c |   4 -
 epplets/CalcEphem.h |   9 +-
 epplets/E-Areas.c   |   2 +-
 epplets/E-Biff.c|   1 -
 epplets/E-Exec.c|   2 -
 epplets/E-Mountbox.c|  47 ---
 epplets/E-PlayCD.c  |   8 +-
 epplets/E-Power.c   |   3 +-
 epplets/E-SD.c  |  10 +--
 epplets/E-ScreenSave.c  |   6 +-
 epplets/E-ScreenShoot.c |   8 +-
 epplets/E-ScreenShoot_ftp.c |   1 -
 epplets/E-Toolbox.c |   7 +-
 epplets/E-UrlWatch.c|  11 +--
 epplets/E-Wireless.c|   1 -
 epplets/Emix.c  |   3 +-
 epplets/Moon.c  |   2 -
 epplets/TestEpplet.c|   1 -
 epplets/cloak.c |   1 -
 epplets/esdcloak.c  |   1 -
 epplets/mbox.c  |   7 +-
 epplets/net.c   |   6 --
 epplets/proc.h  |   7 +-
 26 files changed, 142 insertions(+), 252 deletions(-)

diff --git a/.indent.pro b/.indent.pro
index 39ed16d..6161a53 100644
--- a/.indent.pro
+++ b/.indent.pro
@@ -1 +1 @@
--i3 -bl -bad -nbap -sob -ncdb -di20 -nbc -lp -nce -npcs -sc -ncs -l80
+-i3 -bl -bad -nbap -sob -ncdb -di20 -nbc -lp -nce -npcs -sc -ncs -brs -l80
diff --git a/api/epplet.c b/api/epplet.c
index 7b1fa98..91fdead 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -20,8 +20,7 @@
 
 #define CRSR_WDTH 2
 
-typedef struct epplet_window
-{
+typedef struct {
Window  win;
int w;
int h;
@@ -29,8 +28,7 @@ typedef struct epplet_window
Pixmap  bg_pmap;
Pixmap  bg_mask;
Pixmap  bg_bg;
-}
-EppWindow;
+} EppWindow;
 typedef EppWindow  *Epplet_window;
 
 EAPI Display   *disp = NULL;
@@ -80,27 +78,27 @@ static void*event_data = NULL;
 static void*comms_data = NULL;
 static void*child_data = NULL;
 
-static void (*expose_func) (void *data, Window win, int x, int y, int 
w,
-   int h) = NULL;
-static void (*moveresize_func) (void *data, Window win, int x, int y,
-   int w, int h) = NULL;
-static void (*buttonpress_func) (void *data, Window win, int x, int y,
-int b) = NULL;
-static void (*buttonrelease_func) (void *data, Window win, int x, int 
y,
-  int b) = NULL;
-static void (*mousemotion_func) (void *data, Window win, int x, int y) 
=
+static void (*expose_func)(void *data, Window win, int x, int y, int w,
+  int h) = NULL;
+static void (*moveresize_func)(void *data, Window win, int x, int y,
+  int w, int h) = NULL;
+static void (*buttonpress_func)(void *data, Window win, int x, int y,
+   int b) = NULL;
+static void (*buttonrelease_func)(void *data, Window win, int x, int y,
+ int b) = NULL;
+static void (*mousemotion_func)(void *data, Window win, int x, int y) =
NULL;
-static void (*keypress_func) (void *data, Window win, char *key) = 
NULL;
-static void (*keyrelease_func) (void *data, Window win, char *key) =
+static void (*keypress_func)(void *data, Window win, char *key) = NULL;
+static void (*keyrelease_func)(void *data, Window win, char *key) =
NULL;
-static void (*enter_func) (void *data, Window win) = NULL;
-static void (*leave_func) (void *data, Window win) = NULL;
-static void (*focusin_func) (void *data, Window win) = NULL;
-static void (*focusout_func) (void *data, Window win) = NULL;
-static int  (*delete_func) (void *data, Window win) = NULL;
-static void (*event_func) (void *data, XEvent * ev) = NULL;
-static void (*comms_func) (void *data, const char *s) = NULL;
-static void (*child_func) (void *data, int pid, int exit_code) = NULL;
+static void (*enter_func)(void *data, Window win) = NULL;
+static void (*leave_func)(void *data, Window win) = NULL;
+static void (*focusin_func)(void *data, Window win) = NULL;
+static void (*focusout_func)(void *data, Window win) = NULL;
+static int  (*delete_func)(void *data, Window win) = NULL;
+static void (*event_func)(void *data, XEvent * ev) = NULL;
+static void (*comms_func)(void *data, const char *s) = NULL;
+static void (*child_func)(void

[EGIT] [e16/e16-epplets] master 01/07: Epplet_load_config(): Fix memory leak when called more than once

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=9e2045a54b9ced077eaa6324f32154fe6a1fa685

commit 9e2045a54b9ced077eaa6324f32154fe6a1fa685
Author: Kim Woelders 
Date:   Fri Aug 27 17:05:39 2021 +0200

Epplet_load_config(): Fix memory leak when called more than once
---
 api/epplet.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 8d6a192..3182045 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -5609,10 +5609,12 @@ Epplet_load_config(void)
if (epplet_instance == 0)
   return;
 
-   /* create config file name */
-   snprintf(s, sizeof(s), "%s/%s.cfg", conf_dir, epplet_name);
-   epplet_cfg_file = strdup(s);
-
+   if (!epplet_cfg_file)
+ {
+   /* create config file name */
+   snprintf(s, sizeof(s), "%s/%s.cfg", conf_dir, epplet_name);
+   epplet_cfg_file = strdup(s);
+ }
Epplet_load_config_file(epplet_cfg_file);
 }
 

-- 




[EGIT] [e16/e16-epplets] master 09/10: Introduce Epplet_Exit()

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=b76845e265dd5a951603582485b19eb65abdc4fe

commit b76845e265dd5a951603582485b19eb65abdc4fe
Author: Kim Woelders 
Date:   Fri Aug 27 15:03:30 2021 +0200

Introduce Epplet_Exit()

Avoiding some code duplication.
---
 api/epplet.c   | 8 
 api/epplet.h.in| 7 ++-
 epplets/ConfigTestEpplet.c | 4 +---
 epplets/E-Areas.c  | 4 +---
 epplets/E-Bandwidth.c  | 4 +---
 epplets/E-Biff.c   | 4 +---
 epplets/E-Clock.c  | 4 +---
 epplets/E-Cpu.c| 4 +---
 epplets/E-Disk.c   | 4 +---
 epplets/E-Exec.c   | 3 +--
 epplets/E-Load.c   | 4 +---
 epplets/E-LoadMeter.c  | 4 +---
 epplets/E-Magic.c  | 4 +---
 epplets/E-MemWatch.c   | 4 +---
 epplets/E-Mixer.c  | 5 ++---
 epplets/E-MoonClock.c  | 4 +---
 epplets/E-Mountbox.c   | 5 ++---
 epplets/E-Net.c| 8 ++--
 epplets/E-NetFlame.c   | 8 ++--
 epplets/E-NetGraph.c   | 8 ++--
 epplets/E-OpenGL-Demo.c| 5 ++---
 epplets/E-Pants.c  | 4 +---
 epplets/E-Pinger.c | 4 +---
 epplets/E-PlayCD.c | 4 +---
 epplets/E-Power.c  | 4 +---
 epplets/E-SD.c | 5 ++---
 epplets/E-ScreenSave.c | 5 ++---
 epplets/E-ScreenShoot.c| 5 ++---
 epplets/E-Slides.c | 4 +---
 epplets/E-Sys.c| 4 +---
 epplets/E-Time.c   | 4 +---
 epplets/E-Toolbox.c| 4 +---
 epplets/E-UrlWatch.c   | 7 ++-
 epplets/E-Wireless.c   | 5 ++---
 epplets/E-Xss.c| 5 ++---
 epplets/Emix.c | 5 ++---
 epplets/TestEpplet.c   | 4 +---
 37 files changed, 62 insertions(+), 116 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 8101264..8d6a192 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -659,6 +659,14 @@ Epplet_internal_create_window(int w, int h, const char 
*title, char vertical,
return ret->win;
 }
 
+void
+Epplet_Exit(int rc)
+{
+   Epplet_unremember();
+   Esync();
+   exit(rc);
+}
+
 Window
 Epplet_create_window(int w, int h, const char *title, char vertical)
 {
diff --git a/api/epplet.h.in b/api/epplet.h.in
index b0a6801..c79556b 100644
--- a/api/epplet.h.in
+++ b/api/epplet.h.in
@@ -78,11 +78,16 @@ EAPI void   Epplet_Init(const char *name, const 
char *version,
const char *info, int w, int h,
int argc, char **argv, char vertical);
 
+//
+/* Exit call*/
+//
+/* Should normally be called to exit your epplet (calls Epplet_cleanup()) */
+EAPI void   Epplet_Exit(int rc);
+
 //
 /* Cleanup call */
 //
 /* You HAVE to call this before exiting your epplet!*/
-
 EAPI void   Epplet_cleanup(void);
 
 /* Adjust priority */
diff --git a/epplets/ConfigTestEpplet.c b/epplets/ConfigTestEpplet.c
index 2f76c79..cfeaf89 100644
--- a/epplets/ConfigTestEpplet.c
+++ b/epplets/ConfigTestEpplet.c
@@ -4,9 +4,7 @@
 static void
 cb_close(void *data __UNUSED__)
 {
-   Epplet_unremember();
-   Esync();
-   exit(0);
+   Epplet_Exit(0);
 }
 
 int
diff --git a/epplets/E-Areas.c b/epplets/E-Areas.c
index 732f439..8de9fb2 100644
--- a/epplets/E-Areas.c
+++ b/epplets/E-Areas.c
@@ -23,9 +23,7 @@ static Epplet_gadget b_close;
 static void
 close_cb(void *data __UNUSED__)
 {
-   Epplet_unremember();
-   Esync();
-   exit(0);
+   Epplet_Exit(0);
 }
 
 static void
diff --git a/epplets/E-Bandwidth.c b/epplets/E-Bandwidth.c
index 736bee5..9b27ad7 100644
--- a/epplets/E-Bandwidth.c
+++ b/epplets/E-Bandwidth.c
@@ -137,9 +137,7 @@ timer_cb(void *data __UNUSED__)
 static void
 close_cb(void *data __UNUSED__)
 {
-   Epplet_unremember();
-   Esync();
-   exit(0);
+   Epplet_Exit(0);
 }
 
 static void
diff --git a/epplets/E-Biff.c b/epplets/E-Biff.c
index 9252152..24cc12c 100644
--- a/epplets/E-Biff.c
+++ b/epplets/E-Biff.c
@@ -120,9 +120,7 @@ mailcheck_cb(void *data __UNUSED__)
 static void
 close_cb(void *data __UNUSED__)
 {
-   Epplet_unremember();
-   Esync();
-   exit(0);
+   Epplet_Exit(0);
 }
 
 static void
diff --git a/epplets/E-Clock.c b/epplets/E-Clock.c
index 511291c..0321314 100644
--- a/epplets/E-Clock.c
+++ b/epplets/E-Clock.c
@@ -33,9 +33,7 @@ cb_timer(void *data __UNUSED__)
 static void
 cb_close(void *data __UNUSED__)
 {
-   Epplet_unremember();
-   Esync();
-   exit(0);
+   Epplet_Exit(0);
 }
 
 static void
diff --git a/epplets/E-Cpu.c b/epplets/E-Cpu.c
index 7c44a5c..39a04b5 100644
--- a/epplets/E-Cpu.c
+++ b/epplet

[EGIT] [e16/e16-epplets] master 07/07: E-Net: Enable specifying device in config (no UI).

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=acefe58f1b0c6983ccc6b8551a606e4bc133af4c

commit acefe58f1b0c6983ccc6b8551a606e4bc133af4c
Author: Kim Woelders 
Date:   Fri Sep 3 06:08:40 2021 +0200

E-Net: Enable specifying device in config (no UI).
---
 epplets/E-Net.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/epplets/E-Net.c b/epplets/E-Net.c
index adfb812..4c5208b 100644
--- a/epplets/E-Net.c
+++ b/epplets/E-Net.c
@@ -13,6 +13,7 @@ static int  up_val = 0;
 static int  down_val = 0;
 static double   up_last = 0;
 static double   down_last = 0;
+static const char  *netdev = "eth0";
 static Epplet_gadget load_up;
 static Epplet_gadget load_down;
 
@@ -22,12 +23,12 @@ cb_timer(void *data __UNUSED__)
double  val = -1.0, val2 = -1.0, dval, dval2;
unsigned char   invalid;
 
-   invalid = net_get_bytes_inout("eth0", , );
+   invalid = net_get_bytes_inout(netdev, , );
if (invalid)
  {
Epplet_dialog_ok
-  ("Unable to get network device statistics for eth0:  %s",
-   net_strerror(invalid));
+  ("Unable to get network device statistics for %s:  %s",
+   netdev, net_strerror(invalid));
Epplet_Exit(1);
  }
if (val != -1.0)
@@ -71,6 +72,8 @@ load_conf(void)
 
s = Epplet_query_config_def("downstream_max", "154");
downstream_max = (double)atof(s);
+
+   netdev = Epplet_query_config_def("device", "eth0");
 }
 
 static void

-- 




[EGIT] [e16/e16-epplets] master 08/10: Centralize setting up atexit(Epplet_cleanup)

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=b436df8d7a6355a7c1f5dcded8c5bf810abb3d03

commit b436df8d7a6355a7c1f5dcded8c5bf810abb3d03
Author: Kim Woelders 
Date:   Thu Aug 26 21:54:45 2021 +0200

Centralize setting up atexit(Epplet_cleanup)
---
 api/epplet.c   |  2 ++
 epplets/ConfigTestEpplet.c |  1 -
 epplets/E-Areas.c  |  1 -
 epplets/E-Bandwidth.c  |  1 -
 epplets/E-Biff.c   |  1 -
 epplets/E-Clock.c  |  1 -
 epplets/E-Cpu.c|  2 --
 epplets/E-Disk.c   |  1 -
 epplets/E-Exec.c   |  2 --
 epplets/E-Load.c   |  1 -
 epplets/E-LoadMeter.c  |  2 --
 epplets/E-Magic.c  |  1 -
 epplets/E-Mixer.c  |  2 --
 epplets/E-MoonClock.c  |  2 --
 epplets/E-Mountbox.c   |  1 -
 epplets/E-Net.c|  2 --
 epplets/E-NetFlame.c   |  2 --
 epplets/E-NetGraph.c   |  1 -
 epplets/E-OpenGL-Demo.c|  2 --
 epplets/E-Pants.c  |  2 --
 epplets/E-Pinger.c |  2 --
 epplets/E-PlayCD.c |  2 --
 epplets/E-Power.c  |  1 -
 epplets/E-SD.c | 10 +-
 epplets/E-ScreenSave.c |  9 +
 epplets/E-ScreenShoot.c| 10 +-
 epplets/E-Slides.c |  1 -
 epplets/E-Sys.c|  2 --
 epplets/E-Time.c   |  2 --
 epplets/E-Toolbox.c|  1 -
 epplets/E-UrlWatch.c   | 10 +-
 epplets/E-Wireless.c   |  2 --
 epplets/E-Xss.c|  2 --
 epplets/Emix.c |  1 -
 epplets/TestEpplet.c   |  1 -
 35 files changed, 6 insertions(+), 80 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index bdcd146..8101264 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -560,6 +560,8 @@ Epplet_Init(const char *name, const char *version, const 
char *info,
sa.sa_flags = SA_RESTART;
sigemptyset(_mask);
sigaction(SIGCHLD, , (struct sigaction *)0);
+
+   atexit(Epplet_cleanup);
 }
 
 static  Window
diff --git a/epplets/ConfigTestEpplet.c b/epplets/ConfigTestEpplet.c
index 35ce297..2f76c79 100644
--- a/epplets/ConfigTestEpplet.c
+++ b/epplets/ConfigTestEpplet.c
@@ -6,7 +6,6 @@ cb_close(void *data __UNUSED__)
 {
Epplet_unremember();
Esync();
-   Epplet_cleanup();
exit(0);
 }
 
diff --git a/epplets/E-Areas.c b/epplets/E-Areas.c
index a800b59..732f439 100644
--- a/epplets/E-Areas.c
+++ b/epplets/E-Areas.c
@@ -77,7 +77,6 @@ main(int argc, char **argv)
 {
Epplet_gadget   b_up, b_down, b_left, b_right;
 
-   atexit(Epplet_cleanup);
Epplet_Init("E-Areas", "0.1",
   "A desktop areas navigator; John Slee ",
   3, 3, argc, argv, 0);
diff --git a/epplets/E-Bandwidth.c b/epplets/E-Bandwidth.c
index d5b260c..736bee5 100644
--- a/epplets/E-Bandwidth.c
+++ b/epplets/E-Bandwidth.c
@@ -265,7 +265,6 @@ main(int argc, char **argv)
 {
Epplet_adjust_priority(10);
 
-   atexit(Epplet_cleanup);
Epplet_Init("E-Bandwidth", "0.2", "Enlightenment Network I/O Monitor 
Epplet",
   3, 3, argc, argv, 0);
Epplet_load_config();
diff --git a/epplets/E-Biff.c b/epplets/E-Biff.c
index fdbb44b..9252152 100644
--- a/epplets/E-Biff.c
+++ b/epplets/E-Biff.c
@@ -419,7 +419,6 @@ main(int argc, char **argv)
 {
Epplet_adjust_priority(10);
 
-   atexit(Epplet_cleanup);
Epplet_Init("E-Biff", "0.5", "Enlightenment Mailbox Checker Epplet", 3, 3,
   argc, argv, 0);
Epplet_load_config();
diff --git a/epplets/E-Clock.c b/epplets/E-Clock.c
index 37c2b5c..511291c 100644
--- a/epplets/E-Clock.c
+++ b/epplets/E-Clock.c
@@ -104,7 +104,6 @@ draw_arms(void)
 int
 main(int argc, char **argv)
 {
-   atexit(Epplet_cleanup);
Epplet_Init("E-Clock", "0.1", "Enlightenment Clock Epplet",
   3, 3, argc, argv, 0);
Epplet_timer(cb_timer, NULL, 0.5, "TIMER");
diff --git a/epplets/E-Cpu.c b/epplets/E-Cpu.c
index a116050..7c44a5c 100644
--- a/epplets/E-Cpu.c
+++ b/epplets/E-Cpu.c
@@ -418,8 +418,6 @@ main(int argc, char **argv)
 
Epplet_adjust_priority(10);
 
-   atexit(Epplet_cleanup);
-
cpus = count_cpus();
load_val = calloc(cpus, sizeof(int));
prev_val = calloc(cpus, sizeof(double));
diff --git a/epplets/E-Disk.c b/epplets/E-Disk.c
index 0e91040..9952ebb 100644
--- a/epplets/E-Disk.c
+++ b/epplets/E-Disk.c
@@ -243,7 +243,6 @@ main(int argc, char **argv)
 {
Epplet_adjust_priority(10);
 
-   atexit(Epplet_cleanup);
Epplet_Init("E-Disk", "0.2", "Enlightenment Disk I/O Monitor Epplet", 3, 3,
   argc, argv, 0);
Epplet_load_config();
diff --git a/epplets/E-Exec.c b/epplets/E-Exec.c
index 2966290..b310c8a 100644
--- a/epplets/E-Exec.c
+++ b/epplets/E-Exec.c
@@ -233,8 +233,6 @@ cb_configure(void *data __UNUSED__)
 int
 main(int argc, char *argv[])
 {
-   atexit(Epplet_cleanup);
-
if ((argc > 1) &&

[EGIT] [e16/e16-epplets] master 03/10: Introduce Epplet_adjust_priority()

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=83e1e71bee2b5ad444de2cd50d61c273f2216c1b

commit 83e1e71bee2b5ad444de2cd50d61c273f2216c1b
Author: Kim Woelders 
Date:   Thu Aug 26 19:21:02 2021 +0200

Introduce Epplet_adjust_priority()

Avoiding some code duplication.
---
 api/epplet.c| 10 ++
 api/epplet.h.in |  3 +++
 epplets/E-Bandwidth.c   |  5 +
 epplets/E-Biff.c|  5 +
 epplets/E-Cpu.c |  6 ++
 epplets/E-Disk.c|  5 +
 epplets/E-MemWatch.c|  6 ++
 epplets/E-MoonClock.c   |  7 ++-
 epplets/E-Net.c |  6 ++
 epplets/E-NetFlame.c|  6 ++
 epplets/E-NetGraph.c|  6 ++
 epplets/E-OpenGL-Demo.c |  7 ++-
 epplets/E-PlayCD.c  |  9 +
 epplets/E-SD.c  |  6 +-
 epplets/E-ScreenSave.c  |  5 +
 epplets/E-ScreenShoot.c |  6 +-
 epplets/E-Slides.c  |  6 ++
 epplets/E-Sys.c |  7 ++-
 epplets/E-UrlWatch.c|  7 ++-
 epplets/E-Wireless.c|  6 ++
 epplets/E-Xss.c |  6 +-
 21 files changed, 47 insertions(+), 83 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 97456dd..7b1fa98 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -2,6 +2,7 @@
 #include "epplet.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -977,6 +978,15 @@ Epplet_cleanup(void)
Epplet_save_config();
 }
 
+void
+Epplet_adjust_priority(int nice)
+{
+   int prio;
+
+   prio = getpriority(PRIO_PROCESS, getpid());
+   setpriority(PRIO_PROCESS, getpid(), prio + nice);
+}
+
 void
 Epplet_show(void)
 {
diff --git a/api/epplet.h.in b/api/epplet.h.in
index 4b038c0..6d2141d 100644
--- a/api/epplet.h.in
+++ b/api/epplet.h.in
@@ -91,6 +91,9 @@ EAPI void   Epplet_Init(const char *name, const char 
*version,
 
 EAPI void   Epplet_cleanup(void);
 
+/* Adjust priority */
+EAPI void   Epplet_adjust_priority(int nice);
+
 /* actualy display the app */
 EAPI void   Epplet_show(void);
 
diff --git a/epplets/E-Bandwidth.c b/epplets/E-Bandwidth.c
index 1271ae3..b5c6487 100644
--- a/epplets/E-Bandwidth.c
+++ b/epplets/E-Bandwidth.c
@@ -21,7 +21,6 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include 
-#include 
 
 #include "config.h"
 #include "epplet.h"
@@ -266,10 +265,8 @@ parse_conf(void)
 int
 main(int argc, char **argv)
 {
-   int prio;
+   Epplet_adjust_priority(10);
 
-   prio = getpriority(PRIO_PROCESS, getpid());
-   setpriority(PRIO_PROCESS, getpid(), prio + 10);
atexit(Epplet_cleanup);
Epplet_Init("E-Bandwidth", "0.2", "Enlightenment Network I/O Monitor 
Epplet",
   3, 3, argc, argv, 0);
diff --git a/epplets/E-Biff.c b/epplets/E-Biff.c
index 919e771..1166fda 100644
--- a/epplets/E-Biff.c
+++ b/epplets/E-Biff.c
@@ -22,7 +22,6 @@
  */
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -425,10 +424,8 @@ process_conf(void)
 int
 main(int argc, char **argv)
 {
-   int prio;
+   Epplet_adjust_priority(10);
 
-   prio = getpriority(PRIO_PROCESS, getpid());
-   setpriority(PRIO_PROCESS, getpid(), prio + 10);
atexit(Epplet_cleanup);
Epplet_Init("E-Biff", "0.5", "Enlightenment Mailbox Checker Epplet", 3, 3,
   argc, argv, 0);
diff --git a/epplets/E-Cpu.c b/epplets/E-Cpu.c
index 30a7bad..f5f0dc5 100644
--- a/epplets/E-Cpu.c
+++ b/epplets/E-Cpu.c
@@ -1,6 +1,5 @@
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -421,10 +420,9 @@ int
 main(int argc, char **argv)
 {
Epplet_gadget   p;
-   int prio;
 
-   prio = getpriority(PRIO_PROCESS, getpid());
-   setpriority(PRIO_PROCESS, getpid(), prio + 10);
+   Epplet_adjust_priority(10);
+
atexit(Epplet_cleanup);
 
cpus = count_cpus();
diff --git a/epplets/E-Disk.c b/epplets/E-Disk.c
index 550f32e..67f8595 100644
--- a/epplets/E-Disk.c
+++ b/epplets/E-Disk.c
@@ -22,7 +22,6 @@
  */
 #include 
 #include 
-#include 
 
 #include "config.h"
 #include "epplet.h"
@@ -245,10 +244,8 @@ parse_conf(void)
 int
 main(int argc, char **argv)
 {
-   int prio;
+   Epplet_adjust_priority(10);
 
-   prio = getpriority(PRIO_PROCESS, getpid());
-   setpriority(PRIO_PROCESS, getpid(), prio + 10);
atexit(Epplet_cleanup);
Epplet_Init("E-Disk", "0.2", "Enlightenment Disk I/O Monitor Epplet", 3, 3,
   argc, argv, 0);
diff --git a/epplets/E-MemWatch.c b/epplets/E-MemWatch.c
index 29891f1..7c62efd 100644
--- a/epplets/E-MemWatch.c
+++ b/epplets/E-MemWatch.c
@@ -22,7 +22,6 @@
  */
 #include 
 #include 
-#include 
 
 #include "config.h"
 #include "epplet.h"
@@ -249,7 +248,7 @@ out_cb(void *data __UNUSED__, Window w)
 int
 main(int argc, char **argv)
 {
-   int  

[EGIT] [e16/e16-epplets] master 04/07: E-Wireless: Fix bad memory access

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=4f25ca8cd2265b1bbcf0ae71fb6102de01648cb8

commit 4f25ca8cd2265b1bbcf0ae71fb6102de01648cb8
Author: Kim Woelders 
Date:   Fri Aug 27 18:43:37 2021 +0200

E-Wireless: Fix bad memory access

And a couple of cleanups.
---
 epplets/E-Wireless.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/epplets/E-Wireless.c b/epplets/E-Wireless.c
index d90efe7..2020834 100644
--- a/epplets/E-Wireless.c
+++ b/epplets/E-Wireless.c
@@ -19,7 +19,7 @@ static int *cpu_hist = NULL;
 static int  hist_pos = 0;
 static int  color = 0;
 
-static unsigned char colors[7][3][3] = {
+static const unsigned char colors[7][3][3] = {
{{0x00, 0x23, 0x00}, {0x00, 0x50, 0x00}, {0x00, 0xff, 0x00}},   //green
{{0x00, 0x00, 0x23}, {0x00, 0x00, 0x50}, {0x00, 0x00, 0xff}},   //blue
{{0x23, 0x00, 0x00}, {0x50, 0x00, 0x00}, {0xff, 0x00, 0x00}},   //red
@@ -31,7 +31,7 @@ static unsigned char colors[7][3][3] = {
 
 static void
 draw_line(unsigned char *rgb, int x1, int y1, int x2, int y2,
- unsigned char *clr)
+ const unsigned char *clr)
 {
unsigned char  *rptr;
int i, steep = 0, sx, sy, dx, dy, e;
@@ -115,6 +115,8 @@ draw_graph(void)
 
j = ((hist_pos + 1) % WIDTH);
y = HEIGHT - ((HEIGHT * cpu_hist[j]) / 100);
+   if (y >= HEIGHT)
+  y = HEIGHT - 1;
for (i = 0; i < WIDTH - 1; i++)
  {
j++;
@@ -272,5 +274,5 @@ main(int argc, char *argv[])
Epplet_show();
Epplet_Loop();
 
-   return (0);
+   return 0;
 }

-- 




[EGIT] [e16/e16-epplets] master 02/07: E-MemWatch: Drop ancient (<2.6) kernel support (fixing bad memory access)

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=c6c19d3411d4b496cf10a25502e64443b3de6148

commit c6c19d3411d4b496cf10a25502e64443b3de6148
Author: Kim Woelders 
Date:   Fri Aug 27 15:28:04 2021 +0200

E-MemWatch: Drop ancient (<2.6) kernel support (fixing bad memory access)
---
 epplets/E-MemWatch.c | 104 +++
 1 file changed, 31 insertions(+), 73 deletions(-)

diff --git a/epplets/E-MemWatch.c b/epplets/E-MemWatch.c
index 9d0813e..fd69e3f 100644
--- a/epplets/E-MemWatch.c
+++ b/epplets/E-MemWatch.c
@@ -42,7 +42,6 @@ static Epplet_gadget close_button, mem_bar, swap_bar, 
mem_label, swap_label,
title, cfg_button;
 static int  mem_val = 0, swap_val = 0;
 static int  show_title = 1;
-static int  kernel_2_6 = 0;
 
 static void
 timer_cb(void *data __UNUSED__)
@@ -70,32 +69,25 @@ timer_cb(void *data __UNUSED__)
return;
  }
 
-   if (kernel_2_6)
- {
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );
-
-   total *= 1024;
-   free *= 1024;
-   buffers *= 1024;
-   cached *= 1024;
-   used = total - free;
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );
 
- }
-   else
- {
+   total *= 1024;
+   free *= 1024;
+   buffers *= 1024;
+   cached *= 1024;
+   used = total - free;
 
-   fgets(buff, sizeof(buff), fp);  /* Ignore the first line */
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu %lu %*u %*u %lu %lu", , , ,
-  );
- }
+   fgets(buff, sizeof(buff), fp);  /* Ignore the first line */
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu %lu %*u %*u %lu %lu", , , ,
+ );
 
 #endif /* HAVE_LIBGTOP */
 
@@ -134,31 +126,21 @@ timer_cb(void *data __UNUSED__)
while (swap.total == 0 && swap.used == 0 && check++ < 15);
 #else
 
-   if (kernel_2_6)
- {
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu", );;
-
-   total *= 1024;
-   free *= 1024;
-   used = total - free;
-
- }
-   else
- {
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );
+   fgets(buff, sizeof(buff), fp);
+   sscanf(buff, "%*s %lu", );;
 
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %lu %lu", , );
- }
+   total *= 1024;
+   free *= 1024;
+   used = total - free;
 
fclose(fp);
 #endif /* HAVE_LIBGTOP */
@@ -245,30 +227,6 @@ main(int argc, char **argv)
 {
Epplet_adjust_priority(10);
 
-   /* check for Kernel 2.6 */
-   FILE   *fp;
-   charversion[8], buff[1024];
-
-   if (!(fp = fopen("/proc/version", "r")))
- {
-   D(("Failed to open /proc/version -- %s\nWill assume not 2.6 kernel",
-  strerror(errno)));
-   return 1;
- }
-
-   fgets(buff, sizeof(buff), fp);
-   sscanf(buff, "%*s %*s %s", version);
-
-   if (version[2] == '6')
- {
-   kernel_2_6 = 1;
- }
-
-   fclose(fp);
-   /* end check for Kernel 2.6 */
-
-   atexit(Epplet_cleanup);
-
Epplet_Init("E-MemWatch", "0.1", "Enlightenment RAM/Swap Monitor Epplet", 3,
   3, argc, argv, 0);
Epplet_load_config();

-- 




[EGIT] [e16/e16-epplets] master 07/10: Drop pointer test for free()

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=d1ca9c1c1c9e797001f2fb3a2829f56a63c8e157

commit d1ca9c1c1c9e797001f2fb3a2829f56a63c8e157
Author: Kim Woelders 
Date:   Wed Sep 1 19:53:39 2021 +0200

Drop pointer test for free()
---
 api/epplet.c   | 72 ++
 epplets/ConfigTestEpplet.c |  3 +-
 epplets/E-Mountbox.c   | 50 +
 epplets/E-Pinger.c |  5 +--
 epplets/E-SD.c |  3 +-
 epplets/E-ScreenSave.c |  6 ++--
 epplets/E-ScreenShoot.c| 78 --
 epplets/E-Slides.c |  7 +
 epplets/E-Toolbox.c| 20 +++-
 epplets/E-UrlWatch.c   | 42 +
 10 files changed, 88 insertions(+), 198 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 1c9eb35..bdcd146 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -1467,10 +1467,8 @@ Epplet_remove_timer(const char *name)
q_first = et->next;
 if (et->next)
et->next->in += et->in;
-if (et->name)
-   free(et->name);
-if (et)
-   free(et);
+free(et->name);
+free(et);
 return;
  }
pptr = ptr;
@@ -1508,8 +1506,7 @@ Epplet_handle_timer(void)
(*(et->func)) (et->data);
if (et && et->name)
   free(et->name);
-   if (et)
-  free(et);
+   free(et);
 }
 
 double
@@ -2148,8 +2145,7 @@ Epplet_textbox_insert(Epplet_gadget eg, const char 
*new_contents)
else
   strcat(s, new_contents);
 
-   if (g->contents)
-  free(g->contents);
+   free(g->contents);
 
g->contents = s;
  }
@@ -2194,8 +2190,7 @@ Epplet_change_textbox(Epplet_gadget eg, const char 
*new_contents)
 
if (g->contents == new_contents)
   return;
-   else if (g->contents)
-  free(g->contents);
+   free(g->contents);
 
if ((s = strchr(new_contents, '\n')))
  {
@@ -3955,8 +3950,7 @@ Epplet_change_image(Epplet_gadget gadget, int w, int h, 
const char *image)
GADGET_CONFIRM_TYPE(gadget, E_IMAGE);
g = (GadImage *) gadget;
gg = (GadGeneral *) gadget;
-   if (g->image)
-  free(g->image);
+   free(g->image);
g->image = Epplet_find_file(image);
g->w = w;
g->h = h;
@@ -3975,8 +3969,7 @@ Epplet_move_change_image(Epplet_gadget gadget, int x, int 
y, int w, int h,
g = (GadImage *) gadget;
gg = (GadGeneral *) gadget;
Epplet_draw_image(gadget, 1);
-   if (g->image)
-  free(g->image);
+   free(g->image);
g->image = Epplet_find_file(image);
g->w = w;
g->h = h;
@@ -4633,12 +4626,9 @@ Epplet_gadget_destroy(Epplet_gadget gadget)
   g = (GadButton *) gadget;
   XDestroyWindow(disp, g->win);
   XDeleteContext(disp, g->win, xid_context);
-  if (g->label)
- free(g->label);
-  if (g->image)
- free(g->image);
-  if (g->std)
- free(g->std);
+  free(g->label);
+  free(g->image);
+  free(g->std);
   free(g);
}
break;
@@ -4682,10 +4672,8 @@ Epplet_gadget_destroy(Epplet_gadget gadget)
   g = (GadToggleButton *) gadget;
   XDestroyWindow(disp, g->win);
   XDeleteContext(disp, g->win, xid_context);
-  if (g->label)
- free(g->label);
-  if (g->image)
- free(g->image);
+  free(g->label);
+  free(g->image);
   free(g);
}
break;
@@ -4696,12 +4684,9 @@ Epplet_gadget_destroy(Epplet_gadget gadget)
   g = (GadPopupButton *) gadget;
   XDestroyWindow(disp, g->win);
   XDeleteContext(disp, g->win, xid_context);
-  if (g->std)
- free(g->std);
-  if (g->label)
- free(g->label);
-  if (g->image)
- free(g->image);
+  free(g->std);
+  free(g->label);
+  free(g->image);
   free(g);
}
break;
@@ -4713,15 +4698,12 @@ Epplet_gadget_destroy(Epplet_gadget gadget)
   g = (GadPopup *) gadget;
   for (i = 0; i < g->entry_num; i++)
 {
-   if (g->entry[i].label)
-  free(g->entry[i].label);
-   if (g->entry[i].image)
-  free(g->entry[i].image);
+   free(g->entry[i].label);
+   free(g->entry[i].image);
if (g->entry[i].gadget)
   Epplet_gadget_destroy(g->entry[i].gadget);
 }
-  if (g->entry)
- free(g->entry);
+  free(g->entry);
   XDestroyWindow(disp, g->win);
   XDeleteCon

[EGIT] [e16/e16-epplets] master 05/07: E-Pinger: Fix potential buffer overrun

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=284a5039f9381016a6b6d0cb9b6d4eea9177159f

commit 284a5039f9381016a6b6d0cb9b6d4eea9177159f
Author: Kim Woelders 
Date:   Sun Aug 29 07:30:46 2021 +0200

E-Pinger: Fix potential buffer overrun
---
 epplets/E-Pinger.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/epplets/E-Pinger.c b/epplets/E-Pinger.c
index c143387..0ed7d34 100644
--- a/epplets/E-Pinger.c
+++ b/epplets/E-Pinger.c
@@ -46,7 +46,6 @@ static Epplet_gadget b_close, b_configure, b_help, p_log, 
pb_log, pb_log_small;
 static Epplet_gadget tb_host, tb_pause;
 static Window   win, config_win;
 static int  log_entries, nchild;
-static char buf[BUF_LEN];
 static char*result, *new_result;
 static char*host;
 static int  pinger_pause = 30;
@@ -406,6 +405,7 @@ cb_timer(void *data __UNUSED__)
time_t  now;
int nbyte;
char   *s;
+   chartbuf[32], lbuf[128];
 
if ((nbyte = nb_read(0, new_result, BUF_LEN)) > 0)
  {
@@ -428,12 +428,9 @@ cb_timer(void *data __UNUSED__)
new_result = s;
 
now = time(NULL);
-   strncpy(buf, result, BUF_LEN - 1);
-   strftime(buf + nbyte + 1, BUF_LEN - nbyte - 1, "%H:%M %a %e %b %G",
-localtime());
-   *(buf + nbyte - 1) = ':';
-   *(buf + nbyte) = ' ';
-   add_log(result, buf);
+   strftime(tbuf, sizeof(tbuf), "%H:%M %a %e %b %G", localtime());
+   snprintf(lbuf, sizeof(lbuf), "%s: %s", result, tbuf);
+   add_log(result, lbuf);
  }
else if (new_ping)
  {

-- 




[EGIT] [e16/e16-epplets] master 03/07: E-Mountbox: Fix potential segv when parsing /etc/fstab

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=beae0b229aedf0df0480ed74f2db471aa5853da3

commit beae0b229aedf0df0480ed74f2db471aa5853da3
Author: Kim Woelders 
Date:   Fri Aug 27 17:06:49 2021 +0200

E-Mountbox: Fix potential segv when parsing /etc/fstab
---
 epplets/E-Mountbox.c | 33 +++--
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/epplets/E-Mountbox.c b/epplets/E-Mountbox.c
index 67cdffb..7744f4f 100644
--- a/epplets/E-Mountbox.c
+++ b/epplets/E-Mountbox.c
@@ -1140,44 +1140,25 @@ ParseFstab(void)
 {
FILE   *f;
chars[1024];
-   char   *token = NULL;
-   char   *info[4];
-   int i;
+   charfs_spec[256], fs_file[256], fs_mntops[256];
 
if (!(f = fopen(FSTAB, "r")))
   return 0;
+
*s = 0;
for (; fgets(s, sizeof(s), f);)
  {
/* skip comments and blank lines */
if (!(*s) || (*s == '\n') || (*s == '#'))
- {
-continue;
- }
-
-   for (i = 0; i < 4; i++)
-  info[i] = NULL;
+  continue;
 
/* parse out tokens we need */
-   i = 0;
-   token = strtok(s, " \t");
-   if (token)
- {
-info[i++] = strdup(token);
- }
-   while ((token = strtok(NULL, " \t")))
- {
-info[i++] = strdup(token);
- }
+   fs_spec[0] = fs_file[0] = fs_mntops[0] = '\0';
+   sscanf(s, "%63s %255s %*s %255s", fs_spec, fs_file, fs_mntops);
 
/* see if device is user-mountable */
-   if (strstr(info[3], "user"))
- {
-AddMountPoint(info[0], info[1]);
- }
-
-   for (i = 0; i < 4; i++)
-  free(info[i]);
+   if (strstr(fs_mntops, "user"))
+  AddMountPoint(fs_spec, fs_file);
  }
 
fclose(f);

-- 




[EGIT] [e16/e16-epplets] master 02/10: Drop snprintf source

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=a128ce65cee685fb652e7f34f8d5fb175e141e8b

commit a128ce65cee685fb652e7f34f8d5fb175e141e8b
Author: Kim Woelders 
Date:   Thu Aug 26 20:28:48 2021 +0200

Drop snprintf source

Nobody hasn't got that these days.

Also drop some unused autofoo stuff.
---
 api/Makefile.am |   8 +-
 api/epplet.h.in |   7 -
 api/snprintf.c  | 598 
 configure.ac|  13 --
 4 files changed, 2 insertions(+), 624 deletions(-)

diff --git a/api/Makefile.am b/api/Makefile.am
index 8c7d004..510550f 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -1,8 +1,4 @@
 
-if BUILD_SNPRINTF
-SRCS_SNPRINTF = snprintf.c
-endif
-
 if BUILD_GLX
 EPPLET_LIB_GLX = libepplet_glx.la
 endif
@@ -14,7 +10,7 @@ lib_LTLIBRARIES = libepplet.la $(EPPLET_LIB_GLX)
 
 include_HEADERS = epplet.h
 
-libepplet_la_SOURCES = epplet.c $(SRCS_SNPRINTF)
+libepplet_la_SOURCES = epplet.c
 libepplet_la_CPPFLAGS = $(AM_CPPFLAGS) $(IMLIB2_CFLAGS) $(X_CFLAGS) -D 
ENLIGHTENMENT_ROOT=\"$(datadir)/e16\"
 libepplet_la_LIBADD = $(IMLIB2_LIBS) $(X_LIBS) -lXext -lX11 -lm
 libepplet_la_LDFLAGS = -version-info 3:0:0
@@ -24,4 +20,4 @@ libepplet_glx_la_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS)
 libepplet_glx_la_LIBADD = libepplet.la $(GLX_LIBS)
 libepplet_glx_la_LDFLAGS = -version-info 3:0:0
 
-EXTRA_DIST = epplet.h.in snprintf.c epplet_glx.c
+EXTRA_DIST = epplet.h.in epplet_glx.c
diff --git a/api/epplet.h.in b/api/epplet.h.in
index e8b5a94..4b038c0 100644
--- a/api/epplet.h.in
+++ b/api/epplet.h.in
@@ -35,15 +35,8 @@
 #define __sun__
 #endif
 
-#define HAVE_SNPRINTF @HAVE_SNPRINTF@
-#if HAVE_SNPRINTF
 #define Evsnprintf vsnprintf
 #define Esnprintf snprintf
-#else
-EAPI intEvsnprintf(char *str, size_t count, const char *fmt,
-  va_list args);
-EAPI intEsnprintf(char *str, size_t count, const char *fmt, ...);
-#endif /* HAVE_SNPRINTF */
 
 //
 /* Data structures & primitives */
diff --git a/api/snprintf.c b/api/snprintf.c
deleted file mode 100644
index 57872fc..000
--- a/api/snprintf.c
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * Copyright (C) 1999-2000 Carsten Haitzler, Geoff Harrison and various 
contributors
- * *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * *
- * The above copyright notice and this permission notice shall be included in
- * all copies of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-/* sgi's stdio.h has:
- * 
- * #if _SGIAPI && _NO_ANSIMODE
- * extern int  vsnprintf(char *, ssize_t, const char *, char *);
- * #endif
- * 
- * so workaround...
- */
-
-#include "config.h"
-
-#ifdef __sgi
-#ifdef _NO_ANSIMODE
-#undef _NO_ANSIMODE
-#endif
-#endif
-
-#include "epplet.h"
-#include 
-#ifdef HAVE_STDARG_H
-#include 
-#elif defined(HAVE_VARARGS_H)
-#include 
-#endif
-
-/* 
- * Shamelessly snarfed from sane... 
- * which shamelessly snarfed from LPR 
- * which probably shamelessly snarfed from
- * 
- * Moved comments to end so I can actually read the code.. cleaned out useless
- * junk
- */
-
-#define VA_LOCAL_DECL va_list ap
-#define VA_START(f) va_start(ap, f)
-#define VA_SHIFT(v,t) ;/* no-op for ANSI */
-#define VA_END va_end(ap)
-
-/*
- * dopr(): poor man's version of doprintf
- */
-
-static void dopr(char *buffer, const char *format, va_list args);
-static void fmtstr(char *value, int ljust, int len, int zpad,
-  int precision);
-static void fmtnum(long value, int base, int dosign, int ljust, int 
len,
-  int zpad, int precision);
-static void fmtdouble(int fmt, double value, int ljust, int len,
- int zpad

[EGIT] [e16/e16-epplets] master 01/10: Add option to build with asan

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=b0cbcb1f8aef9d3e1bc1a701516cca8102e1fd52

commit b0cbcb1f8aef9d3e1bc1a701516cca8102e1fd52
Author: Kim Woelders 
Date:   Thu Aug 26 09:59:28 2021 +0200

Add option to build with asan
---
 api/Makefile.am |  3 ++-
 configure.ac|  1 +
 epplets/Makefile.am |  3 ++-
 m4/ec_asan.m4   | 20 
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/api/Makefile.am b/api/Makefile.am
index 9cdab8f..8c7d004 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -7,7 +7,8 @@ if BUILD_GLX
 EPPLET_LIB_GLX = libepplet_glx.la
 endif
 
-AM_CPPFLAGS = -I$(top_builddir) $(CWARNFLAGS) $(CFLAGS_VISIBILITY)
+AM_CPPFLAGS = -I$(top_builddir)
+AM_CFLAGS = $(CWARNFLAGS) $(CFLAGS_VISIBILITY) $(CFLAGS_ASAN)
 
 lib_LTLIBRARIES = libepplet.la $(EPPLET_LIB_GLX)
 
diff --git a/configure.ac b/configure.ac
index 40b63a7..6cb78ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ AC_C_INLINE
 EC_C___ATTRIBUTE__
 EC_C___FUNC__
 EC_C_VISIBILITY(yes)
+EC_C_ASAN()
 
 AC_PATH_XTRA
 
diff --git a/epplets/Makefile.am b/epplets/Makefile.am
index 0b95d5a..9726d98 100644
--- a/epplets/Makefile.am
+++ b/epplets/Makefile.am
@@ -15,7 +15,8 @@ EXTRA_PROGRAMS = EppletTest.epplet EppletConfigTest.epplet 
E-Mixer.epplet \
  Emix.epplet E-PlayCD.epplet E-OpenGL-Demo.epplet \
 E-SD.epplet
 
-AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/api $(IMLIB2_CFLAGS) 
$(X_CFLAGS) $(LIBGTOP_CFLAGS) $(CWARNFLAGS) $(CFLAGS_VISIBILITY)
+AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/api $(IMLIB2_CFLAGS) 
$(X_CFLAGS) $(LIBGTOP_CFLAGS)
+AM_CFLAGS = $(CWARNFLAGS) $(CFLAGS_VISIBILITY) $(CFLAGS_ASAN)
 LDADD = $(top_builddir)/api/libepplet.la $(X_LIBS) $(KSTAT_LIBS)
 
  Conditional Builds 
diff --git a/m4/ec_asan.m4 b/m4/ec_asan.m4
new file mode 100644
index 000..c7d9bfb
--- /dev/null
+++ b/m4/ec_asan.m4
@@ -0,0 +1,20 @@
+dnl Copyright (C) 2020 Kim Woelders
+dnl This code is public domain and can be freely used or copied.
+
+dnl Macro to set compiler flags in CFLAGS_ASAN
+
+dnl Usage: EC_C_ASAN()
+
+AC_DEFUN([EC_C_ASAN], [
+  AC_ARG_ENABLE(gcc-asan,
+[AS_HELP_STRING([--enable-gcc-asan],
+[compile with ASAN support @<:@default=no@:>@])],,
+enable_gcc_asan=no)
+
+  if test "x$GCC" = "xyes"; then
+if test "x$enable_gcc_asan" = "xyes"; then
+  CFLAGS_ASAN="-fsanitize=address -fno-omit-frame-pointer"
+fi
+  fi
+  AC_SUBST(CFLAGS_ASAN)
+])

-- 




[EGIT] [e16/e16-epplets] master 06/07: Fix bad memory access in draw_flame()

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=397463459b4e63399a69d816a47243c0421508c4

commit 397463459b4e63399a69d816a47243c0421508c4
Author: Kim Woelders 
Date:   Wed Sep 1 19:48:18 2021 +0200

Fix bad memory access in draw_flame()
---
 epplets/cloak.c| 2 +-
 epplets/esdcloak.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/epplets/cloak.c b/epplets/cloak.c
index b3774a9..e556fe4 100644
--- a/epplets/cloak.c
+++ b/epplets/cloak.c
@@ -254,7 +254,7 @@ draw_flame(void)
rgb = Epplet_get_rgb_pointer(rgbbuf);
for (y = 0; y < 40; y++)
  {
-   ptr = flame + (y * 40) + 1;
+   ptr = flame + (y * 40);
rptr = rgb + (y * 40 * 4);
for (x = 0; x < 40; x++)
  {
diff --git a/epplets/esdcloak.c b/epplets/esdcloak.c
index 9551b14..717cfed 100644
--- a/epplets/esdcloak.c
+++ b/epplets/esdcloak.c
@@ -291,7 +291,7 @@ draw_flame(void)
rgb = Epplet_get_rgb_pointer(rgbbuf);
for (y = 0; y < 40; y++)
  {
-   ptr = flame + (y * 40) + 1;
+   ptr = flame + (y * 40);
rptr = rgb + (y * 40 * 4);
for (x = 0; x < 40; x++)
  {

-- 




[EGIT] [e16/e16-epplets] master 10/10: Bump .so file version (added symbols)

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=b09b79868155100998cf4b4f4481bc0a2a454c26

commit b09b79868155100998cf4b4f4481bc0a2a454c26
Author: Kim Woelders 
Date:   Thu Aug 26 20:34:02 2021 +0200

Bump .so file version (added symbols)
---
 api/Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/api/Makefile.am b/api/Makefile.am
index 510550f..7a6865c 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -13,11 +13,11 @@ include_HEADERS = epplet.h
 libepplet_la_SOURCES = epplet.c
 libepplet_la_CPPFLAGS = $(AM_CPPFLAGS) $(IMLIB2_CFLAGS) $(X_CFLAGS) -D 
ENLIGHTENMENT_ROOT=\"$(datadir)/e16\"
 libepplet_la_LIBADD = $(IMLIB2_LIBS) $(X_LIBS) -lXext -lX11 -lm
-libepplet_la_LDFLAGS = -version-info 3:0:0
+libepplet_la_LDFLAGS = -version-info 4:0:1
 
 libepplet_glx_la_SOURCES = epplet_glx.c
 libepplet_glx_la_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS)
 libepplet_glx_la_LIBADD = libepplet.la $(GLX_LIBS)
-libepplet_glx_la_LDFLAGS = -version-info 3:0:0
+libepplet_glx_la_LDFLAGS = -version-info 4:0:1
 
 EXTRA_DIST = epplet.h.in epplet_glx.c

-- 




[EGIT] [e16/e16-epplets] master 04/10: Drop unnecessary headers

2021-09-02 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=9d0e6438dbaf53d18cb1c2fb48980f92fa40c4ac

commit 9d0e6438dbaf53d18cb1c2fb48980f92fa40c4ac
Author: Kim Woelders 
Date:   Fri Mar 26 17:47:43 2021 +0100

Drop unnecessary headers
---
 epplets/E-Areas.c   |  3 ---
 epplets/E-Bandwidth.c   |  2 --
 epplets/E-Biff.c|  5 -
 epplets/E-Clock.c   |  2 +-
 epplets/E-Cpu.c |  5 -
 epplets/E-Disk.c|  3 ---
 epplets/E-LoadMeter.c   |  2 --
 epplets/E-Magic.c   |  2 --
 epplets/E-MemWatch.c|  3 ---
 epplets/E-Mixer.c   |  2 --
 epplets/E-Net.c |  5 -
 epplets/E-NetFlame.c|  3 ---
 epplets/E-NetGraph.c|  1 -
 epplets/E-OpenGL-Demo.c |  2 --
 epplets/E-Pants.c   |  2 --
 epplets/E-Pinger.c  |  1 -
 epplets/E-Power.c   |  3 ---
 epplets/E-SD.c  |  2 --
 epplets/E-ScreenSave.c  |  2 --
 epplets/E-ScreenShoot.c |  2 --
 epplets/E-Slides.c  |  1 -
 epplets/E-Sys.c |  2 --
 epplets/E-Time.c|  9 -
 epplets/E-Toolbox.c |  1 -
 epplets/E-UrlWatch.c|  2 --
 epplets/E-Wireless.c|  2 --
 epplets/E-Xss.c |  1 -
 epplets/Emix.c  |  3 +--
 epplets/mbox.c  |  1 -
 epplets/net.c   | 10 --
 30 files changed, 2 insertions(+), 82 deletions(-)

diff --git a/epplets/E-Areas.c b/epplets/E-Areas.c
index 7ee4a70..1d234a7 100644
--- a/epplets/E-Areas.c
+++ b/epplets/E-Areas.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include 
-#include 
-
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-Bandwidth.c b/epplets/E-Bandwidth.c
index b5c6487..65e0966 100644
--- a/epplets/E-Bandwidth.c
+++ b/epplets/E-Bandwidth.c
@@ -20,8 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-
 #include "config.h"
 #include "epplet.h"
 #include "net.h"
diff --git a/epplets/E-Biff.c b/epplets/E-Biff.c
index 1166fda..3dca708 100644
--- a/epplets/E-Biff.c
+++ b/epplets/E-Biff.c
@@ -20,11 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-Clock.c b/epplets/E-Clock.c
index d704baa..37c2b5c 100644
--- a/epplets/E-Clock.c
+++ b/epplets/E-Clock.c
@@ -1,4 +1,4 @@
-#include 
+#include "epplet.h"
 #include "config.h"
 
 static Epplet_gadget b_close, b_help;
diff --git a/epplets/E-Cpu.c b/epplets/E-Cpu.c
index f5f0dc5..9c04dd5 100644
--- a/epplets/E-Cpu.c
+++ b/epplets/E-Cpu.c
@@ -1,8 +1,3 @@
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-Disk.c b/epplets/E-Disk.c
index 67f8595..c6f4f37 100644
--- a/epplets/E-Disk.c
+++ b/epplets/E-Disk.c
@@ -20,9 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-#include 
-
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-LoadMeter.c b/epplets/E-LoadMeter.c
index 729f587..28ed7fb 100644
--- a/epplets/E-LoadMeter.c
+++ b/epplets/E-LoadMeter.c
@@ -20,8 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-Magic.c b/epplets/E-Magic.c
index 791cd49..7cb8c52 100644
--- a/epplets/E-Magic.c
+++ b/epplets/E-Magic.c
@@ -20,8 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-MemWatch.c b/epplets/E-MemWatch.c
index 7c62efd..298c3f8 100644
--- a/epplets/E-MemWatch.c
+++ b/epplets/E-MemWatch.c
@@ -20,9 +20,6 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include 
-#include 
-
 #include "config.h"
 #include "epplet.h"
 
diff --git a/epplets/E-Mixer.c b/epplets/E-Mixer.c
index 4ec699a..109d8e1 100644
--- a/epplets/E-Mixer.c
+++ b/epplets/E-Mixer.c
@@ -22,8 +22,6 @@
  *  */
 
 #include 
-#include 
-#include 
 #include 
 
 #include "config.h"
diff --git a/epplets/E-Net.c b/epplets/E-Net.c
index 67bca67..f07ffc3 100644
--- a/eppl

[EGIT] [e16/e16] master 02/04: Refactor atoms handling

2021-08-27 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=0aa2f07e6bc13366dfdc071706d77cbd1e643f5f

commit 0aa2f07e6bc13366dfdc071706d77cbd1e643f5f
Author: Kim Woelders 
Date:   Sun Aug 22 09:37:31 2021 +0200

Refactor atoms handling

Makes adding/changing atom stuff much easier.
---
 src/Makefile.am |   2 +-
 src/comms.c |  11 +-
 src/desktops.c  |   4 +-
 src/ewmh.c  | 335 
 src/hints.c |  30 ++---
 src/icccm.c |  72 ++--
 src/xprop.c | 251 ++
 src/xprop.h | 159 +++
 src/xpropdefs.h | 185 +++
 9 files changed, 490 insertions(+), 559 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index ee99a583..173291f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -104,7 +104,7 @@ e16_SOURCES = \
util.h  \
warp.c  \
windowmatch.c   windowmatch.h   \
-   xprop.c xprop.h \
+   xprop.c xprop.h  xpropdefs.h\
x.c xwin.h  \
xtypes.h\
$(SRCS_SOUND)   \
diff --git a/src/comms.c b/src/comms.c
index 60dd1895..a67ba47a 100644
--- a/src/comms.c
+++ b/src/comms.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2004-2018 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -155,7 +155,7 @@ ClientCommsGet(Client ** c, XClientMessageEvent * ev)
 
if ((!ev) || (!c))
   return NULL;
-   if (ev->message_type != E16_ATOM_COMMS_MSG)
+   if (ev->message_type != ea_m.ENL_MSG)
   return NULL;
 
s[12] = 0;
@@ -297,8 +297,9 @@ CommsInit(void)
EventCallbackRegister(VROOT, ClientHandleRootEvents, NULL);
 
Esnprintf(s, sizeof(s), "WINID %8x", WinGetXwin(comms_win));
-   ex_window_prop_string_set(WinGetXwin(comms_win), E16_ATOM_COMMS_WIN, s);
-   ex_window_prop_string_set(WinGetXwin(VROOT), E16_ATOM_COMMS_WIN, s);
+   ex_window_prop_string_set(WinGetXwin(comms_win), ea_m.ENLIGHTENMENT_COMMS,
+s);
+   ex_window_prop_string_set(WinGetXwin(VROOT), ea_m.ENLIGHTENMENT_COMMS, s);
 }
 
 static void
@@ -316,7 +317,7 @@ CommsDoSend(EX_Window win, const char *s)
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.window = win;
-   ev.xclient.message_type = E16_ATOM_COMMS_MSG;
+   ev.xclient.message_type = ea_m.ENL_MSG;
ev.xclient.format = 8;
for (i = 0; i < len + 1; i += 12)
  {
diff --git a/src/desktops.c b/src/desktops.c
index ea36f13e..1fdc9597 100644
--- a/src/desktops.c
+++ b/src/desktops.c
@@ -2070,7 +2070,7 @@ DeskPropertyChange(Desk * dsk, XEvent * ev)
 {
EX_Pixmap   pmap;
 
-   if (ev->xproperty.atom == E_XROOTPMAP_ID)
+   if (ev->xproperty.atom == ea_m._XROOTPMAP_ID)
  {
/* Possible race here? */
pmap = HintsGetRootPixmap(EoGetWin(dsk));
@@ -2087,7 +2087,7 @@ DeskPropertyChange(Desk * dsk, XEvent * ev)
Mode.root.ext_pmap_valid = EXDrawableOk(pmap);
DesksBackgroundRefresh(NULL, DESK_BG_REFRESH);
  }
-   else if (ev->xproperty.atom == E_XROOTCOLOR_PIXEL)
+   else if (ev->xproperty.atom == ea_m._XROOTCOLOR_PIXEL)
  {
if (EDebug(EDBUG_TYPE_DESKS))
   Eprintf("%s: win=%#lx _XROOTCOLOR_PIXEL\n", __func__,
diff --git a/src/ewmh.c b/src/ewmh.c
index 01a2dcef..2c89e6f7 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -84,81 +84,81 @@ EWMH_Init(EX_Window win_wm_check)
 
atom_count = 0;
 
-   atom_list[atom_count++] = EX_ATOM_NET_SUPPORTED;
-   atom_list[atom_count++] = EX_ATOM_NET_SUPPORTING_WM_CHECK;
-
-   atom_list[atom_count++] = EX_ATOM_NET_NUMBER_OF_DESKTOPS;
-   atom_list[atom_count++] = EX_ATOM_NET_DESKTOP_GEOMETRY;
-   atom_list[atom_count++] = EX_ATOM_NET_DESKTOP_NAMES;
-   atom_list[atom_count++] = EX_ATOM_NET_CURRENT_DESKTOP;
-   atom_list[atom_count++] = EX_ATOM_NET_DESKTOP_VIEWPORT;
-   atom_list[atom_count++] = EX_ATOM_NET_WORKAREA;
-   atom_list[atom_count++] = EX_ATOM_NET_VIRTUAL_ROOTS;
-   atom_list[atom_count++] = EX_ATOM_NET_SHOWING_DESKTOP;
-
-   atom_list[atom_count++] = EX_ATOM_NET_ACTIVE_WINDOW;
-   atom_list[atom_count++] = EX_ATOM_NET_CLIENT_LIST;
-   atom_list[atom_count++] = EX_ATOM_NET_CLIENT_LIST_STACKING;
-
-   atom_list[atom_count++] = EX_ATOM_NET_CLOSE_WINDOW;
-   atom_list[atom_count++] = EX_ATOM_NET_MOVERESIZE_WINDOW;
-   atom_list[atom_count++] = EX_ATOM_NET_WM_MOVERESIZE;
-
-   atom_list[atom_count++] = EX_ATOM_NET_WM_NAME;
-   atom_list[atom_count++] = EX_ATOM_NET_WM_ICON_NAME;
-   atom_list[atom_count++] =

[EGIT] [e16/e16] master 03/04: Drop initial setting of _NET_WM_NAME = "e16" on the root window

2021-08-27 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=06458b895354ec6296bee86f01a2380d7268287f

commit 06458b895354ec6296bee86f01a2380d7268287f
Author: Kim Woelders 
Date:   Tue Aug 24 10:17:47 2021 +0200

Drop initial setting of _NET_WM_NAME = "e16" on the root window

It is not required and we override it with the desktop name later
anyway.
---
 src/xprop.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/xprop.c b/src/xprop.c
index ca236750..267f4967 100644
--- a/src/xprop.c
+++ b/src/xprop.c
@@ -728,8 +728,6 @@ ex_netwm_wm_identify(EX_Window root, EX_Window check, const 
char *wm_name)
ex_window_prop_window_set(root, ea_n._NET_SUPPORTING_WM_CHECK, , 1);
ex_window_prop_window_set(check, ea_n._NET_SUPPORTING_WM_CHECK, , 1);
_ex_window_prop_string_utf8_set(check, ea_n._NET_WM_NAME, wm_name);
-   /* This one isn't mandatory */
-   _ex_window_prop_string_utf8_set(root, ea_n._NET_WM_NAME, wm_name);
 }
 
 /*

-- 




[EGIT] [e16/e16] master 04/04: Set _NET_WM_PID on WM check window

2021-08-27 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=c464b8bdcb2c02d7182727a463dd79a7aa6d08d3

commit c464b8bdcb2c02d7182727a463dd79a7aa6d08d3
Author: Kim Woelders 
Date:   Tue Aug 24 10:17:47 2021 +0200

Set _NET_WM_PID on WM check window

Shown by utilities like wmctrl and xrestop.
---
 src/xprop.c | 4 
 src/xpropdefs.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/xprop.c b/src/xprop.c
index 267f4967..97d5d844 100644
--- a/src/xprop.c
+++ b/src/xprop.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -725,9 +726,12 @@ ex_netwm_init(void)
 void
 ex_netwm_wm_identify(EX_Window root, EX_Window check, const char *wm_name)
 {
+   unsigned intpid = getpid();
+
ex_window_prop_window_set(root, ea_n._NET_SUPPORTING_WM_CHECK, , 1);
ex_window_prop_window_set(check, ea_n._NET_SUPPORTING_WM_CHECK, , 1);
_ex_window_prop_string_utf8_set(check, ea_n._NET_WM_NAME, wm_name);
+   ex_window_prop_card32_set(check, ea_n._NET_WM_PID, , 1);
 }
 
 /*
diff --git a/src/xpropdefs.h b/src/xpropdefs.h
index f24c85d3..d27cceea 100644
--- a/src/xpropdefs.h
+++ b/src/xpropdefs.h
@@ -148,7 +148,7 @@
notdef_ATOM_NETWM(_NET_WM_ICON_GEOMETRY)/* Not used */
DEFINE_ATOM_NETWM(_NET_WM_ICON)
 
-   notdef_ATOM_NETWM(_NET_WM_PID)  /* Not used */
+   DEFINE_ATOM_NETWM(_NET_WM_PID)
 
notdef_ATOM_NETWM(_NET_WM_HANDLED_ICONS)/* Not used */
 

-- 




[EGIT] [e16/e16] master 01/04: Avoid using "delete"

2021-08-27 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=c4c457d60761f5772a830d7766c44d05d076dda4

commit c4c457d60761f5772a830d7766c44d05d076dda4
Author: Kim Woelders 
Date:   Sat Aug 21 21:15:56 2021 +0200

Avoid using "delete"
---
 lib/e16_hack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/e16_hack.c b/lib/e16_hack.c
index 4809d41e..d5a48c20 100644
--- a/lib/e16_hack.c
+++ b/lib/e16_hack.c
@@ -181,7 +181,7 @@ XSendEvent(Display * display, Window window, Bool propagate,
 typedef int (GWPF) (Display * display, Window w,
Atom property,
long long_offset, long long_length,
-   Bool delete, Atom req_type,
+   Bool delete_, Atom req_type,
Atom * actual_type_return,
int *actual_format_return,
unsigned long *nitems_return,
@@ -190,7 +190,7 @@ typedef int (GWPF) (Display * display, Window w,
 
 __EXPORT__ int
 XGetWindowProperty(Display * display, Window w, Atom property,
-  long long_offset, long long_length, Bool delete,
+  long long_offset, long long_length, Bool delete_,
   Atom req_type, Atom * actual_type_return,
   int *actual_format_return,
   unsigned long *nitems_return,
@@ -205,7 +205,7 @@ XGetWindowProperty(Display * display, Window w, Atom 
property,
if (w == DefaultRootWindow(display))
   w = MyRoot(display);
 
-   return func(display, w, property, long_offset, long_length, delete,
+   return func(display, w, property, long_offset, long_length, delete_,
   req_type, actual_type_return, actual_format_return,
   nitems_return, bytes_after_return, prop_return);
 }

-- 




[EGIT] [e16/e16-epplets] master 03/03: Drop old hint stuff

2021-08-23 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=b0192f91658486d99bb82d19da8c95838879711e

commit b0192f91658486d99bb82d19da8c95838879711e
Author: Kim Woelders 
Date:   Mon Aug 23 14:07:55 2021 +0200

Drop old hint stuff

Has probably been obsolete for more than a decade by now.
---
 api/epplet.c | 21 -
 1 file changed, 21 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 10c8a32..97456dd 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -15,7 +15,6 @@
 
 #define DEBUG_EVENTS 0
 
-#define SET_HINTS_OLD  1
 #define SET_HINTS_EWM  1
 
 #define CRSR_WDTH 2
@@ -437,9 +436,6 @@ Epplet_Init(const char *name, const char *version, const 
char *info,
MWMHintsmwm;
char   *msg;
 
-#if SET_HINTS_OLD
-   unsigned long   val;
-#endif
 #if SET_HINTS_EWM
Atomatom_list[8];
int atom_count;
@@ -533,23 +529,6 @@ Epplet_Init(const char *name, const char *version, const 
char *info,
/* set the icons name property */
XSetIconName(disp, mainwin->win, epplet_name);
 
-#if SET_HINTS_OLD
-   /* set sticky & arrange ignore */
-   val = (1 << 0) /* | (1 << 9) */ ;
-   a = XInternAtom(disp, "_WIN_STATE", False);
-   XChangeProperty(disp, mainwin->win, a, XA_CARDINAL, 32, PropModeReplace,
-  (unsigned char *), 1);
-   /* set the default layer to below */
-   val = 2;
-   a = XInternAtom(disp, "_WIN_LAYER", False);
-   XChangeProperty(disp, mainwin->win, a, XA_CARDINAL, 32, PropModeReplace,
-  (unsigned char *), 1);
-   /* set skip focus, skip winlist dont cover skip taskbar flags */
-   val = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5);
-   a = XInternAtom(disp, "_WIN_HINTS", False);
-   XChangeProperty(disp, mainwin->win, a, XA_CARDINAL, 32, PropModeReplace,
-  (unsigned char *), 1);
-#endif
 #if SET_HINTS_EWM
a = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
atom_count = 0;

-- 




[EGIT] [e16/e16-epplets] master 02/03: Drop obsolete AC_HEADER_SYS_WAIT

2021-08-23 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=c0fb5577000c780546bcbe52d03abd9f42d77e96

commit c0fb5577000c780546bcbe52d03abd9f42d77e96
Author: Kim Woelders 
Date:   Mon Aug 23 14:19:04 2021 +0200

Drop obsolete AC_HEADER_SYS_WAIT
---
 configure.ac | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 3b3cebd..40b63a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,6 @@ EC_C_VISIBILITY(yes)
 AC_PATH_XTRA
 
 dnl# Checks for header files.
-AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(unistd.h time.h math.h pwd.h sys/types.h varargs.h stdarg.h)
 
 dnl# Missing typedefs and replacements

-- 




[EGIT] [e16/e16-epplets] master 01/03: Eliminate obsolete AC_HEADER_TIME

2021-08-23 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16-epplets.git/commit/?id=901f4af6995a7333ce31f17a3b10f3aa96b1daa6

commit 901f4af6995a7333ce31f17a3b10f3aa96b1daa6
Author: Kim Woelders 
Date:   Fri Mar 26 16:15:46 2021 +0100

Eliminate obsolete AC_HEADER_TIME
---
 api/epplet.c | 1 +
 api/epplet.h.in  | 4 
 configure.ac | 1 -
 epplets/E-NetGraph.c | 1 +
 4 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/api/epplet.c b/api/epplet.c
index 4866bd0..10c8a32 100644
--- a/api/epplet.c
+++ b/api/epplet.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/api/epplet.h.in b/api/epplet.h.in
index cef0c5f..e8b5a94 100644
--- a/api/epplet.h.in
+++ b/api/epplet.h.in
@@ -27,10 +27,6 @@
 #include 
 #include 
 
-#ifdef TIME_WITH_SYS_TIME
-#include 
-#endif
-
 #ifdef HAVE_GLX
 #include 
 #endif
diff --git a/configure.ac b/configure.ac
index c310bf1..3b3cebd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,6 @@ AC_PATH_XTRA
 dnl# Checks for header files.
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(unistd.h time.h math.h pwd.h sys/types.h varargs.h stdarg.h)
-AC_HEADER_TIME
 
 dnl# Missing typedefs and replacements
 AC_TYPE_MODE_T
diff --git a/epplets/E-NetGraph.c b/epplets/E-NetGraph.c
index d37651f..4d94027 100644
--- a/epplets/E-NetGraph.c
+++ b/epplets/E-NetGraph.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 #include "config.h"
 #include "epplet.h"

-- 




[EGIT] [e16/e16] master 04/09: Shuffle some property stuff around

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=204999090e25aa25a0c430f3f9fe3bd7038594ca

commit 204999090e25aa25a0c430f3f9fe3bd7038594ca
Author: Kim Woelders 
Date:   Sat Aug 21 15:18:15 2021 +0200

Shuffle some property stuff around

Just somewhat cleaner.
---
 src/desktops.c |  1 +
 src/hints.c| 25 +
 src/hints.h| 22 +-
 src/xprop.c| 56 
 src/xprop.h| 31 ++-
 5 files changed, 69 insertions(+), 66 deletions(-)

diff --git a/src/desktops.c b/src/desktops.c
index effd0823..ea36f13e 100644
--- a/src/desktops.c
+++ b/src/desktops.c
@@ -50,6 +50,7 @@
 #include "slide.h"
 #include "timers.h"
 #include "tooltips.h"
+#include "xprop.h"
 #include "xwin.h"
 
 #define DESK_EVENT_MASK1 \
diff --git a/src/hints.c b/src/hints.c
index d350b5e8..3315c5cc 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -40,28 +40,6 @@
 static void EHintsSetDeskInfo(void);
 static void EHintsSetAreaInfo(void);
 
-static const char  *const atoms_misc_names[] = {
-   /* Misc atoms */
-   "MANAGER",
-
-   /* Root background atoms */
-   "_XROOTPMAP_ID",
-   "_XROOTCOLOR_PIXEL",
-
-   /* E16 atoms */
-   "ENLIGHTENMENT_VERSION",
-
-   "ENLIGHTENMENT_COMMS",
-   "ENL_MSG",
-
-   "ENL_INTERNAL_AREA_DATA",
-   "ENL_INTERNAL_DESK_DATA",
-   "ENL_WIN_DATA",
-   "ENL_WIN_BORDER"
-};
-
-EX_Atom atoms_misc[10];
-
 static unsigned int desk_info = 0;
 
 void
@@ -69,11 +47,10 @@ HintsInit(void)
 {
EX_Window   win;
 
-   ex_atoms_get(atoms_misc_names, E_ARRAY_SIZE(atoms_misc_names), atoms_misc);
-
win = XCreateSimpleWindow(disp, WinGetXwin(VROOT), -200, -200, 5, 5,
 0, 0, 0);
 
+   ex_atoms_init();
ICCCM_Init();
MWM_SetInfo();
 #if ENABLE_GNOME
diff --git a/src/hints.h b/src/hints.h
index 79e6f8c4..0c5b5b24 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2004-2020 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -25,28 +25,8 @@
 #define _HINTS_H_
 
 #include "etypes.h"
-#include "xprop.h"
 #include "xwin.h"
 
-/* Misc atoms */
-
-extern EX_Atom  atoms_misc[];
-
-#define E_XA_MANAGER   atoms_misc[0]
-
-#define E_XROOTPMAP_ID atoms_misc[1]
-#define E_XROOTCOLOR_PIXEL atoms_misc[2]
-
-#define E16_ATOM_VERSION   atoms_misc[3]
-
-#define E16_ATOM_COMMS_WIN atoms_misc[4]
-#define E16_ATOM_COMMS_MSG atoms_misc[5]
-
-#define E16_ATOM_INTERNAL_AREA_DATAatoms_misc[6]
-#define E16_ATOM_INTERNAL_DESK_DATAatoms_misc[7]
-#define E16_ATOM_WIN_DATA  atoms_misc[8]
-#define E16_ATOM_WIN_BORDERatoms_misc[9]
-
 /* ewmh.c */
 voidEWMH_Init(EX_Window win_wm_check);
 voidEWMH_SetDesktopCount(void);
diff --git a/src/xprop.c b/src/xprop.c
index cc754ac6..6fdb86b0 100644
--- a/src/xprop.c
+++ b/src/xprop.c
@@ -350,7 +350,7 @@ ex_window_prop_string_get(EX_Window win, EX_Atom atom)
 static void
 _ex_window_prop_string_utf8_set(EX_Window win, EX_Atom atom, const char *str)
 {
-   XChangeProperty(_ex_disp, win, atom, EX_ATOM_UTF8_STRING, 8,
+   XChangeProperty(_ex_disp, win, atom, E_XA_UTF8_STRING, 8,
   PropModeReplace, (unsigned char *)str, strlen(str));
 }
 
@@ -369,7 +369,7 @@ _ex_window_prop_string_utf8_get(EX_Window win, EX_Atom atom)
str = NULL;
prop_ret = NULL;
XGetWindowProperty(_ex_disp, win, atom, 0, 0x7fff, False,
- EX_ATOM_UTF8_STRING, _ret,
+ E_XA_UTF8_STRING, _ret,
  _ret, _ret, _after, _ret);
if (prop_ret && num_ret > 0 && format_ret == 8)
  {
@@ -567,13 +567,46 @@ ex_window_prop_window_list_get(EX_Window win, EX_Atom 
atom, EX_Window ** plst)
return ex_window_prop_xid_list_get(win, atom, XA_WINDOW, plst);
 }
 
+/*
+ * Misc atom stuff
+ */
+
+static const char  *const atoms_misc_names[] = {
+   /* Misc atoms */
+   "UTF8_STRING",
+   "MANAGER",
+
+   /* Root background atoms */
+   "_XROOTPMAP_ID",
+   "_XROOTCOLOR_PIXEL",
+
+   /* E16 atoms */
+   "ENLIGHTENMENT_VERSION",
+
+   "ENLIGHTENMENT_COMMS",
+   "ENL_MSG",
+
+   "ENL_INTERNAL_AREA_DATA",
+   "ENL_INTERNAL_DESK_DATA",
+   "ENL_WIN_DATA",
+   "ENL_WIN_BORDER",
+};
+EX_Atom atoms_mi

[EGIT] [e16/e16] master 02/09: libhack: Add XGetWindowProperty interception

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=d3bb5e171f6331b1cd9163406f453ff54fdf910b

commit d3bb5e171f6331b1cd9163406f453ff54fdf910b
Author: Kim Woelders 
Date:   Thu Aug 19 10:15:38 2021 +0200

libhack: Add XGetWindowProperty interception
---
 lib/e16_hack.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/lib/e16_hack.c b/lib/e16_hack.c
index 7c63736c..4809d41e 100644
--- a/lib/e16_hack.c
+++ b/lib/e16_hack.c
@@ -173,3 +173,39 @@ XSendEvent(Display * display, Window window, Bool 
propagate,
 
return (*func) (display, window, propagate, event_mask, event_send);
 }
+
+/*
+ * XGetWindowProperty interception
+ */
+
+typedef int (GWPF) (Display * display, Window w,
+   Atom property,
+   long long_offset, long long_length,
+   Bool delete, Atom req_type,
+   Atom * actual_type_return,
+   int *actual_format_return,
+   unsigned long *nitems_return,
+   unsigned long *bytes_after_return,
+   unsigned char **prop_return);
+
+__EXPORT__ int
+XGetWindowProperty(Display * display, Window w, Atom property,
+  long long_offset, long long_length, Bool delete,
+  Atom req_type, Atom * actual_type_return,
+  int *actual_format_return,
+  unsigned long *nitems_return,
+  unsigned long *bytes_after_return,
+  unsigned char **prop_return)
+{
+   static GWPF*func = NULL;
+
+   if (!func)
+  func = (GWPF *) GetFunc("XGetWindowProperty");
+
+   if (w == DefaultRootWindow(display))
+  w = MyRoot(display);
+
+   return func(display, w, property, long_offset, long_length, delete,
+  req_type, actual_type_return, actual_format_return,
+  nitems_return, bytes_after_return, prop_return);
+}

-- 




[EGIT] [e16/e16] master 05/09: xprop.c: Do some sanity checks using static asserts if possible

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=206839b33b4c9760c4336adf62ce9924be042de5

commit 206839b33b4c9760c4336adf62ce9924be042de5
Author: Kim Woelders 
Date:   Sat Aug 21 16:57:40 2021 +0200

xprop.c: Do some sanity checks using static asserts if possible
---
 src/xprop.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/xprop.c b/src/xprop.c
index 6fdb86b0..801ecf28 100644
--- a/src/xprop.c
+++ b/src/xprop.c
@@ -34,13 +34,15 @@
 #define EX_PROP_LIST_ADD   1
 #define EX_PROP_LIST_TOGGLE2
 
-#define DEBUG_CHECK 0
-#if DEBUG_CHECK
-#include 
-#endif
 #include "xprop.h"
 #include "xwin.h"
 
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201112L
+#define E_STATIC_ASSERT(...)   _Static_assert(__VA_ARGS__)
+#else
+#define E_STATIC_ASSERT(...)
+#endif
+
 #define _ex_disp disp
 
 /*
@@ -593,12 +595,11 @@ static const char  *const atoms_misc_names[] = {
 };
 EX_Atom atoms_misc[E_ARRAY_SIZE(atoms_misc_names)];
 
+E_STATIC_ASSERT(CHECK_COUNT_MISC == E_ARRAY_SIZE(atoms_misc));
+
 void
 ex_atoms_init(void)
 {
-#if DEBUG_CHECK
-   assert(CHECK_COUNT_MISC == E_ARRAY_SIZE(atoms_misc));
-#endif
ex_atoms_get(atoms_misc_names, E_ARRAY_SIZE(atoms_misc), atoms_misc);
 }
 
@@ -622,12 +623,11 @@ static const char  *const atoms_icccm_names[] = {
 };
 EX_Atom atoms_icccm[E_ARRAY_SIZE(atoms_icccm_names)];
 
+E_STATIC_ASSERT(CHECK_COUNT_ICCCM == E_ARRAY_SIZE(atoms_icccm));
+
 void
 ex_icccm_init(void)
 {
-#if DEBUG_CHECK
-   assert(CHECK_COUNT_ICCCM == E_ARRAY_SIZE(atoms_icccm));
-#endif
ex_atoms_get(atoms_icccm_names, E_ARRAY_SIZE(atoms_icccm), atoms_icccm);
 }
 
@@ -840,12 +840,11 @@ static const char  *const atoms_netwm_names[] = {
 };
 EX_Atom atoms_netwm[E_ARRAY_SIZE(atoms_netwm_names)];
 
+E_STATIC_ASSERT(CHECK_COUNT_NETWM == E_ARRAY_SIZE(atoms_netwm));
+
 void
 ex_netwm_init(void)
 {
-#if DEBUG_CHECK
-   assert(CHECK_COUNT_NETWM == E_ARRAY_SIZE(atoms_netwm));
-#endif
ex_atoms_get(atoms_netwm_names, E_ARRAY_SIZE(atoms_netwm), atoms_netwm);
 }
 

-- 




[EGIT] [e16/e16] master 08/09: Support _NET_WM_STATE_FOCUSED

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=0d6bdb4272fb5be6abb54e7b45d6303ddecc9a85

commit 0d6bdb4272fb5be6abb54e7b45d6303ddecc9a85
Author: Kim Woelders 
Date:   Thu Aug 19 08:28:41 2021 +0200

Support _NET_WM_STATE_FOCUSED

GTK apps apparently use this.
---
 src/ewmh.c  | 2 ++
 src/focus.c | 7 +++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/ewmh.c b/src/ewmh.c
index 37aeb335..01a2dcef 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -131,6 +131,7 @@ EWMH_Init(EX_Window win_wm_check)
atom_list[atom_count++] = EX_ATOM_NET_WM_STATE_ABOVE;
atom_list[atom_count++] = EX_ATOM_NET_WM_STATE_BELOW;
atom_list[atom_count++] = EX_ATOM_NET_WM_STATE_DEMANDS_ATTENTION;
+   atom_list[atom_count++] = EX_ATOM_NET_WM_STATE_FOCUSED;
 
atom_list[atom_count++] = EX_ATOM_NET_WM_ALLOWED_ACTIONS;
atom_list[atom_count++] = EX_ATOM_NET_WM_ACTION_MOVE;
@@ -383,6 +384,7 @@ EWMH_SetWindowState(const EWin * ewin)
ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_ABOVE, EoGetLayer(ewin) >= 6);
ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_BELOW, EoGetLayer(ewin) <= 2);
ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_DEMANDS_ATTENTION, ewin->state.attention);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_FOCUSED, ewin->state.active);
 
if (ewin->ewmh.current_state == atom_mask)
   return;
diff --git a/src/focus.c b/src/focus.c
index d270af10..7dff4c03 100644
--- a/src/focus.c
+++ b/src/focus.c
@@ -329,10 +329,9 @@ FocusEwinSetActive(EWin * ewin, int active)
EwinUpdateOpacity(ewin);
 
if (active && ewin->state.attention)
- {
-   ewin->state.attention = 0;
-   HintsSetWindowState(ewin);
- }
+  ewin->state.attention = 0;
+
+   HintsSetWindowState(ewin);
 }
 
 static void

-- 




[EGIT] [e16/e16] master 07/09: Add _NET_WM_STATE_FOCUSED to the EWHM atoms

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=8f9a57fb10f684b85807bdfe71ee37e00fb6a914

commit 8f9a57fb10f684b85807bdfe71ee37e00fb6a914
Author: Kim Woelders 
Date:   Thu Aug 19 08:28:41 2021 +0200

Add _NET_WM_STATE_FOCUSED to the EWHM atoms
---
 src/xprop.c |  1 +
 src/xprop.h | 61 +++--
 2 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/src/xprop.c b/src/xprop.c
index 801ecf28..e39539e4 100644
--- a/src/xprop.c
+++ b/src/xprop.c
@@ -786,6 +786,7 @@ static const char  *const atoms_netwm_names[] = {
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_BELOW",
"_NET_WM_STATE_DEMANDS_ATTENTION",
+   "_NET_WM_STATE_FOCUSED",
 
"_NET_WM_ALLOWED_ACTIONS",
"_NET_WM_ACTION_MOVE",
diff --git a/src/xprop.h b/src/xprop.h
index 8fbd5d63..0fd94a88 100644
--- a/src/xprop.h
+++ b/src/xprop.h
@@ -190,30 +190,31 @@ extern EX_Atom  atoms_netwm[];
 #define EX_ATOM_NET_WM_STATE_ABOVE atoms_netwm[37]
 #define EX_ATOM_NET_WM_STATE_BELOW atoms_netwm[38]
 #define EX_ATOM_NET_WM_STATE_DEMANDS_ATTENTION atoms_netwm[39]
+#define EX_ATOM_NET_WM_STATE_FOCUSED   atoms_netwm[40]
 
-#define EX_ATOM_NET_WM_ALLOWED_ACTIONS atoms_netwm[40]
-#define EX_ATOM_NET_WM_ACTION_MOVE atoms_netwm[41]
-#define EX_ATOM_NET_WM_ACTION_RESIZE   atoms_netwm[42]
-#define EX_ATOM_NET_WM_ACTION_MINIMIZE atoms_netwm[43]
-#define EX_ATOM_NET_WM_ACTION_SHADEatoms_netwm[44]
-#define EX_ATOM_NET_WM_ACTION_STICKatoms_netwm[45]
-#define EX_ATOM_NET_WM_ACTION_MAXIMIZE_HORZatoms_netwm[46]
-#define EX_ATOM_NET_WM_ACTION_MAXIMIZE_VERTatoms_netwm[47]
-#define EX_ATOM_NET_WM_ACTION_FULLSCREEN   atoms_netwm[48]
-#define EX_ATOM_NET_WM_ACTION_CHANGE_DESKTOP   atoms_netwm[49]
-#define EX_ATOM_NET_WM_ACTION_CLOSEatoms_netwm[50]
-#define EX_ATOM_NET_WM_ACTION_ABOVEatoms_netwm[51]
-#define EX_ATOM_NET_WM_ACTION_BELOWatoms_netwm[52]
+#define EX_ATOM_NET_WM_ALLOWED_ACTIONS atoms_netwm[41]
+#define EX_ATOM_NET_WM_ACTION_MOVE atoms_netwm[42]
+#define EX_ATOM_NET_WM_ACTION_RESIZE   atoms_netwm[43]
+#define EX_ATOM_NET_WM_ACTION_MINIMIZE atoms_netwm[44]
+#define EX_ATOM_NET_WM_ACTION_SHADEatoms_netwm[45]
+#define EX_ATOM_NET_WM_ACTION_STICKatoms_netwm[46]
+#define EX_ATOM_NET_WM_ACTION_MAXIMIZE_HORZatoms_netwm[47]
+#define EX_ATOM_NET_WM_ACTION_MAXIMIZE_VERTatoms_netwm[48]
+#define EX_ATOM_NET_WM_ACTION_FULLSCREEN   atoms_netwm[49]
+#define EX_ATOM_NET_WM_ACTION_CHANGE_DESKTOP   atoms_netwm[50]
+#define EX_ATOM_NET_WM_ACTION_CLOSEatoms_netwm[51]
+#define EX_ATOM_NET_WM_ACTION_ABOVEatoms_netwm[52]
+#define EX_ATOM_NET_WM_ACTION_BELOWatoms_netwm[53]
 
-#define EX_ATOM_NET_WM_STRUT   atoms_netwm[53]
-#define EX_ATOM_NET_WM_STRUT_PARTIAL   atoms_netwm[54]
+#define EX_ATOM_NET_WM_STRUT   atoms_netwm[54]
+#define EX_ATOM_NET_WM_STRUT_PARTIAL   atoms_netwm[55]
 
-#define EX_ATOM_NET_FRAME_EXTENTS  atoms_netwm[55]
+#define EX_ATOM_NET_FRAME_EXTENTS  atoms_netwm[56]
 
-#define EX_ATOM_NET_WM_ICONatoms_netwm[56]
+#define EX_ATOM_NET_WM_ICONatoms_netwm[57]
 
-#define EX_ATOM_NET_WM_USER_TIME   atoms_netwm[57]
-#define EX_ATOM_NET_WM_USER_TIME_WINDOWatoms_netwm[58]
+#define EX_ATOM_NET_WM_USER_TIME   atoms_netwm[58]
+#define EX_ATOM_NET_WM_USER_TIME_WINDOWatoms_netwm[59]
 
 #if 0  /* Not used */
 #define EX_ATOM_NET_WM_ICON_GEOMETRY   atoms_netwm[0]
@@ -222,27 +223,27 @@ extern EX_Atom  atoms_netwm[];
 
 #define EX_ATOM_NET_WM_PINGatoms_netwm[0]
 #endif
-#define EX_ATOM_NET_WM_SYNC_REQUESTatoms_netwm[59]
-#define EX_ATOM_NET_WM_SYNC_REQUEST_COUNTERatoms_netwm[60]
+#define EX_ATOM_NET_WM_SYNC_REQUESTatoms_netwm[60]
+#define EX_ATOM_NET_WM_SYNC_REQUEST_COUNTERatoms_netwm[61]
 
-#define EX_ATOM_NET_WM_WINDOW_OPACITY  atoms_netwm[61]
+#define EX_ATOM_NET_WM_WINDOW_OPACITY  atoms_netwm[62]
 
 /* Misc window ops */
-#define EX_ATOM_NET_CLOSE_WINDOW   atoms_netwm[62]
-#define EX_ATOM_NET_MOVERESIZE_WINDOW  atoms_netwm[63]
-#define EX_ATOM_NET_WM_MOVERESIZE  atoms_netwm[64]
-#define EX_ATOM_NET_RESTACK_WINDOW atoms_netwm[65]
+#define EX_ATOM_NET_CLOSE_WINDOW   atoms_netwm[63]
+#define EX_ATOM_NET_MOVERESIZE_WINDOW  atoms_netwm[64]
+#define EX_ATOM_NET_WM_MOVERESIZE  atoms_netwm[65]
+#define EX_ATOM_NET_RESTACK_WINDOW atoms_netwm[66]
 
 #if 0  /* Not yet implemented */
 #define EX_ATOM_NET_REQ

[EGIT] [e16/e16] master 01/09: libhack: Cosmetics

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=a2463cfdf3195cbdbfc7655bed56e23e1feb6ac6

commit a2463cfdf3195cbdbfc7655bed56e23e1feb6ac6
Author: Kim Woelders 
Date:   Thu Aug 19 10:18:49 2021 +0200

libhack: Cosmetics
---
 lib/e16_hack.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/e16_hack.c b/lib/e16_hack.c
index b7cc5523..7c63736c 100644
--- a/lib/e16_hack.c
+++ b/lib/e16_hack.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2005-2007 Carsten Haitzler
- * Copyright (C) 2006-2020 Kim Woelders
+ * Copyright (C) 2006-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -71,6 +71,10 @@ GetFunc(const char *name)
return func;
 }
 
+/*
+ * XCreateWindow interception
+ */
+
 typedef Window(CWF) (Display * _display, Window _parent, int _x,
 int _y, unsigned int _width,
 unsigned int _height,
@@ -79,7 +83,6 @@ typedef Window(CWF) (Display * _display, Window 
_parent, int _x,
 unsigned long _valuemask,
 XSetWindowAttributes * _attributes);
 
-/* XCreateWindow intercept hack */
 __EXPORT__  Window
 XCreateWindow(Display * display, Window parent, int x, int y,
  unsigned int width, unsigned int height,
@@ -99,6 +102,10 @@ XCreateWindow(Display * display, Window parent, int x, int 
y,
   clss, visual, valuemask, attributes);
 }
 
+/*
+ * XCreateSimpleWindow interception
+ */
+
 typedef Window(CSWF) (Display * _display, Window _parent, int _x,
  int _y, unsigned int _width,
  unsigned int _height,
@@ -106,7 +113,6 @@ typedef Window(CSWF) (Display * _display, 
Window _parent, int _x,
  unsigned long _border,
  unsigned long _background);
 
-/* XCreateSimpleWindow intercept hack */
 __EXPORT__  Window
 XCreateSimpleWindow(Display * display, Window parent, int x, int y,
unsigned int width, unsigned int height,
@@ -125,10 +131,13 @@ XCreateSimpleWindow(Display * display, Window parent, int 
x, int y,
   border_width, border, background);
 }
 
+/*
+ * XReparentWindow interception
+ */
+
 typedef int (RWF) (Display * _display, Window _window, Window _parent,
   int x, int y);
 
-/* XReparentWindow intercept hack */
 __EXPORT__ int
 XReparentWindow(Display * display, Window window, Window parent, int x, int y)
 {
@@ -143,10 +152,13 @@ XReparentWindow(Display * display, Window window, Window 
parent, int x, int y)
return (*func) (display, window, parent, x, y);
 }
 
+/*
+ * XSendEvent interception
+ */
+
 typedef int (SEF) (Display * display, Window window, Bool propagate,
   long event_mask, XEvent * event_send);
 
-/* XSendEvent intercept hack */
 __EXPORT__ int
 XSendEvent(Display * display, Window window, Bool propagate,
   long event_mask, XEvent * event_send)

-- 




[EGIT] [e16/e16] master 03/09: session.c: Remove unused headers

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=6c173cc65e2148ad543c2f6386f9a841402b6b32

commit 6c173cc65e2148ad543c2f6386f9a841402b6b32
Author: Kim Woelders 
Date:   Sat Aug 21 14:04:06 2021 +0200

session.c: Remove unused headers
---
 src/session.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/session.c b/src/session.c
index 3e911433..e6844451 100644
--- a/src/session.c
+++ b/src/session.c
@@ -26,14 +26,10 @@
 #include "emodule.h"
 #include "events.h"
 #include "ewins.h"
-#include "hints.h"
 #include "session.h"
 #include "settings.h"
 #include "snaps.h"
 #include "user.h"
-#if 0  /* Unused */
-#include "xprop.h"
-#endif
 #include "xwin.h"
 
 #ifdef USE_EXT_INIT_WIN

-- 




[EGIT] [e16/e16] master 06/09: Only update _NET_WM_STATE and _NET_WM_ALLOWED_ACTIONS when changed

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=2c01d2e1a4ed0b5739c45fde7d96bd5681dbc59b

commit 2c01d2e1a4ed0b5739c45fde7d96bd5681dbc59b
Author: Kim Woelders 
Date:   Thu Aug 19 14:21:16 2021 +0200

Only update _NET_WM_STATE and _NET_WM_ALLOWED_ACTIONS when changed

Avoids some hint noise.
---
 src/ewins.h |   2 +
 src/ewmh.c  | 145 
 2 files changed, 60 insertions(+), 87 deletions(-)

diff --git a/src/ewins.h b/src/ewins.h
index e96258a4..8ec49d61 100644
--- a/src/ewins.h
+++ b/src/ewins.h
@@ -232,6 +232,8 @@ struct _ewin {
unsignednormal:1;
 } b;
   } type;
+  unsigned intcurrent_state;
+  unsigned intcurrent_actions;
} ewmh;
struct {
   signed char gravity;
diff --git a/src/ewmh.c b/src/ewmh.c
index f407d283..37aeb335 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -34,6 +34,15 @@
 #include "hints.h"
 #include "xprop.h"
 
+#define ATOM_ADD_IF(atom, cond) \
+do { \
+if (cond) { \
+atom_list[atom_count++] = atom; \
+   atom_mask |= 1U << atom_bit; \
+} \
+atom_bit++; \
+} while(0)
+
 /*
  * _NET_WM_MOVERESIZE client message actions
  */
@@ -62,37 +71,6 @@
 
 #define OPSRC(src) (((src) == _NET_WM_SOURCE_USER) ? _NET_WM_SOURCE_USER : 
_NET_WM_SOURCE_APP)
 
-/*
- * Set/clear Atom in list
- */
-static void
-atom_list_set(EX_Atom * atoms, int size, int *count, EX_Atom atom, int set)
-{
-   int i, n, in_list;
-
-   n = *count;
-
-   /* Check if atom is in list or not (+get index) */
-   for (i = 0; i < n; i++)
-  if (atoms[i] == atom)
-break;
-   in_list = i < n;
-
-   if (set && !in_list)
- {
-   /* Add it (if space left) */
-   if (n < size)
-  atoms[n++] = atom;
-   *count = n;
- }
-   else if (!set && in_list)
- {
-   /* Remove it */
-   atoms[i] = atoms[--n];
-   *count = n;
- }
-}
-
 /*
  * Initialize EWMH stuff
  */
@@ -385,37 +363,30 @@ EWMH_SetWindowDesktop(const EWin * ewin)
 void
 EWMH_SetWindowState(const EWin * ewin)
 {
-   EX_Atom atom_list[64];
-   int len = E_ARRAY_SIZE(atom_list);
+   EX_Atom atom_list[16];
int atom_count;
+   unsigned intatom_mask, atom_bit;
 
atom_count = 0;
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_MODAL,
-ewin->state.modal);
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_STICKY,
-EoIsSticky(ewin));
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_SHADED,
-ewin->state.shaded);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_SKIP_TASKBAR, ewin->props.skip_ext_task);
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_HIDDEN,
-ewin->state.iconified || ewin->state.shaded);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_MAXIMIZED_VERT,
-ewin->state.maximized_vert);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_MAXIMIZED_HORZ,
-ewin->state.maximized_horz);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_FULLSCREEN, ewin->state.fullscreen);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_SKIP_PAGER, ewin->props.skip_ext_pager);
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_ABOVE,
-EoGetLayer(ewin) >= 6);
-   atom_list_set(atom_list, len, _count, EX_ATOM_NET_WM_STATE_BELOW,
-EoGetLayer(ewin) <= 2);
-   atom_list_set(atom_list, len, _count,
-EX_ATOM_NET_WM_STATE_DEMANDS_ATTENTION, ewin->state.attention);
+   atom_mask = atom_bit = 0;
+
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_MODAL, ewin->state.modal);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_STICKY, EoIsSticky(ewin));
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_SHADED, ewin->state.shaded);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_SKIP_TASKBAR, ewin->props.skip_ext_task);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_HIDDEN,
+  ewin->state.iconified || ewin->state.shaded);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_MAXIMIZED_VERT, 
ewin->state.maximized_vert);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_MAXIMIZED_HORZ, 
ewin->state.maximized_horz);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_FULLSCREEN, ewin->state.fullscreen);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_SKIP_PAGER, ewin->props.skip_ext_pager);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_ABOVE, EoGetLayer(ewin) >= 6);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_BELOW, EoGetLayer(ewin) <= 2);
+   ATOM_ADD_IF(EX_ATOM_NET_WM_STATE_DEMANDS_ATTENTION, ewin->state.attention);
+
+   if (ewin->ewmh.current_state == atom_

[EGIT] [e16/e16] master 09/09: COMPLIANCE: Update

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=721656447c3ab4c4159cccf8622d8cc891a7f5ec

commit 721656447c3ab4c4159cccf8622d8cc891a7f5ec
Author: Kim Woelders 
Date:   Sat Aug 21 13:44:57 2021 +0200

COMPLIANCE: Update
---
 COMPLIANCE | 13 +
 1 file changed, 13 insertions(+)

diff --git a/COMPLIANCE b/COMPLIANCE
index 5c3a3a8e..729c94a6 100644
--- a/COMPLIANCE
+++ b/COMPLIANCE
@@ -69,6 +69,14 @@ Application Window Properties
 [/] _NET_WM_WINDOW_TYPE_SPLASH
 [/] _NET_WM_WINDOW_TYPE_DIALOG
 [/] _NET_WM_WINDOW_TYPE_NORMAL
+New window types to be used on override-redirect windows
+
+[ ] _NET_WM_WINDOW_TYPE_DROPDOWN_MENU
+[ ] _NET_WM_WINDOW_TYPE_POPUP_MENU
+[ ] _NET_WM_WINDOW_TYPE_TOOLTIP
+[ ] _NET_WM_WINDOW_TYPE_NOTIFICATION
+[ ] _NET_WM_WINDOW_TYPE_COMBO
+[ ] _NET_WM_WINDOW_TYPE_DND
 [/] _NET_WM_STATE
 [ ] _NET_WM_STATE_MODAL
 [+] _NET_WM_STATE_STICKY
@@ -82,6 +90,7 @@ Application Window Properties
 [+] _NET_WM_STATE_ABOVE
 [+] _NET_WM_STATE_BELOW
 [+] _NET_WM_STATE_DEMANDS_ATTENTION
+[+] _NET_WM_STATE_FOCUSED
 [+] _NET_WM_ALLOWED_ACTIONS
 [+] _NET_WM_ACTION_MOVE
 [+] _NET_WM_ACTION_RESIZE
@@ -105,12 +114,15 @@ Application Window Properties
 [/] _NET_WM_USER_TIME
 [/] _NET_WM_USER_TIME_WINDOW
 [+] _NET_FRAME_EXTENTS
+[ ] _NET_WM_OPAQUE_REGION
+[ ] _NET_WM_BYPASS_COMPOSITOR
 
 Window Manager Protocols
 
 [ ] _NET_WM_PING
 [+] _NET_WM_SYNC_REQUEST
 [+] _NET_WM_SYNC_REQUEST_COUNTER
+[ ] _NET_WM_FULLSCREEN_MONITORS
 
 Other Properties
 
@@ -119,6 +131,7 @@ Other Properties
 Compositing Managers
 
 [+] _NET_WM_CM_Sn
+[ ] WM_TRANSIENT_FOR for override-redirect windows
 
 
 GNOME Compliance (_WIN_... hints)

-- 




[EGIT] [legacy/imlib2] master 01/01: imlib2_view: Fix issue with new default scaling

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=3a4d6d4590f4543267273136999bfb29cb551abe

commit 3a4d6d4590f4543267273136999bfb29cb551abe
Author: Kim Woelders 
Date:   Sat Aug 21 11:56:43 2021 +0200

imlib2_view: Fix issue with new default scaling

Need to distinguish between scaling option value and applied scaling
when viewing multiple images.
---
 src/bin/imlib2_view.c | 37 +
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 51319ad..333faa7 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -18,13 +18,14 @@ static Pixmap   pm = 0;
 static int  depth;
 static int  image_width = 0, image_height = 0;
 static int  window_width = 0, window_height = 0;
-static char scale = 0;
-static double   scale_x = 1.;
-static double   scale_y = 1.;
 static Imlib_Image  bg_im = NULL;
-static char progress_granularity = 10;
-static char progress_print = 0;
-static int  progress_delay = 0;
+
+static char opt_scale = 0;
+static double   opt_scale_x = 1.;
+static double   opt_scale_y = 1.;
+static char opt_progress_granularity = 10;
+static char opt_progress_print = 0;
+static int  opt_progress_delay = 0;
 
 #define Dprintf if (debug) printf
 #define Vprintf if (verbose) printf
@@ -55,9 +56,10 @@ static int
 progress(Imlib_Image im, char percent, int update_x, int update_y,
  int update_w, int update_h)
 {
+   static double   scale_x = 0., scale_y = 0.;
int up_wx, up_wy, up_ww, up_wh;
 
-   if (progress_print)
+   if (opt_progress_print)
   printf("%s: %3d%% %4d,%4d %4dx%4d\n",
  __func__, percent, update_x, update_y, update_w, update_h);
 
@@ -70,6 +72,9 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
  {
 int x, y, onoff;
 
+scale_x = opt_scale_x;
+scale_y = opt_scale_y;
+
 window_width = DisplayWidth(disp, DefaultScreen(disp));
 window_height = DisplayHeight(disp, DefaultScreen(disp));
 window_width -= 32; /* Allow for decorations */
@@ -81,7 +86,7 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
 image_height = imlib_image_get_height();
 Dprintf("Image  WxH=%dx%d\n", image_width, image_height);
 
-if (!scale &&
+if (!opt_scale &&
 (image_width > window_width || image_height > window_height))
   {
  scale_x = scale_y = 1.;
@@ -163,8 +168,8 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
XClearArea(disp, win, up_wx, up_wy, up_ww, up_wh, False);
XFlush(disp);
 
-   if (progress_delay > 0)
-  usleep(progress_delay);
+   if (opt_progress_delay > 0)
+  usleep(opt_progress_delay);
 
return 1;
 }
@@ -188,17 +193,17 @@ main(int argc, char **argv)
  debug += 1;
  break;
   case 'g':
- progress_granularity = atoi(optarg);
+ opt_progress_granularity = atoi(optarg);
  break;
   case 'l':
- progress_delay = 1000 * atoi(optarg);
+ opt_progress_delay = 1000 * atoi(optarg);
  break;
   case 'p':
- progress_print = 1;
+ opt_progress_print = 1;
  break;
   case 's':/* Scale (window size wrt. image size) */
- scale = 1;
- scale_x = scale_y = atof(optarg);
+ opt_scale = 1;
+ opt_scale_x = opt_scale_y = atof(optarg);
  break;
   case 'v':
  verbose += 1;
@@ -238,7 +243,7 @@ main(int argc, char **argv)
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
imlib_context_set_progress_function(progress);
-   imlib_context_set_progress_granularity(progress_granularity);
+   imlib_context_set_progress_granularity(opt_progress_granularity);
imlib_context_set_drawable(win);
 
no = -1;

-- 




[EGIT] [legacy/imlib2] master 04/04: imlib2_view: Add some debug

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=ecc7a342ff11c6d5e559d712de6a319023a8ae95

commit ecc7a342ff11c6d5e559d712de6a319023a8ae95
Author: Kim Woelders 
Date:   Fri Aug 20 06:37:38 2021 +0200

imlib2_view: Add some debug
---
 src/bin/imlib2_view.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index c1228d7..51319ad 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -12,6 +12,7 @@
 
 Display*disp;
 
+static int  debug = 0;
 static Window   win;
 static Pixmap   pm = 0;
 static int  depth;
@@ -25,6 +26,9 @@ static char progress_granularity = 10;
 static char progress_print = 0;
 static int  progress_delay = 0;
 
+#define Dprintf if (debug) printf
+#define Vprintf if (verbose) printf
+
 #define MAX_DIM32767
 
 #define SCALE_X(x) (int)(scale_x * (x) + .5)
@@ -34,6 +38,7 @@ static int  progress_delay = 0;
"Usage:\n" \
"  imlib2_view [OPTIONS] FILE...\n" \
"OPTIONS:\n" \
+   "  -d  : Enable debug\n" \
"  -g N: Set progress granularity to N%% (default 10(%%))\n" \
"  -l N: Introduce N ms delay in progress callback (default 0)\n" \
"  -p  : Print info in progress callback (default no)\n" \
@@ -69,10 +74,12 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
 window_height = DisplayHeight(disp, DefaultScreen(disp));
 window_width -= 32; /* Allow for decorations */
 window_height -= 32;
+Dprintf("Screen WxH=%dx%d\n", window_width, window_height);
 
 imlib_context_set_image(im);
 image_width = imlib_image_get_width();
 image_height = imlib_image_get_height();
+Dprintf("Image  WxH=%dx%d\n", image_width, image_height);
 
 if (!scale &&
 (image_width > window_width || image_height > window_height))
@@ -83,6 +90,7 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
{
   scale_x *= .5;
   scale_y = scale_x;
+  Dprintf(" scale WxH=%.3fx%.3f\n", scale_x, scale_y);
}
   }
 
@@ -98,6 +106,7 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
  window_height = MAX_DIM;
  scale_y = (double)MAX_DIM / image_height;
   }
+Dprintf("Window WxH=%dx%d\n", window_width, window_height);
 
 if (pm)
XFreePixmap(disp, pm);
@@ -171,10 +180,13 @@ main(int argc, char **argv)
 
verbose = 0;
 
-   while ((opt = getopt(argc, argv, "g:l:ps:v")) != -1)
+   while ((opt = getopt(argc, argv, "dg:l:ps:v")) != -1)
  {
 switch (opt)
   {
+  case 'd':
+ debug += 1;
+ break;
   case 'g':
  progress_granularity = atoi(optarg);
  break;
@@ -239,8 +251,7 @@ main(int argc, char **argv)
  exit(0);
   }
 file = argv[no];
-if (verbose)
-   printf("Show  %d: '%s'\n", no, file);
+Vprintf("Show  %d: '%s'\n", no, file);
 image_width = 0;
 im = imlib_load_image(file);
  }
@@ -383,8 +394,7 @@ main(int argc, char **argv)
continue;
 }
   file = argv[no2];
-  if (verbose)
- printf("Show  %d: '%s'\n", no2, file);
+  Vprintf("Show  %d: '%s'\n", no2, file);
   if (no2 == no)
  break;
   image_width = 0;

-- 




[EGIT] [legacy/imlib2] master 01/04: imlib2_view: Move property stuff to separate file

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=0497d2bb0cc4ee6552ae65b58e113f76af8d24d7

commit 0497d2bb0cc4ee6552ae65b58e113f76af8d24d7
Author: Kim Woelders 
Date:   Sun Mar 11 08:51:54 2018 +0100

imlib2_view: Move property stuff to separate file

May reuse it elsewhere.
---
 src/bin/Makefile.am   |  2 +-
 src/bin/imlib2_view.c | 11 +++
 src/bin/props.c   | 25 +
 src/bin/props.h   | 16 
 4 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 4833794..3bbb8c1 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -36,7 +36,7 @@ imlib2_poly_LDADD   = $(top_builddir)/src/lib/libImlib2.la 
-lX11
 imlib2_colorspace_SOURCES = imlib2_colorspace.c
 imlib2_colorspace_LDADD   = $(top_builddir)/src/lib/libImlib2.la -lX11
 
-imlib2_view_SOURCES = imlib2_view.c
+imlib2_view_SOURCES = imlib2_view.c props.c props.h
 imlib2_view_LDADD   = $(top_builddir)/src/lib/libImlib2.la -lX11
 
 imlib2_grab_SOURCES = imlib2_grab.c
diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 685efde..ea0ba8e 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -8,6 +8,7 @@
 #include 
 
 #include "Imlib2.h"
+#include "props.h"
 
 Display*disp;
 Window  win;
@@ -22,9 +23,6 @@ static char progress_granularity = 10;
 static char progress_print = 0;
 static int  progress_delay = 0;
 
-static Atom ATOM_WM_DELETE_WINDOW = None;
-static Atom ATOM_WM_PROTOCOLS = None;
-
 #define MAX_DIM32767
 
 #define SCALE_X(x) (int)(scale_x * (x) + .5)
@@ -200,9 +198,7 @@ main(int argc, char **argv)
XSelectInput(disp, win, KeyPressMask | ButtonPressMask | ButtonReleaseMask |
 ButtonMotionMask | PointerMotionMask);
 
-   ATOM_WM_PROTOCOLS = XInternAtom(disp, "WM_PROTOCOLS", False);
-   ATOM_WM_DELETE_WINDOW = XInternAtom(disp, "WM_DELETE_WINDOW", False);
-   XSetWMProtocols(disp, win, _WM_DELETE_WINDOW, 1);
+   props_win_set_proto_quit(win);
 
imlib_context_set_display(disp);
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
@@ -250,8 +246,7 @@ main(int argc, char **argv)
  break;
 
   case ClientMessage:
- if (ev.xclient.message_type == ATOM_WM_PROTOCOLS &&
- (Atom) ev.xclient.data.l[0] == ATOM_WM_DELETE_WINDOW)
+ if (props_clientmsg_check_quit())
 goto quit;
  break;
   case KeyPress:
diff --git a/src/bin/props.c b/src/bin/props.c
new file mode 100644
index 000..e5e8681
--- /dev/null
+++ b/src/bin/props.c
@@ -0,0 +1,25 @@
+/*
+ * Property handling
+ */
+#include 
+#include 
+
+#include "props.h"
+
+static Atom ATOM_WM_DELETE_WINDOW = None;
+static Atom ATOM_WM_PROTOCOLS = None;
+
+void
+props_win_set_proto_quit(Window win)
+{
+   ATOM_WM_PROTOCOLS = XInternAtom(disp, "WM_PROTOCOLS", False);
+   ATOM_WM_DELETE_WINDOW = XInternAtom(disp, "WM_DELETE_WINDOW", False);
+   XSetWMProtocols(disp, win, _WM_DELETE_WINDOW, 1);
+}
+
+int
+props_clientmsg_check_quit(const XClientMessageEvent * ev)
+{
+   return ev->message_type == ATOM_WM_PROTOCOLS &&
+  (Atom) ev->data.l[0] == ATOM_WM_DELETE_WINDOW;
+}
diff --git a/src/bin/props.h b/src/bin/props.h
new file mode 100644
index 000..aeecbf1
--- /dev/null
+++ b/src/bin/props.h
@@ -0,0 +1,16 @@
+/*
+ * Property handling
+ */
+#ifndef PROPS_H
+#define PROPS_H
+
+#include 
+#include 
+
+extern Display *disp;
+
+voidprops_win_set_proto_quit(Window win);
+
+int props_clientmsg_check_quit(const XClientMessageEvent * ev);
+
+#endif /* PROPS_H */

-- 




[EGIT] [legacy/imlib2] master 02/04: imlib2_view: Cleanups

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=34afe297cd144b123c057fd80a3150326b7ce27b

commit 34afe297cd144b123c057fd80a3150326b7ce27b
Author: Kim Woelders 
Date:   Fri Aug 20 06:39:11 2021 +0200

imlib2_view: Cleanups
---
 src/bin/imlib2_view.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index ea0ba8e..9cf5b09 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -11,14 +11,15 @@
 #include "props.h"
 
 Display*disp;
-Window  win;
-Pixmap  pm = 0;
-int depth;
-int image_width = 0, image_height = 0;
-int window_width = 0, window_height = 0;
-double  scale_x = 1.;
-double  scale_y = 1.;
-Imlib_Image bg_im = NULL;
+
+static Window   win;
+static Pixmap   pm = 0;
+static int  depth;
+static int  image_width = 0, image_height = 0;
+static int  window_width = 0, window_height = 0;
+static double   scale_x = 1.;
+static double   scale_y = 1.;
+static Imlib_Image  bg_im = NULL;
 static char progress_granularity = 10;
 static char progress_print = 0;
 static int  progress_delay = 0;

-- 




[EGIT] [legacy/imlib2] master 03/04: imlib2_view: By default scale large images to fit on screen

2021-08-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=a748550fa456106ec7f49bfec8a915b18dabd43c

commit a748550fa456106ec7f49bfec8a915b18dabd43c
Author: Kim Woelders 
Date:   Fri Aug 20 05:52:36 2021 +0200

imlib2_view: By default scale large images to fit on screen
---
 src/bin/imlib2_view.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 9cf5b09..c1228d7 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -17,6 +17,7 @@ static Pixmap   pm = 0;
 static int  depth;
 static int  image_width = 0, image_height = 0;
 static int  window_width = 0, window_height = 0;
+static char scale = 0;
 static double   scale_x = 1.;
 static double   scale_y = 1.;
 static Imlib_Image  bg_im = NULL;
@@ -64,9 +65,27 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
  {
 int x, y, onoff;
 
+window_width = DisplayWidth(disp, DefaultScreen(disp));
+window_height = DisplayHeight(disp, DefaultScreen(disp));
+window_width -= 32; /* Allow for decorations */
+window_height -= 32;
+
 imlib_context_set_image(im);
 image_width = imlib_image_get_width();
 image_height = imlib_image_get_height();
+
+if (!scale &&
+(image_width > window_width || image_height > window_height))
+  {
+ scale_x = scale_y = 1.;
+ while (window_width < SCALE_X(image_width) ||
+window_height < SCALE_Y(image_height))
+   {
+  scale_x *= .5;
+  scale_y = scale_x;
+   }
+  }
+
 window_width = SCALE_X(image_width);
 window_height = SCALE_Y(image_height);
 if (window_width > MAX_DIM)
@@ -79,6 +98,7 @@ progress(Imlib_Image im, char percent, int update_x, int 
update_y,
  window_height = MAX_DIM;
  scale_y = (double)MAX_DIM / image_height;
   }
+
 if (pm)
XFreePixmap(disp, pm);
 pm = XCreatePixmap(disp, win, window_width, window_height, depth);
@@ -165,6 +185,7 @@ main(int argc, char **argv)
  progress_print = 1;
  break;
   case 's':/* Scale (window size wrt. image size) */
+ scale = 1;
  scale_x = scale_y = atof(optarg);
  break;
   case 'v':

-- 




[E-devel] imlib2-1.7.3

2021-08-09 Thread Kim Woelders
The only change since 1.7.2 is a fix to detect bzip2 availability at 
configure time (for distros which don't add bzip2.pc).


Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.3.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.3.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.3.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.3.tar.gz

/Kim



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] imlib2-1.7.2

2021-07-27 Thread Kim Woelders

Mostly a couple of minor loader fixes and maintenance.
A few specifics:

imlib2 1.7.2:
- Restore file:key functionality (broken since 1.7.0)
- Add XBM loader

imlib2_loaders 1.7.2:
- Disable broken EET loader

Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.2.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.2.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.2.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.2.tar.gz

/Kim


___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] small tga loader fix

2021-07-10 Thread Kim Woelders

Pushed (reverse patch, formatting fixed).

Thanks :)

/Kim

On 7/5/21 4:32 PM, noospot wrote:

hi,

I stumbled upon a tiny tga image  imlib2 couldn't load while other
softs could .

I did check the imlib2-1.7.1/src/modules/loaders/loader_tga.ccode
I found sizeof(tga_footer) is used  -line191- -line201-  earlier than
to check a footer presence -line202-

with patch below the image loads correctly.

image is maybe attached  to this mail   sample_rle_3c_cmap.tga
or its maybe there:  https://filebin.net/enqoaglfjl649ou5
or its maybe there: https://noospot.dynv6.net/sample_rle_3c_cmap.tga

imlib2 version 1.7.1
debian buster packageimlib2_1.7.1-2

thanks



--- imlib2-1.7.1-tgapatch/src/modules/loaders/loader_tga.c
2021-07-05 14:53:54.856994118 +0100 +++
imlib2-1.7.1/src/modules/loaders/loader_tga.c   2020-12-09
16:45:59.0 + @@ -188,7 +188,7 @@ if (fstat(fd, ) < 0)
goto quit;
  
-   if (ss.st_size < (long)(sizeof(tga_header) ) ||

+   if (ss.st_size < (long)(sizeof(tga_header) + sizeof(tga_footer)) ||
 (uintmax_t) ss.st_size > SIZE_MAX)
goto quit;
  
@@ -198,17 +198,11 @@
  
 filedata = seg;

 header = (tga_header *) filedata;
-
-  if (ss.st_size >(long)(sizeof(tga_footer))  ) {
 footer = (tga_footer *) ((char *)filedata + ss.st_size -
sizeof(tga_footer));
 /* check the footer to see if we have a v2.0 TGA file */
 footer_present =
memcmp(footer->signature, TGA_SIGNATURE,
sizeof(footer->signature)) == 0;
-  } else{
-  footer_present =0;
-  }
-
  
 if ((size_t)ss.st_size < sizeof(tga_header) + header->idLength +

 (footer_present ? sizeof(tga_footer) : 0))



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel





___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] small tga loader fix

2021-07-07 Thread Kim Woelders

Hi,

Unless somebody beats me to it I'll deal with this in a couple of days.

Thanks
/Kim

On 7/5/21 4:32 PM, noospot wrote:

hi,

I stumbled upon a tiny tga image  imlib2 couldn't load while other
softs could .

I did check the imlib2-1.7.1/src/modules/loaders/loader_tga.ccode
I found sizeof(tga_footer) is used  -line191- -line201-  earlier than
to check a footer presence -line202-

with patch below the image loads correctly.

image is maybe attached  to this mail   sample_rle_3c_cmap.tga
or its maybe there:  https://filebin.net/enqoaglfjl649ou5
or its maybe there: https://noospot.dynv6.net/sample_rle_3c_cmap.tga

imlib2 version 1.7.1
debian buster packageimlib2_1.7.1-2

thanks



--- imlib2-1.7.1-tgapatch/src/modules/loaders/loader_tga.c
2021-07-05 14:53:54.856994118 +0100 +++
imlib2-1.7.1/src/modules/loaders/loader_tga.c   2020-12-09
16:45:59.0 + @@ -188,7 +188,7 @@ if (fstat(fd, ) < 0)
goto quit;
  
-   if (ss.st_size < (long)(sizeof(tga_header) ) ||

+   if (ss.st_size < (long)(sizeof(tga_header) + sizeof(tga_footer)) ||
 (uintmax_t) ss.st_size > SIZE_MAX)
goto quit;
  
@@ -198,17 +198,11 @@
  
 filedata = seg;

 header = (tga_header *) filedata;
-
-  if (ss.st_size >(long)(sizeof(tga_footer))  ) {
 footer = (tga_footer *) ((char *)filedata + ss.st_size -
sizeof(tga_footer));
 /* check the footer to see if we have a v2.0 TGA file */
 footer_present =
memcmp(footer->signature, TGA_SIGNATURE,
sizeof(footer->signature)) == 0;
-  } else{
-  footer_present =0;
-  }
-
  
 if ((size_t)ss.st_size < sizeof(tga_header) + header->idLength +

 (footer_present ? sizeof(tga_footer) : 0))



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel





___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [PATCH] e16: support user fonts

2021-01-19 Thread Kim Woelders

On 1/19/21 5:55 PM, Kim Woelders wrote:

On 1/17/21 2:35 PM, Andrew Savchenko wrote:

Hello!

The following patch allows users to provide custom fonts via
~/.e16/fonts/

This patch is already used for years in Gentoo and it would be nice
to have it upstream. I use it for user-side theme modification
(winter in my case), because my eyes prefer larger fonts :)

Proposed patch is made on top of current e16 git HEAD, though it
alsa applies well on 1.0.22.


Pushed, thanks :)

Btw, it is also possible to tweak the font configuration with a custom 
~/.e16/fonts.cfg.


/Kim


___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [PATCH] e16: support user fonts

2021-01-19 Thread Kim Woelders

On 1/17/21 2:35 PM, Andrew Savchenko wrote:

Hello!

The following patch allows users to provide custom fonts via
~/.e16/fonts/

This patch is already used for years in Gentoo and it would be nice
to have it upstream. I use it for user-side theme modification
(winter in my case), because my eyes prefer larger fonts :)

Proposed patch is made on top of current e16 git HEAD, though it
alsa applies well on 1.0.22.


Pushed, thanks :)

/Kim



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [PATCH] imlib2-loaders: fix eet loader build failure

2021-01-18 Thread Kim Woelders

On 1/17/21 11:55 AM, Andrew Savchenko wrote:

Hello!

I found that eet loader from imlib2-loaders-1.7.1 fails to build
(with gcc-10.2.0 and efl-1.25.1, full build log is attached):

loader_eet.c:384:5: error: invalid use of incomplete typedef 
�~@~XImlibLoader�~@~Y {aka �~@~Xstruct _imlibloader�~@~Y}
   384 |l->num_formats = sizeof(list_formats) / sizeof(char *);
   | ^~
This happens because struct _imlibloader (aka typedef ImlibLoader)
is not defined within imlib2_loaders sources. As I see imlib2_loaders
copies private headers from imlib2, so the solution is to add and
include missing loaders.h header, see attached patch.


Hello Andrew,

The eet loader has not been kept up-to-date in ages.
I'm not even sure if what it did still is relevant.

I have fixed the build by applying a couple of changes it should have had.

I have also disabled it as it will not work at all anyway for various 
reasons.


/Kim



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] imlib2-1.7.1

2020-12-11 Thread Kim Woelders

imlib2 1.7.1:
- Fix big-endian build
- A couple of fixes for 30 bit depth
- A couple of fixes in XPM and WEBP loaders

Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.1.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.1.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.1.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.1.tar.gz

/Kim


___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] imlib2-1.7.0

2020-08-01 Thread Kim Woelders

imlib2 1.7.0:
- Enable loading image from file descriptor
- Many bug fixes and enhancements in loaders
- Cleanups, maintenance.

Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.0.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.7.0.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.0.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.7.0.tar.gz

/Kim


___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] imlib2-1.6.1

2019-12-13 Thread Kim Woelders

imlib2 1.6.1:
- gz, bz2 loaders: Fix recent breakage when file name has more than two dots
- LBM loader: Fix header-only loading
- Various tweaks in test/demo programs
- Enable specifying loader/filter paths with environment variables
- BMP loader: Fix size calculation when saving files
- A couple of minor loader cleanups and optimizations

Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.6.1.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.6.1.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.6.1.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.6.1.tar.gz

/Kim



___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [legacy/imlib2] master 02/02: gz, bz2 loaders: Fix recent breakage when file name has more than two dots

2019-11-26 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=8bd07dbcea04cd11dbe7cb0774b870848998f212

commit 8bd07dbcea04cd11dbe7cb0774b870848998f212
Author: Kim Woelders 
Date:   Mon Nov 25 21:49:46 2019 +0100

gz, bz2 loaders: Fix recent breakage when file name has more than two dots
---
 src/modules/loaders/loader_bz2.c  | 16 +++-
 src/modules/loaders/loader_zlib.c | 16 +++-
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/modules/loaders/loader_bz2.c b/src/modules/loaders/loader_bz2.c
index c54c162..3b6ceba 100644
--- a/src/modules/loaders/loader_bz2.c
+++ b/src/modules/loaders/loader_bz2.c
@@ -51,14 +51,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
ImlibLoader*loader;
FILE   *fp;
int dest, res;
-   char   *file, *p, *q, tmp[] = "/tmp/imlib2_loader_bz2-XX";
-   char   *real_ext;
+   const char *s, *p, *q;
+   chartmp[] = "/tmp/imlib2_loader_bz2-XX";
+   char   *file, *real_ext;
 
/* make sure this file ends in ".bz2" and that there's another ext
 * (e.g. "foo.png.bz2") */
-   p = strrchr(im->real_file, '.');
-   q = strchr(im->real_file, '.');
-   if (!p || p == im->real_file || strcasecmp(p + 1, "bz2") || p == q)
+   for (s = im->real_file, p = q = NULL; *s; s++)
+ {
+if (*s != '.')
+   continue;
+q = p;
+p = s;
+ }
+   if (!q || q == im->real_file || strcasecmp(p + 1, "bz2"))
   return 0;
 
if (!(real_ext = strndup(q + 1, p - q - 1)))
diff --git a/src/modules/loaders/loader_zlib.c 
b/src/modules/loaders/loader_zlib.c
index 279ac89..3bd9389 100644
--- a/src/modules/loaders/loader_zlib.c
+++ b/src/modules/loaders/loader_zlib.c
@@ -44,14 +44,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
ImlibLoader*loader;
FILE   *fp;
int dest, res;
-   char   *file, *p, *q, tmp[] = "/tmp/imlib2_loader_zlib-XX";
-   char   *real_ext;
+   const char *s, *p, *q;
+   chartmp[] = "/tmp/imlib2_loader_zlib-XX";
+   char   *file, *real_ext;
 
/* make sure this file ends in ".gz" and that there's another ext
 * (e.g. "foo.png.gz") */
-   p = strrchr(im->real_file, '.');
-   q = strchr(im->real_file, '.');
-   if (!p || p == im->real_file || strcasecmp(p + 1, "gz") || p == q)
+   for (s = im->real_file, p = q = NULL; *s; s++)
+ {
+if (*s != '.')
+   continue;
+q = p;
+p = s;
+ }
+   if (!q || q == im->real_file || strcasecmp(p + 1, "gz"))
   return 0;
 
if (!(real_ext = strndup(q + 1, p - q - 1)))

-- 




[EGIT] [legacy/imlib2] master 01/02: gz loader: Use FILE, not fd

2019-11-26 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=1a0c29c8736d69f339a09069edc8f9a55eedaf8a

commit 1a0c29c8736d69f339a09069edc8f9a55eedaf8a
Author: Kim Woelders 
Date:   Mon Nov 25 20:39:13 2019 +0100

gz loader: Use FILE, not fd

Making it more similar to the bz2 loader.
---
 src/modules/loaders/loader_zlib.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/modules/loaders/loader_zlib.c 
b/src/modules/loaders/loader_zlib.c
index e43c779..279ac89 100644
--- a/src/modules/loaders/loader_zlib.c
+++ b/src/modules/loaders/loader_zlib.c
@@ -7,13 +7,13 @@
 #define OUTBUF_SIZE 16484
 
 static int
-uncompress_file(int src, int dest)
+uncompress_file(FILE * fp, int dest)
 {
gzFile  gf;
DATA8   outbuf[OUTBUF_SIZE];
int ret = 1, bytes;
 
-   gf = gzdopen(dup(src), "rb");
+   gf = gzdopen(dup(fileno(fp)), "rb");
if (!gf)
   return 0;
 
@@ -42,7 +42,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
  char progress_granularity, char immediate_load)
 {
ImlibLoader*loader;
-   int src;
+   FILE   *fp;
int dest, res;
char   *file, *p, *q, tmp[] = "/tmp/imlib2_loader_zlib-XX";
char   *real_ext;
@@ -62,17 +62,17 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!loader)
   return 0;
 
-   if ((src = open(im->real_file, O_RDONLY)) < 0)
+   if (!(fp = fopen(im->real_file, "rb")))
   return 0;
 
if ((dest = mkstemp(tmp)) < 0)
  {
-close(src);
+fclose(fp);
 return 0;
  }
 
-   res = uncompress_file(src, dest);
-   close(src);
+   res = uncompress_file(fp, dest);
+   fclose(fp);
close(dest);
 
if (!res)

-- 




[E-devel] imlib2-1.6.0

2019-11-24 Thread Kim Woelders

imlib2 1.6.0:
- Allow to use custom memory management functions for loaded images
- Add new .webp and .ico loaders
- Many bug fixes and enhancements in loaders
- Cleanups, maintenance.

Source packages:
http://downloads.sourceforge.net/enlightenment/imlib2-1.6.0.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2-1.6.0.tar.gz

http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.6.0.tar.bz2
http://downloads.sourceforge.net/enlightenment/imlib2_loaders-1.6.0.tar.gz

/Kim


___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [legacy/imlib2_loaders] master 01/01: 1.6.0.

2019-11-24 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=69ec575281f7afe7f3a1cb3ac54e08ba97f0c0ea

commit 69ec575281f7afe7f3a1cb3ac54e08ba97f0c0ea
Author: Kim Woelders 
Date:   Sun Nov 24 07:10:59 2019 +0100

1.6.0.
---
 ChangeLog| 30 ++
 configure.ac |  2 +-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 453fd7f..b80004d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,34 @@
 
+***
+*** Version 1.6.0 ***
+***
+
+Kim Woelders (23):
+  Autofoo cleanup
+  Set warning options when using gcc.
+  Use headers for funcion prototypes
+  Enable visibility hiding
+  Drop ICO loader
+  Remove unused X11 headers
+  Spec file cleanups
+  Simplify autogen.sh
+  Indent
+  Copy updated headers from imlib2
+  Match various changes done in imlib2 loaders
+  ANI loader: Fix - Don't use __imlib_LoadImage() or tempnam()
+  ANI loader: Fix memory leak in error path
+  ANI loader: Cosmetics
+  XCF loader: Cosmetic rearrangements
+  XCF loader: Prefer DATA32 when accessing imlib2 image data
+  XCF loader: Stop on errors and propagate error status up to load()
+  XCF loader: Fix double free.
+  Fix make dist
+  ANI loader: Make debug stuff similar to elsewhere around here
+  ANI loader: Don't use static buffer for mkstemp() template
+  ANI loader: If .ani looks good we must try .ico loading chunks
+  XCF loader: Avoid accessing unset data in signature check
+
+
 ***
 *** Version 1.5.1 ***
 ***
diff --git a/configure.ac b/configure.ac
index 38ad0b9..7d362f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 # get rid of that stupid cache mechanism
 rm -f config.cache
 
-AC_INIT([imlib2_loaders],[1.5.1],[enlightenment-devel@lists.sourceforge.net])
+AC_INIT([imlib2_loaders],[1.6.0],[enlightenment-devel@lists.sourceforge.net])
 AC_CONFIG_SRCDIR(configure.ac)
 AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_BUILD

-- 




[EGIT] [legacy/imlib2] master 01/01: 1.6.0.

2019-11-24 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=11ced03ba44fa122e51385959666e7ca5bad7180

commit 11ced03ba44fa122e51385959666e7ca5bad7180
Author: Kim Woelders 
Date:   Sat Nov 9 06:18:22 2019 +0100

1.6.0.
---
 ChangeLog| 81 
 configure.ac |  8 +++---
 2 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5c5a511..ae12eb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,85 @@
 
+***
+*** Version 1.6.0 ***
+***
+
+Alexander Volkov (1):
+  Allow to use custom memory management functions for loaded images
+
+Kim Woelders (64):
+  Add __imlib_LoadImageWrapper() handling all load() calls
+  imlib2_conv: Report error on save failure
+  Autofoo cosmetics
+  Trivial cleanups in imlib2_... test programs
+  Add imlib2_test_load program
+  Cleanups in load() functions
+  Centralize handling of im->format
+  Sort loaders in Makefile.am
+  Remove obsolete dmalloc stuff
+  Move SWAP.. macro definitions to common.h
+  Use common PIXEL_ARGB() macro to compose pixels
+  Add new ICO loader
+  Spec file simlifications and cleanups
+  Fix memory leak in imlib_list_fonts()
+  XPM loader: Refactor exit cleanup handling
+  XPM loader: Fix potentially uninitialized pixel data
+  XPM loader: Fixup after "Refactor exit cleanup handling"
+  Revert "XPM loader: Fix potentially uninitialized pixel data"
+  XPM loader: Cosmetics (reduce indent level)
+  XPM loader: Fix several colormap issues
+  XPM loader: Simplify pixel value handling
+  XPM loader: Add missing pixels (malformed xpm)
+  XPM loader: More simplifications
+  JPG loader: Refactor
+  JPG loader: Do proper CMYK conversion
+  Add new WebP loader
+  Remove pointless im->data checks in loaders
+  WepP loader: Fix memory leak in error path
+  JPG loader: Fix memory leaks in error paths
+  Fix ABI break
+  ICO loader: Add binary flag to fopen()
+  JPG loader: Refactor error handling
+  Rename/add byte swap macros
+  BMP loader: Major makeover - numerous bug fixes and feature enhancements
+  Miscellaneous imlib_test_load tweaks
+  GZIP loader: Check filename before uncompress
+  imlib2_test_load: Fixup after recent change
+  Re-indent everything using indent-2.2.12
+  TGA loader: Refactor
+  Eliminate WRITE_RGBA()
+  Simplify autogen.sh
+  Simplify pixel color handling in api.c
+  Use pixel instead of r,b,g,a in __imlib_render_str()
+  Use macro for pixel color access in savers
+  Eliminate READ_RGBA()
+  XPM loader: Accept signature not at the very start of the file
+  Simplify loader lookup functions
+  imlib2_view: Enable selecting next/prev using keys too
+  imlib2_view: Fix event processing bug
+  imlib2_test_load: Fixup recent breakage for real
+  imlib2_test_load: Check progress conditionally
+  imlib2_view: Add verbose option, quit on Escape too
+  TGA loader - Mostly cosmetic refactoring
+  TGA loader: More mostly cosmetic changes
+  TGA loader: Support horiontal flip
+  TGA loader: Add simple 16 bpp handling
+  TGA loader: Tweak error handling
+  ICO loader: Fix non-immediate loading
+  Remove __imlib_AllocateData() w,h args
+  imlib2_view: Fix next/prev selection if last/first image is bad
+  ICO loader: Fix memory leak in error path
+  XPM loader: Correct signature check (avoid accessing unset data)
+  gz, bz2 loaders: Simplify, eliminate unnecessary strdups, cosmetics
+  Bump minor version (new functions)
+
+Olof-Joachim Frahm (欧雅福) (2):
+  Check filename before opening archive file.
+  tga loader: implement handling of palette
+
+Ralph Siemsen (1):
+  loader_tga: fix regression in RLE raw byte handling
+
+
 ***
 *** Version 1.5.1 ***
 ***
diff --git a/configure.ac b/configure.ac
index f00c750..93044d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 # get rid of that stupid cache mechanism
 rm -f config.cache
 
-AC_INIT([imlib2], [1.5.1], [enlightenment-devel@lists.sourceforge.net])
+AC_INIT([imlib2], [1.6.0], [enlightenment-devel@lists.sourceforge.net])
 AC_CONFIG_SRCDIR(configure.ac)
 AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_BUILD
@@ -22,9 +22,9 @@ define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
 define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
 LT_INIT
 
-VERSION_CUR=6
-VERSION_REV=1
-VERSION_AGE=5
+VERSION_CUR=7
+VERSION_REV=0
+VERSION_AGE=6
 lt_version=${VERSION_CUR}:${VERSION_REV}:${VERSION_AGE}
 AC_SUBST(lt_version)
 

-- 




[EGIT] [legacy/imlib2_loaders] master 01/01: XCF loader: Avoid accessing unset data in signature check

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=ec510f793d4b3f14ac5da5e3665f0c71726e5649

commit ec510f793d4b3f14ac5da5e3665f0c71726e5649
Author: Kim Woelders 
Date:   Fri Nov 22 20:10:30 2019 +0100

XCF loader: Avoid accessing unset data in signature check
---
 src/modules/loaders/loader_xcf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index c9a44b2..01d8b6c 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -1534,6 +1534,7 @@ xcf_file_init(char *filename)
 
image->cp = 0;
 
+   memset(id, 0, sizeof(id));
image->cp += xcf_read_int8(image->fp, (DATA8 *) id, 14);
if (strncmp(id, "gimp xcf ", 9) != 0)
  {

-- 




[EGIT] [legacy/imlib2] master 01/01: gz, bz2 loaders: Simplify, eliminate unnecessary strdups, cosmetics

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=f20038b2e78ca193b8c51e375f70cfde92c0a1aa

commit f20038b2e78ca193b8c51e375f70cfde92c0a1aa
Author: Kim Woelders 
Date:   Sun Nov 17 10:04:27 2019 +0100

gz, bz2 loaders: Simplify, eliminate unnecessary strdups, cosmetics

In particular, don't free the original im->real_file.
---
 src/modules/loaders/loader_bz2.c  | 26 +-
 src/modules/loaders/loader_zlib.c | 28 ++--
 2 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/src/modules/loaders/loader_bz2.c b/src/modules/loaders/loader_bz2.c
index 47f68ab..c54c162 100644
--- a/src/modules/loaders/loader_bz2.c
+++ b/src/modules/loaders/loader_bz2.c
@@ -55,8 +55,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
char   *real_ext;
 
/* make sure this file ends in ".bz2" and that there's another ext
-* (e.g. "foo.png.bz2"
-*/
+* (e.g. "foo.png.bz2") */
p = strrchr(im->real_file, '.');
q = strchr(im->real_file, '.');
if (!p || p == im->real_file || strcasecmp(p + 1, "bz2") || p == q)
@@ -65,22 +64,17 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!(real_ext = strndup(q + 1, p - q - 1)))
   return 0;
 
-   if (!(loader = __imlib_FindBestLoaderForFormat(real_ext, 0)))
- {
-free(real_ext);
-return 0;
- }
+   loader = __imlib_FindBestLoaderForFormat(real_ext, 0);
+   free(real_ext);
+   if (!loader)
+  return 0;
 
if (!(fp = fopen(im->real_file, "rb")))
- {
-free(real_ext);
-return 0;
- }
+  return 0;
 
if ((dest = mkstemp(tmp)) < 0)
  {
 fclose(fp);
-free(real_ext);
 return 0;
  }
 
@@ -90,21 +84,19 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 
if (!res)
  {
-free(real_ext);
 unlink(tmp);
 return 0;
  }
 
/* remember the original filename */
-   file = strdup(im->real_file);
-
-   free(im->real_file);
+   file = im->real_file;
im->real_file = strdup(tmp);
+
loader->load(im, progress, progress_granularity, immediate_load);
 
free(im->real_file);
im->real_file = file;
-   free(real_ext);
+
unlink(tmp);
 
return 1;
diff --git a/src/modules/loaders/loader_zlib.c 
b/src/modules/loaders/loader_zlib.c
index d30725b..e43c779 100644
--- a/src/modules/loaders/loader_zlib.c
+++ b/src/modules/loaders/loader_zlib.c
@@ -47,9 +47,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
char   *file, *p, *q, tmp[] = "/tmp/imlib2_loader_zlib-XX";
char   *real_ext;
 
-   /* check that this file ends in *.gz and that there's another ext
-* (e.g. "foo.png.gz"
-*/
+   /* make sure this file ends in ".gz" and that there's another ext
+* (e.g. "foo.png.gz") */
p = strrchr(im->real_file, '.');
q = strchr(im->real_file, '.');
if (!p || p == im->real_file || strcasecmp(p + 1, "gz") || p == q)
@@ -58,22 +57,17 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!(real_ext = strndup(q + 1, p - q - 1)))
   return 0;
 
-   if (!(loader = __imlib_FindBestLoaderForFormat(real_ext, 0)))
- {
-free(real_ext);
-return 0;
- }
+   loader = __imlib_FindBestLoaderForFormat(real_ext, 0);
+   free(real_ext);
+   if (!loader)
+  return 0;
 
if ((src = open(im->real_file, O_RDONLY)) < 0)
- {
-free(real_ext);
-return 0;
- }
+  return 0;
 
if ((dest = mkstemp(tmp)) < 0)
  {
 close(src);
-free(real_ext);
 return 0;
  }
 
@@ -83,21 +77,19 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 
if (!res)
  {
-free(real_ext);
 unlink(tmp);
 return 0;
  }
 
/* remember the original filename */
-   file = strdup(im->real_file);
-
-   free(im->real_file);
+   file = im->real_file;
im->real_file = strdup(tmp);
+
loader->load(im, progress, progress_granularity, immediate_load);
 
free(im->real_file);
im->real_file = file;
-   free(real_ext);
+
unlink(tmp);
 
return 1;

-- 




[EGIT] [legacy/imlib2] master 01/01: XPM loader: Correct signature check (avoid accessing unset data)

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=9b0ab1269787709692abcd423e86ab61130443c8

commit 9b0ab1269787709692abcd423e86ab61130443c8
Author: Kim Woelders 
Date:   Fri Nov 22 17:07:22 2019 +0100

XPM loader: Correct signature check (avoid accessing unset data)
---
 src/modules/loaders/loader_xpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/modules/loaders/loader_xpm.c b/src/modules/loaders/loader_xpm.c
index df23181..a732ac7 100644
--- a/src/modules/loaders/loader_xpm.c
+++ b/src/modules/loaders/loader_xpm.c
@@ -125,10 +125,11 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
if (!f)
   return 0;
 
-   if (fread(s, 1, sizeof(s) - 1, f) < 9)
+   len = fread(s, 1, sizeof(s) - 1, f);
+   if (len < 9)
   goto quit;
 
-   s[sizeof(s) - 1] = '\0';
+   s[len] = '\0';
if (!strstr(s, " XPM */"))
   goto quit;
 

-- 




[EGIT] [legacy/imlib2_loaders] master 01/03: ANI loader: Make debug stuff similar to elsewhere around here

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=93682e883a8e88d6bf7f9bbb549ecadfad4be0b0

commit 93682e883a8e88d6bf7f9bbb549ecadfad4be0b0
Author: Kim Woelders 
Date:   Fri Nov 22 18:53:27 2019 +0100

ANI loader: Make debug stuff similar to elsewhere around here

And a couple of debug message tweaks.
---
 src/modules/loaders/loader_ani.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index def7bf5..a85311d 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -32,16 +32,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE SOFTWARE.
 
 #include "loader_common.h"
 
-/* #define ANI_DBG */
-
-#ifdef ANI_DBG
-#define D(fmt, args...) \
-{ \
-  printf("Imlib2 ANI loader: "); \
-  printf(fmt, ## args); \
-}
+#define ANI_DBG 0
+#if ANI_DBG
+#define D(fmt...) printf("Imlib2 ANI loader: " fmt)
 #else
-#define D(fmt, args...)
+#define D(fmt...)
 #endif
 
 #define SWAP32(x) \
@@ -143,7 +138,7 @@ ani_cleanup(MsAni * ani)
 {
MsChunk*c, *c_next;
 
-   D("Failed to allocate ANI image. Cleaning up\n");
+   D("Cleaning up\n");
 
if (!ani)
   return;
@@ -189,7 +184,7 @@ ani_load_chunk(MsAni * ani)
chunk = calloc(1, sizeof(MsChunk *) + 2 * sizeof(DATA32) + chunk_size);
if (!chunk)
  {
-D("Warning, failed to allocate ANI chunk of size %d\n",
+D("Warning, failed to allocate ANI chunk of size %ld\n",
   sizeof(MsChunk *) + 2 * sizeof(DATA32) + chunk_size);
 return NULL;
  }

-- 




[EGIT] [legacy/imlib2_loaders] master 03/03: ANI loader: If .ani looks good we must try .ico loading chunks

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=7699e6155a22c451c1d585f8e95f644a40e15f9c

commit 7699e6155a22c451c1d585f8e95f644a40e15f9c
Author: Kim Woelders 
Date:   Fri Nov 22 18:59:50 2019 +0100

ANI loader: If .ani looks good we must try .ico loading chunks
---
 src/modules/loaders/loader_ani.c | 50 +++-
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index a4d794c..b6374f8 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -244,6 +244,7 @@ char
 load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
  char immediate_load)
 {
+   int rc;
ImlibLoader*loader;
MsAni  *ani = NULL;
MsChunk*chunk;
@@ -252,46 +253,43 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
if (!loader)
   return 0;
 
-   if (im->loader || immediate_load || progress)
- {
-if (!(ani = ani_init((im->real_file
-   return 0;
+   if (!(ani = ani_init((im->real_file
+  return 0;
 
-ani_load(ani);
+   ani_load(ani);
 
-for (chunk = ani->chunks; chunk; chunk = chunk->next)
+   rc = 0;
+
+   for (chunk = ani->chunks; chunk; chunk = chunk->next)
+ {
+if (chunk->chunk_id == 0x6E6F6369)
   {
- if (chunk->chunk_id == 0x6E6F6369)
-   {
-  char   *file;
-  char   *tmpfile;
+ char   *file;
+ char   *tmpfile;
 
-  if (!(tmpfile = ani_save_ico(chunk)))
- return 0;
+ if (!(tmpfile = ani_save_ico(chunk)))
+break;
 
-  file = im->real_file;
-  im->real_file = tmpfile;
-  loader->load(im, progress, progress_granularity,
+ file = im->real_file;
+ im->real_file = tmpfile;
+ rc = loader->load(im, progress, progress_granularity,
immediate_load);
-  im->real_file = file;
+ im->real_file = file;
 
-  unlink(tmpfile);
-  free(tmpfile);
-  break;
-   }
+ unlink(tmpfile);
+ free(tmpfile);
+ break;
   }
-
-ani_cleanup(ani);
  }
 
-   if (progress)
+   ani_cleanup(ani);
+
+   if (rc == 1 && progress)
  {
 progress(im, 100, 0, 0, im->w, im->h);
  }
 
-   return 1;
-
-   progress_granularity = 0;
+   return rc;
 }
 
 void

-- 




[EGIT] [legacy/imlib2_loaders] master 02/03: ANI loader: Don't use static buffer for mkstemp() template

2019-11-22 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=1626208543bb0471528ec36fd0b22b4f1aee4122

commit 1626208543bb0471528ec36fd0b22b4f1aee4122
Author: Kim Woelders 
Date:   Fri Nov 22 18:56:01 2019 +0100

ANI loader: Don't use static buffer for mkstemp() template
---
 src/modules/loaders/loader_ani.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index a85311d..a4d794c 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -227,7 +227,7 @@ ani_load(MsAni * ani)
 static char*
 ani_save_ico(MsChunk * chunk)
 {
-   static char tmp[] = "/tmp/imlib2_loader_ani-XX";
+   chartmp[] = "/tmp/imlib2_loader_ani-XX";
int fd;
 
fd = mkstemp(tmp);
@@ -237,7 +237,7 @@ ani_save_ico(MsChunk * chunk)
write(fd, >data, chunk->chunk_size);
close(fd);
 
-   return tmp;
+   return strdup(tmp);
 }
 
 char
@@ -276,6 +276,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
   im->real_file = file;
 
   unlink(tmpfile);
+  free(tmpfile);
   break;
}
   }

-- 




[EGIT] [legacy/imlib2_loaders] master 01/01: Fix make dist

2019-11-21 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=5049e8840e35ee53e5f0375c15835a9c4d0b4b5d

commit 5049e8840e35ee53e5f0375c15835a9c4d0b4b5d
Author: Kim Woelders 
Date:   Thu Nov 21 17:16:30 2019 +0100

Fix make dist
---
 src/modules/loaders/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/loaders/Makefile.am b/src/modules/loaders/Makefile.am
index 27af8ea..ed8e09e 100644
--- a/src/modules/loaders/Makefile.am
+++ b/src/modules/loaders/Makefile.am
@@ -19,7 +19,7 @@ $(ANI_L) \
 $(EET_L) \
 $(XCF_L)
 
-EXTRA_DIST = color_values.h common.h image.h loader_common.h
+EXTRA_DIST = common.h image.h loader_common.h
 
 eet_la_SOURCES  = loader_eet.c
 eet_la_CPPFLAGS = @EET_CFLAGS@

-- 




[EGIT] [legacy/imlib2_loaders] master 02/05: XCF loader: Cosmetic rearrangements

2019-11-20 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=a4bcffe55adbf1492bf399f57bf4faa289445bb7

commit a4bcffe55adbf1492bf399f57bf4faa289445bb7
Author: Kim Woelders 
Date:   Sun Nov 17 12:52:07 2019 +0100

XCF loader: Cosmetic rearrangements
---
 src/modules/loaders/loader_xcf.c | 1908 ++
 1 file changed, 919 insertions(+), 989 deletions(-)

diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index 86bdf9c..7ca745d 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -59,29 +59,22 @@
 #include "loader_common.h"
 #include "loader_xcf.h"
 
-/* #define XCF_DBG */
-
-#define FREE(X) { free(X); X = NULL; }
-
-#ifdef XCF_DBG
-#define D(fmt, args...) \
-{ \
-  printf("Imlib2 XCF loader: "); \
-  printf(fmt, ## args); \
-}
+#define XCF_DBG 0
+#if XCF_DBG
+#define D(fmt...) printf("Imlib2 XCF loader: " fmt)
 #else
-#define D(fmt, args...)
+#define D(fmt...)
 #endif
 
 #define TILE_WIDTH   64
 #define TILE_HEIGHT  64
 
-/* --- 
typedefs  */
+/*  typedefs  */
 
 typedef struct _Layer Layer;
 typedef struct _Tile Tile;
 
-/* 
-- 
enums  */
+/*  enums  */
 
 /* These are all the properties that a layer or channel can have.
Only some of them are actually used. */
@@ -161,7 +154,7 @@ typedef enum {
INDEXEDA_GIMAGE
 } GimpImageType;
 
-/* 
 
structs  */
+/*  structs  */
 
 /* Ok, this is what's left of Gimp's layer abstraction. I kicked out
all the stuff that's unnecessary and added the necessary stuff
@@ -254,361 +247,548 @@ struct _GimpImage {
Layer  *floating_sel;
 } _image;
 
-/* - 
prototypes  */
-
-/* stuff that was adapted from xcf.c */
-
-static void xcf_seek_pos(int pos);
-static int  xcf_read_int32(FILE * fp, DATA32 * data, int count);
-
-/*static intxcf_read_float (FILE *fp, float *data, int count);*/
-static int  xcf_read_int8(FILE * fp, DATA8 * data, int count);
-static int  xcf_read_string(FILE * fp, char **data, int count);
-static char xcf_load_prop(PropType * prop_type, DATA32 * prop_size);
-static void xcf_load_image(void);
-static char xcf_load_image_props(void);
-
-static Layer   *xcf_load_channel(void);
-static char xcf_load_channel_props(Layer * layer);
-static Layer   *xcf_load_layer(void);
-static char xcf_load_layer_props(Layer * layer);
-static char xcf_load_hierarchy(Tile ** tiles,
-   int *num_rows, int *num_cols, int *bpp);
-static char xcf_load_level(Tile ** tiles, int hierarchy_width,
-   int hierarchy_height, int bpp,
-   int *num_rows, int *num_cols);
-static char xcf_load_tile(Tile * tile);
-static char xcf_load_tile_rle(Tile * tile, int data_length);
-
-/* new stuff :) */
-
-static Tile*allocate_tiles(int width, int height, int bpp,
-   int *num_rows, int *num_cols);
-static void free_tiles(Tile * tiles, int num_tiles);
-static void init_tile(Tile * tile, int width, int height, int bpp);
-static Layer   *new_layer(int width, int height, GimpImageType type,
-  int opacity, LayerModeEffects mode);
-static void free_layer(Layer * layer);
-static void add_layer_to_image(Layer * layer);
-static void read_tiles_into_data(Tile * tiles, int num_cols, int width,
- int height, int bpp, DATA8 ** data,
- int use_cmap);
-static void apply_layer_mask(Layer * layer);
-static void set_layer_opacity(Layer * layer);
-static void flatten_image(void);
-
-static char xcf_file_init(char *filename);
-static void xcf_cleanup(void);
-static void xcf_to_imlib(ImlibImage * im);
-
-/* 
 
globals  */
+/*  globals  */
 
 /* This makes using the Gimp sources easier */
 struct _GimpImage  *image = &_image;
 
-/* 
--- 
code  */
+/*  prototypes  */
+
+/* new stuff :) */
 
 static void
-xcf_seek_pos(int pos)
+free_tiles(Tile * tiles, int num_tiles)
 {
-   if (image->cp != pos)
- {
-image->cp = 

[EGIT] [legacy/imlib2_loaders] master 05/05: XCF loader: Fix double free.

2019-11-20 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=673826c21594b238bbac729b2a931412418305f6

commit 673826c21594b238bbac729b2a931412418305f6
Author: Kim Woelders 
Date:   Tue Nov 19 17:00:21 2019 +0100

XCF loader: Fix double free.

free_layer() called later takes care of freeing the tiles.
---
 src/modules/loaders/loader_xcf.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index b7d9da8..c9a44b2 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -1167,7 +1167,6 @@ xcf_load_level(Tile ** tiles_p, int hierarchy_width, int 
hierarchy_height,
 if (fail)
   {
  D("Couldn't load tiles.\n");
- free_tiles(tiles, (*num_rows) * (*num_cols));
  return 0;
   }
 

-- 




[EGIT] [legacy/imlib2_loaders] master 01/05: ANI loader: Cosmetics

2019-11-20 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=4f8691a1da822bda0bba5d404c866c38ca6389ac

commit 4f8691a1da822bda0bba5d404c866c38ca6389ac
Author: Kim Woelders 
Date:   Sun Nov 17 18:44:17 2019 +0100

ANI loader: Cosmetics
---
 src/modules/loaders/loader_ani.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index e7a1ac8..def7bf5 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -86,7 +86,7 @@ ani_read_int8(FILE * fp, DATA8 * data, int count)
total = count;
while (count > 0)
  {
-bytes = fread((char *)data, sizeof(char), count, fp);
+bytes = fread(data, 1, count, fp);
 if (bytes <= 0) /* something bad happened */
break;
 count -= bytes;

-- 




[EGIT] [legacy/imlib2_loaders] master 04/05: XCF loader: Stop on errors and propagate error status up to load()

2019-11-20 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=701af6ea3caa62bdef8e9357fe23773e894651ec

commit 701af6ea3caa62bdef8e9357fe23773e894651ec
Author: Kim Woelders 
Date:   Sun Nov 17 14:59:36 2019 +0100

XCF loader: Stop on errors and propagate error status up to load()
---
 src/modules/loaders/loader_xcf.c | 46 +++-
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index a226ba2..b7d9da8 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -847,7 +847,7 @@ xcf_load_layer_props(Layer * layer)
return 0;
 }
 
-static void
+static int
 read_tiles_into_data(Tile * tiles, int num_cols, int width,
  int height, int bpp, DATA32 ** data_p, int use_cmap)
 {
@@ -859,7 +859,7 @@ read_tiles_into_data(Tile * tiles, int num_cols, int width,
int warned = 0;
 
if (!tiles)
-  return;
+  return 0;
 
if (*data_p)
   free(*data_p);
@@ -948,6 +948,8 @@ read_tiles_into_data(Tile * tiles, int num_cols, int width,
  *data++ = PIXEL_ARGB(a, r, g, b);
   }
  }
+
+   return warned;
 }
 
 static int
@@ -1291,8 +1293,7 @@ xcf_load_channel(void)
 {
Layer  *layer;
DATA32  hierarchy_offset;
-   int width;
-   int height;
+   int err, width, height;
char   *name;
 
D("Loading channel ...\n");
@@ -1323,10 +1324,12 @@ xcf_load_channel(void)
(&(layer->tiles), &(layer->num_rows), &(layer->num_cols), 
&(layer->bpp)))
   goto error;
 
-   read_tiles_into_data(layer->tiles, layer->num_cols, layer->width,
-layer->height, layer->bpp, &(layer->data), 0);
+   err = read_tiles_into_data(layer->tiles, layer->num_cols, layer->width,
+  layer->height, layer->bpp, &(layer->data), 0);
free_tiles(layer->tiles, layer->num_rows * layer->num_cols);
layer->tiles = NULL;
+   if (err)
+  goto error;
 
D("Channel loaded successfully.\n");
 
@@ -1344,9 +1347,7 @@ xcf_load_layer(void)
Layer  *layer_mask;
DATA32  hierarchy_offset;
DATA32  layer_mask_offset;
-   int width;
-   int height;
-   int type;
+   int err, width, height, type;
char   *name;
 
D("Loading one layer ...\n");
@@ -1400,11 +1401,13 @@ xcf_load_layer(void)
 layer->mask = layer_mask;
  }
 
-   read_tiles_into_data(layer->tiles, layer->num_cols,
-layer->width, layer->height,
-layer->bpp, &(layer->data), 1);
+   err = read_tiles_into_data(layer->tiles, layer->num_cols,
+  layer->width, layer->height,
+  layer->bpp, &(layer->data), 1);
free_tiles(layer->tiles, layer->num_rows * layer->num_cols);
layer->tiles = NULL;
+   if (err)
+  goto error;
 
set_layer_opacity(layer);
 
@@ -1418,7 +1421,7 @@ xcf_load_layer(void)
return NULL;
 }
 
-static void
+static int
 xcf_load_image(void)
 {
Layer  *layer;
@@ -1488,7 +1491,7 @@ xcf_load_image(void)
/* Flat-o-rama now :) */
flatten_image();
 
-   return;
+   return 1;/* Success */
 
  error:
if (num_successful_elements == 0)
@@ -1496,13 +1499,12 @@ xcf_load_image(void)
 
fprintf(stderr,
"XCF: This file is corrupt!  I have loaded as much of it as I can, 
but it is incomplete.\n");
-
-   return;
+   return 0;
 
  hard_error:
fprintf(stderr,
"XCF: This file is corrupt!  I could not even salvage any partial 
image data from it.\n");
-   return;
+   return 0;
 }
 
 static int
@@ -1593,12 +1595,15 @@ char
 load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
  char immediate_load)
 {
+   int rc = 0;
+
/* initialize */
if (!xcf_file_init(im->real_file))
   return 0;
 
/* do it! */
-   xcf_load_image();
+   if (!xcf_load_image())
+  goto quit;
 
/* Now paste stuff into Imlib image */
xcf_to_imlib(im);
@@ -1609,10 +1614,13 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
 progress(im, 100, 0, 0, im->w, im->h);
  }
 
+   rc = 1;  /* Success */
+
+ quit:
/* cleanup */
xcf_cleanup();
 
-   return 1;
+   return rc;
 }
 
 void

-- 




[EGIT] [legacy/imlib2_loaders] master 03/05: XCF loader: Prefer DATA32 when accessing imlib2 image data

2019-11-20 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=e2194ab37955bc21c4659804884cc9558712442a

commit e2194ab37955bc21c4659804884cc9558712442a
Author: Kim Woelders 
Date:   Wed Nov 20 16:57:08 2019 +0100

XCF loader: Prefer DATA32 when accessing imlib2 image data
---
 src/modules/loaders/color_values.h  |  20 
 src/modules/loaders/loader_xcf.c|  69 +++---
 src/modules/loaders/loader_xcf.h|  76 +++
 src/modules/loaders/loader_xcf_pixelfuncs.c | 143 +++-
 4 files changed, 173 insertions(+), 135 deletions(-)

diff --git a/src/modules/loaders/color_values.h 
b/src/modules/loaders/color_values.h
deleted file mode 100644
index 861daa5..000
--- a/src/modules/loaders/color_values.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __color_values_h
-#define __color_values_h 1
-
-#ifndef WORDS_BIGENDIAN
-
-#define A_VAL(p) ((DATA8 *)(p))[3]
-#define R_VAL(p) ((DATA8 *)(p))[2]
-#define G_VAL(p) ((DATA8 *)(p))[1]
-#define B_VAL(p) ((DATA8 *)(p))[0]
-
-#else
-
-#define A_VAL(p) ((DATA8 *)(p))[0]
-#define R_VAL(p) ((DATA8 *)(p))[1]
-#define G_VAL(p) ((DATA8 *)(p))[2]
-#define B_VAL(p) ((DATA8 *)(p))[3]
-
-#endif
-
-#endif /* __color_values_h */
diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index 7ca745d..a226ba2 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -55,7 +55,6 @@
 #include 
 #include 
 
-#include "color_values.h"
 #include "loader_common.h"
 #include "loader_xcf.h"
 
@@ -194,7 +193,7 @@ struct _Layer {
 * I know, but makes life easier
 */
 
-   DATA8  *data;
+   DATA32 *data;
 
/* Layers are stored as a linked list. */
struct _Layer  *next;
@@ -240,7 +239,7 @@ struct _GimpImage {
/* Tadaa -- the final image data. Layers get pasted
 * onto this one, bottom-up.
 */
-   DATA8  *data;
+   DATA32 *data;
 
Layer  *layers;
Layer  *last_layer;
@@ -410,8 +409,8 @@ set_layer_opacity(Layer * layer)
 
if (layer->opacity != 255)
  {
-for (i = 0, ptr = layer->data; i < layer->width * layer->height;
- i++, ptr += 4)
+for (i = 0, ptr = (DATA8 *) layer->data;
+ i < layer->width * layer->height; i++, ptr += 4)
   {
  *(ptr + 3) = (*(ptr + 3) * layer->opacity) >> 8;
   }
@@ -433,8 +432,8 @@ apply_layer_mask(Layer * layer)
if (!layer->mask)
   return;
 
-   ptr1 = layer->data;
-   ptr2 = layer->mask->data;
+   ptr1 = (DATA8 *) layer->data;
+   ptr2 = (DATA8 *) layer->mask->data;
 
for (i = 0; i < layer->width * layer->height; i++)
  {
@@ -850,12 +849,12 @@ xcf_load_layer_props(Layer * layer)
 
 static void
 read_tiles_into_data(Tile * tiles, int num_cols, int width,
- int height, int bpp, DATA8 ** data_p, int use_cmap)
+ int height, int bpp, DATA32 ** data_p, int use_cmap)
 {
int tile_x, tile_y, x, y, offset_x, offset_y;
-   DATA8  *data;
-   DATA8  *ptr;
+   DATA32 *data;
DATA8  *ptr2;
+   unsigned char   a, r, g, b;
Tile   *t;
int warned = 0;
 
@@ -866,9 +865,10 @@ read_tiles_into_data(Tile * tiles, int num_cols, int width,
   free(*data_p);
 
/* Always allocate the data as 4 bytes per pixel */
-   data = (*data_p) = malloc(sizeof(DATA32) * width * height);
+   data = malloc(sizeof(DATA32) * width * height);
+   *data_p = data;
 
-   ptr = data;
+   a = r = g = b = 0xff;
 
for (y = 0; y < height; y++)
  {
@@ -888,28 +888,28 @@ read_tiles_into_data(Tile * tiles, int num_cols, int 
width,
   /* use colormap if the image has one */
   if (image->cmap && use_cmap)
 {
-   R_VAL(ptr) = image->cmap[*(ptr2) * 3];
-   G_VAL(ptr) = image->cmap[*(ptr2) * 3 + 1];
-   B_VAL(ptr) = image->cmap[*(ptr2) * 3 + 2];
-   A_VAL(ptr) = 255;
+   r = image->cmap[*(ptr2) * 3];
+   g = image->cmap[*(ptr2) * 3 + 1];
+   b = image->cmap[*(ptr2) * 3 + 2];
+   a = 255;
 }
   /* else use colors themselves */
   else
 {
-   R_VAL(ptr) = *(ptr2);
-   G_VAL(ptr) = *(ptr2);
-   B_VAL(ptr) = *(ptr2);
-   A_VAL(ptr) = 255;
+   r = *(ptr2);
+   g = *(ptr2);
+   b = *(ptr2);
+   a = 255;
 }
   break;
 

[EGIT] [legacy/imlib2_loaders] master 01/06: Simplify autogen.sh

2019-11-19 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=081385836200b25f58b2a943ccef074087b5bd99

commit 081385836200b25f58b2a943ccef074087b5bd99
Author: Kim Woelders 
Date:   Sun Nov 17 06:14:25 2019 +0100

Simplify autogen.sh
---
 autogen.sh | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 7aeabb6..0d43361 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,13 +1,9 @@
 #!/bin/sh
+# Run this to generate all the initial makefiles, etc.
 
-rm -rf autom4te.cache
-rm -f aclocal.m4 ltmain.sh
+rm -rf autom4te.cache aclocal.m4
 
-echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
-echo "Running autoheader..." ; autoheader || exit 1
-echo "Running autoconf..." ; autoconf || exit 1
-echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize 
--automake) || exit 1
-echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
+autoreconf -vif
 
 if [ -z "$NOCONFIGURE" ]; then
./configure "$@"

-- 




[EGIT] [legacy/imlib2_loaders] master 06/06: ANI loader: Fix memory leak in error path

2019-11-19 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=85287fcb3fb426ba2a10767af8ed780dd12467e2

commit 85287fcb3fb426ba2a10767af8ed780dd12467e2
Author: Kim Woelders 
Date:   Sun Nov 17 12:26:22 2019 +0100

ANI loader: Fix memory leak in error path
---
 src/modules/loaders/loader_ani.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index c222e18..e7a1ac8 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -121,7 +121,7 @@ ani_init(char *filename)
   return NULL;
 
if (!(ani->fp = fopen(filename, "r")))
-  return NULL;
+  goto bail;
 
ani->filename = filename;
ani->cp += ani_read_int32(ani->fp, >riff_id, 1);
@@ -129,12 +129,13 @@ ani_init(char *filename)
ani->cp += ani_read_int32(ani->fp, >chunk_id, 1);
 
if (ani->riff_id != 0x46464952 || ani->chunk_id != 0x4E4F4341)
- {
-ani_cleanup(ani);
-return NULL;
- }
+  goto bail;
 
return ani;
+
+ bail:
+   ani_cleanup(ani);
+   return NULL;
 }
 
 static void

-- 




[EGIT] [legacy/imlib2_loaders] master 04/06: Match various changes done in imlib2 loaders

2019-11-19 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=043b5706aef70a6e2fc8c3bf65ae99c7807ffe72

commit 043b5706aef70a6e2fc8c3bf65ae99c7807ffe72
Author: Kim Woelders 
Date:   Sun Nov 17 08:58:00 2019 +0100

Match various changes done in imlib2 loaders
---
 src/modules/loaders/loader_ani.c | 12 
 src/modules/loaders/loader_eet.c | 16 
 src/modules/loaders/loader_xcf.c | 12 
 3 files changed, 4 insertions(+), 36 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index 79fedc5..54496da 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -256,18 +256,6 @@ load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
MsAni  *ani = NULL;
MsChunk*chunk;
 
-   /* if immediate_load is 1, then dont delay image laoding as below, or */
-   /* already data in this image - dont load it again */
-   if (im->data)
-  return 0;
-
-   /* set the format string member to the lower-case full extension */
-   /* name for the format - so example names would be: */
-   /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
-
-   if (!im->format)
-  im->format = strdup("ani");
-
if (im->loader || immediate_load || progress)
  {
 if (!(ani = ani_init((im->real_file
diff --git a/src/modules/loaders/loader_eet.c b/src/modules/loaders/loader_eet.c
index 0527a1b..95f9d33 100644
--- a/src/modules/loaders/loader_eet.c
+++ b/src/modules/loaders/loader_eet.c
@@ -73,10 +73,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
DATA32 *ret;
DATA32 *body;
 
-   if (im->data)
-  return 0;
-   if ((!im->file) || (!im->real_file) || (!im->key))
-  return 0;
strcpy(file, im->real_file);
strcpy(key, im->key);
if (!can_read(file))
@@ -133,14 +129,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 }
   im->w = w;
   im->h = h;
-  if (!im->format)
-{
-   if (alpha)
-  SET_FLAG(im->flags, F_HAS_ALPHA);
-   else
-  UNSET_FLAG(im->flags, F_HAS_ALPHA);
-   im->format = strdup("eet");
-}
+  if (alpha)
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+  else
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
}
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
  {
diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index 2da0652..86bdf9c 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -1662,22 +1662,10 @@ char
 load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
  char immediate_load)
 {
-   /* if immediate_load is 1, then dont delay image laoding as below, or */
-   /* already data in this image - dont load it again */
-
-   if (im->data)
-  return 0;
-
/* initialize */
if (!xcf_file_init(im->real_file))
   return 0;
 
-   /* set the format string member to the lower-case full extension */
-   /* name for the format - so example names would be: */
-   /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
-   if (!im->loader)
-  im->format = strdup("xcf");
-
/* do it! */
xcf_load_image();
 

-- 




[EGIT] [legacy/imlib2_loaders] master 05/06: ANI loader: Fix - Don't use __imlib_LoadImage() or tempnam()

2019-11-19 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=fbfa05c5ff590632ac91a6218b5aa538ac91f97a

commit fbfa05c5ff590632ac91a6218b5aa538ac91f97a
Author: Kim Woelders 
Date:   Sun Nov 17 09:05:40 2019 +0100

ANI loader: Fix - Don't use __imlib_LoadImage() or tempnam()
---
 src/modules/loaders/loader_ani.c | 53 
 1 file changed, 21 insertions(+), 32 deletions(-)

diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index 54496da..c222e18 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -231,31 +231,31 @@ ani_load(MsAni * ani)
 static char*
 ani_save_ico(MsChunk * chunk)
 {
-   char   *temp;
-   FILE   *f;
+   static char tmp[] = "/tmp/imlib2_loader_ani-XX";
+   int fd;
 
-   if (!(temp = tempnam(NULL, "ico_")))
+   fd = mkstemp(tmp);
+   if (fd < 0)
   return NULL;
 
-   if (!(f = fopen(temp, "w+")))
- {
-free(temp);
-return NULL;
- }
-
-   fwrite(>data, chunk->chunk_size, 1, f);
-   fclose(f);
+   write(fd, >data, chunk->chunk_size);
+   close(fd);
 
-   return temp;
+   return tmp;
 }
 
 char
 load(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity,
  char immediate_load)
 {
+   ImlibLoader*loader;
MsAni  *ani = NULL;
MsChunk*chunk;
 
+   loader = __imlib_FindBestLoaderForFormat("ico", 0);
+   if (!loader)
+  return 0;
+
if (im->loader || immediate_load || progress)
  {
 if (!(ani = ani_init((im->real_file
@@ -267,30 +267,19 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
   {
  if (chunk->chunk_id == 0x6E6F6369)
{
-  ImlibImage *temp_im;
-  char   *filename;
+  char   *file;
+  char   *tmpfile;
 
-  if (!(filename = ani_save_ico(chunk)))
+  if (!(tmpfile = ani_save_ico(chunk)))
  return 0;
 
-  temp_im =
- __imlib_LoadImage(filename, progress, 
progress_granularity,
-   immediate_load, 0, NULL);
-
-  im->w = temp_im->w;
-  im->h = temp_im->h;
-  SET_FLAG(im->flags, F_HAS_ALPHA);
-
-  if (!(im->data = malloc(sizeof(DATA32) * im->w * im->h)))
-{
-   free(filename);
-   return 0;
-}
+  file = im->real_file;
+  im->real_file = tmpfile;
+  loader->load(im, progress, progress_granularity,
+   immediate_load);
+  im->real_file = file;
 
-  memcpy(im->data, temp_im->data,
- sizeof(DATA32) * im->w * im->h);
-  unlink(filename);
-  free(filename);
+  unlink(tmpfile);
   break;
}
   }

-- 




[EGIT] [legacy/imlib2_loaders] master 03/06: Copy updated headers from imlib2

2019-11-19 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=65da6124f831152bcec87510dd5c809c300d2029

commit 65da6124f831152bcec87510dd5c809c300d2029
Author: Kim Woelders 
Date:   Sun Nov 17 06:40:23 2019 +0100

Copy updated headers from imlib2
---
 src/modules/loaders/common.h | 43 +++
 src/modules/loaders/image.h  | 21 ++---
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/modules/loaders/common.h b/src/modules/loaders/common.h
index 08916a1..0df2338 100644
--- a/src/modules/loaders/common.h
+++ b/src/modules/loaders/common.h
@@ -9,9 +9,6 @@
 #include 
 #include 
 #include 
-#ifdef WITH_DMALLOC
-#include 
-#endif
 
 #define DATABIG unsigned long long
 #define DATA64  unsigned long long
@@ -19,6 +16,35 @@
 #define DATA16  unsigned short
 #define DATA8   unsigned char
 
+#define SWAP32(x) \
+x) & 0x00ff ) << 24) | \
+ (((x) & 0xff00 ) <<  8) | \
+ (((x) & 0x00ff ) >>  8) | \
+ (((x) & 0xff00 ) >> 24))
+
+#define SWAP16(x) \
+x) & 0x00ff ) << 8) | \
+ (((x) & 0xff00 ) >> 8))
+
+#ifdef WORDS_BIGENDIAN
+#define SWAP_LE_16(x) SWAP16(x)
+#define SWAP_LE_32(x) SWAP32(x)
+#define SWAP_LE_16_INPLACE(x) x = SWAP16(x)
+#define SWAP_LE_32_INPLACE(x) x = SWAP32(x)
+#else
+#define SWAP_LE_16(x) (x)
+#define SWAP_LE_32(x) (x)
+#define SWAP_LE_16_INPLACE(x)
+#define SWAP_LE_32_INPLACE(x)
+#endif
+
+#define PIXEL_ARGB(a, r, g, b)  ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
+
+#define PIXEL_A(argb)  (((argb) >> 24) & 0xff)
+#define PIXEL_R(argb)  (((argb) >> 16) & 0xff)
+#define PIXEL_G(argb)  (((argb) >>  8) & 0xff)
+#define PIXEL_B(argb)  (((argb)  ) & 0xff)
+
 #ifdef DO_MMX_ASM
 int __imlib_get_cpuid(void);
 
@@ -27,13 +53,14 @@ int __imlib_get_cpuid(void);
 #endif
 
 #define CLIP(x, y, w, h, xx, yy, ww, hh) \
-if (x < (xx)) {w += (x - (xx)); x = (xx);} \
-if (y < (yy)) {h += (y - (yy)); y = (yy);} \
-if ((x + w) > ((xx) + (ww))) {w = (ww) - (x - xx);} \
-if ((y + h) > ((yy) + (hh))) {h = (hh) - (y - yy);}
+if (x < (xx)) { w += (x - (xx)); x = (xx); } \
+if (y < (yy)) { h += (y - (yy)); y = (yy); } \
+if ((x + w) > ((xx) + (ww))) { w = (ww) - (x - xx); } \
+if ((y + h) > ((yy) + (hh))) { h = (hh) - (y - yy); }
+
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
-#define round(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
+#define round(x) ((x) >=0 ? (int)((x) + 0.5) : (int)((x) - 0.5))
 
 #endif
diff --git a/src/modules/loaders/image.h b/src/modules/loaders/image.h
index ac35f6b..991f428 100644
--- a/src/modules/loaders/image.h
+++ b/src/modules/loaders/image.h
@@ -24,6 +24,7 @@ typedef int (*ImlibProgressFunction)(ImlibImage * im, 
char percent,
  int update_x, int update_y,
  int update_w, int update_h);
 typedef void(*ImlibDataDestructorFunction)(ImlibImage * im, void 
*data);
+typedef void   *(*ImlibImageDataMemoryFunction)(void *, size_t size);
 
 enum _iflags {
F_NONE = 0,
@@ -66,6 +67,7 @@ struct _imlibimage {
ImlibImageTag  *tags;
char   *real_file;
char   *key;
+   ImlibImageDataMemoryFunction data_memory_func;
 };
 
 #ifdef BUILD_X11
@@ -102,6 +104,10 @@ struct _imlibloader {
ImlibLoader*next;
 };
 
+DATA32 *__imlib_AllocateData(ImlibImage * im);
+void__imlib_FreeData(ImlibImage * im);
+void__imlib_ReplaceData(ImlibImage * im, DATA32 * new_data);
+
 void__imlib_AttachTag(ImlibImage * im, const char *key,
   int val, void *data,
   ImlibDataDestructorFunction destructor);
@@ -137,9 +143,8 @@ void__imlib_CleanupImagePixmapCache(void);
 void__imlib_RemoveAllLoaders(void);
 ImlibLoader*__imlib_FindBestLoaderForFile(const char *file,
   int for_save);
-ImlibLoader*__imlib_FindBestLoaderForFileFormat(const char *file,
-char *format,
-int for_save);
+ImlibLoader*__imlib_FindBestLoaderForFormat(const char *format,
+int for_save);
 void__imlib_SetImageAlphaFlag(ImlibImage * im, char alpha);
 ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data);
 ImlibImage *__imlib_LoadImage(const char *file,
@@ -180,12 +185,14 @@ void__imlib_SaveImage(ImlibImage * im, 
const char *file,
 #define SET_FLAG(flags, f) ((fla

[EGIT] [legacy/imlib2] master 01/01: ICO loader: Fix memory leak in error path

2019-11-17 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=947b602ccadeb5fe466792ff9055f44a721197c1

commit 947b602ccadeb5fe466792ff9055f44a721197c1
Author: Kim Woelders 
Date:   Sun Nov 17 10:51:41 2019 +0100

ICO loader: Fix memory leak in error path
---
 src/modules/loaders/loader_ico.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c
index d423626..e973394 100644
--- a/src/modules/loaders/loader_ico.c
+++ b/src/modules/loaders/loader_ico.c
@@ -214,7 +214,7 @@ ico_read(char *filename)
 
ico->fp = fopen(filename, "rb");
if (!ico->fp)
-  return NULL;
+  goto bail;
 
nr = fread(>idir, 1, sizeof(ico->idir), ico->fp);
if (nr != sizeof(ico->idir))

-- 




[EGIT] [legacy/imlib2] master 01/01: imlib2_view: Fix next/prev selection if last/first image is bad

2019-11-17 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=baaddf9366aea48bbdf26b9191f538f895e79fba

commit baaddf9366aea48bbdf26b9191f538f895e79fba
Author: Kim Woelders 
Date:   Sun Nov 17 06:03:49 2019 +0100

imlib2_view: Fix next/prev selection if last/first image is bad
---
 src/bin/imlib2_view.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index d98da4a..26f5dec 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -326,9 +326,15 @@ main(int argc, char **argv)
{
   no += inc;
   if (no >= argc)
- no = argc - 1;
-  else if (no <= 0)
- no = 0;
+{
+   inc = -1;
+   continue;
+}
+  else if (no < 0)
+{
+   inc = 1;
+   continue;
+}
   file = argv[no];
   if (verbose)
  printf("Show  %d: '%s'\n", no, file);

-- 




[EGIT] [legacy/imlib2] master 01/03: TGA loader: Tweak error handling

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=9bae2c9f0232cc7f4395dece1207365259e4198b

commit 9bae2c9f0232cc7f4395dece1207365259e4198b
Author: Kim Woelders 
Date:   Sat Nov 16 21:06:41 2019 +0100

TGA loader: Tweak error handling
---
 src/modules/loaders/loader_tiff.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/modules/loaders/loader_tiff.c 
b/src/modules/loaders/loader_tiff.c
index d4998c3..30a24d2 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -306,6 +306,12 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!TIFFRGBAImageBegin((TIFFRGBAImage *) & rgba_image, tif, 1, txt))
   goto quit1;
 
+   if (!rgba_image.rgba.put.any)
+ {
+fprintf(stderr, "imlib2-tiffloader: No put function");
+goto quit2;
+ }
+
rgba_image.image = im;
switch (rgba_image.rgba.orientation)
  {
@@ -341,23 +347,14 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 rgba_image.progress = progress;
 rgba_image.pper = rgba_image.py = 0;
 rgba_image.progress_granularity = progress_granularity;
-rast = (uint32 *) _TIFFmalloc(sizeof(uint32) * num_pixels);
 
-if ((!rast) || (!__imlib_AllocateData(im, im->w, im->h)))   /* 
Error checking */
-  {
- fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
+if (!__imlib_AllocateData(im, im->w, im->h))
+   goto quit2;
 
- if (rast)
-_TIFFfree(rast);
- __imlib_FreeData(im);
- goto quit2;
-  }
-
-if (!rgba_image.rgba.put.any)
+rast = (uint32 *) _TIFFmalloc(sizeof(uint32) * num_pixels);
+if (!rast)
   {
- fprintf(stderr, "imlib2-tiffloader: No put function");
-
- _TIFFfree(rast);
+ fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
  __imlib_FreeData(im);
  goto quit2;
   }

-- 




[EGIT] [legacy/imlib2] master 03/03: Remove __imlib_AllocateData() w, h args

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=1a6a6b6433f8af374ab26d1fe0fcb70c670675ac

commit 1a6a6b6433f8af374ab26d1fe0fcb70c670675ac
Author: Kim Woelders 
Date:   Sat Nov 16 20:41:08 2019 +0100

Remove __imlib_AllocateData() w,h args

im->w and im->h must always be set before __imlib_AllocateData() is
called due to non-immediate loading (__imlib_AllocateData() only
comes in play when the pixel data must be loaded).
---
 src/lib/image.c   | 13 +++--
 src/lib/image.h   |  2 +-
 src/modules/loaders/loader_argb.c |  5 +++--
 src/modules/loaders/loader_bmp.c  |  2 +-
 src/modules/loaders/loader_ff.c   |  2 +-
 src/modules/loaders/loader_gif.c  |  4 ++--
 src/modules/loaders/loader_ico.c  |  2 +-
 src/modules/loaders/loader_jpeg.c |  4 ++--
 src/modules/loaders/loader_lbm.c  |  2 +-
 src/modules/loaders/loader_png.c  |  4 +---
 src/modules/loaders/loader_pnm.c  |  5 ++---
 src/modules/loaders/loader_tga.c  | 12 ++--
 src/modules/loaders/loader_tiff.c |  2 +-
 src/modules/loaders/loader_webp.c |  2 +-
 src/modules/loaders/loader_xpm.c  |  4 ++--
 15 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/src/lib/image.c b/src/lib/image.c
index d2e0fb9..8533a33 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -28,18 +28,19 @@ static ImlibLoader *loaders = NULL;
 static int  cache_size = 4096 * 1024;
 
 __EXPORT__ DATA32  *
-__imlib_AllocateData(ImlibImage * im, int w, int h)
+__imlib_AllocateData(ImlibImage * im)
 {
+   int w = im->w;
+   int h = im->h;
+
+   if (w <= 0 || h <= 0)
+  return NULL;
+
if (im->data_memory_func)
   im->data = im->data_memory_func(NULL, w * h * sizeof(DATA32));
else
   im->data = malloc(w * h * sizeof(DATA32));
 
-   if (im->data)
- {
-im->w = w;
-im->h = h;
- }
return im->data;
 }
 
diff --git a/src/lib/image.h b/src/lib/image.h
index 37ca713..991f428 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -104,7 +104,7 @@ struct _imlibloader {
ImlibLoader*next;
 };
 
-DATA32 *__imlib_AllocateData(ImlibImage * im, int w, int h);
+DATA32 *__imlib_AllocateData(ImlibImage * im);
 void__imlib_FreeData(ImlibImage * im);
 void__imlib_ReplaceData(ImlibImage * im, DATA32 * new_data);
 
diff --git a/src/modules/loaders/loader_argb.c 
b/src/modules/loaders/loader_argb.c
index 2a092bc..337b784 100644
--- a/src/modules/loaders/loader_argb.c
+++ b/src/modules/loaders/loader_argb.c
@@ -40,6 +40,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
   else
  UNSET_FLAG(im->flags, F_HAS_ALPHA);
}
+
if (im->loader || immediate_load || progress)
  {
 DATA32 *ptr;
@@ -47,8 +48,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 charpper = 0;
 
 /* must set the im->data member before callign progress function */
-ptr = __imlib_AllocateData(im, w, h);
-if (!im->data)
+ptr = __imlib_AllocateData(im);
+if (!ptr)
   {
  im->w = 0;
  fclose(f);
diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c
index fc868fa..9601c7c 100644
--- a/src/modules/loaders/loader_bmp.c
+++ b/src/modules/loaders/loader_bmp.c
@@ -404,7 +404,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!buffer)
   goto quit_err;
 
-   if (!__imlib_AllocateData(im, w, h))
+   if (!__imlib_AllocateData(im))
   goto quit_err;
 
if (fread(buffer, imgsize, 1, f) != 1)
diff --git a/src/modules/loaders/loader_ff.c b/src/modules/loaders/loader_ff.c
index 3c97ad6..e52b99e 100644
--- a/src/modules/loaders/loader_ff.c
+++ b/src/modules/loaders/loader_ff.c
@@ -47,7 +47,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 h = im->h;
 rowlen = w * (sizeof("RGBA") - 1);
 
-if (!(__imlib_AllocateData(im, w, h)) ||
+if (!(__imlib_AllocateData(im)) ||
 !(row = malloc(rowlen * sizeof(uint16_t
   {
  __imlib_FreeData(im);
diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c
index 6b3f724..baa17c5 100644
--- a/src/modules/loaders/loader_gif.c
+++ b/src/modules/loaders/loader_gif.c
@@ -151,10 +151,10 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
colormap[bg] & 0x00ff : 0x;
   }
 
-if (!__imlib_AllocateData(im, w, h))
+ptr = __imlib_AllocateData(im);
+if (!ptr)
goto quit;
 
-ptr = im->data;
 per_inc = 100.0 / (float)h;
 for (i = 0; i < h; i++)
   {
diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c
index 061b384..d423626 1006

[EGIT] [legacy/imlib2] master 02/03: ICO loader: Fix non-immediate loading

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=2339dcb1cfb80536e82d0f2eefa9288a08396a5f

commit 2339dcb1cfb80536e82d0f2eefa9288a08396a5f
Author: Kim Woelders 
Date:   Sat Nov 16 20:01:57 2019 +0100

ICO loader: Fix non-immediate loading
---
 src/modules/loaders/loader_ico.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c
index c228d39..061b384 100644
--- a/src/modules/loaders/loader_ico.c
+++ b/src/modules/loaders/loader_ico.c
@@ -274,7 +274,7 @@ ico_data_get_nibble(DATA8 * data, int w, int x, int y)
 }
 
 static int
-ico_load(ico_t * ico, ImlibImage * im)
+ico_load(ico_t * ico, ImlibImage * im, int load_data)
 {
int ic, x, y, w, h, d;
DATA32 *cmap;
@@ -312,16 +312,22 @@ ico_load(ico_t * ico, ImlibImage * im)
 
w = ie->w;
h = ie->h;
-   if (w <= 0 || h <= 0)
+   if (!IMAGE_DIMENSIONS_OK(w, h))
   return 0;
 
+   im->w = w;
+   im->h = h;
+
+   SET_FLAG(im->flags, F_HAS_ALPHA);
+
+   if (!load_data)
+  return 1;
+
if (!__imlib_AllocateData(im, w, h))
   return 0;
 
D("Loading icon %d: WxHxD=%dx%dx%d\n", ic, w, h, ie->bih.bpp);
 
-   SET_FLAG(im->flags, F_HAS_ALPHA);
-
cmap = ie->cmap;
pxls = ie->pxls;
mask = ie->mask;
@@ -404,29 +410,23 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
  char immediate_load)
 {
ico_t  *ico;
+   int ok, load_data;
 
ico = ico_read(im->real_file);
if (!ico)
   return 0;
 
-   if (im->loader || immediate_load || progress)
+   load_data = im->loader || immediate_load || progress;
+   ok = ico_load(ico, im, load_data);
+   if (ok)
  {
-if (!ico_load(ico, im))
-   goto error;
-
 if (progress)
progress(im, 100, 0, 0, im->w, im->h);
  }
 
ico_delete(ico);
 
-   return 1;
-
- error:
-   ico_delete(ico);
-   __imlib_FreeData(im);
-
-   return 0;
+   return ok;
 }
 
 void

-- 




[EGIT] [legacy/imlib2] master 02/04: TGA loader: More mostly cosmetic changes

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=9cdd1bc007d777dff6de5d94fb0e6bdcd78046c8

commit 9cdd1bc007d777dff6de5d94fb0e6bdcd78046c8
Author: Kim Woelders 
Date:   Sat Nov 16 08:57:05 2019 +0100

TGA loader: More mostly cosmetic changes
---
 src/modules/loaders/loader_tga.c | 60 +---
 1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index ce724dd..7516e5b 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -185,17 +185,14 @@ load(ImlibImage * im, ImlibProgressFunction progress,
int fd, rc;
void   *seg, *filedata;
struct stat ss;
-   int bpp, vinverted = 0;
-   int rle = 0, footer_present = 0;
-
tga_header *header;
tga_footer *footer;
-
+   int footer_present;
+   int rle, bpp, hasa, vinverted;
unsigned long   datasize;
unsigned char  *bufptr, *bufend, *palette = 0;
DATA32 *dataptr;
-
-   int y, palcnt = 0, palbpp = 0;
+   int palcnt = 0, palbpp = 0;
unsigned char   a, r, g, b;
 
fd = open(im->real_file, O_RDONLY);
@@ -221,12 +218,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
footer = (tga_footer *) ((char *)filedata + ss.st_size - 
sizeof(tga_footer));
 
/* check the footer to see if we have a v2.0 TGA file */
-   if (memcmp(footer->signature, TGA_SIGNATURE, sizeof(footer->signature)) == 
0)
-  footer_present = 1;
-
-   if (!footer_present)
- {
- }
+   footer_present =
+  memcmp(footer->signature, TGA_SIGNATURE, sizeof(footer->signature)) == 0;
 
if ((size_t)ss.st_size < sizeof(tga_header) + header->idLength +
(footer_present ? sizeof(tga_footer) : 0))
@@ -244,30 +237,42 @@ load(ImlibImage * im, ImlibProgressFunction progress,
/* this flag indicated bottom-up pixel storage */
vinverted = !(header->descriptor & TGA_DESC_VERTICAL);
 
+   rle = 0; /* RLE compressed */
+
switch (header->imageType)
  {
+ default:
+goto quit;
+
+ case TGA_TYPE_MAPPED:
+ case TGA_TYPE_COLOR:
+ case TGA_TYPE_GRAY:
+break;
+
  case TGA_TYPE_MAPPED_RLE:
  case TGA_TYPE_COLOR_RLE:
  case TGA_TYPE_GRAY_RLE:
 rle = 1;
 break;
+ }
 
- case TGA_TYPE_MAPPED:
- case TGA_TYPE_COLOR:
- case TGA_TYPE_GRAY:
-rle = 0;
-break;
+   bpp = header->bpp;   /* Bits per pixel */
+   hasa = 0;/* Has alpha */
 
+   switch (bpp)
+ {
  default:
 goto quit;
+ case 32:
+if (header->descriptor & TGA_DESC_ABITS)
+   hasa = 1;
+break;
+ case 24:
+break;
+ case 8:
+break;
  }
 
-   /* bits per pixel */
-   bpp = header->bpp;
-
-   if (!((bpp == 32) || (bpp == 24) || (bpp == 8)))
-  goto quit;
-
/* endian-safe loading of 16-bit sizes */
im->w = (header->widthHi << 8) | header->widthLo;
im->h = (header->heightHi << 8) | header->heightLo;
@@ -275,7 +280,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
   goto quit;
 
-   if (bpp == 32)
+   if (hasa)
   SET_FLAG(im->flags, F_HAS_ALPHA);
else
   UNSET_FLAG(im->flags, F_HAS_ALPHA);
@@ -292,9 +297,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!__imlib_AllocateData(im, im->w, im->h))
   goto quit;
 
-   /* first we read the file data into a buffer for parsing */
-   /* then we decode from RAM */
-
/* find out how much data must be read from the file */
/* (this is NOT simply width*height*4, due to compression) */
 
@@ -328,11 +330,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 
if (!rle)
  {
+int x, y;
+
 /* decode uncompressed BGRA data */
 for (y = 0; y < im->h; y++) /* for each row */
   {
- int x;
-
  /* point dataptr at the beginning of the row */
  if (vinverted)
 /* some TGA's are stored upside-down! */

-- 




[EGIT] [legacy/imlib2] master 04/04: TGA loader: Add simple 16 bpp handling

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=a2cb8276e5bff36f5564290a4162f4ab29d3e23b

commit a2cb8276e5bff36f5564290a4162f4ab29d3e23b
Author: Kim Woelders 
Date:   Fri Nov 15 20:09:44 2019 +0100

TGA loader: Add simple 16 bpp handling

Probably not entirely correct (N alpha bits?).
---
 src/modules/loaders/loader_tga.c | 71 +++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index 053c695..51cb6b8 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -188,12 +188,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
tga_header *header;
tga_footer *footer;
int footer_present;
-   int rle, bpp, hasa, fliph, flipv;
+   int rle, bpp, hasa, hasc, fliph, flipv;
unsigned long   datasize;
unsigned char  *bufptr, *bufend, *palette = 0;
DATA32 *dataptr;
int palcnt = 0, palbpp = 0;
unsigned char   a, r, g, b;
+   unsigned intpix16;
 
fd = open(im->real_file, O_RDONLY);
if (fd < 0)
@@ -240,6 +241,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
flipv = !(header->descriptor & TGA_DESC_VERTICAL);
 
rle = 0; /* RLE compressed */
+   hasc = 0;/* Has color */
 
switch (header->imageType)
  {
@@ -247,12 +249,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 goto quit;
 
  case TGA_TYPE_MAPPED:
+break;
  case TGA_TYPE_COLOR:
+hasc = 1;
+break;
  case TGA_TYPE_GRAY:
 break;
 
  case TGA_TYPE_MAPPED_RLE:
+rle = 1;
+break;
  case TGA_TYPE_COLOR_RLE:
+hasc = 1;
+rle = 1;
+break;
  case TGA_TYPE_GRAY_RLE:
 rle = 1;
 break;
@@ -271,6 +281,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 break;
  case 24:
 break;
+ case 16:
+if (header->descriptor & TGA_DESC_ABITS)
+   hasa = 1;
+break;
  case 8:
 break;
  }
@@ -367,6 +381,24 @@ load(ImlibImage * im, ImlibProgressFunction progress,
*dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 
+case 16:
+   b = *bufptr++;
+   a = *bufptr++;
+   if (hasc)
+ {
+pix16 = b | ((unsigned short)a << 8);
+r = (pix16 >> 7) & 0xf8;
+g = (pix16 >> 2) & 0xf8;
+b = (pix16 << 3) & 0xf8;
+a = (hasa && !(pix16 & 0x8000)) ? 0x00 : 0xff;
+ }
+   else
+ {
+r = g = b;
+ }
+   *dataptr++ = PIXEL_ARGB(a, r, g, b);
+   break;
+
 case 8:/* 8-bit grayscale or palette */
b = *bufptr++;
a = 0xff;
@@ -431,6 +463,25 @@ load(ImlibImage * im, ImlibProgressFunction progress,
   *dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 
+case 16:
+   b = *bufptr++;
+   a = *bufptr++;
+   if (hasc)
+ {
+pix16 = b | ((unsigned short)a << 8);
+r = (pix16 >> 7) & 0xf8;
+g = (pix16 >> 2) & 0xf8;
+b = (pix16 << 3) & 0xf8;
+a = (hasa && !(pix16 & 0x8000)) ? 0x00 : 0xff;
+ }
+   else
+ {
+r = g = b;
+ }
+   for (i = 0; (i < count) && (dataptr < final_pixel); i++)
+  *dataptr++ = PIXEL_ARGB(a, r, g, b);
+   break;
+
 case 8:
b = *bufptr++;
a = 0xff;
@@ -476,6 +527,24 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 *dataptr++ = PIXEL_ARGB(a, r, g, b);
 break;
 
+ case 16:
+b = *bufptr++;
+a = *bufptr++;
+if (hasc)
+  {
+ pix16 = b | ((unsigned short)a << 8);
+ r 

[EGIT] [legacy/imlib2] master 02/02: imlib2_view: Add verbose option, quit on Escape too

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=83243f08fadcb31e1f5d64abf42d89ca3f84da24

commit 83243f08fadcb31e1f5d64abf42d89ca3f84da24
Author: Kim Woelders 
Date:   Sat Nov 16 08:26:34 2019 +0100

imlib2_view: Add verbose option, quit on Escape too
---
 src/bin/imlib2_view.c | 51 +++
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 0f63ce2..d98da4a 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -118,11 +118,18 @@ main(int argc, char **argv)
char   *s;
Imlib_Image*im = NULL;
char   *file = NULL;
-   int no = 1, inc;
+   int no, inc;
+   int verbose;
 
-   for (no = 1; no < argc; no++)
+   verbose = 0;
+
+   for (;;)
  {
-s = argv[no];
+argv++;
+argc--;
+if (argc <= 0)
+   break;
+s = argv[0];
 if (*s++ != '-')
break;
 switch (*s)
@@ -130,13 +137,18 @@ main(int argc, char **argv)
   default:
  break;
   case 's':/* Scale (window size wrt. image size) */
- if (++no < argc)
-scale_x = scale_y = atof(argv[no]);
+ if (argc-- < 2)
+break;
+ argv++;
+ scale_x = scale_y = atof(argv[0]);
+ break;
+  case 'v':
+ verbose += 1;
  break;
   }
  }
 
-   if (no >= argc)
+   if (argc <= 0)
  {
 fprintf(stderr, "imlib2_view [-s ] file...\n");
 return 1;
@@ -167,26 +179,24 @@ main(int argc, char **argv)
imlib_context_set_progress_granularity(10);
imlib_context_set_drawable(win);
 
-   file = argv[no];
-   im = imlib_load_image(file);
-   while (!im)
+   no = -1;
+   for (im = NULL; !im;)
  {
 no++;
 if (no == argc)
   {
- fprintf(stderr, "Image format not available\n");
+ fprintf(stderr, "No loadable image\n");
  exit(0);
   }
 file = argv[no];
+if (verbose)
+   printf("Show  %d: '%s'\n", no, file);
 image_width = 0;
 im = imlib_load_image(file);
-imlib_context_set_image(im);
- }
-   if (!im)
- {
-fprintf(stderr, "Image format not available\n");
-exit(0);
  }
+
+   imlib_context_set_image(im);
+
for (;;)
  {
 int x, y, b, count, fdsize, xfd, timeout = 0;
@@ -212,7 +222,7 @@ main(int argc, char **argv)
  break;
   case KeyPress:
  key = XLookupKeysym(, 0);
- if (key == XK_q)
+ if (key == XK_q || key == XK_Escape)
 return 0;
  if (key == XK_Right)
 goto show_next;
@@ -312,15 +322,16 @@ main(int argc, char **argv)
  zoom_mode = 0;
  imlib_context_set_image(im);
  imlib_free_image_and_decache();
- im = NULL;
- for (; !im;)
+ for (im = NULL; !im;)
{
   no += inc;
   if (no >= argc)
  no = argc - 1;
   else if (no <= 0)
- no = 1;
+ no = 0;
   file = argv[no];
+  if (verbose)
+ printf("Show  %d: '%s'\n", no, file);
   image_width = 0;
   im = imlib_load_image(file);
}

-- 




[EGIT] [legacy/imlib2] master 01/02: imlib2_test_load: Check progress conditionally

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=d6c13ec444eff6568701abe304fd058c3d8f5dda

commit d6c13ec444eff6568701abe304fd058c3d8f5dda
Author: Kim Woelders 
Date:   Sat Nov 16 06:08:15 2019 +0100

imlib2_test_load: Check progress conditionally
---
 src/bin/imlib2_test_load.c | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/bin/imlib2_test_load.c b/src/bin/imlib2_test_load.c
index 2489bbd..c5cfeea 100644
--- a/src/bin/imlib2_test_load.c
+++ b/src/bin/imlib2_test_load.c
@@ -10,7 +10,6 @@
 #define PROG_NAME "imlib2_test_load"
 
 static char progress_called;
-static char break_on_error;
 
 static void
 usage(int exit_status)
@@ -36,7 +35,10 @@ main(int argc, char **argv)
const char *s;
Imlib_Image im;
Imlib_Load_Errorlerr;
+   int check_progress;
+   int break_on_error;
 
+   check_progress = 0;
break_on_error = 0;
 
for (;;)
@@ -53,21 +55,32 @@ main(int argc, char **argv)
   case 'e':
  break_on_error += 1;
  break;
+  case 'p':
+ check_progress = 1;
+ break;
   }
  }
 
if (argc <= 0)
   usage(0);
 
-   imlib_context_set_progress_function(progress);
-   imlib_context_set_progress_granularity(10);
+   if (check_progress)
+ {
+imlib_context_set_progress_function(progress);
+imlib_context_set_progress_granularity(10);
+ }
 
for (; argc > 0; argc--, argv++)
  {
 progress_called = 0;
 
 printf("Loading image: '%s'\n", argv[0]);
-im = imlib_load_image_with_error_return(argv[0], );
+
+lerr = 0;
+if (check_progress)
+   im = imlib_load_image_with_error_return(argv[0], );
+else
+   im = imlib_load_image(argv[0]);
 if (!im)
   {
  printf("*** Error %d loading image: %s\n", lerr, argv[0]);
@@ -75,9 +88,11 @@ main(int argc, char **argv)
 break;
  continue;
   }
+
 imlib_context_set_image(im);
 imlib_free_image_and_decache();
-if (!progress_called)
+
+if (check_progress && !progress_called)
   {
  printf("*** No progress during image load\n");
  if (break_on_error & 1)

-- 




[EGIT] [legacy/imlib2] master 01/04: TGA loader - Mostly cosmetic refactoring

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=f01353d1554bda8f331266df3baab3c361cea95f

commit f01353d1554bda8f331266df3baab3c361cea95f
Author: Kim Woelders 
Date:   Fri Nov 15 17:31:48 2019 +0100

TGA loader - Mostly cosmetic refactoring
---
 src/modules/loaders/loader_tga.c | 135 +++
 1 file changed, 67 insertions(+), 68 deletions(-)

diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index 0713911..ce724dd 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -196,6 +196,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
DATA32 *dataptr;
 
int y, palcnt = 0, palbpp = 0;
+   unsigned char   a, r, g, b;
 
fd = open(im->real_file, O_RDONLY);
if (fd < 0)
@@ -347,36 +348,37 @@ load(ImlibImage * im, ImlibProgressFunction progress,
   switch (bpp)
 {
 case 32:   /* 32-bit BGRA pixels */
-   *dataptr++ =
-  PIXEL_ARGB(bufptr[3], bufptr[2], bufptr[1],
- bufptr[0]);
-   bufptr += 4;
+   b = *bufptr++;
+   g = *bufptr++;
+   r = *bufptr++;
+   a = *bufptr++;
+   *dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 
 case 24:   /* 24-bit BGR pixels */
-   *dataptr++ =
-  PIXEL_ARGB(0xff, bufptr[2], bufptr[1], bufptr[0]);
-   bufptr += 3;
+   b = *bufptr++;
+   g = *bufptr++;
+   r = *bufptr++;
+   a = 0xff;
+   *dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 
 case 8:/* 8-bit grayscale or palette */
-   if (!palette)
+   b = *bufptr++;
+   a = 0xff;
+   if (palette)
  {
-*dataptr++ =
-   PIXEL_ARGB(0xff, bufptr[0], bufptr[0],
-  bufptr[0]);
+if (b >= palcnt)
+   goto quit;
+r = palette[b * palbpp + 2];
+g = palette[b * palbpp + 1];
+b = palette[b * palbpp + 0];
  }
else
  {
-if (*bufptr >= palcnt)
-   goto quit;
-*dataptr++ =
-   PIXEL_ARGB(0xff,
-  palette[*bufptr * palbpp + 2],
-  palette[*bufptr * palbpp + 1],
-  palette[*bufptr * palbpp + 0]);
+r = g = b;
  }
-   bufptr += 1;
+   *dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 }
 
@@ -386,13 +388,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
else
  {
 /* decode RLE compressed data */
-unsigned char   curbyte, red, green, blue, alpha;
 DATA32 *final_pixel = dataptr + im->w * im->h;
 
 /* loop until we've got all the pixels or run out of input */
 while ((dataptr < final_pixel))
   {
  int i, count;
+ unsigned char   curbyte;
 
  if ((bufptr + 1 + (bpp / 8)) > bufend)
 goto quit;
@@ -405,43 +407,40 @@ load(ImlibImage * im, ImlibProgressFunction progress,
   switch (bpp)
 {
 case 32:
-   blue = *bufptr++;
-   green = *bufptr++;
-   red = *bufptr++;
-   alpha = *bufptr++;
+   b = *bufptr++;
+   g = *bufptr++;
+   r = *bufptr++;
+   a = *bufptr++;
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
-  *dataptr++ = PIXEL_ARGB(alpha, red, green, blue);
+  *dataptr++ = PIXEL_ARGB(a, r, g, b);
break;
 
 case 24:
-   blue = *bufptr++;
-   green = *bufptr++;
-   red = *bufptr++;
-   alpha = 0xff;
+   b = *bufptr++;
+   g = *bufptr++;
+   r = *bufp

[EGIT] [legacy/imlib2] master 03/04: TGA loader: Support horiontal flip

2019-11-16 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=0d0a701a96bf87a5df95fd8bb599b414b6a6a220

commit 0d0a701a96bf87a5df95fd8bb599b414b6a6a220
Author: Kim Woelders 
Date:   Sat Nov 16 08:29:12 2019 +0100

TGA loader: Support horiontal flip
---
 src/modules/loaders/loader_tga.c | 53 +---
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index 7516e5b..053c695 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -17,7 +17,7 @@
 #include "blend.h"
 
 /* flip an inverted image - see RLE reading below */
-static void tgaflip(DATA32 * in, int w, int h);
+static void tgaflip(DATA32 * in, int w, int h, int fliph, int flipv);
 
 /* TGA pixel formats */
 #define TGA_TYPE_MAPPED  1
@@ -188,7 +188,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
tga_header *header;
tga_footer *footer;
int footer_present;
-   int rle, bpp, hasa, vinverted;
+   int rle, bpp, hasa, fliph, flipv;
unsigned long   datasize;
unsigned char  *bufptr, *bufend, *palette = 0;
DATA32 *dataptr;
@@ -234,8 +234,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 
/* now parse the header */
 
-   /* this flag indicated bottom-up pixel storage */
-   vinverted = !(header->descriptor & TGA_DESC_VERTICAL);
+   /* this flag indicates right-to-left pixel storage */
+   fliph = !!(header->descriptor & TGA_DESC_HORIZONTAL);
+   /* this flag indicates bottom-up pixel storage */
+   flipv = !(header->descriptor & TGA_DESC_VERTICAL);
 
rle = 0; /* RLE compressed */
 
@@ -336,7 +338,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 for (y = 0; y < im->h; y++) /* for each row */
   {
  /* point dataptr at the beginning of the row */
- if (vinverted)
+ if (flipv)
 /* some TGA's are stored upside-down! */
 dataptr = im->data + ((im->h - y - 1) * im->w);
  else
@@ -386,6 +388,9 @@ load(ImlibImage * im, ImlibProgressFunction progress,
 
}/* end for (each pixel) */
   }
+
+if (fliph)
+   tgaflip(im->data, im->w, im->h, fliph, 0);
  }
else
  {
@@ -493,9 +498,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
}/* end if (raw packet) */
   } /* end for (each packet) */
 
-/* must now flip a bottom-up image */
-if (vinverted)
-   tgaflip(im->data, im->w, im->h);
+if (fliph || flipv)
+   tgaflip(im->data, im->w, im->h, fliph, flipv);
  }
 
if (progress)
@@ -529,28 +533,27 @@ formats(ImlibLoader * l)
 
 /**/
 
-/* flip a DATA32 image block vertically in place */
-
-static void
-tgaflip(DATA32 * in, int w, int h)
+/* flip a DATA32 image block in place */
+void
+tgaflip(DATA32 * in, int w, int h, int fliph, int flipv)
 {
-   DATA32 *adv, *adv2;
-   int x, y;
+   DATA32  tmp;
+   int x, y, x2, y2, dx, dy, nx, ny;
 
-   adv = in;
-   adv2 = in + (w * (h - 1));
+   dx = fliph ? -1 : 1;
+   dy = flipv ? -1 : 1;
+   nx = fliph ? w / 2 : w;
+   ny = flipv && !fliph ? h / 2 : h;
 
-   for (y = 0; y < (h / 2); y++)
+   y2 = flipv ? h - 1 : 0;
+   for (y = 0; y < ny; y++, y2 += dy)
  {
-DATA32  tmp;
-
-for (x = 0; x < w; x++)
+x2 = fliph ? w - 1 : 0;
+for (x = 0; x < nx; x++, x2 += dx)
   {
- tmp = adv[x];
- adv[x] = adv2[x];
- adv2[x] = tmp;
+ tmp = in[y * h + x];
+ in[y * h + x] = in[y2 * h + x2];
+ in[y2 * h + x2] = tmp;
   }
-adv2 -= w;
-adv += w;
  }
 }

-- 




[EGIT] [legacy/imlib2] master 01/01: imlib2_test_load: Fixup recent breakage for real

2019-11-15 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=6eb958fb1b1cde59ae98488f45da428d21006108

commit 6eb958fb1b1cde59ae98488f45da428d21006108
Author: Kim Woelders 
Date:   Thu Nov 14 16:38:57 2019 +0100

imlib2_test_load: Fixup recent breakage for real
---
 src/bin/imlib2_test_load.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/bin/imlib2_test_load.c b/src/bin/imlib2_test_load.c
index c5dcc78..2489bbd 100644
--- a/src/bin/imlib2_test_load.c
+++ b/src/bin/imlib2_test_load.c
@@ -56,19 +56,14 @@ main(int argc, char **argv)
   }
  }
 
-   if (argc < 1)
+   if (argc <= 0)
   usage(0);
 
imlib_context_set_progress_function(progress);
imlib_context_set_progress_granularity(10);
 
-   for (;;)
+   for (; argc > 0; argc--, argv++)
  {
-argc--;
-argv++;
-if (argc <= 0)
-   break;
-
 progress_called = 0;
 
 printf("Loading image: '%s'\n", argv[0]);

-- 




[EGIT] [legacy/imlib2] master 04/04: imlib2_view: Fix event processing bug

2019-11-10 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=bb42ef3f2291c5d4df0f8f0bcd3b4bdd983d0fd4

commit bb42ef3f2291c5d4df0f8f0bcd3b4bdd983d0fd4
Author: Kim Woelders 
Date:   Sun Nov 10 14:22:26 2019 +0100

imlib2_view: Fix event processing bug
---
 src/bin/imlib2_view.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index c94b39c..0f63ce2 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -327,6 +327,10 @@ main(int argc, char **argv)
  imlib_context_set_image(im);
  break;
   }
+
+if (XPending(disp))
+   continue;
+
 t1 = 0.2;
 tval.tv_sec = (long)t1;
 tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 100);
@@ -334,10 +338,12 @@ main(int argc, char **argv)
 fdsize = xfd + 1;
 FD_ZERO();
 FD_SET(xfd, );
+
 if (timeout)
count = select(fdsize, , NULL, NULL, );
 else
count = select(fdsize, , NULL, NULL, NULL);
+
 if (count < 0)
   {
  if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))

-- 




[EGIT] [legacy/imlib2] master 02/04: Simplify loader lookup functions

2019-11-10 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=5d1e984e57e23068219d02aefe6a3a4be24b9ade

commit 5d1e984e57e23068219d02aefe6a3a4be24b9ade
Author: Kim Woelders 
Date:   Tue Oct 15 19:21:00 2019 +0200

Simplify loader lookup functions
---
 src/lib/image.c   | 111 ++
 src/lib/image.h   |   5 +-
 src/modules/loaders/loader_bz2.c  |   4 +-
 src/modules/loaders/loader_zlib.c |   4 +-
 4 files changed, 34 insertions(+), 90 deletions(-)

diff --git a/src/lib/image.c b/src/lib/image.c
index 99f05db..d2e0fb9 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -741,28 +741,13 @@ __imlib_LoadAllLoaders(void)
 }
 
 __EXPORT__ ImlibLoader *
-__imlib_FindBestLoaderForFile(const char *file, int for_save)
+__imlib_FindBestLoaderForFormat(const char *format, int for_save)
 {
-   char   *extension, *lower, *rfile;
-   ImlibLoader*l = NULL;
-
-   /* use the file extension for a "best guess" as to what loader to try */
-   /* first at any rate */
-
-   rfile = __imlib_FileRealFile(file);
-   extension = __imlib_FileExtension(rfile);
-   free(rfile);
-   /* change the extensiont o all lower case as all "types" are listed as */
-   /* lower case strings from the loader that represent all the possible */
-   /* extensions that file format could have */
-   lower = extension;
-   while (*lower)
- {
-*lower = tolower(*lower);
-lower++;
- }
-   if (!extension)
+   ImlibLoader*l;
+
+   if (!format || format[0] == '\0')
   return NULL;
+
/* go through the loaders - first loader that claims to handle that */
/* image type (extension wise) wins as a first guess to use - NOTE */
/* this is an OPTIMISATION - it is possible the file has no extension */
@@ -775,8 +760,7 @@ __imlib_FindBestLoaderForFile(const char *file, int 
for_save)
/* to be used first next time in this search mechanims - this */
/* assumes you tend to laod a few image types and ones generally */
/* of the same format */
-   l = loaders;
-   while (l)
+   for (l = loaders; l; l = l->next)
  {
 int i;
 
@@ -784,83 +768,44 @@ __imlib_FindBestLoaderForFile(const char *file, int 
for_save)
 for (i = 0; i < l->num_formats; i++)
   {
  /* does it match ? */
- if (!strcmp(l->formats[i], extension))
+ if (strcasecmp(l->formats[i], format) == 0)
{
   /* does it provide the function we need? */
   if ((for_save && l->save) || (!for_save && l->load))
-{
-   /* free the memory allocated for the extension */
-   free(extension);
-   /* return the loader */
-   return l;
-}
+ goto done;
}
   }
-l = l->next;
  }
-   /* free the memory allocated for the extension */
+
+ done:
+   return l;
+}
+
+__EXPORT__ ImlibLoader *
+__imlib_FindBestLoaderForFile(const char *file, int for_save)
+{
+   char   *extension;
+   ImlibLoader*l;
+
+   extension = __imlib_FileExtension(file);
+
+   l = __imlib_FindBestLoaderForFormat(extension, for_save);
+
free(extension);
-   /* return the loader */
+
return l;
 }
 
-ImlibLoader*
+static ImlibLoader *
 __imlib_FindBestLoaderForFileFormat(const char *file, char *format,
 int for_save)
 {
-   char   *extension, *lower;
-   ImlibLoader*l = NULL;
-
/* if the format is provided ("png" "jpg" etc.) use that */
+   /* otherwise us the file extension */
if (format)
-  extension = strdup(format);
-   /* otherwise us the extension */
+  return __imlib_FindBestLoaderForFormat(format, for_save);
else
- {
-extension = __imlib_FileExtension(file);
-/* change the extension to all lower case as all "types" are listed as 
*/
-/* lower case strings from the loader that represent all the possible 
*/
-/* extensions that file format could have */
-if (extension)
-  {
- lower = extension;
- while (*lower)
-   {
-  *lower = tolower(*lower);
-  lower++;
-   }
-  }
- }
-   if (!extension)
-  return NULL;
-   /* look through the loaders one by one to see if one matches that format */
-   l = loaders;
-   while (l)
- {
-int i;
-
-/* go through all the formats that loader supports */
-for (i = 0; i < l->num_formats; i++)
-  {
- /* does it match ? */
- if (!strcmp(l->formats[i], extension))
-   {
-  /* does it pro

[EGIT] [legacy/imlib2] master 03/04: imlib2_view: Enable selecting next/prev using keys too

2019-11-10 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=3748dd580ff305f0c83c61ad0ef3c785ee9a8e6f

commit 3748dd580ff305f0c83c61ad0ef3c785ee9a8e6f
Author: Kim Woelders 
Date:   Sat Nov 9 17:12:10 2019 +0100

imlib2_view: Enable selecting next/prev using keys too
---
 src/bin/imlib2_view.c | 82 ++-
 1 file changed, 36 insertions(+), 46 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index ecb73a3..c94b39c 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -118,7 +118,7 @@ main(int argc, char **argv)
char   *s;
Imlib_Image*im = NULL;
char   *file = NULL;
-   int no = 1;
+   int no = 1, inc;
 
for (no = 1; no < argc; no++)
  {
@@ -202,6 +202,9 @@ main(int argc, char **argv)
 XNextEvent(disp, );
 switch (ev.type)
   {
+  default:
+ break;
+
   case ClientMessage:
  if (ev.xclient.message_type == ATOM_WM_PROTOCOLS &&
  (Atom) ev.xclient.data.l[0] == ATOM_WM_DELETE_WINDOW)
@@ -211,6 +214,10 @@ main(int argc, char **argv)
  key = XLookupKeysym(, 0);
  if (key == XK_q)
 return 0;
+ if (key == XK_Right)
+goto show_next;
+ if (key == XK_Left)
+goto show_prev;
  break;
   case ButtonPress:
  b = ev.xbutton.button;
@@ -239,51 +246,9 @@ main(int argc, char **argv)
  if (b == 3)
 zoom_mode = 0;
  if (b == 1)
-   {
-  no++;
-  if (no == argc)
- no = argc - 1;
-  file = argv[no];
-  image_width = 0;
-  zoom = 1.0;
-  zoom_mode = 0;
-  imlib_context_set_image(im);
-  imlib_free_image_and_decache();
-  im = imlib_load_image(file);
-  while (!im)
-{
-   no++;
-   if (no == argc)
-  exit(0);
-   file = argv[no];
-   image_width = 0;
-   im = imlib_load_image(file);
-}
-  imlib_context_set_image(im);
-   }
+goto show_next;
  if (b == 2)
-   {
-  no--;
-  if (no == 0)
- no = 1;
-  file = argv[no];
-  image_width = 0;
-  zoom = 1.0;
-  zoom_mode = 0;
-  imlib_context_set_image(im);
-  imlib_free_image_and_decache();
-  im = imlib_load_image(file);
-  while (!im)
-{
-   no--;
-   if (no == 0)
-  no = 1;
-   file = argv[no];
-   image_width = 0;
-   im = imlib_load_image(file);
-}
-  imlib_context_set_image(im);
-   }
+goto show_prev;
  break;
   case MotionNotify:
  while (XCheckTypedWindowEvent(disp, win, MotionNotify, ));
@@ -334,7 +299,32 @@ main(int argc, char **argv)
   XFlush(disp);
   timeout = 1;
}
-  default:
+ break;
+
+   show_next:
+ inc = 1;
+ goto show_next_prev;
+   show_prev:
+ inc = -1;
+ goto show_next_prev;
+   show_next_prev:
+ zoom = 1.0;
+ zoom_mode = 0;
+ imlib_context_set_image(im);
+ imlib_free_image_and_decache();
+ im = NULL;
+ for (; !im;)
+   {
+  no += inc;
+  if (no >= argc)
+ no = argc - 1;
+  else if (no <= 0)
+ no = 1;
+  file = argv[no];
+  image_width = 0;
+  im = imlib_load_image(file);
+   }
+ imlib_context_set_image(im);
  break;
   }
 t1 = 0.2;

-- 




[EGIT] [legacy/imlib2] master 01/04: XPM loader: Accept signature not at the very start of the file

2019-11-10 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=7a2769cad7181a4ecf844714d0c06a423156b739

commit 7a2769cad7181a4ecf844714d0c06a423156b739
Author: Kim Woelders 
Date:   Sat Nov 9 14:09:37 2019 +0100

XPM loader: Accept signature not at the very start of the file
---
 src/modules/loaders/loader_xpm.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/modules/loaders/loader_xpm.c b/src/modules/loaders/loader_xpm.c
index c18faa2..c35f32d 100644
--- a/src/modules/loaders/loader_xpm.c
+++ b/src/modules/loaders/loader_xpm.c
@@ -125,14 +125,15 @@ load(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity,
if (!f)
   return 0;
 
-   if (fread(s, 1, 9, f) != 9)
+   if (fread(s, 1, sizeof(s) - 1, f) < 9)
   goto quit;
 
-   rewind(f);
-   s[9] = 0;
-   if (strcmp("/* XPM */", s))
+   s[sizeof(s) - 1] = '\0';
+   if (!strstr(s, " XPM */"))
   goto quit;
 
+   rewind(f);
+
i = 0;
j = 0;
w = 10;

-- 




[EGIT] [legacy/imlib2] master 05/05: Eliminate READ_RGBA()

2019-11-09 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=484bd5cc79500d6f345b6bd0bd624d94b467bc65

commit 484bd5cc79500d6f345b6bd0bd624d94b467bc65
Author: Kim Woelders 
Date:   Sat Nov 9 08:04:05 2019 +0100

Eliminate READ_RGBA()
---
 src/lib/blend.h | 15 ---
 src/lib/grad.c  | 28 ++--
 2 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/lib/blend.h b/src/lib/blend.h
index c848fba..d589833 100644
--- a/src/lib/blend.h
+++ b/src/lib/blend.h
@@ -19,21 +19,6 @@
 
 #endif
 
-/* FIXME: endian dependent */
-#define READ_RGB(p, r, g, b)  \
-   (r) = R_VAL(p); \
-   (g) = G_VAL(p); \
-   (b) = B_VAL(p);
-
-#define READ_ALPHA(p, a) \
-   (a) = A_VAL(p);
-
-#define READ_RGBA(p, r, g, b, a) \
-   (r) = R_VAL(p); \
-   (g) = G_VAL(p); \
-   (b) = B_VAL(p); \
-   (a) = A_VAL(p);
-
 #define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
((x < (xx + ww)) && \
(y < (yy + hh)) && \
diff --git a/src/lib/grad.c b/src/lib/grad.c
index b5085b2..5686a9e 100644
--- a/src/lib/grad.c
+++ b/src/lib/grad.c
@@ -8,6 +8,14 @@
 #include "grad.h"
 #include "image.h"
 
+#define ARGB_TO_R_G_B_A(argb, r, g, b, a) \
+do { \
+r = PIXEL_R(argb); \
+g = PIXEL_G(argb); \
+b = PIXEL_B(argb); \
+a = PIXEL_A(argb); \
+} while(0)
+
 ImlibRange *
 __imlib_CreateRange(void)
 {
@@ -334,7 +342,7 @@ __imlib_DrawGradient(ImlibImage * im, int x, int y, int w, 
int h,
   i = 0;
else if (i >= len)
   i = len - 1;
-   READ_RGBA(&(map[i]), r, g, b, a);
+   ARGB_TO_R_G_B_A(map[i], r, g, b, a);
BLEND_DST_ALPHA(r, g, b, a, p);
p++;
 }
@@ -352,7 +360,7 @@ __imlib_DrawGradient(ImlibImage * im, int x, int y, int w, 
int h,
   i = 0;
else if (i >= len)
   i = len - 1;
-   READ_RGBA(&(map[i]), r, g, b, a);
+   ARGB_TO_R_G_B_A(map[i], r, g, b, a);
BLEND(r, g, b, a, p);
p++;
 }
@@ -370,7 +378,7 @@ __imlib_DrawGradient(ImlibImage * im, int x, int y, int w, 
int h,
  i = 0;
   else if (i >= len)
  i = len - 1;
-  READ_RGBA(&(map[i]), r, g, b, a);
+  ARGB_TO_R_G_B_A(map[i], r, g, b, a);
   BLEND_SUB(r, g, b, a, p);
   p++;
}
@@ -387,7 +395,7 @@ __imlib_DrawGradient(ImlibImage * im, int x, int y, int w, 
int h,
  i = 0;
   else if (i >= len)
  i = len - 1;
-  READ_RGBA(&(map[i]), r, g, b, a);
+  ARGB_TO_R_G_B_A(map[i], r, g, b, a);
   BLEND_SUB(r, g, b, a, p);
   p++;
}
@@ -404,7 +412,7 @@ __imlib_DrawGradient(ImlibImage * im, int x, int y, int w, 
int h,
  i = 0;
   else if (i >= len)
  i = len - 1;
-  READ_RGBA(&(map[i]), r, g, b, a);
+  ARGB_TO_R_G_B_A(map[i], r, g, b, a);
   BLEND_RE(r, g, b, a, p);
   p++;
}
@@ -527,7 +535,7 @@ __imlib_DrawHsvaGradient(ImlibImage * im, int x, int y, int 
w, int h,
   i = 0;
else if (i >= len)
   i = len - 1;
-   READ_RGBA(&(map[i]), r, g, b, a);
+   ARGB_TO_R_G_B_A(map[i], r, g, b, a);
BLEND_DST_ALPHA(r, g, b, a, p);
p++;
 }
@@ -545,7 +553,7 @@ __imlib_DrawHsvaGradient(ImlibImage * im, int x, int y, int 
w, int h,
   i = 0;
else if (i >= len)
   i = len - 1;
-   READ_RGBA(&(map[i]), r, g, b, a);
+   ARGB_TO_R_G_B_A(map[i], r, g, b, a);
BLEND(r, g, b, a, p);
p++;
 }
@@ -563,7 +571,7 @@ __imlib_DrawHsvaGradient(ImlibImage * im, int x, int y, int 
w, int h,
  i = 0;
   else if (i >= len)
  i = len - 1;
-  READ_RGBA(&(map[i]), r, g, b, a);
+  ARGB_TO_R_G_B_A(map[i], r, g, b, a);
   BLEND_SUB(r, g, b, a, p);
   p++;
}
@@ -580,7 +588,7 @@ __imlib_DrawHsvaGradient(ImlibImage * im, int x, int y, int 
w, int h,
  i = 0;
   else if (i >= len)
  i = len - 1;
-  READ_RGBA(&(map[i]), 

[EGIT] [legacy/imlib2] master 04/05: Use macro for pixel color access in savers

2019-11-09 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=3e082b2310c02d086e4ee2c4f6d96ea74b44a79c

commit 3e082b2310c02d086e4ee2c4f6d96ea74b44a79c
Author: Kim Woelders 
Date:   Sat Nov 9 07:48:34 2019 +0100

Use macro for pixel color access in savers
---
 src/lib/common.h  |  5 +
 src/modules/loaders/loader_bmp.c  |  6 +++---
 src/modules/loaders/loader_jpeg.c |  9 +
 src/modules/loaders/loader_png.c  |  9 ++---
 src/modules/loaders/loader_pnm.c  | 20 +++-
 src/modules/loaders/loader_tga.c  | 22 ++
 src/modules/loaders/loader_tiff.c |  8 
 7 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/src/lib/common.h b/src/lib/common.h
index 201df30..0df2338 100644
--- a/src/lib/common.h
+++ b/src/lib/common.h
@@ -40,6 +40,11 @@
 
 #define PIXEL_ARGB(a, r, g, b)  ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
 
+#define PIXEL_A(argb)  (((argb) >> 24) & 0xff)
+#define PIXEL_R(argb)  (((argb) >> 16) & 0xff)
+#define PIXEL_G(argb)  (((argb) >>  8) & 0xff)
+#define PIXEL_B(argb)  (((argb)  ) & 0xff)
+
 #ifdef DO_MMX_ASM
 int __imlib_get_cpuid(void);
 
diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c
index 0193cb9..fc868fa 100644
--- a/src/modules/loaders/loader_bmp.c
+++ b/src/modules/loaders/loader_bmp.c
@@ -941,9 +941,9 @@ save(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity)
 for (j = 0; j < im->w; j++)
   {
  pixel = im->data[im->w * (im->h - i - 1) + j];
- WriteleByte(f, pixel & 0xff);
- WriteleByte(f, (pixel >> 8) & 0xff);
- WriteleByte(f, (pixel >> 16) & 0xff);
+ WriteleByte(f, PIXEL_B(pixel));
+ WriteleByte(f, PIXEL_G(pixel));
+ WriteleByte(f, PIXEL_R(pixel));
   }
 for (j = 0; j < pad; j++)
WriteleByte(f, 0);
diff --git a/src/modules/loaders/loader_jpeg.c 
b/src/modules/loaders/loader_jpeg.c
index 314b61d..3957987 100644
--- a/src/modules/loaders/loader_jpeg.c
+++ b/src/modules/loaders/loader_jpeg.c
@@ -286,10 +286,11 @@ save(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity)
 /* convcert scaline from ARGB to RGB packed */
 for (j = 0, i = 0; i < im->w; i++)
   {
- buf[j++] = ((*ptr) >> 16) & 0xff;
- buf[j++] = ((*ptr) >> 8) & 0xff;
- buf[j++] = ((*ptr)) & 0xff;
- ptr++;
+ DATA32  pixel = *ptr++;
+
+ buf[j++] = PIXEL_R(pixel);
+ buf[j++] = PIXEL_G(pixel);
+ buf[j++] = PIXEL_B(pixel);
   }
 /* write scanline */
 jbuf = (JSAMPROW *) ();
diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c
index fb9541f..a6533e5 100644
--- a/src/modules/loaders/loader_png.c
+++ b/src/modules/loaders/loader_png.c
@@ -347,13 +347,16 @@ save(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity)
{
   for (j = 0, x = 0; x < im->w; x++)
 {
-   data[j++] = (ptr[x] >> 16) & 0xff;
-   data[j++] = (ptr[x] >> 8) & 0xff;
-   data[j++] = (ptr[x]) & 0xff;
+   DATA32  pixel = ptr[x];
+
+   data[j++] = PIXEL_R(pixel);
+   data[j++] = PIXEL_G(pixel);
+   data[j++] = PIXEL_B(pixel);
 }
   row_ptr = (png_bytep) data;
}
  png_write_rows(png_ptr, _ptr, 1);
+
  if (progress)
{
   charper;
diff --git a/src/modules/loaders/loader_pnm.c b/src/modules/loaders/loader_pnm.c
index 1b63b3c..b29c626 100644
--- a/src/modules/loaders/loader_pnm.c
+++ b/src/modules/loaders/loader_pnm.c
@@ -467,12 +467,13 @@ save(ImlibImage * im, ImlibProgressFunction progress, 
char progress_granularity)
  bptr = buf;
  for (x = 0; x < im->w; x++)
{
-  bptr[0] = ((*ptr) >> 16) & 0xff;
-  bptr[1] = ((*ptr) >> 8) & 0xff;
-  bptr[2] = ((*ptr)) & 0xff;
-  bptr[3] = ((*ptr) >> 24) & 0xff;
+  DATA32  pixel = *ptr++;
+
+  bptr[0] = PIXEL_R(pixel);
+  bptr[1] = PIXEL_G(pixel);
+  bptr[2] = PIXEL_B(pixel);
+  bptr[3] = PIXEL_A(pixel);
   bptr += 4;
-  ptr++;
}
  fwrite(buf, im->w * 4, 1, f);
  if (progress &&
@@ -495,11 +496,12 @@ save(

[EGIT] [legacy/imlib2] master 03/05: Use pixel instead of r, b, g, a in __imlib_render_str()

2019-11-09 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=755dc017f26e4756fed3402abaeac3598afc6817

commit 755dc017f26e4756fed3402abaeac3598afc6817
Author: Kim Woelders 
Date:   Sat Nov 9 07:23:09 2019 +0100

Use pixel instead of r,b,g,a in __imlib_render_str()
---
 src/lib/api.c   |  4 +---
 src/lib/font.h  |  3 +--
 src/lib/font_draw.c | 11 ---
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/lib/api.c b/src/lib/api.c
index 062a71b..3476aa1 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -3299,9 +3299,7 @@ imlib_text_draw_with_return_metrics(int x, int y, const 
char *text,
if (ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0)
   dir = IMLIB_TEXT_TO_RIGHT;
 
-   __imlib_render_str(im, fn, x, y, text, (DATA8) ctx->color.red,
-  (DATA8) ctx->color.green, (DATA8) ctx->color.blue,
-  (DATA8) ctx->color.alpha, (char)dir,
+   __imlib_render_str(im, fn, x, y, text, ctx->pixel, dir,
   ctx->angle, width_return, height_return, 0,
   horizontal_advance_return, vertical_advance_return,
   ctx->operation,
diff --git a/src/lib/font.h b/src/lib/font.h
index 8b94141..af791c3 100644
--- a/src/lib/font.h
+++ b/src/lib/font.h
@@ -104,8 +104,7 @@ int 
__imlib_font_query_text_at_pos(ImlibFont * fn,
 Imlib_Font_Glyph   *__imlib_font_cache_glyph_get(ImlibFont * fn, FT_UInt 
index);
 void__imlib_render_str(ImlibImage * im, ImlibFont * f,
int drx, int dry, const char *text,
-   DATA8 r, DATA8 g, DATA8 b, DATA8 a,
-   char dir, double angle,
+   DATA32 pixel, int dir, double angle,
int *retw, int *reth, int blur,
int *nextx, int *nexty, ImlibOp op,
int clx, int cly, int clw, int clh);
diff --git a/src/lib/font_draw.c b/src/lib/font_draw.c
index 7faac47..ea49e14 100644
--- a/src/lib/font_draw.c
+++ b/src/lib/font_draw.c
@@ -68,14 +68,14 @@ __imlib_font_cache_glyph_get(ImlibFont * fn, FT_UInt index)
 
 void
 __imlib_render_str(ImlibImage * im, ImlibFont * fn, int drx, int dry,
-   const char *text, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
-   char dir, double angle, int *retw, int *reth, int blur,
+   const char *text, DATA32 pixel, int dir, double angle,
+   int *retw, int *reth, int blur,
int *nextx, int *nexty, ImlibOp op, int clx, int cly,
int clw, int clh)
 {
int w, h, ascent;
ImlibImage *im2;
-   DATA32 *data, col;
+   DATA32 *data;
int nx, ny;
 
__imlib_font_query_advance(fn, text, , NULL);
@@ -95,12 +95,9 @@ __imlib_render_str(ImlibImage * im, ImlibFont * fn, int drx, 
int dry,
  }
SET_FLAG(im2->flags, F_HAS_ALPHA);
 
-   /* TODO check for endianess */
-   col = PIXEL_ARGB(a, r, g, b);
-
ascent = __imlib_font_max_ascent_get(fn);
 
-   __imlib_font_draw(im2, col, fn, 0, ascent, text, , , 0, 0, w, h);
+   __imlib_font_draw(im2, pixel, fn, 0, ascent, text, , , 0, 0, w, h);
 
/* OK, now we have small ImlibImage with text rendered, 
 * have to blend it on im */

-- 




[EGIT] [legacy/imlib2] master 02/05: Simplify pixel color handling in api.c

2019-11-09 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=e6269a9b9b1faceeb0c0f21a4a9aaea27facb32b

commit e6269a9b9b1faceeb0c0f21a4a9aaea27facb32b
Author: Kim Woelders 
Date:   Fri Nov 8 21:14:18 2019 +0100

Simplify pixel color handling in api.c
---
 src/lib/api.c | 96 ---
 1 file changed, 39 insertions(+), 57 deletions(-)

diff --git a/src/lib/api.c b/src/lib/api.c
index 58044e1..062a71b 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -94,6 +94,7 @@ struct _imlibcontext {
Imlib_Text_Direction direction;
double  angle;
Imlib_Color color;
+   DATA32  pixel;
Imlib_Color_Range   color_range;
Imlib_Image image;
Imlib_Image_Data_Memory_Function image_data_memory_func;
@@ -187,6 +188,7 @@ imlib_context_new(void)
context->color.red = 255;
context->color.green = 255;
context->color.blue = 255;
+   context->pixel = 0x;
context->color_range = NULL;
context->image = NULL;
context->image_data_memory_func = NULL;
@@ -842,11 +844,21 @@ imlib_context_get_direction(void)
 EAPI void
 imlib_context_set_color(int red, int green, int blue, int alpha)
 {
+   DATA8   r, g, b, a;
+
CHECK_CONTEXT(ctx);
-   ctx->color.red = red;
-   ctx->color.green = green;
-   ctx->color.blue = blue;
-   ctx->color.alpha = alpha;
+
+   r = red;
+   g = green;
+   b = blue;
+   a = alpha;
+
+   ctx->color.red = r;
+   ctx->color.green = g;
+   ctx->color.blue = b;
+   ctx->color.alpha = a;
+
+   ctx->pixel = PIXEL_ARGB(a, r, g, b);
 }
 
 /**
@@ -973,11 +985,21 @@ imlib_context_get_color_hlsa(float *hue, float 
*lightness, float *saturation,
 EAPI void
 imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha)
 {
+   DATA8   r, g, b, a;
+
CHECK_CONTEXT(ctx);
-   ctx->color.red = 255 - cyan;
-   ctx->color.green = 255 - magenta;
-   ctx->color.blue = 255 - yellow;
-   ctx->color.alpha = alpha;
+
+   r = 255 - cyan;
+   g = 255 - magenta;
+   b = 255 - yellow;
+   a = alpha;
+
+   ctx->color.red = r;
+   ctx->color.green = g;
+   ctx->color.blue = b;
+   ctx->color.alpha = a;
+
+   ctx->pixel = PIXEL_ARGB(a, r, g, b);
 }
 
 /**
@@ -4028,7 +4050,6 @@ EAPIImlib_Updates
 imlib_image_draw_pixel(int x, int y, char make_updates)
 {
ImlibImage *im;
-   DATA32  color;
 
CHECK_CONTEXT(ctx);
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_pixel", "image", ctx->image,
@@ -4037,11 +4058,7 @@ imlib_image_draw_pixel(int x, int y, char make_updates)
if (__imlib_LoadImageData(im))
   return NULL;
__imlib_DirtyImage(im);
-   A_VAL() = (DATA8) ctx->color.alpha;
-   R_VAL() = (DATA8) ctx->color.red;
-   G_VAL() = (DATA8) ctx->color.green;
-   B_VAL() = (DATA8) ctx->color.blue;
-   return (Imlib_Updates) __imlib_Point_DrawToImage(x, y, color, im,
+   return (Imlib_Updates) __imlib_Point_DrawToImage(x, y, ctx->pixel, im,
 ctx->cliprect.x,
 ctx->cliprect.y,
 ctx->cliprect.w,
@@ -4068,7 +4085,6 @@ EAPIImlib_Updates
 imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
 {
ImlibImage *im;
-   DATA32  color;
 
CHECK_CONTEXT(ctx);
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line", "image", ctx->image,
@@ -4077,12 +4093,8 @@ imlib_image_draw_line(int x1, int y1, int x2, int y2, 
char make_updates)
if (__imlib_LoadImageData(im))
   return NULL;
__imlib_DirtyImage(im);
-   A_VAL() = (DATA8) ctx->color.alpha;
-   R_VAL() = (DATA8) ctx->color.red;
-   G_VAL() = (DATA8) ctx->color.green;
-   B_VAL() = (DATA8) ctx->color.blue;
-   return (Imlib_Updates) __imlib_Line_DrawToImage(x1, y1, x2, y2, color, im,
-   ctx->cliprect.x,
+   return (Imlib_Updates) __imlib_Line_DrawToImage(x1, y1, x2, y2, ctx->pixel,
+   im, ctx->cliprect.x,
ctx->cliprect.y,
ctx->cliprect.w,
ctx->cliprect.h,
@@ -4106,7 +4118,6 @@ EAPI void
 imlib_image_draw_rectangle(int x, int y, int width, int height)
 {
ImlibImage *im;
-   DATA32  color;
 
CHECK_CONTEXT(ctx);
CHECK_PARAM_POINTER("imlib_image_draw_rectangle", "image", ctx->image);
@@ -4114,11 +4125,7 @@ imlib_image_draw_rectangle(int x, int y, int width, int 
height)
if (__imlib_LoadImageData(im))
   return;
__imlib_DirtyImage(im);
-   A_VAL() 

[EGIT] [legacy/imlib2] master 01/05: Simplify autogen.sh

2019-11-09 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=9f5af1341b912bbff88d09a8ed3093d6f475b6ee

commit 9f5af1341b912bbff88d09a8ed3093d6f475b6ee
Author: Kim Woelders 
Date:   Sat Nov 9 06:16:35 2019 +0100

Simplify autogen.sh
---
 autogen.sh | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 753a7d3..0d43361 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,13 +1,9 @@
 #!/bin/sh
+# Run this to generate all the initial makefiles, etc.
 
-rm -rf autom4te.cache
-rm -f aclocal.m4 ltmain.sh
+rm -rf autom4te.cache aclocal.m4
 
-echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1
-echo "Running autoheader..." ; autoheader || exit 1
-echo "Running autoconf..." ; autoconf || exit 1
-echo "Running libtoolize..." ; (libtoolize --copy --automake $LIBTOOL_FLAGS || 
glibtoolize --automake) || exit 1
-echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
+autoreconf -vif
 
 if [ -z "$NOCONFIGURE" ]; then
./configure "$@"

-- 




[EGIT] [legacy/imlib2] master 01/04: imlib2_test_load: Fixup after recent change

2019-11-08 Thread Kim Woelders
kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=d41d593e4bb139479949b2af545d0a3576a7814c

commit d41d593e4bb139479949b2af545d0a3576a7814c
Author: Kim Woelders 
Date:   Fri Nov 8 17:40:26 2019 +0100

imlib2_test_load: Fixup after recent change
---
 src/bin/imlib2_test_load.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/imlib2_test_load.c b/src/bin/imlib2_test_load.c
index 263b200..c5dcc78 100644
--- a/src/bin/imlib2_test_load.c
+++ b/src/bin/imlib2_test_load.c
@@ -56,7 +56,7 @@ main(int argc, char **argv)
   }
  }
 
-   if (argc <= 1)
+   if (argc < 1)
   usage(0);
 
imlib_context_set_progress_function(progress);

-- 




<    1   2   3   4   5   6   7   8   9   10   >