Skip to content

Commit

Permalink
Merge pull request #23 from william8000/xv5-fix-warnings
Browse files Browse the repository at this point in the history
Xv5 HiDPI, C23, fixes
  • Loading branch information
mdadams authored Aug 12, 2024
2 parents be94fb3 + 3052257 commit 20ccd8f
Show file tree
Hide file tree
Showing 88 changed files with 6,098 additions and 4,838 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# staging area
tmp*

# temporary build files
*-
*.err
*.log
*.orig
*.rej
*.save

#objects
*.o

# executables
xv
bggen
vdcomp
xcmap
xvpictoppm
32 changes: 30 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 3.12)
# The major, minor, and micro version numbers of the project.
set(XV_VERSION_MAJOR 5)
set(XV_VERSION_MINOR 2)
set(XV_VERSION_PATCH 0)
set(XV_VERSION_DATE "20240625")
set(XV_VERSION_PATCH 3)
set(XV_VERSION_DATE "20240801")

# Generate the project version.
set(XV_VERSION "${XV_VERSION_MAJOR}.${XV_VERSION_MINOR}.${XV_VERSION_PATCH}")
Expand All @@ -28,6 +28,8 @@ option(XV_ENABLE_PDS "Enable PDF Support" ON)
option(XV_ENABLE_PNG "Enable PNG Support" ON)
option(XV_ENABLE_TIFF "Enable TIFF Support" ON)
option(XV_ENABLE_WEBP "Enable WEBP Support" ON)
option(XV_ENABLE_G3 "Enable G3 Support" ON)
option(XV_ENABLE_XRANDR "Enable XRANDR Support" ON)

option(XV_STRICT "Treat compiler warnings as errors" OFF)

Expand Down Expand Up @@ -198,11 +200,37 @@ if(XV_ENABLE_WEBP AND NOT TARGET WebP::libwebp)
set(XV_ENABLE_WEBP OFF)
endif()

if(XV_ENABLE_XRANDR)
find_path(XRANDR_INCLUDE_DIR NAMES X11/extensions/Xrandr.h
PATH_SUFFIXES X11/extensions
DOC "The XRANDR include directory"
)

find_library(XRANDR_LIBRARY NAMES Xrandr
DOC "The XRANDR library"
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XRANDR DEFAULT_MSG XRANDR_LIBRARY XRANDR_INCLUDE_DIR)

mark_as_advanced(XRANDR_INCLUDE_DIR XRANDR_LIBRARY)

if(XRANDR_FOUND)
set(XRANDR_LIBRARIES ${XRANDR_LIBRARY})
set(XRANDR_INCLUDE_DIRS ${XRANDR_INCLUDE_DIR})
else()
message(WARNING "Disabling RANDR Support.")
set(XV_ENABLE_XRANDR OFF)
endif()
endif()

message("JP2K: ${XV_ENABLE_JP2K}")
message("JPEG: ${XV_ENABLE_JPEG}")
message("TIFF: ${XV_ENABLE_TIFF}")
message("PNG: ${XV_ENABLE_PNG}")
message("WEBP: ${XV_ENABLE_WEBP}")
message("G3: ${XV_ENABLE_G3}")
message("RANDR: ${XV_ENABLE_XRANDR}")

################################################################################
# Subdirectories.
Expand Down
47 changes: 47 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@

* Made some improvements to WEBP support.

5.0.1 (2024-08-01)
==================

* Applied patches from other xv forks.
Add contributed xv.xpm and xv.desktop.
BMP updates for WIN_95, 98, and NT.
xv was not really exiting with 0 for a valid call "xv -help".
sprintf() to snprintf() safety fix.
Add XrandR support.
Add webp support for browsing and saving.
Add support for reading G3 facsimile image files.
Eliminate flicker in the image window.
Add TRUE and FALSE defines in case these don't get defined elsewhere.
Change C++ style comments to C style.
Allow main and save/load window resizes.
Add README.debian.
Fix dashes and formatting on manual pages.
Minor tweak to 'nopos' parameter.
24-bit autocrop bug partial fix (applied to all four places).
* Increased some buffers to fix compile warnings and sanitizer warnings.
* Fixed unused variable warnings with XV_UNUSED macro or by removing the variables.
* Updated prototypes in xv.h to fix warnings about declarations without prototypes.
* Added a -c option to the build script to do a clean build.
* Added .gitignore
* Fixes for G3, tiff, and wbmp processing.
* Fixed memory leak of tv->lines in computeText() in xvtext.c.
* Fixed possible overwrite in add_filelist_to_namelist() in xv.c.
* Added overprint.ps sample PS image.
* Switched order of calloc() args to fix compile warning in xvbrowse.c.
* Fixed crash on long file names in xv.c.
* Added Add a test image with a long file name in data/images.
* Rebuilt with clang and fixed compile warnings.
* Added HiDPI support.
New options -dpimult # to set the scale factor,
-hidpi to set a scale factor of 2,
+hidpi to set a scale factor of 1.
Most dialogs scale based on the dpi multiplier.
xv automatically defaults to -hidpi for displays with more than 144 dpi.
* Fixed error from negative shift in xvpic.c.
* Fixed crash on NULL monofsetinfo in xv.c.
* Fixed bad pointer reference in last interation of LoadCurrentDirectory in xvdir.c.
* Fixed loop limit in CharsetDelWin to avoid accessing csinfo out of bounds if there are no text windows in xvtext.c.
* Convert function definitions to use prototypes as required by C23.
* Add support for xz compressed files.
* Fixed opening archives and compressed files with special characters in their name.
* Fixed opening compressed archives.

5.0.0 (2024-02-06)
==================

Expand Down
70 changes: 64 additions & 6 deletions build/build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ usage()
Set the build directory to \$build_dir.
-i \$install_dir
Set the install directory to \$install_dir.
-c
Clean the build and install directories.
-r
Build to make a release.
-d
Build for debugging.
-s
Strict build to treat warnings as errors.
-o \$configure_options
Add \$configure_options to the cmake command line.
-f
Fast build, don't install.
-p clang|gcc
Set compiler
-v
Enable verbose mode.
-h
Expand All @@ -34,32 +48,48 @@ usage()

program_dir=$(dirname "$0") || exit 1
top_dir="$program_dir/.."
real_top_dir=$(realpath "$top_dir")
if [ -n "$real_top_dir" ] && [ -d "$real_top_dir" ] ; then top_dir="$real_top_dir" ; fi

verbose=0
build_dir=
install_dir=
tmp_dir=
install=1
mode=release
strict=0
clean=0
c_compiler=
configure_options=()

while getopts vb:i:t:drs opt; do
while getopts vhcb:i:o:t:fp:drs opt; do
case $opt in
s)
strict=1;;
r)
mode=release;;
d)
mode=debug;;
t)
tmp_dir="$OPTARG";;
b)
build_dir="$OPTARG";;
i)
install_dir="$OPTARG";;
o)
configure_options+=("$OPTARG");;
c)
clean=1;;
f)
install=0;;
p)
c_compiler="$OPTARG";;
v)
verbose=$((verbose + 1));;
h)
usage;;
usage "$@";;
\?)
usage;;
usage "$@";;
esac
done
shift $((OPTIND - 1))
Expand All @@ -74,9 +104,29 @@ if [ -z "$install_dir" ]; then
install_dir="$tmp_dir/install"
fi

cmake --version || panic "cannot run cmake"
if [ "$clean" -ge 1 ]; then
echo "Cleaning..."
case "$build_dir" in
*tmp*/*build*)
rm -rf "$build_dir" || panic "Could not clean build dir ${build_dir}.";;
*)
panic "Not cleaning build dir ${build_dir}. Does not look match *tmp*build.";;
esac
case "$install_dir" in
*tmp*/*install*)
rm -rf "$install_dir" || panic "Could not clean install dir ${install_dir}.";;
*)
panic "Not cleaning install dir ${install_dir}. Does not look match *tmp*install.";;
esac
fi

configure_options=()
case "$c_compiler" in
gcc) configure_options+=(-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++) ;;
clang) configure_options+=(-DCMAKE_C_COMPILER="$c_compiler" -DCMAKE_CXX_COMPILER="${c_compiler}++") ;;
*) if [ -n "$c_compiler" ] ; then panic "Unknown compiler ${c_compiler}." ; fi
esac

cmake --version || panic "cannot run cmake"

configure_options+=(-DCMAKE_INSTALL_PREFIX="$install_dir")

Expand All @@ -93,9 +143,17 @@ if [ "$strict" -ne 0 ]; then
configure_options+=(-DXV_STRICT=1)
fi

echo "Starting $mode build"
echo "Top dir: $top_dir"
echo "Build dir: $build_dir"
echo "Install dir: $install_dir"
echo "Options: ${configure_options[*]}"

cmake "${configure_options[@]}" -H"$top_dir" -B"$build_dir" || \
panic "configure failed"

cmake --build "$build_dir" || panic "build failed"

cmake --build "$build_dir" --target install || panic "install failed"
if [ "$install" -ne 0 ]; then
cmake --build "$build_dir" --target install || panic "install failed"
fi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/newtonian_fractal.pcd
Binary file not shown.
Binary file added data/images/overprint.ps
Binary file not shown.
Binary file added data/images/pythagoras_tree.wbmp
Binary file not shown.
Binary file added data/images/sierpinski_triangle.g3
Binary file not shown.
21 changes: 20 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@ if(XV_ENABLE_JP2K)
set(xv_libs ${xv_libs} Jasper::Jasper)
endif()

if(XV_ENABLE_G3)
add_compile_definitions(DOG3)
endif()

if(XV_ENABLE_PDS)
add_compile_definitions(DOPDS)
#set(xv_libs ${xv_libs} XXX::XXX)
endif()

if(XV_ENABLE_XRANDR)
add_compile_definitions(DOXRANDR)
set(xv_libs ${xv_libs} ${XRANDR_LIBRARIES})
endif()

set(xv_sources
vprintf.c
xv24to8.c
Expand All @@ -59,6 +68,7 @@ set(xv_sources
xvdir.c
xvevent.c
xvfits.c
xvg3.c
xvgam.c
xvgif.c
xvgifwr.c
Expand Down Expand Up @@ -92,6 +102,7 @@ set(xv_sources
xvrle.c
xvroot.c
xvscrl.c
xvselect.c
xvsmooth.c
xvsunras.c
xvtarga.c
Expand All @@ -100,7 +111,7 @@ set(xv_sources
xvtiffwr.c
xvvd.c
xvwbmp.c
xvwebp.c
xvwebp.c
xvxbm.c
xvxpm.c
xvxwd.c
Expand Down Expand Up @@ -205,3 +216,11 @@ install(FILES
# Install directories into DOCDIR/manuals.
install(DIRECTORY docs/manuals/html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/manuals")

# Install files into share/pixmaps
install(FILES contrib/xv.xpm
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")

# Install files into share/applications
install(FILES contrib/xv.desktop
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
8 changes: 8 additions & 0 deletions src/README.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To compile on at least Debian 7 through 9, install the following packages
first:

build-essential libx11-dev libxrandr-dev libxrender-dev libwebp-dev
libxau-dev libc6-dev libxt-dev libjpeg-dev
libtiff-dev libpng-dev libjasper-dev

This should translate across most Debian-based distributions.
8 changes: 7 additions & 1 deletion src/README.jumbo
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ not finished (and/or even started ;-) ):
unknown tags (or truncated/corrupted images)
- fix for minor .Z inefficiency in xv.c ("FIXME")
- fix for filename entry-field mouse/cursor deficiencies
(positioning fixed 20070104 by Ross Combs; would like select/cut/paste, too)
(positioning fixed 20070104 by Ross Combs; would like
select/cut/copy/paste, too)
- fix for .ppm.gz "disk leak" [can't reproduce...already fixed?]
(maybe occurs only if filesystem is already nearly full? bad .gz?)

Expand All @@ -379,6 +380,11 @@ not finished (and/or even started ;-) ):
- MNG/JNG support
- SVG support

- tooltips for buttons with icons
- fix meta/alt/mod1 confusion in event handling and docs
- fix strange non-ICCCM positioning which causes windows to drift
when operations are performed and other strangeness


ChangeLog
---------
Expand Down
17 changes: 5 additions & 12 deletions src/bggen.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ void writePPM PARM((byte *, int, int, int));


/*************************************/
int main(argc,argv)
int argc;
char **argv;
int main(int argc, char **argv)
{
byte *pic24, *rpic24, *pp, *sp;
int i,j,cnt,x,y;
Expand Down Expand Up @@ -318,7 +316,7 @@ static int distdebug;


/*************************************/
void usage()
void usage(void)
{
fprintf(stderr,"usage: bggen [-h high] [-w wide] [-b bits] [-g geom]\n");
fprintf(stderr,"\t\t[-d disp] [-a] [-r rot] [-G rptgeom] \n");
Expand All @@ -328,9 +326,7 @@ void usage()


/*************************************/
void dorot(pic, w, h, rot)
byte *pic;
int w, h, rot;
void dorot(byte *pic, int w, int h, int rot)
{
byte *pp;
double maxd, mind, del, d, rat, crat, cval;
Expand Down Expand Up @@ -398,8 +394,7 @@ void dorot(pic, w, h, rot)



double computeDist(x, y, cx, cy, rot)
int x,y,cx,cy,rot;
double computeDist(int x, int y, int cx, int cy, int rot)
{
/* rot has to be in range 0-359 */

Expand Down Expand Up @@ -437,9 +432,7 @@ double computeDist(x, y, cx, cy, rot)


/******************************/
void writePPM(pic, w, h, doascii)
byte *pic;
int w,h,doascii;
void writePPM(byte *pic, int w, int h, int doascii)
{
/* dumps a pic24 in PPM format to stdout */

Expand Down
Loading

0 comments on commit 20ccd8f

Please sign in to comment.