Skip to content

Commit

Permalink
Add HiDPI scaling support for high resolution displays
Browse files Browse the repository at this point in the history
Add an optional --hidpi configure flag to allow installing
as a fully SVG theme, with an updated index.theme for HiDPI
support. This will be seen when Scaling is set to 2x or 3x.

Fixes issues where wrong icons are shown in some places with
scaling enabled (like the Places sidebars in file managers),
and blurry icon issues, especially with scaling enabled.
The PNG non-HiDPI theme also restricted the amount of zoom
steps the icons had with scaling enabled, so this should
resolve that as well.

Fixes shimmerproject#124
Fixes shimmerproject#317
Fixes shimmerproject#362
Fixes shimmerproject#403
  • Loading branch information
newhoa committed Apr 5, 2024
1 parent 5210944 commit 847b5e3
Show file tree
Hide file tree
Showing 5 changed files with 1,955 additions and 23 deletions.
67 changes: 48 additions & 19 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PREFIX=@prefix@
HIDPI=@hidpi@
DESTDIR=
CC?=gcc
export

SUBDIRS := svgtopng

Expand All @@ -11,11 +13,16 @@ $(SUBDIRS):

install:
install -d $(DESTDIR)/$(PREFIX)/share/icons
cp -rf build/elementary-xfce $(DESTDIR)/$(PREFIX)/share/icons
cp -rf build/elementary-xfce-dark $(DESTDIR)/$(PREFIX)/share/icons
cp -rf build/elementary-xfce-darker $(DESTDIR)/$(PREFIX)/share/icons
cp -rf build/elementary-xfce-darkest $(DESTDIR)/$(PREFIX)/share/icons
@echo
@-if $(HIDPI); \
then \
cp -rf build/elementary-xfce-hidpi $(DESTDIR)/$(PREFIX)/share/icons; \
else \
cp -rf build/elementary-xfce $(DESTDIR)/$(PREFIX)/share/icons; \
cp -rf build/elementary-xfce-dark $(DESTDIR)/$(PREFIX)/share/icons; \
cp -rf build/elementary-xfce-darker $(DESTDIR)/$(PREFIX)/share/icons; \
cp -rf build/elementary-xfce-darkest $(DESTDIR)/$(PREFIX)/share/icons; \
fi
@echo The icon-theme cache has not yet been regenerated, which means your changes may not be visible yet. Please run 'make icon-caches' next.

uninstall:
Expand All @@ -31,26 +38,48 @@ icon-caches:
gtk-update-icon-cache -f $(DESTDIR)/$(PREFIX)/share/icons/elementary-xfce-darkest

test: builddir $(SUBDIRS)
chmod +x ./svgtopng/pngtheme.sh
@./svgtopng/pngtheme.sh build/elementary-xfce
@./svgtopng/pngtheme.sh build/elementary-xfce-dark
@./svgtopng/pngtheme.sh build/elementary-xfce-darker
@./svgtopng/pngtheme.sh build/elementary-xfce-darkest
@-if ! $(HIDPI); \
then \
echo "test not HiDPI $(HIDPI)"; \
chmod +x ./svgtopng/pngtheme.sh; \
./svgtopng/pngtheme.sh build/elementary-xfce; \
./svgtopng/pngtheme.sh build/elementary-xfce-dark; \
./svgtopng/pngtheme.sh build/elementary-xfce-darker; \
./svgtopng/pngtheme.sh build/elementary-xfce-darkest; \
fi
@echo Build finished, ready to run install!

build: test
@echo == Optimizing all icon pngs
@find build -type f -iname '*.png' | xargs optipng -strip all -silent
@-if ! $(HIDPI); \
then \
echo == "build test HiDpi is False"; \
echo == Optimizing all icon pngs; \
find build -type f -iname '*.png' | xargs optipng -strip all -silent; \
fi

builddir:
mkdir -p build
mkdir -p build/elementary-xfce && cp -R elementary-xfce/. build/elementary-xfce
mkdir -p build/elementary-xfce-dark && cp -R elementary-xfce-dark/. build/elementary-xfce-dark
mkdir -p build/elementary-xfce-darker && cp -R elementary-xfce-darker/. build/elementary-xfce-darker
mkdir -p build/elementary-xfce-darkest && cp -R elementary-xfce-darkest/. build/elementary-xfce-darkest
rm build/elementary-xfce/AUTHORS && cp AUTHORS build/elementary-xfce
rm build/elementary-xfce/CONTRIBUTORS && cp CONTRIBUTORS build/elementary-xfce
rm build/elementary-xfce/LICENSE && cp LICENSE build/elementary-xfce
rm build/elementary-xfce/README.md && cp README.md build/elementary-xfce
@-if $(HIDPI); \
then \
echo "HiDPI is true!" $(HIDPI); \
mkdir -p build/elementary-xfce-hidpi && cp -R elementary-xfce/. build/elementary-xfce-hidpi; \
mv build/elementary-xfce-hidpi/index-hidpi.theme build/elementary-xfce-hidpi/index.theme; \
rm build/elementary-xfce-hidpi/AUTHORS && cp AUTHORS build/elementary-xfce-hidpi; \
rm build/elementary-xfce-hidpi/CONTRIBUTORS && cp CONTRIBUTORS build/elementary-xfce-hidpi; \
rm build/elementary-xfce-hidpi/LICENSE && cp LICENSE build/elementary-xfce-hidpi; \
rm build/elementary-xfce-hidpi/README.md && cp README.md build/elementary-xfce-hidpi; \
find build/elementary-xfce-hidpi -mindepth 1 -maxdepth 1 -type d -exec sh -c "ln -sr '{}' '{}'@2x" \; \
-exec sh -c "ln -sr '{}' '{}'@3x" \;; \
else \
mkdir -p build/elementary-xfce && cp -R elementary-xfce/. build/elementary-xfce; \
mkdir -p build/elementary-xfce-dark && cp -R elementary-xfce-dark/. build/elementary-xfce-dark; \
mkdir -p build/elementary-xfce-darker && cp -R elementary-xfce-darker/. build/elementary-xfce-darker; \
mkdir -p build/elementary-xfce-darkest && cp -R elementary-xfce-darkest/. build/elementary-xfce-darkest; \
rm build/elementary-xfce/AUTHORS && cp AUTHORS build/elementary-xfce; \
rm build/elementary-xfce/CONTRIBUTORS && cp CONTRIBUTORS build/elementary-xfce; \
rm build/elementary-xfce/LICENSE && cp LICENSE build/elementary-xfce; \
rm build/elementary-xfce/README.md && cp README.md build/elementary-xfce; \
fi

.PHONY: all $(SUBDIRS)

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ make icon-caches
make
sudo make install
sudo make icon-caches
```

HiDPI scaling is supported by using the `--hidpi` configure flag.
13 changes: 9 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

help () {
echo "Supported options are:"
echo " --help print this help and exit"
echo " --prefix=<path> specify installation prefix"
echo " default <path> is /usr/local"
echo " --help Print this help and exit"
echo " --prefix=<path> Specify installation prefix, default <path> is /usr/local"
echo " --hidpi Use SVG icons for 2-3x scaling, high resolution displays"
}

PREFIX="/usr/local"
HIDPI="false"
SUBDIRS="svgtopng"
while [ $# -gt 0 ]; do
case $1 in
--help)
Expand All @@ -17,6 +19,9 @@ while [ $# -gt 0 ]; do
--prefix=*)
PREFIX=`echo $1 | sed 's/--prefix=//'`
;;
--hidpi)
HIDPI="true"
;;
*)
echo "Unknown option $1"
;;
Expand All @@ -25,5 +30,5 @@ while [ $# -gt 0 ]; do
done

echo "Creating Makefile..."
sed -e s,@prefix@,$PREFIX, Makefile.in > Makefile
sed -e s,@prefix@,$PREFIX, -e s,@hidpi@,$HIDPI, Makefile.in > Makefile
echo "Installation prefix is $PREFIX"
Loading

0 comments on commit 847b5e3

Please sign in to comment.