dockapps-b9baa8f/000077500000000000000000000000001261212373500140765ustar00rootroot00000000000000dockapps-b9baa8f/AUTHORS000066400000000000000000000007661261212373500151570ustar00rootroot00000000000000Alfredo K. Kojima Original creator and maintainer of libdockapp. Pascal G. Hofstee Took over development and maintenance from Alfredo when he couldn't find time for it anymore (due to the development of Window Maker and work). Alban G. Hertroys Co-maintainer while Pascal was responsible for maintenance. Took over the responsibility (and development/maintainence) after Pascal became too bussy in turn. dockapps-b9baa8f/BUGS000066400000000000000000000003611261212373500145610ustar00rootroot0000000000000020050716: - The standard options -h -v and -w cannot be combined into mixed options like the user specified ones. For example, if there's a user specified option -s and -ws is executed, the -w option gets ignored. dockapps-b9baa8f/COPYING000066400000000000000000000020211261212373500151240ustar00rootroot00000000000000Copyright (c) 1999 Alfredo K. Kojima 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 or substantial portions of the Software. 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 AUTHOR 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. dockapps-b9baa8f/ChangeLog000066400000000000000000000206101261212373500156470ustar00rootroot000000000000002015-10-20 Doug Torrance * configure.ac: Bump to version 0.7.2. 2015-10-20 Doug Torrance * Makefile.am: Clean generated file dockapp.pc. Based on the Debian patch [1]. [1] https://sources.debian.net/src/1:0.7.1-1/debian/patches/ clean_dockapp.pc.patch/ 2015-10-20 Doug Torrance * configure.ac, src/Makefile.am: Remove AC_PATH_XTRA macro from configure.ac We already check for libraries with the PKG_CHECK_MODULES macros. This also allows the Debian package to drop the Build-Depend on libice-dev. Based on the Debian patch [1]. [1] https://sources.debian.net/src/1:0.7.1-1/debian/patches/ remove_AC_PATH_XTRA.diff/ 2015-10-20 Doug Torrance * Recompress fonts without timestamp. This fixes the package-contains-timestamped-gzip warning given by Lintian for the Debian package. (This warning is really unnecessary, as its purpose it to check for reproducible builds and the fonts are not compressed at build time, but I see no harm in removing these timestamps.) 2015-10-17 Doug Torrance * configure.ac: Bump to version 0.7.1. 2015-10-17 Doug Torrance * Makefile.am: Update update-changelog target in Makefile. Only grab libdockapp commits. 2015-10-17 Doug Torrance * examples/basic/basic.c, examples/rectangles/rectangles.c: Update header location in examples. 2015-10-09 Shining * README: Simplify instructions to generate a ./configure script. Based on suggestions by Alexey Frolov and BALATON Zoltan. 2015-10-05 Shining * README: Info about generating 'configure' script in README. In the README it is said to run ./configure but there's no such script in the tarball. I wrote instructions to generate a ./configure with libtool and autotools. 2015-08-15 Rodolfo García Peñas (kix) * Include libwmgeneral in libdockapp. This patch includes the libwmgeneral library in the libdockapp library. The new library is now version 3 (previous was version 2) and it includes the new include folder in $libdir/libdockapp. The wmgeneral files were moved from the previous folder (libwmgeneral) and the folder is now removed. Signed-off-by: Rodolfo García Peñas (kix) 2014-11-28 Doug Torrance * NEWS, configure.ac: Release version 0.6.4. 2014-11-28 Doug Torrance * Makefile.am, NEWS, configure.ac: Update contact information. 2014-11-28 Doug Torrance * Add update-changelog target to Makefile to update ChangeLog. 2014-11-25 Doug Torrance * ChangeLog, NEWS, examples/basic/basic.c, src/dockapp.h: Merge ChangeLog into NEWS (they were largely the same). 2014-11-25 Doug Torrance * examples/basic/basic.c: Add #include to basic example. Otherwise, we get the following compiler warning basic.c: Infunction ‘main’: basic.c:111:2: warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration] srandom(time(NULL)); ^ 2014-11-25 Doug Torrance * README, examples/Makefile.am, examples/basic/Imakefile, examples/basic/Makefile, examples/rectangles/Imakefile, examples/rectangles/Makefile: Replace example Imakefiles with Makefiles. imake is deprecated. 2014-11-25 Doug Torrance * examples/basic/basic.c, examples/rectangles/rectangles.c, src/daargs.c, src/daargs.h, src/dacallback.c, src/dacolor.c, src/daevent.c, src/damain.c, src/dapixmap.c, src/darect.c, src/dashaped.c, src/dautil.c, src/dockapp.h: Use consistent code formatting. Used uncrustify to minimize warnings and errors from checkpatch.pl in the Window Maker source tree. 2014-11-25 Doug Torrance * examples/basic/Imakefile, examples/basic/basic.c, examples/rectangles/Imakefile, examples/rectangles/rectangles.c, src/Makefile.am, src/daargs.c, src/daargs.h, src/dacallback.c, src/dacolor.c, src/daevent.c, src/damain.c, src/dapixmap.c, src/darect.c, src/dashaped.c, src/dautil.c, src/dautil.h, src/dockapp.h: Remove CVS cruft. 2014-11-25 Doug Torrance * examples/basic/Imakefile, examples/basic/README, examples/basic/basic.c, examples/rectangles/Imakefile, examples/rectangles/rectangles.c, fonts/Makefile.am, src/dacallback.c, src/dacolor.c, src/daevent.c, src/damain.c, src/dapixmap.c, src/dashaped.c, src/dockapp.h: Remove trailing whitespace. 2014-11-24 Doug Torrance * INSTALL, Makefile.in, aclocal.m4, compile, config.guess, config.sub, configure, dockapp.pc, examples/Makefile.in, fonts/Makefile.in, install-sh, ltmain.sh, missing, src/Makefile.in: Remove autotools-generated files. 2014-11-24 Doug Torrance * Add version 0.6.3 to repository. Obtained from: http://sourceforge.net/projects/files/ libdockapp-0.6.3.tar.gz/download ** Changes above this point from git log in dockapps git repository. ** 2014-06-06 Doug Torrance * ChangeLog, NEWS: updated Changelog and NEWS files with new version 2014-06-06 Doug Torrance * Makefile.am: add xext to dockapp.pc 2014-06-06 Doug Torrance * configure.ac, src/Makefile.am: add xpm to linked libraries 2014-06-06 Doug Torrance * .gitignore, autogen.sh, do_verify.sh: add more autotools-generated files to .gitignore 2014-06-06 Doug Torrance * configure.ac, src/Makefile.am: use pkg-config for linked libraries 2014-05-02 Doug Torrance * Makefile.am: added BUGS to distribution tarball 2014-05-02 Doug Torrance * .gitignore: Update .gitignore (add configure.no-verify). 2014-05-01 Doug Torrance * .gitignore, Makefile.am: Add pkg-config dockapp.pc file. 2014-05-01 Doug Torrance * configure.ac: Modernize configure.ac. 2014-05-01 Doug Torrance * .gitignore, Makefile.in, aclocal.m4, compile, config.guess, config.sub, configure, examples/Makefile.in, fonts/Makefile.in, ltmain.sh, missing, src/Makefile.in: Remove autotools-generated files, update .gitignore. 2014-05-01 Doug Torrance * fonts/Makefile.am: Actually added fonts to distribution tarball. Despite the commit message of the previous commit, this was not done. Now it is. 2014-05-01 Doug Torrance * configure.ac, fonts/Makefile.am, fonts/fonts.alias, fonts/fonts.dir: Various changes to `make install' of fonts. * Use font-util macros. * Include fonts in distribution tarball. * Removed fonts.dir (built by `make install') and fonts.alias (empty file). 2014-04-30 Doug Torrance * examples/Makefile.am: rewrite examples Makefile.am to ensure they are included in the tarball 2014-04-30 Doug Torrance * INSTALL, Makefile.in, aclocal.m4, compile, config.guess, config.sub, configure, configure.ac, configure.in, examples/Makefile.in, fonts/Makefile.in, install-sh, ltmain.sh, missing, src/Makefile.in: rename configure.in -> configure.ac 2014-04-30 Doug Torrance * .gitignore: added .gitignore 2014-04-30 Doug Torrance * CVS/Entries, CVS/Repository, CVS/Root, autom4te.cache/output.0, autom4te.cache/output.1, autom4te.cache/requests, autom4te.cache/traces.0, autom4te.cache/traces.1, examples/CVS/Entries, examples/CVS/Repository, examples/CVS/Root, examples/basic/CVS/Entries, examples/basic/CVS/Repository, examples/basic/CVS/Root, examples/rectangles/CVS/Entries, examples/rectangles/CVS/Repository, examples/rectangles/CVS/Root, examples/shapes/CVS/Entries, examples/shapes/CVS/Repository, examples/shapes/CVS/Root, fonts/CVS/Entries, fonts/CVS/Repository, fonts/CVS/Root, src/CVS/Entries, src/CVS/Repository, src/CVS/Root: Removed CVS directories 2014-04-24 Doug Torrance * Initial commit ** Changes above this point from git log in sourceforge git repository. ** dockapps-b9baa8f/Makefile.am000066400000000000000000000016261261212373500161370ustar00rootroot00000000000000if COND_FONT COND_FONT = fonts else COND_FONT = endif if COND_EXAMPLES COND_XMPS = examples endif SUBDIRS = src $(COND_FONT) $(COND_XMPS) pkgconfigdir = $(libdir)/pkgconfig dist_pkgconfig_DATA = dockapp.pc dockapp.pc: Makefile @echo "Generating $@" @echo 'Name: dockapp' > $@ @echo 'Description: Window Maker dockapp support' >> $@ @echo 'URL: http://windowmaker.org/dockapps/?name=libdockapp' >> $@ @echo 'Version: $(VERSION)' >> $@ @echo 'Requires: x11 xext xpm' >> $@ @echo 'Libs: -L${libdir} -ldockapp' >> $@ @echo 'Cflags: -I${includedir}' >> $@ CLEANFILES = dockapp.pc EXTRA_DIST = BUGS update-changelog: @git log `git log -1 --pretty=%h -- ChangeLog`..HEAD \ --pretty --numstat --summary -- . | \ git2cl | \ sed 's/libdockapp: \?//g' | \ sed 's/libdockapp\///g' > ChangeLog.new @mv ChangeLog ChangeLog.old @cat ChangeLog.new ChangeLog.old > ChangeLog @rm ChangeLog.new ChangeLog.old dockapps-b9baa8f/NEWS000066400000000000000000000121631261212373500146000ustar00rootroot00000000000000This file is maintained by wmaker-dev@lists.windowmaker.org, and available from http://windowmaker.org/dockapps/?name=libdockapp. News for for all libDockApp users. ---------------------------------- This file contains a reverse chronology of changes. The contents of this file will apply mostly to developers of dockapps. Please read this when you update. 20141128 Release of libdockapp 0.6.4. Source code cleanup. Now maintained by Window Maker Developers Team. 20140606 Release of libdockapp 0.6.3. Updated autotools input files. Added dockapp.pc file for use with pkg-config. 20050716: Release of libdockapp 0.6.1 Fixed parsing multi-character short options. 20050522: Release of libDockapp 0.6.0. 20050420: Added DAError and DAWarning functions. 20050414: Added DAFreeShapedPixmap. 20050408: Added functions to read an XPM file dynamically. Added a function to retrieve the program name from the program arguments. 20030210: Added a new global variable DAIcon. The value of this variable is None if the dockapp runs in "windowed mode". Added functions DAGetIconWindow() and DASetIconWindow(Window icon_window). The "...Window"-part is because X discerns between icon windows and icon pixmaps. DAWindow now always points to the shown window. Normally this is the icon window (DAIcon), but in "windowed mode" this is the leader window (DALeader). 20030131: Bumped the version of the library to 2. 20030130: Added WMProtocol for WM_DELETE_WINDOW. Dockapps run in "windowed mode" will have a proper close-button now. Child windows of a dockapp are now mapped as well when calling DAShow(). Reworked basic example to use a Window instead of drawing and erasing pixmaps by hand. This removes a lot of the complex parts of the example. Revamped the Changelog. Changedates have become important now that we use them for backward compatibility. 20030126: Added expected against actual version matching system. This has the purpose of keeping the library backward compatible, even when the API changes (as happened with DAGetDisplay). Use the function DASetExpectedVersion() in your dockapp to ensure backward compatibility. !!! COMPATIBILITY WARNING !!! Renamed DAGetDisplay() to DAOpenDisplay(). The function opened a display, this name makes more sense and there was a potential namespace conflict (see below). Added functions: Display* DAGetDisplay(char *display, ...) Window DAGetWindow() Window DAGetLeader() int DAGetDepth() Visual* DAGetVisual() DAGetDisplay(Display *display) DAGetWindow(Window window) DAGetLeader(Window leader) DAGetDepth(int depth) DAGetVisual(Visual *visual) These functions just wrap the global variables DADisplay, DAWindow, DALeader, DADepth and DAVisual. The globals are still available, and will probably remain in future releases (The wrappers are for calls from other dynamic objects). If DASetExpectedVersion is before 20030126 (or not set), DAGetDisplay will behave in the old way, opening the display instead of reading out the variable. The NEW version of DAGetDisplay should be called as: Display *d = DAGetDisplay(NULL); 20021220: Added event handling for DestroyNotify, EnterWindow and LeaveWindow. 20021016: Added a more complex example ("rectangles") showing the use of 'action rectangles' and the handling of _all_ recognised event types; this one may need some simplification. Added an example ("shapes") of using the shaped pixmap API. No code yet, just a directory. 20020926: Added programming examples. There are three examples in the make: A relatively simple example ("basic") without event handling and with only basic shape implementation. 20020924: Added a 7-segment display font. This font was donated by Jim Knoble. Thanks Jim (It doesn't get installed, yet. I still need to make a Makefile for this...). 20020922: Added DAShapedPixmap type and functions to work with it. There is an entire API around shaped pixmaps now, keeping pixmap, mask and geometry together. It allows copying areas from both the pixmap and the mask to another shaped pixmap, etc. Added new global GC: DAClearGC. If you want to draw parts, you will also want to erase parts. 20020921: Added default colors as X-resources: DockApp*foreground and DockApp*background. These colors are the foreground colors of DAGC and DAClearGC respectively. 20020905: "Inherited" the project from Pascal Hofstee. He stopped maintaining it, and gave his okay when I asked to maintain it. We used to work on this together, I'll continue the effort alone. Release of libDockapp 0.4 Since libDockApp 0.2 -------------------- DockApps can now change shape on the fly. Motion Events are properly handled now. Code review/cleanup Added DARect and DAActionRect structures. These allow You to easily specify regions, and functions that should be called when clicked in these regions. DAEventLoop now finaly no longer causes Huge CPU-usage. Turned out I had to disable the GCGraphicsExposures GC-Values, which were generating huge amounts of "NoExpose" events which were simply discarded anyway. -- Before this, libdockapp was maintained and copyright by Alfredo Kojima. dockapps-b9baa8f/README000066400000000000000000000050201261212373500147530ustar00rootroot00000000000000DockApp Development Standard Library Alban G. Hertroys Alfredo K. Kojima Pascal G. Hofstee ............................................................................... You must have libXpm library installed and the shape extension supported by your X server to be able to build and install libdockapp. If you received this file in a tarball then you probably need to generate the configuration environment yourself. You need libtool and autotools for this purpose. To compile libDockApp enter the libdockapp directory and type: autoreconf -if ./configure make install You can choose to not install the examples or the fonts with configure options: --with-font install the dockapp font (default=yes) --with-examples install the examples (default=yes) The API is described in dockapp.h There are some examples in the examples directory. These aren't build by default. You can compile them like: cd examples/basic make Optionally you can "make install" if you really like the example application. License: Copyright (c) 1999-2003 Alfredo K. Kojima, Pascal Hofstee, Alban G. Hertroys All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dockapps-b9baa8f/configure.ac000066400000000000000000000026371261212373500163740ustar00rootroot00000000000000AC_INIT([libdockapp],[0.7.2],[wmaker-dev@lists.windowmaker.org]) AC_CONFIG_SRCDIR([src/dockapp.h]) AM_INIT_AUTOMAKE LT_INIT dnl Specify whether to install font and examples dnl ============================================ AC_ARG_WITH(font, [ --with-font install the dockapp font (default=yes)], with_font=$withval, with_font=yes) AC_ARG_WITH(examples, [ --with-examples install the examples (default=yes)], with_examples=$withval, with_examples=yes) AM_CONDITIONAL(COND_FONT, [test "$with_font" = yes]) AM_CONDITIONAL(COND_EXAMPLES, [test "$with_examples" = yes]) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL dnl Checks for libraries. PKG_CHECK_MODULES([X11],[x11]) PKG_CHECK_MODULES([Xext],[xext]) PKG_CHECK_MODULES([xpm],[xpm]) dnl Checks for header files. dnl Checks for typedefs, structures, and compiler characteristics. dnl Debugging dnl ========= AC_ARG_ENABLE(debug, [ --enable-debug enable debugging ],, enable_debug=no) if test "$enable_debug" = yes; then DFLAGS="-Wall -g -ansi -pedantic" fi AC_SUBST(DFLAGS) dnl Font-util macros dnl ================ m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])]) XORG_FONT_MACROS_VERSION(1.1) XORG_FONT_COMMON_UTILS() XORG_FONTDIR([misc]) AC_CONFIG_FILES([Makefile src/Makefile fonts/Makefile examples/Makefile]) AC_OUTPUT dockapps-b9baa8f/examples/000077500000000000000000000000001261212373500157145ustar00rootroot00000000000000dockapps-b9baa8f/examples/Makefile.am000066400000000000000000000002651261212373500177530ustar00rootroot00000000000000nobase_doc_DATA = README \ basic/Makefile \ basic/README \ basic/ball_red.xpm \ basic/basic.c \ rectangles/Makefile \ rectangles/rectangles.c EXTRA_DIST = $(nobase_doc_DATA) dockapps-b9baa8f/examples/README000066400000000000000000000033401261212373500165740ustar00rootroot00000000000000About the examples ------------------ In this directory you find the example applications for libDockApp. This is a work in progress. It is not easy to come up with good examples of how to use features without bloating it with "stuff you don't need to know". That's why it is far from finished, and that's also why I INVITE YOU TO SUBMIT simple dockapps that provide good examples of certain features. The examples: ------------ basic: This is an example that uses a few simple shapes; a rectangle containing a bouncing ball. It shows how to use the abstracted DAShapedPixmap structs and how to use X Window types for overlaying one shape on top of another (something much easier and more flexible than trying to blend the pixmaps together). It also shows some simple event handling (a timeout event and a window close event). rectangles: This example shows how to use "action rectangles". Those are areas that you define callbacks for events on. The example got rather mixed up with X drawing calls, and creating shapes by hand from X regions. I'm thinking about either stripping it of most functionality to make it a proper example of what it tries to show, or to rename it to "tangles". It even uses some deprecated features... shapes: NOT IMPLEMENTED YET. And maybe a tad superfluous, as "basic" already show how to use shapes. Needed examples: --------------- I need examples that show one or more of the following (less is better): - Something very basic; just showing how to get started. - Command line parameter parsing. - Action rectangles; my example isn't very good. - How to handle different icon sizes flexibly (I think that could result in some new library functions to be added). - Loading pixmaps in runtime. dockapps-b9baa8f/examples/basic/000077500000000000000000000000001261212373500167755ustar00rootroot00000000000000dockapps-b9baa8f/examples/basic/Makefile000066400000000000000000000005261261212373500204400ustar00rootroot00000000000000CC=gcc INSTALL=install PREFIX=/usr/local CFLAGS+=-Wall `pkg-config --cflags dockapp` LIBS=`pkg-config --libs dockapp` basic: basic.o $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) basic.o: basic.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $< install: $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin $(INSTALL) basic $(DESTDIR)$(PREFIX)/bin clean: rm -f basic basic.o dockapps-b9baa8f/examples/basic/README000066400000000000000000000124061261212373500176600ustar00rootroot00000000000000This example dockapp is public domain. It may freely be used as a basis for any application. The original version was made by Alban G. Hertroys (dalroi@solfertje.student.utwente.nl). The red ball in the example originates from the public domain icons provided with the Apache server distribution. The following statement was included with these icons: ----------------------------------------------------------------------------- Public Domain Icons These icons were originally made for Mosaic for X and have been included in the NCSA httpd and Apache server distributions in the past. They are in the public domain and may be freely included in any application. The originals were done by Kevin Hughes (kevinh@kevcom.com). Many thanks to Andy Polyakov for tuning the icon colors and adding a few new images. If you'd like to contribute additions or ideas to this set, please let me know. Almost all of these icons are 20x22 pixels in size. There are alternative icons in the "small" directory that are 16x16 in size, provided by Mike Brown (mike@hyperreal.org). Suggested Uses The following are a few suggestions, to serve as a starting point for ideas. Please feel free to tweak and rename the icons as you like. a.gif This might be used to represent PostScript or text layout languages. alert.black.gif, alert.red.gif These can be used to highlight any important items, such as a README file in a directory. back.gif, forward.gif These can be used as links to go to previous and next areas. ball.gray.gif, ball.red.gif These might be used as bullets. binary.gif This can be used to represent binary files. binhex.gif This can represent BinHex-encoded data. blank.gif This can be used as a placeholder or a spacing element. bomb.gif This can be used to repreesnt core files. box1.gif, box2.gif These icons can be used to represent generic 3D applications and related files. broken.gif This can represent corrupted data. burst.gif This can call attention to new and important items. c.gif This might represent C source code. comp.blue.gif, comp.red.gif These little computer icons can stand for telnet or FTP sessions. compressed.gif This may represent compressed data. continued.gif This can be a link to a continued listing of a directory. down.gif, up.gif, left.gif, right.gif These can be used to scroll up, down, left and right in a listing or may be used to denote items in an outline. dvi.gif This can represent DVI files. f.gif This might represent FORTRAN or Forth source code. folder.gif, folder.open.gif, folder.sec.gif The folder can represent directories. There is also a version that can represent secure directories or directories that cannot be viewed. generic.gif, generic.sec.gif, generic.red.gif These can represent generic files, secure files, and important files, respectively. hand.right.gif, hand.up.gif These can point out important items (pun intended). image1.gif, image2.gif, image3.gif These can represent image formats of various types. index.gif This might represent a WAIS index or search facility. layout.gif This might represent files and formats that contain graphics as well as text layout, such as HTML and PDF files. link.gif This might represent files that are symbolic links. movie.gif This can represent various movie formats. p.gif This may stand for Perl or Python source code. pie0.gif ... pie8.gif These icons can be used in applications where a list of documents is returned from a search. The little pie chart images can denote how relevant the documents may be to your search query. patch.gif This may stand for patches and diff files. portal.gif This might be a link to an online service or a 3D world. ps.gif, quill.gif These may represent PostScript files. screw1.gif, screw2.gif These may represent CAD or engineering data and formats. script.gif This can represent any of various interpreted languages, such as Perl, python, TCL, and shell scripts, as well as server configuration files. sound1.gif, sound2.gif These can represent sound files. sphere1.gif, sphere2.gif These can represent 3D worlds or rendering applications and formats. tex.gif This can represent TeX files. text.gif This can represent generic (plain) text files. transfer.gif This can represent FTP transfers or uploads/downloads. unknown.gif This may represent a file of an unknown type. uuencoded.gif This can stand for uuencoded data. world1.gif, world2.gif These can represent 3D worlds or other 3D formats. ----------------------------------------------------------------------------- dockapps-b9baa8f/examples/basic/ball_red.xpm000066400000000000000000000004521261212373500212700ustar00rootroot00000000000000/* XPM */ static char * ball_red_xpm[] = { "10 11 6 1", " c None", ". c #000000", "+ c #FF9999", "@ c #FF3333", "# c #FFFFFF", "$ c #660000", " .... ", " .+++@. ", " .+#+@@$. ", ".++#++@@$.", ".@+@+@$$$.", ".+@+@@@$..", ".@@@@$$$..", ".@@$@$$...", " .$$$$.$. ", " .$.... ", " .... "}; dockapps-b9baa8f/examples/basic/basic.c000066400000000000000000000110251261212373500202210ustar00rootroot00000000000000/* * Copyright (c) 2002 Alban G. Hertroys * * Basic example of libDockapp usage * * This dockapp will draw a rectangle with a * bouncing ball in it. */ /* also includes Xlib, Xresources, XPM, stdlib and stdio */ #include #include /* include the pixmap to use */ #include "ball_red.xpm" #define SPEED 20 #define MAX_MOVE 4 /* * Prototypes for local functions */ void drawRelief(Pixmap pixmap); void moveBall(void); void destroy(void); /* * Global variables */ Window ballWin; DAShapedPixmap *ballPix; /* * M A I N */ int main(int argc, char **argv) { unsigned int x = 1, y = 1; Pixmap back; DACallbacks eventCallbacks = { destroy, /* destroy */ NULL, /* buttonPress */ NULL, /* buttonRelease */ NULL, /* motion (mouse) */ NULL, /* mouse enters window */ NULL, /* mouse leaves window */ moveBall /* timeout */ }; /* provide standard command-line options */ DAParseArguments( argc, argv, /* Where the options come from */ NULL, 0, /* Our list with options - none as you can see */ "This is the help text for the basic example of how to " "use libDockapp.\n", "Basic example version 1.1"); /* Tell libdockapp what version we expect it to be (a date from * NEWS should do). */ DASetExpectedVersion(20020126); DAOpenDisplay( NULL /* default display */, argc, argv /* needed by libdockapp */ ); DACreateIcon( "daBasicExample" /* WM_CLASS hint; don't use chars in [.?*: ] */, 48, 48 /* geometry of dockapp internals */, argc, argv /* needed by libdockapp */ ); /* The pixmap that makes up the background of the dockapp */ back = DAMakePixmap(); drawRelief(back); DASetPixmap(back); XFreePixmap(DADisplay, back); /* A window(!) for the ball pixmap. * Moving a window is a lot easier then erasing/copying the pixmap all * the time. * * I use a DAShapedPixmap here, which contains all the information * related to the pixmap: pixmap, mask and geometry. */ ballPix = DAMakeShapedPixmapFromData(ball_red_xpm); ballWin = XCreateSimpleWindow(DADisplay, DAWindow, x, y, /* Use the geometry of the shaped pixmap */ ballPix->geometry.width, ballPix->geometry.height, 0, 0, 0); DASPSetPixmapForWindow(ballWin, ballPix); /* Respond to destroy and timeout events (the ones not NULL in the * eventCallbacks variable. */ DASetCallbacks(&eventCallbacks); /* Set the time for timeout events (in msec) */ DASetTimeout(SPEED); /* Randomize movement variation. * Run multiple versions of the dockapp simultaneously to see the effect * best. * (which function to use is set from the Imakefile) */ #ifdef HAS_RANDOMDEV srandomdev(); #else srandom(time(NULL)); #endif DAShow(); /* Show the dockapp window. */ /* Process events and keep the dockapp running */ DAEventLoop(); /* not reached */ exit(EXIT_SUCCESS); } void drawRelief(Pixmap pixmap) { XGCValues gcv; GC lightGrayGC, darkGrayGC; /* GC's */ gcv.foreground = DAGetColor("Navy"); XChangeGC(DADisplay, DAClearGC, GCForeground, &gcv); gcv.foreground = DAGetColor("lightGray"); gcv.graphics_exposures = False; lightGrayGC = XCreateGC(DADisplay, DAWindow, GCForeground | GCGraphicsExposures, &gcv); gcv.foreground = DAGetColor("#222222"); darkGrayGC = XCreateGC(DADisplay, DAWindow, GCForeground | GCGraphicsExposures, &gcv); /* Drawing */ XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46); XDrawLine(DADisplay, pixmap, darkGrayGC, 0, 0, 0, 46); XDrawLine(DADisplay, pixmap, darkGrayGC, 1, 0, 47, 0); XDrawLine(DADisplay, pixmap, lightGrayGC, 0, 47, 47, 47); XDrawLine(DADisplay, pixmap, lightGrayGC, 47, 1, 47, 46); /* Free the GC's, we don't use them anymore */ XFreeGC(DADisplay, lightGrayGC); XFreeGC(DADisplay, darkGrayGC); } void moveBall(void) { static int x = 1; static int y = 1; static int dx; static int dy; signed int var = random() % 3 - 1; if (dx == 0) dx = var; if (dy == 0) dy = var; if (dx > MAX_MOVE) dx = MAX_MOVE; if (dy > MAX_MOVE) dy = MAX_MOVE; /* calculate new position */ x += dx; y += dy; if (x < 1) { x = 1; dx = -dx + var; } if (y < 1) { y = 1; dy = -dy + var; } if (x + ballPix->geometry.width > 46) { x = 46 - ballPix->geometry.width; dx = -dx + var; } if (y + ballPix->geometry.height > 46) { y = 46 - ballPix->geometry.height; dy = -dy + var; } XMoveWindow(DADisplay, ballWin, x, y); } void destroy(void) { XFreePixmap(DADisplay, ballPix->pixmap); XFreePixmap(DADisplay, ballPix->shape); fprintf(stderr, "Destroyed!\n"); /* exit is done by libdockapp */ } dockapps-b9baa8f/examples/rectangles/000077500000000000000000000000001261212373500200435ustar00rootroot00000000000000dockapps-b9baa8f/examples/rectangles/Makefile000066400000000000000000000005711261212373500215060ustar00rootroot00000000000000CC=gcc INSTALL=install PREFIX=/usr/local CFLAGS+=-Wall `pkg-config --cflags dockapp` LIBS=`pkg-config --libs dockapp` rectangles: rectangles.o $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) rectangles.o: rectangles.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $< install: $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin $(INSTALL) rectangles $(DESTDIR)$(PREFIX)/bin clean: rm -f rectangles rectangles.o dockapps-b9baa8f/examples/rectangles/rectangles.c000066400000000000000000000374541261212373500223530ustar00rootroot00000000000000/* * Copyright (c) 2002 Alban G. Hertroys * * libDockapp example - Usage of action rectangles * * Some clickable and draggable areas for you to play * with. * * There's a bit much in here... */ /* The cursor font - stamdard cursor glyphs. */ #include /* Required because we don't use a pixmap for the shape (using a DASetShape * variation). Instead we use the XLib call "XShapeCombineRegion". * Window shapes are an extension (since X11R5). */ #include #include /* already includes Xlib, Xresources, XPM, stdlib and stdio */ /* * Type definitions */ /* I like to keep my graphic contexts (GCs) together */ struct Colors { GC white; /* foreground color from X-resource, or default */ GC black; /* background color, idem */ GC lightGray; /* Some GC's we'll have to define for colors */ GC darkGray; GC slider; /* draw-color when not highlighted, * dark-color when highlighted */ GC sliderLight; /* draw-color when highlighted */ GC sliderDark; /* dark-color when not highlighted */ }; /* * Global variables */ Pixmap pixmap; /* pixmap pixmap */ DARect *buttonDown = NULL; struct Colors *colors; /* our colors */ DAActionRect **actionRects; float sliderPos = 0.7; int mouseIn = 0; Cursor pointer; /* * Prototypes for local functions */ struct Colors *setGCs(Drawable d); unsigned long adjustColor(unsigned long color, signed int adjustment); /* drawing routines */ void createBtn(DARect rect); void drawRaisedFrame(DARect rect); void drawSunkenFrame(DARect rect); void createSquare(DARect rect); void drawSquare(DARect rect, int button); void createSlider(DARect rect); void drawSlider(DARect rect); void setPointerColor(GC); /* utility functions */ DAActionRect setRectAction(DARect rect, DARectCallback action); /* event handlers functions */ void destroy(void); void buttonPress(int button, int state, int x, int y); void buttonRelease(int button, int state, int x, int y); void mouseMove(int x, int y); void mouseEnter(void); void mouseLeave(void); /* what to do for a specific event for every 'item' in the dockapp */ /* Button that can be pressed "down" and jumps back "up" again */ void btnDown(int x, int y, DARect rect, void *data); void btnUp(int x, int y, DARect rect, void *data); void btnLeave(int x, int y, DARect rect, void *data); /* Square that tells which button was pressed (number) */ void squareDown(int x, int y, DARect rect, void *data); /* A draggable slider that highlights when the mouse is over it */ void sliderDown(int x, int y, DARect rect, void *data); void sliderUp(int x, int y, DARect rect, void *data); void sliderMove(int x, int y, DARect rect, void *data); void sliderEnter(int x, int y, DARect rect, void *data); void sliderLeave(int x, int y, DARect rect, void *data); /* * M A I N */ int main(int argc, char **argv) { /* define the event handlers for the events */ DACallbacks eventCallbacks = { destroy, /* destroy */ buttonPress, /* buttonPress */ buttonRelease, /* buttonRelease */ mouseMove, /* motion (mouse) */ mouseEnter, /* mouse enters window */ mouseLeave, /* mouse leaves window */ NULL /* timeout */ }; /* define regions (x, y, width, height) that need event-handling */ Region clipRegion = XCreateRegion(); DARect btn = {0, 0, 16, 16}, square = {0, 25, 22, 22}, slider = {24, 0, 23, 48}; /* define what to do if an event occurs in a rectangle */ DAActionRect *buttonPressRects, *buttonReleaseRects, *mouseMoveRects, *mouseEnterRects, *mouseLeaveRects; buttonPressRects = malloc(3 * sizeof(DAActionRect)); buttonPressRects[0] = setRectAction(btn, btnDown); buttonPressRects[1] = setRectAction(square, squareDown); buttonPressRects[2] = setRectAction(slider, sliderDown); buttonReleaseRects = malloc(2 * sizeof(DAActionRect)); buttonReleaseRects[0] = setRectAction(btn, btnUp); buttonReleaseRects[1] = setRectAction(slider, sliderUp); mouseMoveRects = malloc(sizeof(DAActionRect)); mouseMoveRects[0] = setRectAction(slider, sliderMove); mouseEnterRects = malloc(sizeof(DAActionRect)); mouseEnterRects[0] = setRectAction(slider, sliderEnter); mouseLeaveRects = malloc(2 * sizeof(DAActionRect)); mouseLeaveRects[0] = setRectAction(btn, btnLeave); mouseLeaveRects[1] = setRectAction(slider, sliderLeave); /* XXX: make action rectangles available outside main() * ...libDockapp should be able to do this... (reminder) */ actionRects = malloc(6 * sizeof(DAActionRect *)); actionRects[0] = buttonPressRects; actionRects[1] = buttonReleaseRects; actionRects[2] = mouseMoveRects; actionRects[3] = mouseEnterRects; actionRects[4] = mouseLeaveRects; actionRects[5] = NULL; /* provide standard command-line options */ DAParseArguments( argc, argv, /* Where the options come from */ NULL, 0, /* Our list with options - none as you can see */ "This is the help text for the rectangle example of how to " "use libDockapp.\n", "Rectangle example version 1.0"); /* Tell libdockapp what version we expect it to be, so that you can use * older programs with newer versions of libdockapp with less risc for * compatibility problems. */ DASetExpectedVersion(20030126); /* Initialize a dockapp */ DAInitialize( "", /* Use default display */ "daRectangleExample", /* WM_CLASS hint; don't use chars in [.?*: ] */ 48, 48, /* geometry of dockapp internals */ argc, argv /* (needed internally) */ ); /* Create a pixmap to draw on, and to display */ pixmap = DAMakePixmap(); /* size == dockapp geometry (48,48) */ colors = setGCs(pixmap); XFillRectangle(DADisplay, pixmap, DAClearGC, 0, 0, 48, 48); XClearWindow(DADisplay, DAWindow); /* Make a "Region" from the shapes we have */ XUnionRectWithRegion(&btn, clipRegion, clipRegion); XUnionRectWithRegion(&square, clipRegion, clipRegion); XUnionRectWithRegion(&slider, clipRegion, clipRegion); /* Make this region a window shape mask */ XShapeCombineRegion(DADisplay, DAWindow, ShapeBounding, 0, 0, clipRegion, ShapeSet); /* We don't need the region anymore (it is copied by XShapeCombineRegion). * XXX: That's not certain, it is not documented. XSetRegion does so, * though, so it is a likely assumption that it does copy. */ XDestroyRegion(clipRegion); /* The cursor we want to use. * Specify 'None' for the default, * or one from X11/cursorfont.h */ pointer = XCreateFontCursor(DADisplay, XC_based_arrow_up); XDefineCursor(DADisplay, DAWindow, pointer); /* a square with an image that changes when clicked (A button). */ createBtn(btn); /* a square that shows the number of the mouse-button pressed on click. */ createSquare(square); /* a slider a using two dashed line GC's. */ createSlider(slider); /* Tell libdockapp this is the pixmap that we want to show */ DASetPixmap(pixmap); /* Process events every 100ms */ DASetTimeout(100); /* set event callbacks */ DASetCallbacks(&eventCallbacks); /* Display the pixmap we said it to show */ DAShow(); /* Process events and keep the dockapp running */ DAEventLoop(); return 0; } /* Create our GC's to draw colored lines and such */ struct Colors * setGCs(Drawable d) { struct Colors *colors; XGCValues gcv; unsigned long origColor; char dashList[2] = {3, 1}; colors = malloc(sizeof(struct Colors)); if (colors == NULL) return NULL; /* Get the GC-values of the default GC */ XGetGCValues(DADisplay, DAGC, GCForeground | GCBackground | GCGraphicsExposures, &gcv); origColor = gcv.foreground; /* don't send expose events */ gcv.graphics_exposures = False; /* GC for white color */ gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); colors->white = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for dark blue color */ #if 1 gcv.foreground = DAGetColor("navy"); #else gcv.foreground = 0; #endif colors->black = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for light borders */ gcv.foreground = DAGetColor("lightGray"); colors->lightGray = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for dark borders (note re-use of gcv-values) */ gcv.foreground = DAGetColor("#222222"); colors->darkGray = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for the un-/highlighted colors and dashed line of the slider */ gcv.foreground = origColor; gcv.line_width = 9; gcv.line_style = LineOnOffDash; colors->slider = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->slider, 1, dashList, 2); /* light slider GC */ gcv.foreground = adjustColor(origColor, +0x40); colors->sliderLight = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2); /* dark slider GC */ gcv.foreground = adjustColor(origColor, -0x40); colors->sliderDark = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2); return colors; } /* Make a (GC) color lighter or darker */ unsigned long adjustColor(unsigned long color, signed int adjustment) { signed long r, g, b; r = color >> 16; g = (color - (r << 16)) >> 8; b = (color - (g << 8) - (r << 16)); r += adjustment; g += adjustment; b += adjustment; if (r > 0xff) r = 0xff; if (g > 0xff) g = 0xff; if (b > 0xff) b = 0xff; if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; return ((unsigned short)r << 16) + ((unsigned short)g << 8) + (unsigned short)b; } void setPointerColor(GC color) { XGCValues gcv; XColor fcolor, bcolor; XGetGCValues(DADisplay, color, GCForeground, &gcv); fcolor.pixel = gcv.foreground; fcolor.flags = DoRed | DoGreen | DoBlue; bcolor.red = 0; bcolor.green = 0; bcolor.blue = 0; XRecolorCursor(DADisplay, pointer, &fcolor, &bcolor); } /* event handlers functions */ void destroy(void) { } void buttonPress(int button, int state, int x, int y) { int *data = malloc(sizeof(int *)); *data = button; DAProcessActionRects(x, y, actionRects[0], 3, (void *)data); free(data); } void buttonRelease(int button, int state, int x, int y) { DAProcessActionRects(x, y, actionRects[1], 2, NULL); } void mouseMove(int x, int y) { DAProcessActionRects(x, y, actionRects[2], 1, NULL); } void mouseEnter(void) { mouseIn = 1; drawSlider(actionRects[3][0].rect); } void mouseLeave(void) { mouseIn = 0; /* mouse pointer left the dockapp window */ DAProcessActionRects(0, 0, actionRects[4], 2, NULL); /* if the button is still depressed, make it go up again. */ /* TODO: Use data in actionRects[4] here instead of below check */ if (buttonDown != NULL) btnUp(0, 0, *buttonDown, NULL); drawSlider(actionRects[4][1].rect); } /* what to do for a specific event for every 'item' in the dockapp */ /* Button that can be pressed "down" and jumps back "up" again */ void btnDown(int x, int y, DARect rect, void *data) { buttonDown = ▭ drawSunkenFrame(rect); } void btnUp(int x, int y, DARect rect, void *data) { buttonDown = NULL; drawRaisedFrame(rect); } void btnLeave(int x, int y, DARect rect, void *data) { if (buttonDown == NULL) return; drawRaisedFrame(rect); } /* Square that tells which button was pressed (number) */ void squareDown(int x, int y, DARect rect, void *data) { int button; if (data) { int *tmp = (int *)data; button = *tmp; } else button = 0; drawSquare(rect, button); } /* A draggable slider that highlights when the mouse is over it */ void sliderDown(int x, int y, DARect rect, void *data) { buttonDown = ▭ setPointerColor(colors->sliderDark); } void sliderUp(int x, int y, DARect rect, void *data) { buttonDown = NULL; setPointerColor(colors->black); } void sliderMove(int x, int y, DARect rect, void *data) { if (buttonDown == NULL /* || rect.x != buttonDown->x || rect.y != buttonDown->y || rect.width != buttonDown->width || rect.height != buttonDown->height */) return; sliderPos = (float)(rect.height - y) / (float)rect.height; if (sliderPos > 1.0) sliderPos = 1.0; if (sliderPos < 0.0) sliderPos = 0.0; drawSlider(rect); } void sliderEnter(int x, int y, DARect rect, void *data) { } void sliderLeave(int x, int y, DARect rect, void *data) { } /* * Drawing functions */ void createBtn(DARect rect) { /* fill square excluding borders */ XFillRectangle(DADisplay, pixmap, colors->lightGray, rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); drawRaisedFrame(rect); } void drawRaisedFrame(DARect rect) { /* left border */ XDrawLine(DADisplay, pixmap, colors->white, rect.x, rect.y, rect.x, rect.y + rect.height - 2); /* top border */ XDrawLine(DADisplay, pixmap, colors->white, rect.x + 1, rect.y, rect.width - 1, rect.y); /* bottom border */ XDrawLine(DADisplay, pixmap, colors->darkGray, rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); /* right border */ XDrawLine(DADisplay, pixmap, colors->darkGray, rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, rect.y + rect.height - 2); DASetPixmap(pixmap); } void drawSunkenFrame(DARect rect) { /* left border */ XDrawLine(DADisplay, pixmap, colors->darkGray, rect.x, rect.y, rect.x, rect.y + rect.height - 2); /* top border */ XDrawLine(DADisplay, pixmap, colors->darkGray, rect.x + 1, rect.y, rect.width - 1, rect.y); /* bottom border */ XDrawLine(DADisplay, pixmap, colors->white, rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); /* right border */ XDrawLine(DADisplay, pixmap, colors->white, rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, rect.y + rect.height - 2); DASetPixmap(pixmap); } void createSquare(DARect rect) { /* fill square excluding borders */ XFillRectangle(DADisplay, pixmap, colors->black, rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); XDrawRectangle(DADisplay, pixmap, colors->lightGray, rect.x, rect.y, rect.width - 1, rect.height - 1); drawSquare(rect, 0); } void drawSquare(DARect rect, int button) { char label[3]; XFillRectangle(DADisplay, pixmap, colors->black, rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); snprintf(label, 3, "%2d", button); XDrawString(DADisplay, pixmap, colors->white, rect.x + 3, rect.y + rect.height - 5, label, 2); DASetPixmap(pixmap); } void createSlider(DARect rect) { /* fill square excluding borders */ XFillRectangle(DADisplay, pixmap, colors->black, rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); drawSunkenFrame(rect); drawSlider(rect); } void drawSlider(DARect rect) { GC highColor, lowColor; /* determine colors to use */ if (mouseIn) { highColor = colors->sliderLight; lowColor = colors->slider; } else { highColor = colors->slider; lowColor = colors->sliderDark; } /* Draw two lines from bottom to sliderPos fraction of height */ if (sliderPos < 1.0) { XDrawLine(DADisplay, pixmap, highColor, rect.x + 6, rect.y + rect.height - 2, rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2)); XDrawLine(DADisplay, pixmap, highColor, rect.x + 17, rect.y + rect.height - 2, rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2)); } if (sliderPos > 0.0) { XDrawLine(DADisplay, pixmap, lowColor, rect.x + 6, rect.y + 1, rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2)); XDrawLine(DADisplay, pixmap, lowColor, rect.x + 17, rect.y + 1, rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2)); } DASetPixmap(pixmap); } DAActionRect setRectAction(DARect rect, DARectCallback action) { DAActionRect ar; ar.rect = rect; ar.action = action; return ar; } dockapps-b9baa8f/fonts/000077500000000000000000000000001261212373500152275ustar00rootroot00000000000000dockapps-b9baa8f/fonts/Makefile.am000066400000000000000000000003051261212373500172610ustar00rootroot00000000000000fontdir = @FONTDIR@ dist_font_DATA = luxel-ascii-06x09.pcf.gz \ seg7-ascii-05x07.pcf.gz install-data-hook: @rm -f $(DESTDIR)$(fontdir)/font.dir $(MKFONTDIR) $(DESTDIR)$(fontdir) @RUN_FCCACHE@ dockapps-b9baa8f/fonts/luxel-ascii-06x09.pcf.gz000066400000000000000000000046511261212373500213510ustar00rootroot00000000000000lg?-Zcz wwPZB֮Hrt(if#Q-fYf?.q.L3b0]tYd3$~灧_uf&aO?}}߻[=K0g_>- *Sp ySWC4J_N׫PVq/&wԯ?h_J-0k 'U8` 3 0 􀯐l/ J60Wg }B %yD8by6 KAmS23%JĘg1?`RT5H4%әnQԙ썏hk;+*Rˁ!ڑH65go0[ uP:ّgbjdlxEl:ݒRjOv%ZdOے t[Kg&ٖvnJGcT(=mJd>(@ߙYHQ4K&)!FMCc;nss#C [ަёޑ=#ÏjCl35&:;puFvn7&d}}΃Ή޾ lf!y E[6pb\W 1WLx /S%"sȼsh}/t %Gr33ͼ 9A3πp"^@p|! {ZEZez[":%Zuݮ#Q->29w寲g6/UN1^fcAΞ†:v†v: e0FM]?j}LlZt@H/E5UPl_mkWJ=\4S|%[#5 %u]ݻ m8J_#nw,: ޷3jՓLwhm4{}_Kn_IqTlB:*UIuVkk:ϫ4Ly,RGU'/]ߤcc޶ؼtLc6cPzl1S'Ygoo}|@ӾP?3Khnǯ/}S,VMu*sмm:3j.QIK:y~tc6砩~(κv->M}/bLFw s5TG= թ-t:LӘսl}?՚P?3=]G'IwBgg?u ϟbT5?DU=wZó>9Tf樨9u&?5=Y!#0yQ6}&gUͬ*T^\γ|O><ˡSM4,mrbfZB`Zk֤7;3)5Hll] ?[*5+=i}g؛D)kI&?񩕼Γ7m J ^;n ;Dޅ]X>;d-TOJ|wҧ>V3>KE 9r#?(H! S>OFDQL1S)I[h+P+iq2IiuQ7У@Qvn=G}h/=ItDia:BtYWJTƁH}{L߳kB-`Y qpL!8^_7w8A%ZaQZA< z 1pR m}p \o߃/}p,jPV5`= ~0T)UM]p^o??w?]>x`3:@8 cnz,뵬ϲ~,lȲaFḽ==,aKxX"VWUe/xY*^V񲊏U|SaX*>V񱊏Ug?劰Ug?Y%*V JUraY%*V JUd Y%*A?d Y%*!V JUBbfV JU¬f0Y%*aV JXF Y%*VJU"aDX%"NE ;; << == >> ?ԻROd*U0hV,#Uԓ1AQaA\3 &dockapps-b9baa8f/fonts/seg7-ascii-05x07.pcf.gz000066400000000000000000000036301261212373500210560ustar00rootroot00000000000000[lTEǿmK r)wd.v={]vݖZvh@1\N˶냗1&5QC-M4AMAI|iY0o曙393s\GED.P"{I5hDy :Yxjfcz@g9DQY 궬0"v@wu0N.aYQF0aӆC9dxxx ;¸#a|Ka|aw1E#!.QWmĥڈ0N2trozN6{ξL;+۝荵'{L{bT;RkG-&Smݔ>3497|lmTw EA Q" mh=LJqJPS%IE)%jQh7~r߈b . 4+~gv v ap obU? ^W}!| 'ޯ/?ua`XV `+1 q$O x 's|~o`. Vu , $@8΂ ` <^Wmp[p"E0JhDž V JU`XbU,VXbU,VXbUd Y%*AV JUdX%*!V JUBbX%*aV JU¬f0Y%*aVJU"aDX%*VJU|--/- ҒeP!Ye)|R'|R'|R'|R'|R'R/R/R/A''dockapps-b9baa8f/src/000077500000000000000000000000001261212373500146655ustar00rootroot00000000000000dockapps-b9baa8f/src/Makefile.am000066400000000000000000000012521261212373500167210ustar00rootroot00000000000000 AUTOMAKE_OPTIONS = no-dependencies lib_LTLIBRARIES = libdockapp.la libdockapp_la_LDFLAGS = -version-info 3:0:0 otherincludedir = $(includedir)/libdockapp otherinclude_HEADERS = dockapp.h \ wmgeneral.h \ list.h \ misc.h libdockapp_la_SOURCES = \ dockapp.h \ daargs.c\ dacallback.c \ dacolor.c \ daevent.c \ damain.c \ dapixmap.c \ darect.c \ dashaped.c \ dautil.c \ list.c \ misc.c \ wmgeneral.c # Include these in a distribution, but don't install noinst_HEADERS = daargs.h dautil.h AM_CFLAGS = $(X11_CFLAGS) $(Xext_CFLAGS) $(xpm_CFLAGS) AM_CPPFLAGS = @CPPFLAGS@ @DFLAGS@ LIBS += $(X11_LIBS) $(Xext_LIBS) $(xpm_LIBS) LIBLIST = libdockapp.la @XLIBS@ dockapps-b9baa8f/src/daargs.c000066400000000000000000000164601261212373500163010ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban G. Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ #include #include #include "daargs.h" #include "dautil.h" #define DEFAULT_OPTION_COUNT 3 extern struct DAContext *_daContext; /* * Prototypes */ static void _daContextAddDefaultOptions(void); static void _daContextAddOptions(DAProgramOption *options, int count); static void printHelp(char *description); int contains(char *needle, char *haystack); int parseOption(DAProgramOption *option, int i, int argc, char **argv); int readIntOption(int index, char **argv); /* * Public functions */ void DAParseArguments( int argc, char **argv, DAProgramOption *options, int count, char *programDescription, char *versionDescription) { int i, j, size; int found = 0; _daContext = DAContextInit(); _daContext->argc = argc; _daContext->argv = argv; _daContext->programName = argv[0]; size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption *); _daContext->options = malloc(size); memset(_daContext->options, 0, size); _daContextAddDefaultOptions(); _daContextAddOptions(options, count); for (i = 1; i < argc; i++) { char *optStr = argv[i]; /* Handle default options */ if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) printHelp(programDescription), exit(0); if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) puts(versionDescription), exit(0); if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "--windowed") == 0) { _daContext->windowed = 1; continue; } found = 0; /* options with a one-to-one mapping */ for (j = 0; j < count; j++) { DAProgramOption *option = &options[j]; if ((option->longForm && strcmp(option->longForm, optStr) == 0) || (option->shortForm && strcmp(option->shortForm, optStr) == 0)) { found = 1; i = parseOption(option, i, argc, argv); } } /* mixed options */ if (!found) /* XXX: Parsing all options again... */ for (j = 0; j < count; j++) { DAProgramOption *option = &options[j]; if (option->shortForm && contains(option->shortForm, optStr)) { found = 1; i = parseOption(option, i, argc, argv); } } if (!found) { printf("%s: unrecognized option '%s'\n", argv[0], argv[i]); printHelp(programDescription), exit(1); } } } int contains(char *needle, char *haystack) { char c, *pos; assert(strlen(needle) == 2); c = needle[1]; pos = strchr(haystack, c); return (pos != NULL); } int parseOption(DAProgramOption *option, int i, int argc, char **argv) { option->used = True; if (option->type == DONone) return i; i++; if (i >= argc) printf("%s: missing argument for option '%s'\n", argv[0], argv[i-1]), exit(1); switch (option->type) { case DOInteger: *option->value.integer = readIntOption(i, argv); break; case DONatural: *option->value.integer = readIntOption(i, argv); if (*option->value.integer < 0) printf("%s: argument %s must be >= 0\n", argv[0], argv[i-1]), exit(1); break; case DOString: *option->value.string = argv[i]; break; } return i; } int readIntOption(int index, char **argv) { int integer; if (sscanf(argv[index], "%i", &integer) != 1) DAError("error parsing argument for option %s\n", argv[index-1]), exit(1); return integer; } int DAGetArgC() { return _daContext->argc; } char ** DAGetArgV() { return _daContext->argv; } char * DAGetProgramName() { return _daContext->programName; } /* * Local functions */ struct DAContext * DAContextInit(void) { struct DAContext *context = malloc(sizeof(struct DAContext)); memset(context, 0, sizeof(struct DAContext)); return context; } void DAFreeContext(void) { if (_daContext->optionCount > 0) { int i; for (i = 0; i < _daContext->optionCount; i++) free(_daContext->options[i]); free(_daContext->options); } free(_daContext); } static void _daContextAddOption(DAProgramOption *option) { /* If the buffer is full, double its size */ if (sizeof(_daContext->options) == _daContext->optionCount * sizeof(DAProgramOption)) { DAProgramOption **options; options = (DAProgramOption **)realloc( (DAProgramOption **)_daContext->options, 2 * sizeof(_daContext->options)); if (options == NULL) DAError("Out of memory"); _daContext->options = options; } _daContext->options[_daContext->optionCount] = option; _daContext->optionCount++; } static void _daContextAddOptionData(char *shortForm, char *longForm, char *description, short type) { DAProgramOption *option = malloc(sizeof(DAProgramOption)); option->shortForm = shortForm; option->longForm = longForm; option->description = description; option->type = type; option->used = False; option->value.ptr = NULL; _daContextAddOption(option); } static void _daContextAddDefaultOptions(void) { _daContextAddOptionData("-h", "--help", "show this help text and exit", DONone); _daContextAddOptionData("-v", "--version", "show program version and exit", DONone); _daContextAddOptionData("-w", "--windowed", "run the application in windowed mode", DONone); } static void _daContextAddOptions(DAProgramOption *options, int count) { int i; for (i = 0; i < count; i++) _daContextAddOptionData( options[i].shortForm, options[i].longForm, options[i].description, options[i].type); } static void printHelp(char *description) { int i; DAProgramOption **options = _daContext->options; int count = _daContext->optionCount; printf("Usage: %s [OPTIONS]\n", _daContext->programName); if (description) puts(description); for (i = 0; i < count; i++) { char blank[30]; int c; if (options[i]->shortForm && options[i]->longForm) c = printf(" %s, %s", options[i]->shortForm, options[i]->longForm); else if (options[i]->shortForm) c = printf(" %s", options[i]->shortForm); else if (options[i]->longForm) c = printf(" %s", options[i]->longForm); else continue; if (options[i]->type != DONone) { switch (options[i]->type) { case DOInteger: c += printf(" "); break; case DOString: c += printf(" "); break; case DONatural: c += printf(" "); break; } } memset(blank, ' ', 30); if (c > 29) c = 1; blank[30-c] = 0; printf("%s %s\n", blank, options[i]->description); } } dockapps-b9baa8f/src/daargs.h000066400000000000000000000030321261212373500162750ustar00rootroot00000000000000/* * Copyright (c) 2005 Alban G. Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ #include "dockapp.h" /* * Context structure to keep track of globals */ struct DAContext { int argc; /* Raw input data */ char **argv; int windowed; int width, height; int timeOut; DACallbacks callbacks; char *programName; /* shortcut to argv[0] */ DAProgramOption **options; /* Array of option pointers */ short optionCount; }; struct DAContext *DAContextInit(void); void DAFreeContext(void); dockapps-b9baa8f/src/dacallback.c000066400000000000000000000033531261212373500170760ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include "dockapp.h" #include "daargs.h" extern struct DAContext *_daContext; void DASetCallbacks(DACallbacks *callbacks) { long mask = 0; _daContext->callbacks = *callbacks; if (callbacks->destroy) mask |= StructureNotifyMask; if (callbacks->buttonPress) mask |= ButtonPressMask; if (callbacks->buttonRelease) mask |= ButtonReleaseMask; if (callbacks->motion) mask |= PointerMotionMask; if (callbacks->enter) mask |= EnterWindowMask; if (callbacks->leave) mask |= LeaveWindowMask; XSelectInput(DADisplay, DAWindow, mask); XFlush(DADisplay); } void DASetTimeout(int milliseconds) { _daContext->timeOut = milliseconds; } dockapps-b9baa8f/src/dacolor.c000066400000000000000000000032431261212373500164560ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include "dockapp.h" #include "daargs.h" #include "dautil.h" extern struct DAContext *_daContext; unsigned long DAGetColor(char *colorName) { XColor color; if (!XParseColor(DADisplay, DefaultColormap(DADisplay, DefaultScreen(DADisplay)), colorName, &color)) DAError("could not parse color %s", colorName); if (!XAllocColor(DADisplay, DefaultColormap(DADisplay, DefaultScreen(DADisplay)), &color)) { DAWarning("could not allocate color %s. Using black instead", colorName); return BlackPixel(DADisplay, DefaultScreen(DADisplay)); } return color.pixel; } dockapps-b9baa8f/src/daevent.c000066400000000000000000000076531261212373500164720ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include #include #include #include #include "dockapp.h" #include "daargs.h" #include "dautil.h" extern struct DAContext *_daContext; extern Atom WM_DELETE_WINDOW; Bool DAProcessEvent(XEvent *event) { if (event->xany.window == DAWindow) return DAProcessEventForWindow(DAWindow, event); else if (event->xany.window == DALeader) /* XXX: Is this superfluous now that DAWindow always references the * dockapp window? */ return DAProcessEventForWindow(DALeader, event); else /* XXX: What about handling events for child windows? */ return False; } Bool DAProcessEventForWindow(Window window, XEvent *event) { if (event->xany.window != window) return False; switch (event->type) { case ClientMessage: if (event->xclient.data.l[0] != WM_DELETE_WINDOW) break; /* fallthrough */ case DestroyNotify: if (_daContext->callbacks.destroy) (*_daContext->callbacks.destroy)(); DAFreeContext(); XCloseDisplay(DADisplay); #ifdef DEBUG debug("%s: DestroyNotify\n", _daContext->programName); #endif exit(0); break; case ButtonPress: if (_daContext->callbacks.buttonPress) (*_daContext->callbacks.buttonPress)(event->xbutton.button, event->xbutton.state, event->xbutton.x, event->xbutton.y); break; case ButtonRelease: if (_daContext->callbacks.buttonRelease) (*_daContext->callbacks.buttonRelease)(event->xbutton.button, event->xbutton.state, event->xbutton.x, event->xbutton.y); break; case MotionNotify: if (_daContext->callbacks.motion) (*_daContext->callbacks.motion)(event->xmotion.x, event->xmotion.y); break; case EnterNotify: if (_daContext->callbacks.enter) (*_daContext->callbacks.enter)(); break; case LeaveNotify: if (_daContext->callbacks.leave) (*_daContext->callbacks.leave)(); break; default: return False; } return True; } void DAEventLoop(void) { DAEventLoopForWindow(DAWindow); } void DAEventLoopForWindow(Window window) { XEvent event; for (;; ) { if (_daContext->timeOut >= 0) { if (!DANextEventOrTimeout(&event, _daContext->timeOut)) { if (_daContext->callbacks.timeout) (*_daContext->callbacks.timeout)(); continue; } } else XNextEvent(DADisplay, &event); DAProcessEventForWindow(window, &event); } } Bool DANextEventOrTimeout(XEvent *event, unsigned long milliseconds) { struct timeval timeout; fd_set rset; XSync(DADisplay, False); if (XPending(DADisplay)) { XNextEvent(DADisplay, event); return True; } timeout.tv_sec = milliseconds / 1000; timeout.tv_usec = (milliseconds % 1000) * 1000; FD_ZERO(&rset); FD_SET(ConnectionNumber(DADisplay), &rset); if (select(ConnectionNumber(DADisplay)+1, &rset, NULL, NULL, &timeout) > 0) { XNextEvent(DADisplay, event); return True; } return False; } dockapps-b9baa8f/src/damain.c000066400000000000000000000150151261212373500162640ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include "dockapp.h" #include "daargs.h" #include "dautil.h" #define MIN(a, b) (a < b ? a : b) struct DAContext *_daContext; DARect DANoRect = {0, 0, 0, 0}; Display *DADisplay = NULL; Window DALeader = None; Window DAIcon = None; Window DAWindow = None; int DADepth = 0; Visual *DAVisual = NULL; unsigned long DAExpectedVersion = 0; GC DAGC = NULL, DAClearGC = NULL; DARect DAPreferredIconSizes = {-1, -1, 0, 0}; Atom WM_DELETE_WINDOW; void DAOpenDisplay(char *display, int argc, char **argv) { /* Open Connection to X Server */ DADisplay = XOpenDisplay(display); if (!DADisplay) { printf("%s: could not open display %s!\n", _daContext->programName, XDisplayName(display)); exit(EXIT_FAILURE); } DADepth = DefaultDepth(DADisplay, DefaultScreen(DADisplay)); DAVisual = DefaultVisual(DADisplay, DefaultScreen(DADisplay)); DAGC = DefaultGC(DADisplay, DefaultScreen(DADisplay)); } void DAProposeIconSize(unsigned width, unsigned height) { XIconSize *iconSizes; int nrSizes = 0; _daContext->width = width; _daContext->height = height; /* Get the nearest allowed icon size if the WM specifies such */ iconSizes = XAllocIconSize(); if (XGetIconSizes(DADisplay, DefaultRootWindow(DADisplay), &iconSizes, &nrSizes)) { int i; int da = -1; int min_w = -1, min_h = -1; int max_w = 0, max_h = 0; for (i = 0; i < nrSizes; i++) { int w1, h1, w, h; if ((max_w < iconSizes[i].max_width) || (max_h < iconSizes[i].max_height)) { max_w = iconSizes[i].max_width; max_h = iconSizes[i].max_height; } if ((min_w > iconSizes[i].min_width) || (min_h > iconSizes[i].min_height) || (min_w == -1)) { min_w = iconSizes[i].min_width; min_h = iconSizes[i].min_height; } if ((width > iconSizes[i].max_width) || (width < iconSizes[i].min_width) || (height > iconSizes[i].max_height) || (height < iconSizes[i].min_height)) continue; w1 = (iconSizes[i].max_width - width) % iconSizes[i].width_inc; h1 = (iconSizes[i].max_height - height) % iconSizes[i].height_inc; w = MIN(w1, iconSizes[i].width_inc - w1); h = MIN(h1, iconSizes[i].height_inc - h1); if ((w * h < da) || (da == -1)) { _daContext->width = width + w; _daContext->height = height + h; da = w * h; } } DAPreferredIconSizes.x = min_w; DAPreferredIconSizes.y = min_h; DAPreferredIconSizes.width = max_w; DAPreferredIconSizes.height = max_h; if (da == -1) /* requested size is out of bounds */ DAWarning("Requested icon-size (%d x %d) is out of the range " "allowed by the window manager\n", _daContext->width, _daContext->height); } XFree(iconSizes); } void DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv) { XClassHint *classHint; XWMHints *wmHints; XGCValues gcv; unsigned long valueMask; char *resourceValue; _daContext->width = width; _daContext->height = height; /* Create Windows */ DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), 0, 0, width, height, 0, 0, 0); if (!_daContext->windowed) { DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), 0, 0, width, height, 0, 0, 0); DAWindow = DAIcon; } else { DAIcon = None; DAWindow = DALeader; } /* Set ClassHint */ classHint = XAllocClassHint(); if (!classHint) printf("%s: can't allocate memory for class hints!\n", _daContext->programName), exit(1); classHint->res_class = RES_CLASSNAME; classHint->res_name = name; XSetClassHint(DADisplay, DALeader, classHint); XFree(classHint); /* Set WMHints */ wmHints = XAllocWMHints(); if (!wmHints) printf("%s: can't allocate memory for wm hints!\n", _daContext->programName), exit(1); wmHints->flags = WindowGroupHint; wmHints->window_group = DALeader; if (!_daContext->windowed) { wmHints->flags |= IconWindowHint|StateHint; wmHints->icon_window = DAIcon; wmHints->initial_state = WithdrawnState; } XSetWMHints(DADisplay, DALeader, wmHints); XFree(wmHints); /* Set WMProtocols */ WM_DELETE_WINDOW = XInternAtom(DADisplay, "WM_DELETE_WINDOW", True); XSetWMProtocols(DADisplay, DALeader, &WM_DELETE_WINDOW, 1); /* Set Command to start the app so it can be docked properly */ XSetCommand(DADisplay, DALeader, argv, argc); gcv.graphics_exposures = False; valueMask = GCGraphicsExposures; /* continue setting the foreground GC */ resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "foreground"); if (resourceValue) { gcv.foreground = DAGetColor(resourceValue); valueMask |= GCForeground; } XChangeGC(DADisplay, DAGC, valueMask, &gcv); /* set background GC values before setting value for foreground */ resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background"); if (resourceValue) gcv.foreground = DAGetColor(resourceValue); DAClearGC = XCreateGC(DADisplay, DAWindow, GCGraphicsExposures|GCForeground, &gcv); XFlush(DADisplay); } void DAShow(void) { DAShowWindow(DALeader); } void DAShowWindow(Window window) { XMapRaised(DADisplay, window); if ((window == DALeader) && !_daContext->windowed) XMapSubwindows(DADisplay, DAIcon); else XMapSubwindows(DADisplay, window); XFlush(DADisplay); } /* Deprecated */ void DAInitialize(char *display, char *name, unsigned width, unsigned height, int argc, char **argv) { DAOpenDisplay(display, argc, argv); DACreateIcon(name, width, height, argc, argv); } dockapps-b9baa8f/src/dapixmap.c000066400000000000000000000067371261212373500166510ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include #include #include #include #include "dockapp.h" #include "daargs.h" extern struct DAContext *_daContext; /* Local typedef */ typedef enum { daXpmSourceData, daXpmSourceFile } daXpmSource; /* Function prototype */ Bool _daMakePixmap(daXpmSource source, char **data, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height); void DASetShapeWithOffset(Pixmap shapeMask, int x_ofs, int y_ofs) { DASetShapeWithOffsetForWindow(DAWindow, shapeMask, x_ofs, y_ofs); } void DASetShapeWithOffsetForWindow(Window window, Pixmap shapeMask, int x_ofs, int y_ofs) { XShapeCombineMask(DADisplay, window, ShapeBounding, -x_ofs, -y_ofs, shapeMask, ShapeSet); XFlush(DADisplay); } void DASetPixmap(Pixmap pixmap) { DASetPixmapForWindow(DAWindow, pixmap); } void DASetPixmapForWindow(Window window, Pixmap pixmap) { XSetWindowBackgroundPixmap(DADisplay, window, pixmap); XClearWindow(DADisplay, window); XFlush(DADisplay); } Pixmap DAMakePixmap(void) { return (XCreatePixmap(DADisplay, DAWindow, _daContext->width, _daContext->height, DADepth)); } Pixmap DAMakeShape(void) { return (XCreatePixmap(DADisplay, DAWindow, _daContext->width, _daContext->height, 1)); } Bool DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height) { return _daMakePixmap(daXpmSourceData, data, pixmap, mask, width, height); } Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height) { if (access(filename, R_OK) < 0) return False; return _daMakePixmap(daXpmSourceFile, (char **)filename, pixmap, mask, width, height); } Bool _daMakePixmap(daXpmSource source, char **data, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height) { XpmAttributes xpmAttr; xpmAttr.valuemask = XpmCloseness; xpmAttr.closeness = 40000; if (source == daXpmSourceData && (XpmCreatePixmapFromData( DADisplay, DAWindow, data, pixmap, mask, &xpmAttr) != 0)) return False; else if (source == daXpmSourceFile && (XpmReadFileToPixmap( DADisplay, DAWindow, (char *)data, pixmap, mask, &xpmAttr) != 0)) return False; *width = xpmAttr.width; *height = xpmAttr.height; return True; } dockapps-b9baa8f/src/darect.c000066400000000000000000000034411261212373500162750ustar00rootroot00000000000000/* * Copyright (c) 2002-2005 Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. */ #include "dockapp.h" /* TODO: Add a feature to detect the pointer entering/leaving a rectangle */ void DAProcessActionRects(int x, int y, DAActionRect *actionrects, int count, void *data) { int index = 0; if (!actionrects) return; while ((index < count) && ((x < actionrects[index].rect.x) || (x > actionrects[index].rect.x + actionrects[index].rect.width) || (y < actionrects[index].rect.y) || (y > actionrects[index].rect.y + actionrects[index].rect.height))) index++; if (index == count) return; if (actionrects[index].action) (*actionrects[index].action)(x - actionrects[index].rect.x, y - actionrects[index].rect.y, actionrects[index].rect, data); } dockapps-b9baa8f/src/dashaped.c000066400000000000000000000113161261212373500166040ustar00rootroot00000000000000/* * Copyright (c) 2002-2005 Alban G. Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ #include #include #include "dockapp.h" #include "daargs.h" /* * DAShapedPixmap functions */ /* Local typedef */ typedef enum { daShapeSourceData, daShapeSourceFile } daShapeSource; /* local functions */ void setGCs(DAShapedPixmap *dasp); DAShapedPixmap *_daMakeShapedPixmap(daShapeSource source, char **data); extern struct DAContext *_daContext; /* Create a new shaped pixmap with width & height of dockapp window */ DAShapedPixmap * DAMakeShapedPixmap() { DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); if (dasp == NULL) return NULL; memset(dasp, 0, sizeof(DAShapedPixmap)); dasp->pixmap = DAMakePixmap(); dasp->shape = DAMakeShape(); dasp->geometry.width = _daContext->width; dasp->geometry.height = _daContext->height; setGCs(dasp); DASPClear(dasp); return dasp; } /* Create a new shaped pixmap from XPM-data */ DAShapedPixmap * DAMakeShapedPixmapFromData(char **data) { return _daMakeShapedPixmap(daShapeSourceData, data); } /* Create a new shaped pixmap from XPM-data */ DAShapedPixmap * DAMakeShapedPixmapFromFile(char *filename) { return _daMakeShapedPixmap(daShapeSourceFile, (char **)filename); } /* Free memory reserved for a shaped pixmap */ void DAFreeShapedPixmap(DAShapedPixmap *dasp) { assert(dasp); XFreePixmap(DADisplay, dasp->pixmap); XFreePixmap(DADisplay, dasp->shape); XFreeGC(DADisplay, dasp->shapeGC); free(dasp); } /* Copy shape-mask and pixmap-data from an area in one shaped pixmap * into another shaped pixmap */ void DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, int x1, int y1, int w, int h, int x2, int y2) { assert(src != NULL && dst != NULL); XCopyPlane(DADisplay, src->shape, dst->shape, src->shapeGC, x1, y1, w, h, x2, y2, 1); XCopyArea(DADisplay, src->pixmap, dst->pixmap, src->drawGC, x1, y1, w, h, x2, y2); } /* Clear a shaped pixmap */ void DASPClear(DAShapedPixmap *dasp) { XGCValues gcv; assert(dasp != NULL); gcv.foreground = 0; XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); /* Clear pixmaps */ XFillRectangle(DADisplay, dasp->pixmap, DAClearGC, 0, 0, dasp->geometry.width, dasp->geometry.height); XFillRectangle(DADisplay, dasp->shape, dasp->shapeGC, 0, 0, dasp->geometry.width, dasp->geometry.height); gcv.foreground = 1; XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); } /* Show the pixmap in the dockapp-window */ void DASPSetPixmap(DAShapedPixmap *dasp) { DASPSetPixmapForWindow(DAWindow, dasp); } void DASPSetPixmapForWindow(Window window, DAShapedPixmap *dasp) { assert(dasp != NULL); DASetShapeForWindow(window, dasp->shape); DASetPixmapForWindow(window, dasp->pixmap); } void setGCs(DAShapedPixmap *dasp) { XGCValues gcv; dasp->drawGC = DAGC; dasp->clearGC = DAClearGC; /* create GC for bit-plane operations in shapes */ gcv.graphics_exposures = False; gcv.foreground = 1; gcv.background = 0; gcv.plane_mask = 1; dasp->shapeGC = XCreateGC( DADisplay, dasp->shape, GCGraphicsExposures|GCForeground|GCBackground|GCPlaneMask, &gcv); } /* Create a new shaped pixmap using specified method */ DAShapedPixmap * _daMakeShapedPixmap(daShapeSource source, char **data) { Bool success; DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); if (dasp == NULL) return NULL; memset(dasp, 0, sizeof(DAShapedPixmap)); if (source == daShapeSourceData) success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape, &dasp->geometry.width, &dasp->geometry.height); else success = DAMakePixmapFromFile((char *)data, &dasp->pixmap, &dasp->shape, &dasp->geometry.width, &dasp->geometry.height); if (!success) return NULL; setGCs(dasp); return dasp; } dockapps-b9baa8f/src/dautil.c000066400000000000000000000067551261212373500163300ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban G. Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ #include #include "daargs.h" #include "dautil.h" extern struct DAContext *_daContext; /* * Function prototypes */ void _message(const char *label, const char *fmt, va_list args); /* * Exported functions. */ void DASetExpectedVersion(unsigned long expectedVersion) { DAExpectedVersion = expectedVersion; if (expectedVersion > DA_VERSION) DAWarning("Version of libdockapp (%u) is older than " "version expected (%u)", DA_VERSION, DAExpectedVersion); } Display * DAGetDisplay(char *d, ...) { /* Be backward compatible */ if (DAExpectedVersion < 20030126) { va_list ap; int argc; char **argv; va_start(ap, d); argc = va_arg(ap, int); argv = va_arg(ap, char **); va_end(ap); DAOpenDisplay(d, argc, argv); DAWarning("Expected version of libdockapp is not set."); DAWarning("Obsolete call to DAGetDisplay()."); return NULL; } return DADisplay; } void DASetDisplay(Display *display) { DADisplay = display; } Window DAGetWindow(void) { return DAWindow; } void DASetWindow(Window window) { DAWindow = window; } Window DAGetLeader(void) { return DALeader; } void DASetLeader(Window leader) { DALeader = leader; } Window DAGetIconWindow(void) { return DAIcon; } void DASetIconWindow(Window icon_win) { DAIcon = icon_win; } int DAGetDepth(void) { return DADepth; } void DASetDepth(int depth) { DADepth = depth; } Visual * DAGetVisual(void) { return DAVisual; } void DASetVisual(Visual *visual) { DAVisual = visual; } void DAWarning(const char *fmt, ...) { va_list args; va_start(args, fmt); _message("Warning", fmt, args); va_end(args); } void DAError(const char *fmt, ...) { va_list args; va_start(args, fmt); _message("Error", fmt, args); exit(1); va_end(args); } /* * Local functions */ void _message(const char *label, const char *fmt, va_list args) { char *w_fmt; if (_daContext->programName != NULL) { /* put default string in front of message, add newline */ w_fmt = malloc((strlen(_daContext->programName) + strlen(fmt) + 13) * sizeof(char)); sprintf(w_fmt, "%s: %s: %s\n", _daContext->programName, label, fmt); } else { w_fmt = malloc((strlen(fmt) + 1) * sizeof(char)); sprintf(w_fmt, "%s\n", fmt); } /* print the message */ vfprintf(stderr, w_fmt, args); } void debug(const char *fmt, ...) { #ifdef DEBUG va_list args; va_start(args, fmt); _message("debug", fmt, args); va_end(args); #endif } dockapps-b9baa8f/src/dautil.h000066400000000000000000000021721261212373500163220ustar00rootroot00000000000000/* * Copyright (c) 2003-2005 Alban G. Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ void debug(const char *message, ...); dockapps-b9baa8f/src/dockapp.h000066400000000000000000000272441261212373500164700ustar00rootroot00000000000000/* * Copyright (c) 1999-2005 Alfredo K. Kojima, Alban Hertroys * * 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 or substantial portions of the Software. * * 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 * AUTHOR 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. * */ #ifndef _DOCKAPP_H_ #define _DOCKAPP_H_ #define DA_VERSION 20050716 /* * This is a simple (trivial) library for writing Window Maker dock * applications, or dockapps (those that only show up in the dock), easily. * * It is very limited and can be only used for dockapps that open a single * appicon for process in only ibe single display, but this seems to be * enough for most, if not all, dockapps. */ #include #include #include #include #include #include #include /* class-name for X-resources and Window Maker attributes */ #define RES_CLASSNAME "DockApp" /* !!! DEPRECATED !!! * This feature may be removed in the future. Use DAEventCallbacks instead. * * the callbacks for events related to the dockapp window your program wants * to handle */ typedef struct { /* the dockapp window was destroyed */ void (*destroy)(void); /* button pressed */ void (*buttonPress)(int button, int state, int x, int y); /* button released */ void (*buttonRelease)(int button, int state, int x, int y); /* pointer motion */ void (*motion)(int x, int y); /* pointer entered dockapp window */ void (*enter)(void); /* pointer left dockapp window */ void (*leave)(void); /* timer expired */ void (*timeout)(void); } DACallbacks; typedef struct { char *shortForm; /* short form for option, like -w */ char *longForm; /* long form for option, like --withdrawn */ char *description; /* description for the option */ short type; /* type of argument */ Bool used; /* if the argument was passed on the cmd-line */ /* the following are only set if the "used" field is True */ union { void *ptr; /* a ptr for the value that was passed */ int *integer; /* on the command line */ char **string; } value; } DAProgramOption; typedef XRectangle DARect; /* * A callback function for an event on an "action rectangle" */ typedef void DARectCallback(int x, int y, DARect rect, void *data); /* * The action rectangle structure */ typedef struct { DARect rect; DARectCallback *action; } DAActionRect; /* option argument types */ enum { DONone, /* simple on/off flag */ DOInteger, /* an integer number */ DOString, /* a string */ DONatural /* positive integer number */ }; /* Shaped pixmaps: Shapes in combination with pixmaps */ typedef struct { Pixmap pixmap; Pixmap shape; /* needs a 1-bit plane GC (shapeGC). */ GC drawGC, clearGC, shapeGC; DARect geometry; /* position and size */ DAActionRect *triggers; } DAShapedPixmap; extern Display *DADisplay; extern Window DAWindow, DALeader, DAIcon; /* see [NOTE] */ extern int DADepth; extern Visual *DAVisual; extern GC DAGC, DAClearGC; extern DARect DANoRect; extern unsigned long DAExpectedVersion; /* [NOTE] * DALeader is the group-leader window, DAIcon is the icon window. * DAWindow is the one of these two that is visible. Depending on whether the * dockapp was started normally or windowed, that will be DAIcon and DALeader * respectively. * DAIcon is None if the dockapp runs in "windowed mode". */ /* * Set the version of the library that the dockapp expects. * This is a date in the format 'yyyymmdd'. You can find this date * in NEWS. */ void DASetExpectedVersion(unsigned long expectedVersion); /* * DAParseArguments- * Command line arguments parser. The program is exited if there are * syntax errors. * * -h, --help and --version are automatically handled (causing the program * to exit) * -w is handled automatically as well and causes the dockapp to be run * in windowed mode. */ void DAParseArguments(int argc, char **argv, DAProgramOption *options, int count, char *programDescription, char *versionDescription); /* * DAInitialize- * Initialize the dockapp, open a connection to the X Server, * create the needed windows and set them up to become an appicon window. * It will automatically detect if Window Maker is present and use * an appropriate window form. * * You must call this always before calling anything else (except for * DAParseArguments()) * * Arguments: * display - the name of the display to connect to. * Use "" to use the default value. * name - the name of your dockapp, used as the instance name * for the WM_CLASS hint. Like wmyaclock. * The ClassName is set to "DockApp" on default. * width, height - the size of the dockapp window. 48x48 is the * preferred size. * argc, argc - the program arguments. argv[0] will be used * as the instance name for the WM_CLASS hint. */ void DAInitialize(char *display, char *name, unsigned width, unsigned height, int argc, char **argv); void DAOpenDisplay(char *display, int argc, char **argv); void DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv); void DAProposeIconSize(unsigned width, unsigned height); /* * Wrapper functions for global variables. */ /* Get/Set DADisplay value. For use with external code. * Call with NULL as only argument. Other arguments are for backward compatibility * only. * XXX: Argument list is a kludge. */ Display *DAGetDisplay(char *d, ...); void DASetDisplay(Display *display); /* Get program name (from argv[0]). Returns a reference. */ char *DAGetProgramName(); /* Get/Set DAWindow and DALeader values respectively. For use with external code. */ Window DAGetWindow(void); void DASetWindow(Window window); Window DAGetLeader(void); void DASetLeader(Window leader); Window DAGetIconWindow(void); void DASetIconWindow(Window icon_win); /* Get/Set DADepth; the display depth. For use with external code. */ int DAGetDepth(void); void DASetDepth(int depth); /* Get/Set DAVisual; the visual type for the screen. For use with external code. */ Visual *DAGetVisual(void); void DASetVisual(Visual *visual); /* * DASetShapeWithOffset- * Sets the shape mask of the dockapp to the specified one. This is * optional. If you pass None as shapeMask, the dockapp will become * non-shaped. * * This is only needed if you want the dockapp to be shaped. */ #define DASetShape(shapeMask) \ (DASetShapeWithOffset((shapeMask), 0, 0)) #define DASetShapeForWindow(window, shapeMask) \ (DASetShapeWithOffsetForWindow((window), (shapeMask), 0, 0)) void DASetShapeWithOffset(Pixmap shapeMask, int x_ofs, int y_ofs); void DASetShapeWithOffsetForWindow(Window window, Pixmap shapeMask, int x_ofs, int y_ofs); /* * DASetPixmap- * Sets the image pixmap for the dockapp. Once you set the image with it, * you don't need to handle expose events. */ void DASetPixmap(Pixmap pixmap); void DASetPixmapForWindow(Window window, Pixmap pixmap); /* * DAMakePixmap- * Creates a pixmap suitable for use with DASetPixmap() */ Pixmap DAMakePixmap(void); /* * DAMakeShape- * Creates a shape pixmap suitable for use with DASetShape() */ Pixmap DAMakeShape(void); /* * DAMakePixmapFromData- * Creates a pixmap and mask from XPM data * Returns true on success, false on failure. */ Bool DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height); /* * DAMakePixmapFromFile- * Creates a pixmap and mask from an XPM file * Returns true on success, false on failure. */ Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask, unsigned short *width, unsigned short *height); /* * DAMakeShapedPixmap- * Creates a shaped pixmap with width & height of dockapp window. */ DAShapedPixmap *DAMakeShapedPixmap(); /* * DAMakeShapedPixmapFromData- * Creates a shaped pixmap from XPM-data. * Returns shaped pixmap on success, NULL on failure. */ DAShapedPixmap *DAMakeShapedPixmapFromData(char **data); /* * DAMakeShapedPixmapFromFile- * Creates a shaped pixmap from an XPM file. * Returns shaped pixmap on success, NULL on failure. */ DAShapedPixmap *DAMakeShapedPixmapFromFile(char *filename); /* * DAFreeShapedPixmap- * Free memory reserved for a ShapedPixmap */ void DAFreeShapedPixmap(DAShapedPixmap *dasp); /* * DASPCopyArea- * Copies shape-mask and pixmap-data from an area in one shaped pixmap * into another shaped pixmap. */ void DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, int x1, int y1, int w, int h, int x2, int y2); /* * DASPClear- * Clears a shaped pixmaps contents. */ void DASPClear(DAShapedPixmap *dasp); /* DASPShow- * Displays the pixmap in the dockapp-window. */ void DASPSetPixmap(DAShapedPixmap *dasp); void DASPSetPixmapForWindow(Window window, DAShapedPixmap *dasp); /* * DAGetColor- * Returns an X color index. */ unsigned long DAGetColor(char *colorName); /* * DAShow- * Displays the dockapp. * * Always call this function or the dockapp won't show up. */ void DAShow(void); /* * DAShowWindow- * Display a window. Also displays subwindows if it is the dockapp leader * window (DALeader). */ void DAShowWindow(Window window); /* * DASetCallbacks- * Register a set of callbacks for events like mouse clicks. * * Only needed if you want to receive some event. */ void DASetCallbacks(DACallbacks *callbacks); /* * DASetTimeout- * Sets a timeout for the DAEventLoop(). The timeout callback * will be called whenever the app doesn't get any events from the * X server in the specified time. */ void DASetTimeout(int milliseconds); /* * DANextEventOrTimeout- * Waits until a event is received or the timeout limit has * expired. Returns True if an event was received. */ Bool DANextEventOrTimeout(XEvent *event, unsigned long milliseconds); /* * DAProcessEvent- * Processes an event. Returns True if the event was handled and * False otherwise. * * Must be called from your event loop, unless you use DAEventLoop() */ Bool DAProcessEvent(XEvent *event); Bool DAProcessEventForWindow(Window window, XEvent *event); /* * DAEventLoop- * Enters an event loop where events are processed until the dockapp * is closed. This function never returns. */ void DAEventLoop(void); void DAEventLoopForWindow(Window window); /* * DAProcessActionRects- * Processes the current coordinates with one of the functions in * the array of action rectangles. Coordinates are converted to relative * coordinates in one of the rectangles. The last item in the array of * action rectangles must be NULL. */ void DAProcessActionRects(int x, int y, DAActionRect *actionrects, int count, void *data); /* * Error handling functions */ /* Print a warning to stderr and continue */ void DAWarning(const char *fmt, ...); /* Print an error to stderr and exit with 1 */ void DAError(const char *fmt, ...); #endif dockapps-b9baa8f/src/list.c000066400000000000000000000067371261212373500160210ustar00rootroot00000000000000/* Generic single linked list to keep various information Copyright (C) 1993, 1994 Free Software Foundation, Inc. Author: Kresten Krab Thorup Many modifications by Alfredo K. Kojima This file is part of GNU CC. GNU CC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ #include "list.h" #ifdef HAVE_SYS_TYPES_H # include #endif #include /* Return a cons cell produced from (head . tail) */ LinkedList* list_cons(void* head, LinkedList* tail) { LinkedList* cell; cell = (LinkedList*)malloc(sizeof(LinkedList)); cell->head = head; cell->tail = tail; return cell; } /* Return the length of a list, list_length(NULL) returns zero */ int list_length(LinkedList* list) { int i = 0; while(list) { i += 1; list = list->tail; } return i; } /* Return the Nth element of LIST, where N count from zero. If N larger than the list length, NULL is returned */ void* list_nth(int index, LinkedList* list) { while(index-- != 0) { if(list->tail) list = list->tail; else return 0; } return list->head; } /* Remove the element at the head by replacing it by its successor */ void list_remove_head(LinkedList** list) { if (!*list) return; if ((*list)->tail) { LinkedList* tail = (*list)->tail; /* fetch next */ *(*list) = *tail; /* copy next to list head */ free(tail); /* free next */ } else /* only one element in list */ { free(*list); (*list) = 0; } } /* Remove the element with `car' set to ELEMENT */ /* void list_remove_elem(LinkedList** list, void* elem) { while (*list) { if ((*list)->head == elem) list_remove_head(list); *list = (*list ? (*list)->tail : NULL); } }*/ LinkedList * list_remove_elem(LinkedList* list, void* elem) { LinkedList *tmp; if (list) { if (list->head == elem) { tmp = list->tail; free(list); return tmp; } list->tail = list_remove_elem(list->tail, elem); return list; } return NULL; } /* Return element that has ELEM as car */ LinkedList* list_find(LinkedList* list, void* elem) { while(list) { if (list->head == elem) return list; list = list->tail; } return NULL; } /* Free list (backwards recursive) */ void list_free(LinkedList* list) { if(list) { list_free(list->tail); free(list); } } /* Map FUNCTION over all elements in LIST */ void list_mapcar(LinkedList* list, void(*function)(void*)) { while(list) { (*function)(list->head); list = list->tail; } } dockapps-b9baa8f/src/list.h000066400000000000000000000032661261212373500160200ustar00rootroot00000000000000/* Generic single linked list to keep various information Copyright (C) 1993, 1994 Free Software Foundation, Inc. Author: Kresten Krab Thorup This file is part of GNU CC. GNU CC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ #ifndef __LIST_H_ #define __LIST_H_ typedef struct LinkedList { void *head; struct LinkedList *tail; } LinkedList; LinkedList* list_cons(void* head, LinkedList* tail); int list_length(LinkedList* list); void* list_nth(int index, LinkedList* list); void list_remove_head(LinkedList** list); LinkedList *list_remove_elem(LinkedList* list, void* elem); void list_mapcar(LinkedList* list, void(*function)(void*)); LinkedList*list_find(LinkedList* list, void* elem); void list_free(LinkedList* list); #endif dockapps-b9baa8f/src/misc.c000066400000000000000000000073231261212373500157710ustar00rootroot00000000000000/* wmgeneral miscellaneous functions * * from dock.c - built-in Dock module for WindowMaker window manager * * Copyright (c) 1997 Alfredo K. Kojima * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA. */ #define _POSIX_C_SOURCE 200809L #include #include #include #include "list.h" #include "misc.h" /* *---------------------------------------------------------------------- * parse_command-- * Divides a command line into a argv/argc pair. *---------------------------------------------------------------------- */ #define PRC_ALPHA 0 #define PRC_BLANK 1 #define PRC_ESCAPE 2 #define PRC_DQUOTE 3 #define PRC_EOS 4 #define PRC_SQUOTE 5 typedef struct { short nstate; short output; } DFA; static DFA mtable[9][6] = { {{3,1},{0,0},{4,0},{1,0},{8,0},{6,0}}, {{1,1},{1,1},{2,0},{3,0},{5,0},{1,1}}, {{1,1},{1,1},{1,1},{1,1},{5,0},{1,1}}, {{3,1},{5,0},{4,0},{1,0},{5,0},{6,0}}, {{3,1},{3,1},{3,1},{3,1},{5,0},{3,1}}, {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */ {{6,1},{6,1},{7,0},{6,1},{5,0},{3,0}}, {{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}}, {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */ }; char* next_token(char *word, char **next) { char *ptr; char *ret, *t; int state, ctype; t = ret = malloc(strlen(word)+1); if (ret == NULL) { fprintf(stderr, "Insufficient memory.\n"); exit(EXIT_FAILURE); } ptr = word; state = 0; *t = 0; while (1) { if (*ptr==0) ctype = PRC_EOS; else if (*ptr=='\\') ctype = PRC_ESCAPE; else if (*ptr=='"') ctype = PRC_DQUOTE; else if (*ptr=='\'') ctype = PRC_SQUOTE; else if (*ptr==' ' || *ptr=='\t') ctype = PRC_BLANK; else ctype = PRC_ALPHA; if (mtable[state][ctype].output) { *t = *ptr; t++; *t = 0; } state = mtable[state][ctype].nstate; ptr++; if (mtable[state][0].output<0) { break; } } if (*ret==0) t = NULL; else t = strdup(ret); free(ret); if (ctype==PRC_EOS) *next = NULL; else *next = ptr; return t; } extern void parse_command(char *command, char ***argv, int *argc) { LinkedList *list = NULL; char *token, *line; int count, i; line = command; do { token = next_token(line, &line); if (token) { list = list_cons(token, list); } } while (token!=NULL && line!=NULL); count = list_length(list); *argv = malloc(sizeof(char*)*count); i = count; while (list!=NULL) { (*argv)[--i] = list->head; list_remove_head(&list); } *argc = count; } extern pid_t execCommand(char *command) { pid_t pid; char **argv; int argc; parse_command(command, &argv, &argc); if (argv==NULL) { return 0; } if ((pid=fork())==0) { char **args; int i; args = malloc(sizeof(char*)*(argc+1)); if (!args) exit(10); for (i=0; i extern void parse_command(char *, char ***, int *); extern pid_t execCommand(char *); #endif /* __MISC_H */ dockapps-b9baa8f/src/wmgeneral.c000066400000000000000000000336121261212373500170170ustar00rootroot00000000000000/* wmgeneral was taken from wmppp. It has a lot of routines which most of the wm* programs use. ------------------------------------------------------------ Copyright (C) 1998 Martijn Pieterse (pieterse@xs4all.nl) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- CHANGES: --- 10/10/2003 (Simon Law, sfllaw@debian.org) * changed the parse_rcfile function to use getline instead of fgets. 10/14/2000 (Chris Gray, cgray@tribsoft.com) * Removed a bug from parse_rcfile. An extra newline would cause a segfault. 14/09/1998 (Dave Clark, clarkd@skyia.com) * Updated createXBMfromXPM routine * Now supports >256 colors 11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Removed a bug from parse_rcfile. You could not use "start" in a command if a label was also start. * Changed the needed geometry string. We don't use window size, and don't support negative positions. 03/09/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Added parse_rcfile2 02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Added -geometry support (untested) 28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Added createXBMfromXPM routine * Saves a lot of work with changing xpm's. 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl) * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon * debugged the parse_rc file. 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Ripped similar code from all the wm* programs, and put them in a single file. */ #define _POSIX_C_SOURCE 200809L #include "wmgeneral.h" #include /* for XCopyArea, etc */ #include /* for XSizeHints, XWMHints, etc */ #include /* for XShapeCombineMask */ #include /* for ShapeBounding, ShapeSet */ #include /* for XpmAttributes, Pixel, etc */ #include /* for size_t */ #include /* for fprintf, stderr, NULL, etc */ #include /* for exit, free */ #include /* for strcmp, strdup, strcspn, etc */ /*****************/ /* X11 Variables */ /*****************/ Window Root; int screen; int x_fd; int d_depth; XSizeHints mysizehints; XWMHints mywmhints; Pixel back_pix, fore_pix; Window iconwin, win; GC NormalGC; XpmIcon wmgen; Pixmap pixmask; /*****************/ /* Mouse Regions */ /*****************/ typedef struct { int enable; int top; int bottom; int left; int right; } MOUSE_REGION; 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); /*******************************************************************************\ |* parse_rcfile *| \*******************************************************************************/ void parse_rcfile(const char *filename, rckeys *keys) { char *p; FILE *fp; fp = fopen(filename, "r"); if (fp) { char temp[128]; while (fgets(temp, 128, fp)) { char *q, *saveptr; char *tokens = " :\t\n"; int key; key = 0; q = strdup(temp); q = strtok_r(q, tokens, &saveptr); if(!q) continue; while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { int i; p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = '\0'; *keys[key].var = strdup(p); key = -1; } else key++; } } fclose(fp); } } /*******************************************************************************\ |* parse_rcfile2 *| \*******************************************************************************/ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; FILE *fp; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { int key; key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { char *tokens = " :\t\n"; int i; p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; *keys[key].var = strdup(p); key = -1; } else key++; } } fclose(fp); } } /*******************************************************************************\ |* 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); 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); } /*******************************************************************************\ |* RedrawWindowXY *| \*******************************************************************************/ void RedrawWindowXY(int x, int y) { flush_expose(iconwin); XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0); flush_expose(win); XCopyArea(display, wmgen.pixmap, win, NormalGC, x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0); } /*******************************************************************************\ |* 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= mouse_region[i].left && y <= mouse_region[i].bottom && y >= mouse_region[i].top) found = 1; } if (!found) return -1; return (i-1); } /*******************************************************************************\ |* createXBMfromXPM *| \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { int i,j,k; int width, height, numcol, depth; int zero=0; int curpixel; sscanf(*xpm, "%10d %10d %10d %10d", &width, &height, &numcol, &depth); for (k=0; k!=depth; k++) { zero <<=8; zero |= xpm[1][k]; } for (i=numcol+1; i < numcol+sy+1; i++) { unsigned char bwrite; int bcount; bcount = 0; bwrite = 0; for (j=0; j>= 1; curpixel=0; for (k=0; k!=depth; k++) { curpixel <<=8; curpixel |= xpm[i][j+k]; } if ( curpixel != zero ) { bwrite += 128; } bcount++; if (bcount == 8) { *xbm = bwrite; xbm++; bcount = 0; bwrite = 0; } } } } /*******************************************************************************\ |* 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; char *geometry = NULL; int dummy=0; int i; for (i=1; argv[i]; i++) { if (!strcmp(argv[i], "-display")) display_name = argv[++i]; else if (!strcmp(argv[i], "-geometry")) geometry = argv[++i]; } 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); } dockapps-b9baa8f/src/wmgeneral.h000066400000000000000000000042421261212373500170210ustar00rootroot00000000000000/* wmgeneral was taken from wmppp. It has a lot of routines which most of the wm* programs use. ------------------------------------------------------------ Copyright (C) 1998 Martijn Pieterse (pieterse@xs4all.nl) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef WMGENERAL_H_INCLUDED #define WMGENERAL_H_INCLUDED #include /* for Pixmap */ #include /* for Display */ #include /* for XpmAttributes */ /***********/ /* Defines */ /***********/ #define MAX_MOUSE_REGION (16) /************/ /* Typedefs */ /************/ struct _rckeys { const char *label; char **var; }; typedef struct _rckeys rckeys; struct _rckeys2 { const char *family; const char *label; char **var; }; typedef struct _rckeys2 rckeys2; typedef struct { Pixmap pixmap; Pixmap mask; XpmAttributes attributes; } XpmIcon; /*******************/ /* Global variable */ /*******************/ 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 RedrawWindowXY(int x, int y); void createXBMfromXPM(char *, char **, int, int); void copyXPMArea(int, int, int, int, int, int); void copyXBMArea(int, int, int, int, int, int); void setMaskXY(int, int); void parse_rcfile(const char *, rckeys *); #endif