/usr/include/libdockapp/dockapp.h is in libdockapp-dev 1:0.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | /*
* 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 <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/xpm.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
/* 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
|