[PATCH 4/4] wmxres: Bump to version 1.4.

11 views
Skip to first unread message

Torrance, Douglas

unread,
Aug 15, 2020, 3:50:27 PM8/15/20
to wmake...@googlegroups.com, Torrance, Douglas
---
wmxres/configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/wmxres/configure.ac b/wmxres/configure.ac
index 2d1ff3d..4673496 100644
--- a/wmxres/configure.ac
+++ b/wmxres/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([wmxres], [1.3], [wmake...@googlegroups.com])
+AC_INIT([wmxres], [1.4], [wmake...@googlegroups.com])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([configure.ac])
AC_PROG_CC
--
2.25.1

Torrance, Douglas

unread,
Aug 15, 2020, 3:50:27 PM8/15/20
to wmake...@googlegroups.com, Torrance, Douglas
This will make the following patches unnecessary:
* https://sources.debian.org/src/wmxres/1.3-1/debian/patches/no-root.patch/
* https://bugs.debian.org/968433

Also move source files from wmxres directory to root directory; otherwise
this directory will conflict with the binary that's built.
---
wmxres/INSTALL | 8 +++---
wmxres/Makefile | 41 ---------------------------
wmxres/Makefile.am | 6 ++++
wmxres/autogen.sh | 2 ++
wmxres/configure.ac | 10 +++++++
wmxres/{wmxres => }/wmxres-mask.xbm | 0
wmxres/{wmxres => }/wmxres-master.xpm | 0
wmxres/{wmxres => }/wmxres.c | 4 +--
8 files changed, 23 insertions(+), 48 deletions(-)
delete mode 100644 wmxres/Makefile
create mode 100644 wmxres/Makefile.am
create mode 100755 wmxres/autogen.sh
create mode 100644 wmxres/configure.ac
rename wmxres/{wmxres => }/wmxres-mask.xbm (100%)
rename wmxres/{wmxres => }/wmxres-master.xpm (100%)
rename wmxres/{wmxres => }/wmxres.c (98%)

diff --git a/wmxres/INSTALL b/wmxres/INSTALL
index ed64cc8..fe9a90d 100644
--- a/wmxres/INSTALL
+++ b/wmxres/INSTALL
@@ -1,4 +1,4 @@
-Installation instructions for WMXRES.
+Installation instructions for WMXRES.

Requirements
------------
@@ -6,9 +6,9 @@ Requirements

Installation
------------
-1) % tar -zxvf wmxres-1.0-0.tar.gz
-2) % cd wmxres.app
-3) % make
+1) % tar -zxvf wmxres-*.tar.gz
+2) % ./configure
+3) % make
4) % make install


diff --git a/wmxres/Makefile b/wmxres/Makefile
deleted file mode 100644
index 519acc2..0000000
--- a/wmxres/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-# Edited for Debian GNU/Linux
-DESTDIR =
-
-CC = gcc
-CFLAGS = -O2 -Wall -fstack-protector -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
-FINAL_CFLAGS = -O2 -Wall -fstack-protector -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wl,-z,norelro
-DEBUG_CFLAGS = -g -Wall
-INCDIR = -I/usr/X11R6/include
-LIBDIR = -L/usr/X11R6/lib
-LIBS = -lXpm -lXext -lX11 -lXxf86vm
-OBJS = wmxres/wmxres.o \
- wmgeneral/wmgeneral.o \
-
-# ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
-# CFLAGS += -g
-# endif
-
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
- INSTALL_FLAGS += -s
-endif
-
-.c.o:
- cc -c $(CFLAGS) -D$(shell echo `uname -s`) $< -o $*.o $(INCDIR)
-
-all: wmxres/wmxres
-
-wmxres/wmxres: $(OBJS)
- gcc $(CFLAGS) -o wmxres/wmxres $^ $(LIBDIR) $(LIBS)
-
-debug: $(OBJS)
- gcc $(DEBUG_CFLAGS) -o wmxres/wmxres $^ $(LIBDIR) $(LIBS)
-install:: all
- install $(INSTALL_FLAGS) -m 4755 -o root wmxres/wmxres \
- $(DESTDIR)/usr/bin
-
-.PHONY :clean
-clean:
- for i in $(OBJS) ; do \
- rm -f $$i; \
- done
- rm -f wmxres/wmxres
diff --git a/wmxres/Makefile.am b/wmxres/Makefile.am
new file mode 100644
index 0000000..67b5e4a
--- /dev/null
+++ b/wmxres/Makefile.am
@@ -0,0 +1,6 @@
+bin_PROGRAMS = wmxres
+wmxres_SOURCES = wmgeneral/wmgeneral.c wmgeneral/wmgeneral.h \
+ wmxres.c wmxres-mask.xbm wmxres-master.xpm
+
+AM_CFLAGS = $(X11_CFLAGS) $(XEXT_CFLAGS) $(XPM_CFLAGS) $(XXF86VM_CFLAGS)
+LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XPM_LIBS) $(XXF86VM_LIBS)
diff --git a/wmxres/autogen.sh b/wmxres/autogen.sh
new file mode 100755
index 0000000..af8c78c
--- /dev/null
+++ b/wmxres/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf --force --verbose --install
diff --git a/wmxres/configure.ac b/wmxres/configure.ac
new file mode 100644
index 0000000..8d52891
--- /dev/null
+++ b/wmxres/configure.ac
@@ -0,0 +1,10 @@
+AC_INIT([wmxres], [1.3], [wmake...@googlegroups.com])
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+AC_CONFIG_SRCDIR([configure.ac])
+AC_PROG_CC
+PKG_CHECK_MODULES([X11], [x11])
+PKG_CHECK_MODULES([XEXT], [xext])
+PKG_CHECK_MODULES([XPM], [xpm])
+PKG_CHECK_MODULES([XXF86VM], [xxf86vm])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/wmxres/wmxres/wmxres-mask.xbm b/wmxres/wmxres-mask.xbm
similarity index 100%
rename from wmxres/wmxres/wmxres-mask.xbm
rename to wmxres/wmxres-mask.xbm
diff --git a/wmxres/wmxres/wmxres-master.xpm b/wmxres/wmxres-master.xpm
similarity index 100%
rename from wmxres/wmxres/wmxres-master.xpm
rename to wmxres/wmxres-master.xpm
diff --git a/wmxres/wmxres/wmxres.c b/wmxres/wmxres.c
similarity index 98%
rename from wmxres/wmxres/wmxres.c
rename to wmxres/wmxres.c
index b054a36..1e9e871 100644
--- a/wmxres/wmxres/wmxres.c
+++ b/wmxres/wmxres.c
@@ -15,12 +15,10 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xxf86dga.h>
#include <X11/extensions/xf86vmode.h>
-#include "../wmgeneral/wmgeneral.h"
+#include "wmgeneral/wmgeneral.h"
#include "wmxres-master.xpm"
#include "wmxres-mask.xbm"

-#define VERSION "1.3"
-
/*
* Les Definitions
*/
--
2.25.1

Torrance, Douglas

unread,
Aug 15, 2020, 3:50:27 PM8/15/20
to wmake...@googlegroups.com, Torrance, Douglas
https://sources.debian.org/src/wmxres/1.3-1/debian/wmxres.1/
---
wmxres/Makefile.am | 1 +
wmxres/wmxres.1 | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 wmxres/wmxres.1

diff --git a/wmxres/Makefile.am b/wmxres/Makefile.am
index f170be0..0edaf08 100644
--- a/wmxres/Makefile.am
+++ b/wmxres/Makefile.am
@@ -1,5 +1,6 @@
bin_PROGRAMS = wmxres
wmxres_SOURCES = wmxres.c wmxres-mask.xbm wmxres-master.xpm
+dist_man_MANS = wmxres.1

AM_CFLAGS = $(X11_CFLAGS) $(XXF86VM_CFLAGS) $(DOCKAPP_CFLAGS)
LIBS += $(X11_LIBS) $(XXF86VM_LIBS) $(DOCKAPP_LIBS)
diff --git a/wmxres/wmxres.1 b/wmxres/wmxres.1
new file mode 100644
index 0000000..0e3dacd
--- /dev/null
+++ b/wmxres/wmxres.1
@@ -0,0 +1,25 @@
+.\" Hey, EMACS: -*- nroff -*-
+.\" wmxres.1 is copyright 2001 by
+.\" Todd Troxell <ttro...@debian.org>
+.\"
+.\" This is free documentation, see the latest version of the GNU
+.\" General Public License for copying conditions. There is NO warranty.
+.TH WMXRES 1 "May 5, 2001"
+
+.SH NAME
+wmxres \- dockable application to change X modes
+
+.SH SYNOPSIS
+.B wmxres
+
+.SH DESCRIPTION
+dockable application to select your display mode from those available. It is written in C.
+
+.SH INFO
+This manual page was written for the Debian GNU/Linux distribution
+because the original program does not have a manual page.
+.PP
+
+.SH AUTHOR
+This manual page was written by Todd Troxell <ttro...@debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
--
2.25.1

Torrance, Douglas

unread,
Aug 15, 2020, 3:50:27 PM8/15/20
to wmake...@googlegroups.com, Torrance, Douglas
This also centers the dockapp in its icon window instead of being placed
in the upper left hand corner.
---
wmxres/Makefile.am | 7 +-
wmxres/configure.ac | 5 +-
wmxres/wmgeneral/wmgeneral.c | 331 -----------------------------------
wmxres/wmgeneral/wmgeneral.h | 41 -----
wmxres/wmxres.c | 209 ++++++++++++----------
5 files changed, 120 insertions(+), 473 deletions(-)
delete mode 100644 wmxres/wmgeneral/wmgeneral.c
delete mode 100644 wmxres/wmgeneral/wmgeneral.h

diff --git a/wmxres/Makefile.am b/wmxres/Makefile.am
index 67b5e4a..f170be0 100644
--- a/wmxres/Makefile.am
+++ b/wmxres/Makefile.am
@@ -1,6 +1,5 @@
bin_PROGRAMS = wmxres
-wmxres_SOURCES = wmgeneral/wmgeneral.c wmgeneral/wmgeneral.h \
- wmxres.c wmxres-mask.xbm wmxres-master.xpm
+wmxres_SOURCES = wmxres.c wmxres-mask.xbm wmxres-master.xpm

-AM_CFLAGS = $(X11_CFLAGS) $(XEXT_CFLAGS) $(XPM_CFLAGS) $(XXF86VM_CFLAGS)
-LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XPM_LIBS) $(XXF86VM_LIBS)
+AM_CFLAGS = $(X11_CFLAGS) $(XXF86VM_CFLAGS) $(DOCKAPP_CFLAGS)
+LIBS += $(X11_LIBS) $(XXF86VM_LIBS) $(DOCKAPP_LIBS)
diff --git a/wmxres/configure.ac b/wmxres/configure.ac
index 8d52891..2d1ff3d 100644
--- a/wmxres/configure.ac
+++ b/wmxres/configure.ac
@@ -1,10 +1,9 @@
AC_INIT([wmxres], [1.3], [wmake...@googlegroups.com])
-AM_INIT_AUTOMAKE([foreign subdir-objects])
+AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([configure.ac])
AC_PROG_CC
PKG_CHECK_MODULES([X11], [x11])
-PKG_CHECK_MODULES([XEXT], [xext])
-PKG_CHECK_MODULES([XPM], [xpm])
PKG_CHECK_MODULES([XXF86VM], [xxf86vm])
+PKG_CHECK_MODULES([DOCKAPP], [dockapp])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/wmxres/wmgeneral/wmgeneral.c b/wmxres/wmgeneral/wmgeneral.c
deleted file mode 100644
index 67cdb60..0000000
--- a/wmxres/wmgeneral/wmgeneral.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- It has a lot of routines which most of the wm* programs use.
-
- ------------------------------------------------------------
-
- Author: Martijn Pieterse (piet...@xs4all.nl)
-
- ---
- CHANGES:
- ---
- 24/06/1998 (Soren, so...@linuxwarez.com)
- * Modified RedrawWindowXY to RedrawWindowXYWH.
- * Changed -display to -d.
- 30/04/1998 (Martijn Pieterse, piet...@xs4all.nl)
- * Ripped similar code from all the wm* programs,
- and put them in a single file.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdarg.h>
-
-#include <X11/Xlib.h>
-#include <X11/xpm.h>
-#include <X11/extensions/shape.h>
-
-#include "wmgeneral.h"
-
- /*****************/
- /* X11 Variables */
-/*****************/
-
-Window Root;
-int screen;
-int x_fd;
-int d_depth;
-XSizeHints mysizehints;
-XWMHints mywmhints;
-Pixel back_pix, fore_pix;
-char *Geometry = "";
-Window iconwin, win;
-GC NormalGC;
-XpmIcon wmgen;
-Pixmap pixmask;
-Display *display;
-
- /*****************/
- /* Mouse Regions */
-/*****************/
-
-typedef struct {
- int enable;
- int top;
- int bottom;
- int left;
- int right;
-} MOUSE_REGION;
-
-#define MAX_MOUSE_REGION (8)
-MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
-
- /***********************/
- /* Function Prototypes */
-/***********************/
-
-static void GetXPM(XpmIcon *, char **);
-static Pixel GetColor(char *);
-void RedrawWindow(void);
-void AddMouseRegion(int, int, int, int, int);
-int CheckMouseRegion(int, int);
-
-/*******************************************************************************\
-|* GetXPM *|
-\*******************************************************************************/
-
-static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
-
- XWindowAttributes attributes;
- int err;
-
- /* For the colormap */
- XGetWindowAttributes(display, Root, &attributes);
-
- wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions
- | XpmExactColors | XpmCloseness);
- wmgen->attributes.exactColors = False;
- wmgen->attributes.closeness = 65536;
-
- err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen->pixmap),
- &(wmgen->mask), &(wmgen->attributes));
-
- if (err != XpmSuccess) {
- fprintf(stderr, "Not enough free colorcells.\n");
- exit(1);
- }
-}
-
-/*******************************************************************************\
-|* GetColor *|
-\*******************************************************************************/
-
-static Pixel GetColor(char *name) {
-
- XColor color;
- XWindowAttributes attributes;
-
- XGetWindowAttributes(display, Root, &attributes);
-
- color.pixel = 0;
- if (!XParseColor(display, attributes.colormap, name, &color)) {
- fprintf(stderr, "wm.app: can't parse %s.\n", name);
- } else if (!XAllocColor(display, attributes.colormap, &color)) {
- fprintf(stderr, "wm.app: can't allocate %s.\n", name);
- }
- return color.pixel;
-}
-
-/*******************************************************************************\
-|* flush_expose *|
-\*******************************************************************************/
-
-static int flush_expose(Window w) {
-
- XEvent dummy;
- int i=0;
-
- while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
- i++;
-
- return i;
-}
-
-/*******************************************************************************\
-|* RedrawWindow *|
-\*******************************************************************************/
-
-void RedrawWindow(void) {
-
- flush_expose(iconwin);
- XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
- 0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
- flush_expose(win);
- XCopyArea(display, wmgen.pixmap, win, NormalGC,
- 0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
-}
-
-/*******************************************************************************\
-|* RedrawWindowXYWH *|
-\*******************************************************************************/
-
-void RedrawWindowXYWH(int x,int y, int w,int h) {
-
- flush_expose(iconwin);
- XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x,y, w,h, x,y);
- flush_expose(win);
- XCopyArea(display, wmgen.pixmap, win, NormalGC, x,y, w,h, x,y);
-}
-
-/*******************************************************************************\
-|* AddMouseRegion *|
-\*******************************************************************************/
-
-void AddMouseRegion(int index, int left, int top, int right, int bottom) {
-
- if (index < MAX_MOUSE_REGION) {
- mouse_region[index].enable = 1;
- mouse_region[index].top = top;
- mouse_region[index].left = left;
- mouse_region[index].bottom = bottom;
- mouse_region[index].right = right;
- }
-}
-
-/*******************************************************************************\
-|* CheckMouseRegion *|
-\*******************************************************************************/
-
-int CheckMouseRegion(int x, int y) {
-
- int i;
- int found;
-
- found = 0;
-
- for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
- if (mouse_region[i].enable &&
- x <= mouse_region[i].right &&
- x >= mouse_region[i].left &&
- y <= mouse_region[i].bottom &&
- y >= mouse_region[i].top)
- found = 1;
- }
- if (!found) return -1;
- return (i-1);
-}
-
-/*******************************************************************************\
-|* copyXPMArea *|
-\*******************************************************************************/
-
-void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
-
- XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
-
-}
-
-/*******************************************************************************\
-|* copyXBMArea *|
-\*******************************************************************************/
-
-void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
-
- XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
-}
-
-
-/*******************************************************************************\
-|* setMaskXY *|
-\*******************************************************************************/
-
-void setMaskXY(int x, int y) {
-
- XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
- XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
-}
-
-/*******************************************************************************\
-|* openXwindow *|
-\*******************************************************************************/
-void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
-
- unsigned int borderwidth = 1;
- XClassHint classHint;
- char *display_name = NULL;
- char *wname = argv[0];
- XTextProperty name;
-
- XGCValues gcv;
- unsigned long gcm;
-
-
- int dummy=0;
- int i;
-
- for (i=1; argv[i]; i++) {
- if (!strcmp(argv[i], "-d"))
- display_name = argv[i+1];
- }
-
- if (!(display = XOpenDisplay(display_name))) {
- fprintf(stderr, "%s: can't open display %s\n",
- wname, XDisplayName(display_name));
- exit(1);
- }
- screen = DefaultScreen(display);
- Root = RootWindow(display, screen);
- d_depth = DefaultDepth(display, screen);
- x_fd = XConnectionNumber(display);
-
- /* Convert XPM to XImage */
- GetXPM(&wmgen, pixmap_bytes);
-
- /* Create a window to hold the stuff */
- mysizehints.flags = USSize | USPosition;
- mysizehints.x = 0;
- mysizehints.y = 0;
-
- back_pix = GetColor("white");
- fore_pix = GetColor("black");
-
- XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
- &mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
-
- mysizehints.width = 64;
- mysizehints.height = 64;
-
- win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
- mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
-
- iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
- mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
-
- /* Activate hints */
- XSetWMNormalHints(display, win, &mysizehints);
- classHint.res_name = wname;
- classHint.res_class = wname;
- XSetClassHint(display, win, &classHint);
-
- XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
- XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
-
- if (XStringListToTextProperty(&wname, 1, &name) == 0) {
- fprintf(stderr, "%s: can't allocate window name\n", wname);
- exit(1);
- }
-
- XSetWMName(display, win, &name);
-
- /* Create GC for drawing */
-
- gcm = GCForeground | GCBackground | GCGraphicsExposures;
- gcv.foreground = fore_pix;
- gcv.background = back_pix;
- gcv.graphics_exposures = 0;
- NormalGC = XCreateGC(display, Root, gcm, &gcv);
-
- /* ONLYSHAPE ON */
-
- pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
-
- XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
- XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
-
- /* ONLYSHAPE OFF */
-
- mywmhints.initial_state = WithdrawnState;
- mywmhints.icon_window = iconwin;
- mywmhints.icon_x = mysizehints.x;
- mywmhints.icon_y = mysizehints.y;
- mywmhints.window_group = win;
- mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
-
- XSetWMHints(display, win, &mywmhints);
-
- XSetCommand(display, win, argv, argc);
- XMapWindow(display, win);
-
-}
diff --git a/wmxres/wmgeneral/wmgeneral.h b/wmxres/wmgeneral/wmgeneral.h
deleted file mode 100644
index 8e35b7c..0000000
--- a/wmxres/wmgeneral/wmgeneral.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef WMGENERAL_H_INCLUDED
-#define WMGENERAL_H_INCLUDED
-
- /***********/
- /* Defines */
-/***********/
-
-#define MAX_MOUSE_REGION (8)
-
- /************/
- /* Typedefs */
-/************/
-
-typedef struct {
- Pixmap pixmap;
- Pixmap mask;
- XpmAttributes attributes;
-} XpmIcon;
-
- /*******************/
- /* Global variable */
-/*******************/
-
-extern Display *display;
-
- /***********************/
- /* Function Prototypes */
-/***********************/
-
-void AddMouseRegion(int index, int left, int top, int right, int bottom);
-int CheckMouseRegion(int x, int y);
-
-void openXwindow(int argc, char *argv[], char **, char *, int, int);
-void RedrawWindow(void);
-void RedrawWindowXYWH(int x, int y, int w, int h);
-
-void copyXPMArea(int, int, int, int, int, int);
-void copyXBMArea(int, int, int, int, int, int);
-void setMaskXY(int, int);
-
-#endif
diff --git a/wmxres/wmxres.c b/wmxres/wmxres.c
index 1e9e871..64998e6 100644
--- a/wmxres/wmxres.c
+++ b/wmxres/wmxres.c
@@ -7,15 +7,13 @@
* Les includes
*/

-#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <X11/xpm.h>
+#include <X11/X.h>
#include <X11/Xlib.h>
-#include <X11/extensions/Xxf86dga.h>
#include <X11/extensions/xf86vmode.h>
-#include "wmgeneral/wmgeneral.h"
+#include <libdockapp/dockapp.h>
#include "wmxres-master.xpm"
#include "wmxres-mask.xbm"

@@ -32,6 +30,7 @@ char res_active[12];
char res_list[100][20];
XF86VidModeModeInfo **res_modelines;
XEvent Event;
+Pixmap pixmap;

/*
* Les Fonctions
@@ -44,22 +43,38 @@ void GetXModes(void);
void ActiveXNewMode(void);
void GetXActiveMode(void);

+void pressActivate(int x, int y, DARect rect, void *data);
+void pressLeft(int x, int y, DARect rect, void *data);
+void pressRight(int x, int y, DARect rect, void *data);
+void buttonPress(int button, int state, int x, int y);
+
+void releaseActivate(int x, int y, DARect rect, void *data);
+void releaseLeft(int x, int y, DARect rect, void *data);
+void releaseRight(int x, int y, DARect rect, void *data);
+void buttonRelease(int button, int state, int x, int y);
+
/*
* Yalla
*/
int main(int argc,char *argv[])
{
- if (argc == 2 && strcmp(argv[1], "-v") == 0) {
- printf("wmxres "VERSION"\n");
- return 0;
- }
+ DACallbacks eventCallbacks = {NULL, buttonPress, buttonRelease,
+ NULL, NULL, NULL, NULL};
+ Pixmap mask;
+ unsigned short width, height;

- openXwindow(argc, argv, wmxres_master_xpm, wmxres_mask_bits,
- wmxres_mask_width, wmxres_mask_height);
+ DAParseArguments(argc, argv, NULL, 0,
+ "Window Maker dockapp to select your display mode",
+ PACKAGE_STRING);

- AddMouseRegion(0,43,44,55,55); /* Bouton d'activation */
- AddMouseRegion(1,19,44,31,55); /* Bouton scan gauche */
- AddMouseRegion(2,31,44,43,55); /* Bouton scan droit */
+ DAInitialize(NULL, PACKAGE_NAME, 56, 56, argc, argv);
+ DASetCallbacks(&eventCallbacks);
+
+ DAMakePixmapFromData(wmxres_master_xpm, &pixmap, NULL, &width, &height);
+ mask = DAMakeShapeFromData(wmxres_mask_bits,
+ wmxres_mask_width, wmxres_mask_height);
+ DASetPixmap(pixmap);
+ DASetShape(mask);

GetXModes();
GetXActiveMode();
@@ -67,65 +82,67 @@ int main(int argc,char *argv[])
DrawResMode(res_selected);
DrawLight(1);

- while (1)
- {
- while (XPending(display))
- {
- XNextEvent(display, &Event);
- switch (Event.type)
- {
- case Expose:
- /* On se fait beau */
- RedrawWindow();
- break;
- case DestroyNotify:
- /* Ciao */
- XCloseDisplay(display);
- exit(0);
- break;
- case ButtonPress:
- /* Bouton enfonce */
- isw = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
- switch (isw)
- {
- case 0: /* Activation */
- ButtonDown(0);
- ActiveXNewMode();
- DrawLight(1);
- break;
- case 1: /* Je scan a gauche */
- ButtonDown(1);
- DrawResMode(res_selected);
- DrawLight(0);
- break;
- case 2: /* Je scan a droite */
- ButtonDown(2);
- DrawResMode(res_selected);
- DrawLight(0);
- break;
- }
- if (res_selected==res_i_active) { DrawLight(1); }
- button_state = isw;
- break;
- case ButtonRelease:
- /* Bouton relache donc pas enfonce */
- switch (button_state)
- {
- case 0:
- ButtonUp(0);
- break;
- case 1:
- ButtonUp(1);
- break;
- case 2:
- ButtonUp(2);
- break;
- }
- break;
- }
- }
- usleep (200000);
- }
+ DASetTimeout(200);
+ DAShow();
+ DAEventLoop();
+}
+
+void pressActivate(int x, int y, DARect rect, void *data)
+{
+ ButtonDown(0);
+ ActiveXNewMode();
+ DrawLight(1);
+}
+
+void pressLeft(int x, int y, DARect rect, void *data)
+{
+ ButtonDown(1);
+ DrawResMode(res_selected);
+ DrawLight(res_selected == res_i_active ? 1 : 0);
+}
+
+void pressRight(int x, int y, DARect rect, void *data)
+{
+ ButtonDown(2);
+ DrawResMode(res_selected);
+ DrawLight(res_selected == res_i_active ? 1 : 0);
+}
+
+void buttonPress(int button, int state, int x, int y)
+{
+ DAActionRect pressRects[] = {
+ {{43, 44, 12, 12}, pressActivate},
+ {{19, 44, 12, 12}, pressLeft},
+ {{31, 44, 12, 12}, pressRight}
+ };
+
+ DAProcessActionRects(x, y, pressRects, 3, NULL);
+}
+
+void releaseActivate(int x, int y, DARect rect, void *data)
+{
+ ButtonUp(0);
+}
+
+void releaseLeft(int x, int y, DARect rect, void *data)
+{
+ ButtonUp(1);
+}
+
+void releaseRight(int x, int y, DARect rect, void *data)
+{
+ ButtonUp(2);
+}
+
+void buttonRelease(int button, int state, int x, int y)
+{
+ DAActionRect releaseRects[] = {
+ {{43, 44, 12, 12}, releaseActivate},
+ {{19, 44, 12, 12}, releaseLeft},
+ {{31, 44, 12, 12}, releaseRight}
+ };
+
+ DAProcessActionRects(x, y, releaseRects, 3, NULL);
}

/*
@@ -136,7 +153,7 @@ void GetXModes(void)
int c;

if (!(res_count > 0)) {
- XF86VidModeGetAllModeLines( display, XDefaultScreen(display), &res_count, &res_modelines);
+ XF86VidModeGetAllModeLines(DADisplay, XDefaultScreen(DADisplay), &res_count, &res_modelines);

if (res_count < 2) {
printf("Error : X must be configured with more than one mode.\n");
@@ -162,7 +179,7 @@ void GetXActiveMode(void)
XF86VidModeModeLine vm_modelines;
int a, i;

- XF86VidModeGetModeLine( display, XDefaultScreen(display), &a, &vm_modelines);
+ XF86VidModeGetModeLine(DADisplay, XDefaultScreen(DADisplay), &a, &vm_modelines);
sprintf(res_active, "%dx%d", vm_modelines.hdisplay, vm_modelines.vdisplay);

for(i=0; i < res_count; i++) {
@@ -177,8 +194,8 @@ int a, i;
*/
void ActiveXNewMode()
{
- XF86VidModeSwitchToMode( display, XDefaultScreen(display), res_modelines[res_selected]);
- XFlush(display);
+ XF86VidModeSwitchToMode(DADisplay, XDefaultScreen(DADisplay), res_modelines[res_selected]);
+ XFlush(DADisplay);
res_i_active=res_selected;
}

@@ -203,7 +220,8 @@ char *strtmp;
for (i=0; buf[i]; i++) {
c = buf[i];
c -= '0';
- copyXPMArea(c * 6, 61, 6, 7, k-1, 9);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ c * 6, 61, 6, 7, k-1, 9);
k += 6;
}

@@ -213,11 +231,12 @@ char *strtmp;
for (i=0; buf[i]; i++) {
c = buf[i];
c -= '0';
- copyXPMArea(c * 6, 61, 6, 7, k-1, 18);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ c * 6, 61, 6, 7, k-1, 18);
k += 6;
}

- RedrawWindow();
+ DASetPixmap(pixmap);
}

/*
@@ -225,9 +244,9 @@ char *strtmp;
*/
void DrawLight(int light_state)
{
- copyXPMArea (102, light_state? 35: 47, 14, 11, 1, 44);
- RedrawWindowXYWH(1, 44, 14, 11);
- RedrawWindow();
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 102, light_state? 35: 47, 14, 11, 1, 44);
+ DASetPixmap(pixmap);
}


@@ -240,22 +259,23 @@ void ButtonDown(int button)
switch (button)
{
case 0:
- copyXPMArea(79, 96, 12, 11, 43, 44);
- RedrawWindowXYWH(43, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 79, 96, 12, 11, 43, 44);
break;
case 1:
- copyXPMArea(55, 96, 12, 11, 19, 44);
- RedrawWindowXYWH(19, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 55, 96, 12, 11, 19, 44);
res_selected--;
if (res_selected < 0) { res_selected=res_count-1; }
break;
case 2:
- copyXPMArea(67, 96, 12, 11, 31, 44);
- RedrawWindowXYWH(31, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 67, 96, 12, 11, 31, 44);
res_selected++;
if (res_selected > res_count-1) { res_selected=0; }
break;
}
+ DASetPixmap(pixmap);
}

/*
@@ -266,17 +286,18 @@ void ButtonUp(int button)
switch (button)
{
case 0:
- copyXPMArea(79, 84, 12, 11, 43, 44);
- RedrawWindowXYWH(43, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 79, 84, 12, 11, 43, 44);
break;
case 1:
- copyXPMArea(55, 84, 12, 11, 19, 44);
- RedrawWindowXYWH(19, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 55, 84, 12, 11, 19, 44);
break;
case 2:
- copyXPMArea(67, 84, 12, 11, 31, 44);
- RedrawWindowXYWH(31, 44, 12, 11);
+ XCopyArea(DADisplay, pixmap, pixmap, DAGC,
+ 67, 84, 12, 11, 31, 44);
break;
}
+ DASetPixmap(pixmap);
}

--
2.25.1
Reply all
Reply to author
Forward
0 new messages