mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-03 20:48:31 +00:00
updating docs; removed useless cairo stuff
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@370 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
ba536a86a7
commit
b3f72c8b4a
88
README
88
README
@ -4,16 +4,16 @@ conky(1) conky(1)
|
||||
|
||||
NAME
|
||||
conky - A system monitor for X originally based on the torsmo code, but
|
||||
more kickass. It just keeps on given’er. Yeah.
|
||||
more kickass. It just keeps on given'er. Yeah.
|
||||
|
||||
SYNOPSIS
|
||||
conky [options]
|
||||
|
||||
DESCRIPTION
|
||||
Conky is a system monitor for X originally based on the torsmo code.
|
||||
Since it’s original conception, Conky has changed a fair bit from it’s
|
||||
Since it's original conception, Conky has changed a fair bit from it's
|
||||
predecessor. Conky can display just about anything, either on your
|
||||
root desktop or in it’s own window. Conky has many built-in objects,
|
||||
root desktop or in it's own window. Conky has many built-in objects,
|
||||
as well as the ability to execute programs and scripts, then display
|
||||
the output from stdout.
|
||||
|
||||
@ -28,11 +28,11 @@ COMPILING
|
||||
libraries installed. This should be a package along the lines of
|
||||
"libx11-dev or xorg-x11-dev".
|
||||
|
||||
Gentoo users -- Conky is in Gentoo’s Portage... simply use "emerge app-
|
||||
Gentoo users -- Conky is in Gentoo's Portage... simply use "emerge app-
|
||||
admin/conky" for installation. There is also usually an up-to-date
|
||||
ebuild within Conky’s package or in CVS.
|
||||
ebuild within Conky's package or in CVS.
|
||||
|
||||
Debian,etc. users -- Conky will be in Debian’s repositories soon (by
|
||||
Debian,etc. users -- Conky will be in Debian's repositories soon (by
|
||||
mid-September, hopefully), and then Ubuntu shortly thereafter. Until
|
||||
then, "dpkg -i" the .deb package to install.
|
||||
|
||||
@ -51,14 +51,14 @@ COMPILING
|
||||
|
||||
src/conky
|
||||
|
||||
Conky probably doesn’t compile with compilers other than gcc and icc.
|
||||
It doesn’t compile with C89 compiler and not even with pure C99. It
|
||||
uses a few things that might not exist: strdup(), strcasecmp(), strn‐
|
||||
Conky probably doesn't compile with compilers other than gcc and icc.
|
||||
It doesn't compile with C89 compiler and not even with pure C99. It
|
||||
uses a few things that might not exist: strdup(), strcasecmp(), strn-
|
||||
casecmp(), optarg variable with getopt() and long long (not in C89).
|
||||
Crashes in file system statistics stuff when compiled with icc, I don’t
|
||||
Crashes in file system statistics stuff when compiled with icc, I don't
|
||||
know exactly why.
|
||||
|
||||
You can disable ’drawing to own window’ feature in case you don’t need
|
||||
You can disable 'drawing to own window' feature in case you don't need
|
||||
it by passing --disable-own-window to configure -script.
|
||||
|
||||
|
||||
@ -69,14 +69,14 @@ YOU SHOULD KNOW
|
||||
rest of Conky.
|
||||
|
||||
If you do use them, please do not complain about memory or CPU usage,
|
||||
unless you think something’s seriously wrong (mem leak, etc.).
|
||||
unless you think something's seriously wrong (mem leak, etc.).
|
||||
|
||||
An easy way to force Conky to reload your ~/.conkyrc: "killall -SIGUSR1
|
||||
conky". Saves you the trouble of having to kill and then restart.
|
||||
|
||||
IMPORTANT: For previous Conky users, Conky 1.3 no longer supports the
|
||||
metar stuff. mdsplib was causing way too many problems. Hopefully
|
||||
there’ll be a better solution in Conky 2.x...
|
||||
there'll be a better solution in Conky 2.x...
|
||||
|
||||
OPTIONS
|
||||
Command line options override configurations defined in configuration
|
||||
@ -111,7 +111,7 @@ OPTIONS
|
||||
|
||||
|
||||
-t TEXT
|
||||
Text to render, remember single quotes, like -t ’ $uptime ’
|
||||
Text to render, remember single quotes, like -t ' $uptime '
|
||||
|
||||
|
||||
-u SECONDS
|
||||
@ -133,14 +133,14 @@ OPTIONS
|
||||
CONFIGURATION SETTINGS
|
||||
Default configuration file is $HOME/.conkyrc (can be changed from
|
||||
conky.c among other things). See conkyrc.sample. If installing from
|
||||
Debian package, this should be in /usr/share/doc/conky/examples ("gun‐
|
||||
Debian package, this should be in /usr/share/doc/conky/examples ("gun-
|
||||
zip conkyrc.sample.gz" to get conkyrc.sample).
|
||||
|
||||
You might want to copy it to $HOME/.conkyrc and then start modifying
|
||||
it. Other configs can be found at http://conky.sf.net
|
||||
|
||||
alignment
|
||||
Aligned position on screen, may be top_left, top_right, bot‐
|
||||
Aligned position on screen, may be top_left, top_right, bot-
|
||||
tom_left, bottom_right, or none
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ CONFIGURATION SETTINGS
|
||||
|
||||
|
||||
default_shade_color
|
||||
Default shading color and border’s shading color
|
||||
Default shading color and border's shading color
|
||||
|
||||
|
||||
default_outline_color
|
||||
@ -178,8 +178,8 @@ CONFIGURATION SETTINGS
|
||||
|
||||
|
||||
double_buffer
|
||||
Use the Xdbe extension? (eliminates flicker) It is highly recom‐
|
||||
mended to use own window with this one so double buffer won’t be
|
||||
Use the Xdbe extension? (eliminates flicker) It is highly recom-
|
||||
mended to use own window with this one so double buffer won't be
|
||||
so big.
|
||||
|
||||
|
||||
@ -309,7 +309,7 @@ CONFIGURATION SETTINGS
|
||||
VARIABLES
|
||||
Colors are parsed using XParsecolor(), there might be a list of them:
|
||||
/usr/X11R6/lib/X11/rgb.txt. Also, http://sedition.com/perl/rgb.html
|
||||
[http://sedition.com/perl/rgb.html]. Color can be also in #rrggbb for‐
|
||||
[http://sedition.com/perl/rgb.html]. Color can be also in #rrggbb for-
|
||||
mat (hex). Note that when displaying bytes, power is 1024 and not 1000
|
||||
so 1M really means 1024*1024 bytes and not 1000*1000.
|
||||
|
||||
@ -385,7 +385,7 @@ VARIABLES
|
||||
|
||||
|
||||
cpubar (cpu number) (height),(width)
|
||||
Bar that shows CPU usage, height is bar’s height in pixels. See
|
||||
Bar that shows CPU usage, height is bar's height in pixels. See
|
||||
$cpu for more info on SMP.
|
||||
|
||||
|
||||
@ -422,8 +422,8 @@ VARIABLES
|
||||
|
||||
|
||||
exec command
|
||||
Executes a shell command and displays the output in conky. warn‐
|
||||
ing: this takes a lot more resources than other variables. I’d
|
||||
Executes a shell command and displays the output in conky. warn-
|
||||
ing: this takes a lot more resources than other variables. I'd
|
||||
recommend coding wanted behaviour in C and posting a patch.
|
||||
|
||||
|
||||
@ -438,7 +438,7 @@ VARIABLES
|
||||
|
||||
|
||||
execi interval command
|
||||
Same as exec but with specific interval. Interval can’t be less
|
||||
Same as exec but with specific interval. Interval can't be less
|
||||
than update_interval in configuration. See also $texeci
|
||||
|
||||
|
||||
@ -495,7 +495,7 @@ VARIABLES
|
||||
|
||||
head logfile lines (interval)
|
||||
Displays first N lines of supplied text text file. If interval
|
||||
is not supplied, Conky assumes 2x Conky’s interval. Max of 30
|
||||
is not supplied, Conky assumes 2x Conky's interval. Max of 30
|
||||
lines can be displayed, or until the text buffer is filled.
|
||||
|
||||
|
||||
@ -540,7 +540,7 @@ VARIABLES
|
||||
|
||||
i8k_left_fan_rpm
|
||||
If running the i8k kernel driver for Inspiron laptops, displays
|
||||
the left fan’s rate of rotation, in revolutions per minute as
|
||||
the left fan's rate of rotation, in revolutions per minute as
|
||||
listed in /proc/i8k. Beware, some laptops i8k reports these fans
|
||||
in reverse order.
|
||||
|
||||
@ -554,7 +554,7 @@ VARIABLES
|
||||
|
||||
i8k_right_fan_rpm
|
||||
If running the i8k kernel driver for Inspiron laptops, displays
|
||||
the right fan’s rate of rotation, in revolutions per minute as
|
||||
the right fan's rate of rotation, in revolutions per minute as
|
||||
listed in /proc/i8k. Beware, some laptops i8k reports these fans
|
||||
in reverse order.
|
||||
|
||||
@ -675,7 +675,7 @@ VARIABLES
|
||||
|
||||
|
||||
mpd_bar (height),(width)
|
||||
Bar of mpd’s progress
|
||||
Bar of mpd's progress
|
||||
|
||||
|
||||
mpd_bitrate
|
||||
@ -691,19 +691,19 @@ VARIABLES
|
||||
|
||||
|
||||
mpd_vol
|
||||
MPD’s volume
|
||||
MPD's volume
|
||||
|
||||
|
||||
mpd_elapsed
|
||||
Song’s elapsed time
|
||||
Song's elapsed time
|
||||
|
||||
|
||||
mpd_length
|
||||
Song’s length
|
||||
Song's length
|
||||
|
||||
|
||||
mpd_percent
|
||||
Percent of song’s progress
|
||||
Percent of song's progress
|
||||
|
||||
|
||||
mpd_random
|
||||
@ -796,7 +796,7 @@ VARIABLES
|
||||
|
||||
Examples:
|
||||
|
||||
${tcp_portmon 6881 6889 count} - displays the number of connec‐
|
||||
${tcp_portmon 6881 6889 count} - displays the number of connec-
|
||||
tions in the bittorrent port range
|
||||
|
||||
${tcp_portmon 22 22 rip 0} - displays the remote host ip of the
|
||||
@ -815,7 +815,7 @@ VARIABLES
|
||||
name of the fifteenth connection in the range of all ports
|
||||
|
||||
Note that port monitor variables which share the same port range
|
||||
actually refer to the same monitor, so many references to a sin‐
|
||||
actually refer to the same monitor, so many references to a sin-
|
||||
gle port range for different items and different indexes all use
|
||||
the same monitor internally. In other words, the program avoids
|
||||
creating redundant monitors.
|
||||
@ -823,7 +823,7 @@ VARIABLES
|
||||
texeci interval command
|
||||
Runs a command at an interval inside a thread and displays the
|
||||
output. Same as $execi, except the command is run inside a
|
||||
thread. Use this if you have a slow script to keep Conky updat‐
|
||||
thread. Use this if you have a slow script to keep Conky updat-
|
||||
ing. You should make the interval slightly longer then the time
|
||||
it takes your script to execute. For example, if you have a
|
||||
script that take 5 seconds to execute, you should make the
|
||||
@ -836,18 +836,18 @@ VARIABLES
|
||||
|
||||
tail logfile lines (interval)
|
||||
Displays last N lines of supplied text text file. If interval is
|
||||
not supplied, Conky assumes 2x Conky’s interval. Max of 30 lines
|
||||
not supplied, Conky assumes 2x Conky's interval. Max of 30 lines
|
||||
can be displayed, or until the text buffer is filled.
|
||||
|
||||
|
||||
time (format)
|
||||
Local time, see man strftime to get more information about for‐
|
||||
Local time, see man strftime to get more information about for-
|
||||
mat
|
||||
|
||||
|
||||
totaldown net
|
||||
Total download, overflows at 4 GB on Linux with 32-bit arch and
|
||||
there doesn’t seem to be a way to know how many times it has
|
||||
there doesn't seem to be a way to know how many times it has
|
||||
already done that before conky has started.
|
||||
|
||||
|
||||
@ -910,7 +910,7 @@ VARIABLES
|
||||
|
||||
|
||||
EXAMPLES
|
||||
conky -t ’${time %D %H:%m}’ -o -u 30
|
||||
conky -t '${time %D %H:%m}' -o -u 30
|
||||
Start Conky in its own window with date and clock as text and 30
|
||||
sec update interval.
|
||||
|
||||
@ -921,9 +921,9 @@ FILES
|
||||
~/.conkyrc default configuration file
|
||||
|
||||
BUGS
|
||||
Drawing to root or some other desktop window directly doesn’t work with
|
||||
all window managers. Especially doesn’t work well with Gnome and it has
|
||||
been reported that it doesn’t work with KDE either. Nautilus can be
|
||||
Drawing to root or some other desktop window directly doesn't work with
|
||||
all window managers. Especially doesn't work well with Gnome and it has
|
||||
been reported that it doesn't work with KDE either. Nautilus can be
|
||||
disabled from drawing to desktop with program gconf-editor. Uncheck
|
||||
show_desktop in /apps/nautilus/preferences/. There is -w switch in
|
||||
Conky to set some specific window id. You might find xwininfo -tree
|
||||
@ -933,13 +933,13 @@ BUGS
|
||||
SEE ALSO
|
||||
http://conky.sourceforge.net [http://conky.sourceforge.net]
|
||||
|
||||
http://www.sourceforge.net/projects/conky [http://www.source‐
|
||||
http://www.sourceforge.net/projects/conky [http://www.source-
|
||||
forge.net/projects/conky]
|
||||
|
||||
#conky on irc.freenode.net
|
||||
|
||||
AUTHORS
|
||||
The Conky dev team. What’s up now!
|
||||
The Conky dev team. What's up now!
|
||||
|
||||
|
||||
|
||||
|
27
configure.in
27
configure.in
@ -128,32 +128,6 @@ dnl
|
||||
dnl Cairo
|
||||
dnl
|
||||
|
||||
want_cairo=no
|
||||
AC_ARG_ENABLE(cairo,
|
||||
[ --enable-cairo enable if you want Cairo support [[default=no]]],
|
||||
[want_cairo="$enableval"])
|
||||
|
||||
AM_CONDITIONAL(BUILD_CAIRO, test x$want_cairo = xyes)
|
||||
|
||||
|
||||
if test "$want_cairo" = "yes"; then
|
||||
AC_CHECK_HEADERS([cairo.h cairo-xlib.h], [], [CAIRO_MISSING=yes])
|
||||
if test "x$CAIRO_MISSING" = xyes; then
|
||||
AC_MSG_ERROR([something went wrong when checking for cairo, you're probably missing headers or it's not installed])
|
||||
fi
|
||||
AC_PATH_PROG(CAIROCONFIG, pkg-config)
|
||||
if test x$CAIROCONFIG != x; then
|
||||
dnl TODO: needs more checks
|
||||
|
||||
AC_DEFINE(CAIRO, 1, [Define if you are using Cairo])
|
||||
CFLAGS="$CFLAGS `$CAIROCONFIG --cflags cairo` `$CAIROCONFIG --libs cairo` "
|
||||
CAIRO_LIBS="`$CAIROCONFIG --libs cairo` `$CAIROCONFIG --cflags cairo`"
|
||||
else
|
||||
want_cairo=no
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl MLDonkey
|
||||
dnl
|
||||
@ -278,7 +252,6 @@ AC_CHECK_HEADERS([sys/mount.h], [], [],
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
])
|
||||
dnl For cairo
|
||||
|
||||
dnl
|
||||
dnl Check doc stuff
|
||||
|
@ -69,7 +69,7 @@
|
||||
Ubuntu shortly thereafter. Until then, "dpkg -i" the .deb package to install.
|
||||
</para>
|
||||
<para>
|
||||
To compile and run Conky with all optional components:
|
||||
Example to compile and run Conky with all optional components (note that some configure options may differ for your system):
|
||||
</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
@ -79,11 +79,7 @@
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>./configure </option></command><option>
|
||||
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
|
||||
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib
|
||||
--enable-double-buffer --enable-own-window --enable-proc-uptime
|
||||
--enable-mpd --enable-xft --enable-seti</option>
|
||||
<command><option>./configure </option></command><option>--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-xft --enable-seti --enable-double-buffer --enable-own-window --enable-proc-uptime --enable-mpd --enable-mldonkey --enable-x11 --enable-portmon</option>
|
||||
</term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -30,10 +30,6 @@ if BUILD_PORT_MONITORS
|
||||
port_monitors = libtcp-portmon.h libtcp-portmon.c hash.h hash.c
|
||||
endif
|
||||
|
||||
if BUILD_CAIRO
|
||||
cairo = cairo.c
|
||||
endif
|
||||
|
||||
if BUILD_MLDONKEY
|
||||
mldonkey = mldonkey.c
|
||||
endif
|
||||
|
231
src/cairo.c
231
src/cairo.c
@ -1,231 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
/* Small example demonstrating emulating knockout-groups as in PDF-1.4
|
||||
* using cairo_set_operator().
|
||||
*
|
||||
* Owen Taylor,
|
||||
|
||||
* v0.1 30 November 2002
|
||||
* v0.2 1 December 2002 - typo fixes from Keith Packard
|
||||
* v0.3 17 April 2003 - Tracking changes in Xr, (Removal of Xr{Push,Pop}Group)
|
||||
* v0.4 29 September 2003 - Use cairo_rectangle rather than private rect_path
|
||||
* Use cairo_arc for oval_path
|
||||
* Keeping log of changes in ChangeLog/CVS now. (2003-11-19) Carl Worth
|
||||
*/
|
||||
#include "conky.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <cairo.h>
|
||||
#include <cairo-xlib.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Fill the given area with checks in the standard style
|
||||
* for showing compositing effects.
|
||||
*/
|
||||
static void fill_checks(cairo_t * cr, int x, int y, int width, int height)
|
||||
{
|
||||
cairo_surface_t *check;
|
||||
cairo_pattern_t *check_pattern;
|
||||
|
||||
cairo_save(cr);
|
||||
|
||||
#define CHECK_SIZE 32
|
||||
|
||||
check =
|
||||
cairo_surface_create_similar(cairo_current_target_surface(cr),
|
||||
CAIRO_FORMAT_RGB24,
|
||||
2 * CHECK_SIZE, 2 * CHECK_SIZE);
|
||||
cairo_surface_set_repeat(check, 1);
|
||||
|
||||
/* Draw the check */
|
||||
{
|
||||
cairo_save(cr);
|
||||
|
||||
cairo_set_target_surface(cr, check);
|
||||
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_SRC);
|
||||
|
||||
cairo_set_rgb_color(cr, 0.4, 0.4, 0.4);
|
||||
|
||||
cairo_rectangle(cr, 0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
|
||||
cairo_fill(cr);
|
||||
|
||||
cairo_set_rgb_color(cr, 0.7, 0.7, 0.7);
|
||||
|
||||
cairo_rectangle(cr, x, y, CHECK_SIZE, CHECK_SIZE);
|
||||
cairo_fill(cr);
|
||||
cairo_rectangle(cr, x + CHECK_SIZE, y + CHECK_SIZE,
|
||||
CHECK_SIZE, CHECK_SIZE);
|
||||
cairo_fill(cr);
|
||||
|
||||
cairo_restore(cr);
|
||||
}
|
||||
|
||||
/* Fill the whole surface with the check */
|
||||
|
||||
check_pattern = cairo_pattern_create_for_surface(check);
|
||||
cairo_set_pattern(cr, check_pattern);
|
||||
cairo_rectangle(cr, 0, 0, width, height);
|
||||
cairo_fill(cr);
|
||||
|
||||
cairo_pattern_destroy(check_pattern);
|
||||
cairo_surface_destroy(check);
|
||||
|
||||
cairo_restore(cr);
|
||||
}
|
||||
|
||||
static void draw_pee(cairo_t * cr, double xc, double yc)
|
||||
{
|
||||
cairo_set_rgb_color(cr, 0, 0, 0);
|
||||
cairo_show_text(cr, "Conky");
|
||||
}
|
||||
|
||||
static void draw(cairo_t * cr, int width, int height)
|
||||
{
|
||||
cairo_surface_t *overlay;
|
||||
|
||||
/* Fill the background */
|
||||
double xc = width / 2.;
|
||||
double yc = height / 2.;
|
||||
|
||||
overlay =
|
||||
cairo_surface_create_similar(cairo_current_target_surface(cr),
|
||||
CAIRO_FORMAT_ARGB32, width,
|
||||
height);
|
||||
if (overlay == NULL)
|
||||
return;
|
||||
|
||||
fill_checks(cr, 0, 0, width, height);
|
||||
|
||||
cairo_save(cr);
|
||||
cairo_set_target_surface(cr, overlay);
|
||||
|
||||
cairo_set_alpha(cr, 0.5);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
draw_pee(cr, xc, yc);
|
||||
|
||||
cairo_restore(cr);
|
||||
|
||||
cairo_show_surface(cr, overlay, width, height);
|
||||
|
||||
cairo_surface_destroy(overlay);
|
||||
}
|
||||
|
||||
int do_it(void)
|
||||
{
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window w;
|
||||
Pixmap pixmap;
|
||||
char *title = "cairo: Knockout Groups";
|
||||
unsigned int quit_keycode;
|
||||
int needs_redraw;
|
||||
GC gc;
|
||||
XWMHints *wmhints;
|
||||
XSizeHints *normalhints;
|
||||
XClassHint *classhint;
|
||||
|
||||
int width = 400;
|
||||
int height = 400;
|
||||
|
||||
dpy = XOpenDisplay(NULL);
|
||||
screen = DefaultScreen(dpy);
|
||||
|
||||
w = XCreateSimpleWindow(dpy, RootWindow(dpy, screen),
|
||||
0, 0, width, height, 0,
|
||||
BlackPixel(dpy, screen), WhitePixel(dpy,
|
||||
screen));
|
||||
|
||||
normalhints = XAllocSizeHints();
|
||||
normalhints->flags = 0;
|
||||
normalhints->x = 0;
|
||||
normalhints->y = 0;
|
||||
normalhints->width = width;
|
||||
normalhints->height = height;
|
||||
|
||||
classhint = XAllocClassHint();
|
||||
classhint->res_name = "cairo-knockout";
|
||||
classhint->res_class = "Cairo-knockout";
|
||||
|
||||
wmhints = XAllocWMHints();
|
||||
wmhints->flags = InputHint;
|
||||
wmhints->input = True;
|
||||
|
||||
XmbSetWMProperties(dpy, w, title, "cairo-knockout", 0, 0,
|
||||
normalhints, wmhints, classhint);
|
||||
XFree(wmhints);
|
||||
XFree(classhint);
|
||||
XFree(normalhints);
|
||||
|
||||
pixmap =
|
||||
XCreatePixmap(dpy, w, width, height,
|
||||
DefaultDepth(dpy, screen));
|
||||
gc = XCreateGC(dpy, pixmap, 0, NULL);
|
||||
|
||||
quit_keycode = XKeysymToKeycode(dpy, XStringToKeysym("Q"));
|
||||
|
||||
XSelectInput(dpy, w,
|
||||
ExposureMask | StructureNotifyMask | ButtonPressMask |
|
||||
KeyPressMask);
|
||||
XMapWindow(dpy, w);
|
||||
|
||||
needs_redraw = 1;
|
||||
|
||||
while (1) {
|
||||
XEvent xev;
|
||||
|
||||
/* Only do the redraw if there are no events pending. This
|
||||
* avoids us getting behind doing several redraws for several
|
||||
* consecutive resize events for example.
|
||||
*/
|
||||
if (!XPending(dpy) && needs_redraw) {
|
||||
cairo_t *cr = cairo_create();
|
||||
|
||||
cairo_set_target_drawable(cr, dpy, pixmap);
|
||||
|
||||
draw(cr, width, height);
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
||||
XCopyArea(dpy, pixmap, w, gc,
|
||||
0, 0, width, height, 0, 0);
|
||||
|
||||
needs_redraw = 0;
|
||||
}
|
||||
|
||||
XNextEvent(dpy, &xev);
|
||||
|
||||
switch (xev.xany.type) {
|
||||
case ButtonPress:
|
||||
/* A click on the canvas ends the program */
|
||||
goto DONE;
|
||||
case KeyPress:
|
||||
if (xev.xkey.keycode == quit_keycode)
|
||||
goto DONE;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
/* Note new size and create new pixmap. */
|
||||
width = xev.xconfigure.width;
|
||||
height = xev.xconfigure.height;
|
||||
XFreePixmap(dpy, pixmap);
|
||||
pixmap =
|
||||
XCreatePixmap(dpy, w, width, height,
|
||||
DefaultDepth(dpy, screen));
|
||||
needs_redraw = 1;
|
||||
break;
|
||||
case Expose:
|
||||
XCopyArea(dpy, pixmap, w, gc,
|
||||
xev.xexpose.x, xev.xexpose.y,
|
||||
xev.xexpose.width, xev.xexpose.height,
|
||||
xev.xexpose.x, xev.xexpose.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DONE:
|
||||
|
||||
XFreeGC(dpy, gc);
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user