pax_global_header00006660000000000000000000000064107263745400014522gustar00rootroot0000000000000052 comment=4da8b88454d841f26fd6f5b859a3cfebfa2f4d24 fdclock-20071208/000075500000000000000000000000001072637454000133725ustar00rootroot00000000000000fdclock-20071208/AUTHORS000064400000000000000000000000001072637454000144300ustar00rootroot00000000000000fdclock-20071208/Makefile.am000064400000000000000000000011411072637454000154230ustar00rootroot00000000000000INCLUDES = @FDCLOCK_CFLAGS@ COMMON_SRCS = fdlogo.c fdface.c fdclock_SOURCES = \ fdclock.c fdhand.c findargb.c \ $(COMMON_SRCS) fdfacepng_SOURCES = \ fdfacepng.c \ $(COMMON_SRCS) bin_PROGRAMS = fdclock fdfacepng fdclock_LDADD = @FDCLOCK_LIBS@ fdfacepng_LDADD = @FDCLOCK_LIBS@ @PNG_LIBS@ EXTRA_DIST = ChangeLog MAINTAINERCLEANFILES = ChangeLog .PHONY: ChangeLog ChangeLog: (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) dist-hook: ChangeLog fdclock-20071208/NEWS000064400000000000000000000000001072637454000140570ustar00rootroot00000000000000fdclock-20071208/README000064400000000000000000000000001072637454000142400ustar00rootroot00000000000000fdclock-20071208/autogen.sh000075500000000000000000000000761072637454000153760ustar00rootroot00000000000000#! /bin/sh autoreconf -v --install || exit 1 ./configure "$@" fdclock-20071208/configure.ac000064400000000000000000000013331072637454000156600ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) AC_CONFIG_SRCDIR([fdclock.c]) AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([stdlib.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_TIME AC_STRUCT_TM # Checks for library functions. AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday localtime_r]) PKG_CHECK_MODULES(FDCLOCK, cairo) PKG_CHECK_MODULES(PNG, libpng12) AC_CONFIG_FILES([Makefile]) AC_OUTPUT fdclock-20071208/fdclock.c000064400000000000000000000206151072637454000151470ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include "fdface.h" #include "fdhand.h" #include "findargb.h" #define CLOCK_WIDTH 150 #define CLOCK_HEIGHT 150 static void clear (cairo_t *cr, double width, double height, double alpha) { cairo_save (cr); cairo_set_source_rgba (cr, 1, 1, 1, alpha); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_restore (cr); } cairo_surface_t * make_background (cairo_surface_t *buffer_surface, cairo_content_t content, int width, int height, Bool opaque) { cairo_surface_t *back_surface = cairo_surface_create_similar (buffer_surface, content, width, height); cairo_surface_t *temp_surface = 0; cairo_t *cr; if (content == CAIRO_CONTENT_COLOR_ALPHA) { temp_surface = cairo_surface_create_similar (back_surface, CAIRO_CONTENT_COLOR_ALPHA, width, height); /* * draw the background to the temporary surface */ cr = cairo_create (temp_surface); } else cr = cairo_create (back_surface); clear (cr, width, height, temp_surface ? 0 : 1); if (temp_surface) { cairo_save (cr); { cairo_set_source_rgba (cr, 1, 1, 1, opaque ? 1 : 0.5); cairo_scale (cr, width, height); cairo_translate (cr, 0.5, 0.5); cairo_arc (cr, 0, 0, 0.5, 0, 2 * M_PI); cairo_fill (cr); } cairo_restore (cr); } fdface_draw (cr, width, height); if (temp_surface) { cairo_destroy (cr); cr = cairo_create (back_surface); cairo_set_source_surface (cr, temp_surface, 0, 0); cairo_paint_with_alpha (cr, opaque ? 1 : 0.8); cairo_surface_destroy (temp_surface); } cairo_destroy (cr); return back_surface; } static void main_x (char *dpy_name, char *geom, Bool seconds, Bool translucent, Bool square, Bool opaque) { Display *dpy; int scr; int x = 0, y = 0; unsigned int u_width = CLOCK_WIDTH, u_height = CLOCK_HEIGHT; int width, height; Window root; Visual *visual; XWMHints *wmhints; XSizeHints *normalhints; XClassHint *classhint; char *name; XSetWindowAttributes wattr; unsigned long wmask; int depth; Colormap cmap; Window w; cairo_surface_t *background = NULL; cairo_surface_t *window; cairo_content_t content; XEvent ev; Bool paint = False; int timeout; dpy = XOpenDisplay (dpy_name); if (!dpy) { fprintf (stderr, "Cannot open display\n"); return; } if (geom) XParseGeometry (geom, &x, &y, &u_width, &u_height); width = (int) u_width; height = (int) u_height; scr = DefaultScreen (dpy); root = RootWindow (dpy, scr); if (translucent) visual = find_argb_visual (dpy, scr); else visual = 0; wattr.event_mask = (ExposureMask | StructureNotifyMask); if (visual) { depth = 32; wattr.background_pixel = 0; wattr.border_pixel = 0; wattr.colormap = cmap = XCreateColormap (dpy, root, visual, AllocNone); content = CAIRO_CONTENT_COLOR_ALPHA; } else { visual = DefaultVisual (dpy, scr); depth = DefaultDepth (dpy, scr); wattr.colormap = cmap = DefaultColormap (dpy, scr); wattr.background_pixel = WhitePixel (dpy, scr); wattr.border_pixel = BlackPixel (dpy, scr); content = CAIRO_CONTENT_COLOR; } wmask = CWEventMask | CWBackPixel | CWBorderPixel | CWColormap; w = XCreateWindow (dpy, root, x, y, width, height, 0, depth, InputOutput, visual, wmask, &wattr); window = cairo_xlib_surface_create (dpy, w, visual, width, height); name = "fdclock"; normalhints = XAllocSizeHints (); normalhints->flags = 0; normalhints->x = x; normalhints->y = y; normalhints->width = width; normalhints->height = height; classhint = XAllocClassHint (); classhint->res_name = "fdclock"; classhint->res_class = "Fdclock"; wmhints = XAllocWMHints (); wmhints->flags = InputHint; wmhints->input = True; Xutf8SetWMProperties (dpy, w, name, name, 0, 0, normalhints, wmhints, classhint); XFree (wmhints); XFree (classhint); XFree (normalhints); XMapWindow (dpy, w); if (seconds) timeout = 100; else timeout = 1000; for (;;) { struct pollfd a; a.fd = ConnectionNumber (dpy); a.events = POLLIN; if (XEventsQueued (dpy, QueuedAfterFlush) || poll (&a, 1, timeout) > 0) { do { XNextEvent (dpy, &ev); switch (ev.type) { case Expose: paint = True; break; case ConfigureNotify: if (width != ev.xconfigure.width || height != ev.xconfigure.height) { width = ev.xconfigure.width; height = ev.xconfigure.height; if (background) { cairo_surface_destroy (background); background = NULL; } cairo_xlib_surface_set_size (window, width, height); XClearArea (dpy, w, 0, 0, 0, 0, False); paint = True; } break; } } while (XPending (dpy)); } else paint = True; if (paint) { cairo_surface_t *buffer; cairo_t *cr; int x_off = 0, y_off = 0; int u_width = width, u_height = height; if (square) { if (width < height) u_width = u_height = width; else u_width = u_height = height; x_off = (width - u_width) / 2; y_off = (height - u_height) / 2; } /* * Create a pixmap holding the background clock image * so it doesn't have to be painted every tick */ if (!background) background = make_background (window, content, u_width, u_height, opaque); buffer = cairo_surface_create_similar (window, content, u_width, u_height); cr = cairo_create (buffer); cairo_save (cr); { cairo_set_source_surface (cr, background, 0, 0); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint (cr); } cairo_restore (cr); fdhand_draw_now (cr, u_width, u_height, seconds); cairo_destroy (cr); cr = cairo_create (window); cairo_set_source_surface (cr, buffer, x_off, y_off); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint (cr); cairo_destroy (cr); cairo_surface_destroy (buffer); paint = False; } } } extern char *optarg; extern int optind, opterr, optopt; int main (int argc, char **argv) { char *dpy_name = 0; char *geom = 0; Bool seconds = False, translucent = False, square = False, opaque = False; int c; while ((c = getopt (argc, argv, "staod:g:")) > 0) { switch (c) { case 'd': dpy_name = optarg; break; case 'g': geom = optarg; break; case 's': seconds = True; break; case 't': translucent = True; opaque = False; break; case 'o': translucent = True; opaque = True; break; case 'a': square = True; break; default: fprintf (stderr, "usage: %s -sta -d -g \n", argv[0]); exit (1); break; } } main_x (dpy_name, geom, seconds, translucent, square, opaque); return 0; } fdclock-20071208/fdface.c000064400000000000000000000050671072637454000147560ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include "fdface.h" static void draw_fancy_tick (cairo_t *cr, double radius) { cairo_save (cr); cairo_arc (cr, 0, 0, radius, 0, 2 * M_PI); cairo_set_source_rgb (cr, 0.231, 0.502, 0.682); cairo_fill (cr); cairo_set_source_rgb (cr, 0.73, 0.73, 0.73); cairo_set_line_width (cr, radius * 2 / 3); cairo_arc (cr, 0, 0, radius * 2, 0, 2 * M_PI); cairo_stroke (cr); cairo_restore (cr); } static void draw_plain_tick (cairo_t *cr, double radius) { cairo_save (cr); cairo_arc (cr, 0, 0, radius, 0, 2 * M_PI); cairo_set_source_rgb (cr, 0.73, 0.73, 0.73); cairo_fill (cr); cairo_restore (cr); } void fdface_draw (cairo_t *cr, double width, double height) { int minute; cairo_save (cr); { cairo_scale (cr, width, height); cairo_save (cr); { cairo_translate (cr, .15, .15); cairo_scale (cr, .7, .7); fdlogo_draw (cr, 1, 1); } cairo_restore (cr); cairo_translate (cr, 0.5, 0.5); cairo_scale (cr, 0.93, 0.93); for (minute = 0; minute < 60; minute++) { double degrees, radians; cairo_save (cr); degrees = minute * 6.0; radians = degrees * M_PI / 180; cairo_rotate (cr, radians); cairo_translate (cr, 0, 0.5); if (minute % 15 == 0) draw_fancy_tick (cr, 0.015); else if (minute % 5 == 0) draw_fancy_tick (cr, 0.01); else draw_plain_tick (cr, 0.01); cairo_restore (cr); } } cairo_restore (cr); } fdclock-20071208/fdface.h000064400000000000000000000024451072637454000147600ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FDFACE_H_ #define _FDFACE_H_ #include "fdlogo.h" void fdface_draw (cairo_t *cr, double width, double height); #endif /* _FDFACE_H_ */ fdclock-20071208/fdfacepng.c000064400000000000000000000037071072637454000154620ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include "fdface.h" static int dump_png (int width, int height) { cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cairo_t *cr = cairo_create (surface); char out[1024]; cairo_move_to (cr, 0, 0); cairo_line_to (cr, width, 0); cairo_line_to (cr, width, height); cairo_line_to (cr, 0, height); cairo_close_path (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); fdface_draw (cr, width, height); cairo_destroy (cr); sprintf (out, "freedesktop-clock-%d.png", width); cairo_surface_write_to_png (surface, out); cairo_surface_destroy (surface); return 0; } int main (int argc, char **argv) { return dump_png (2400, 2400); } fdclock-20071208/fdhand.c000064400000000000000000000106441072637454000147670ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include "fdhand.h" #include #include #include #define PI_6 (M_PI/6.0) static void draw_hour (cairo_t *cr, double width, double length) { double r = width / 2; cairo_move_to (cr, length, -r); cairo_arc (cr, length, 0, r, -M_PI_2, M_PI_2); cairo_line_to (cr, width * M_SQRT2, r); cairo_arc (cr, 0, 0, r*2, PI_6, - PI_6); cairo_close_path (cr); } static void draw_minute (cairo_t *cr, double width, double length) { double r = width / 2; cairo_move_to (cr, length, -r); cairo_arc (cr, length, 0, r, -M_PI_2, M_PI_2); cairo_line_to (cr, 0, r); cairo_line_to (cr, 0, -r); cairo_close_path (cr); } static void draw_second (cairo_t *cr, double width, double length) { double r = width / 2; double thick = width; double back = length / 3; double back_thin = length / 10; cairo_move_to (cr, length, -r); cairo_arc (cr, length, 0, r, -M_PI_2, M_PI_2); cairo_line_to (cr, -back_thin, r); cairo_line_to (cr, -back_thin, thick); cairo_line_to (cr, -back, thick); cairo_line_to (cr, -back, -thick); cairo_line_to (cr, -back_thin, -thick); cairo_line_to (cr, -back_thin, -r); cairo_close_path (cr); } static void draw_hand (cairo_t *cr, double noon_deg, double width, double length, double alt, void (*draw) (cairo_t *cr, double width, double length)) { cairo_save (cr); cairo_translate (cr, alt/2, alt); cairo_rotate (cr, noon_deg * M_PI / 180.0 - M_PI_2); (*draw) (cr, width, length); cairo_restore (cr); } #define HOUR_WIDTH 0.03 #define HOUR_LENGTH 0.25 #define HOUR_ALT 0.010 #define MINUTE_WIDTH 0.015 #define MINUTE_LENGTH 0.39 #define MINUTE_ALT 0.020 #define SECOND_WIDTH 0.0075 #define SECOND_LENGTH 0.32 #define SECOND_ALT 0.026 static void draw_time (cairo_t *cr, double width, double height, struct timeval *tv, int seconds) { double hour_angle, minute_angle, second_angle; struct tm tm_ret; struct tm *tm; tm = localtime_r (&tv->tv_sec, &tm_ret); second_angle = (tm->tm_sec + tv->tv_usec / 1000000.0) * 6.0; minute_angle = tm->tm_min * 6.0 + second_angle / 60.0; hour_angle = tm->tm_hour * 30.0 + minute_angle / 12.0; cairo_save (cr); { cairo_scale (cr, width, height); cairo_translate (cr, 0.5, 0.5); draw_hand (cr, hour_angle, HOUR_WIDTH, HOUR_LENGTH, HOUR_ALT, draw_hour); draw_hand (cr, minute_angle, MINUTE_WIDTH, MINUTE_LENGTH, MINUTE_ALT, draw_minute); if (seconds) draw_hand (cr, second_angle, SECOND_WIDTH, SECOND_LENGTH, SECOND_ALT, draw_second); cairo_set_source_rgba (cr, 0, 0, 0, 0.3); cairo_fill (cr); cairo_set_source_rgba (cr, 0, 0, 0, 1); draw_hand (cr, hour_angle, HOUR_WIDTH, HOUR_LENGTH, 0.0, draw_hour); cairo_fill (cr); draw_hand (cr, minute_angle, MINUTE_WIDTH, MINUTE_LENGTH, 0.0, draw_minute); cairo_fill (cr); if (seconds) draw_hand (cr, second_angle, SECOND_WIDTH, SECOND_LENGTH, 0.0, draw_second); cairo_fill (cr); } cairo_restore (cr); } void fdhand_draw_now (cairo_t *cr, double width, double height, int seconds) { struct timeval tv; gettimeofday (&tv, NULL); draw_time (cr, width, height, &tv, seconds); } fdclock-20071208/fdhand.h000064400000000000000000000024661072637454000147770ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FDHAND_H_ #define _FDHAND_H_ #include void fdhand_draw_now (cairo_t *cr, double width, double height, int seconds); #endif /* _FDHAND_H_ */ fdclock-20071208/fdlogo.c000064400000000000000000000107311072637454000150120ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include "fdlogo.h" static void draw_boundary (cairo_t *cr) { cairo_move_to (cr, 63.000, 36.000); cairo_curve_to (cr, 63.000, 43.000, 58.000, 47.000, 51.000, 47.000); cairo_line_to (cr, 13.000, 47.000); cairo_curve_to (cr, 6.000, 47.000, 1.000, 43.000, 1.000, 36.000); cairo_line_to (cr, 1.000, 12.000); cairo_curve_to (cr, 1.000, 5.000, 6.000, 1.000, 13.000, 1.000); cairo_line_to (cr, 51.000, 1.000); cairo_curve_to (cr, 58.000, 1.000, 63.000, 5.000, 63.000, 12.000); cairo_close_path (cr); } static void draw_outline (cairo_t *cr) { cairo_set_source_rgb (cr, 0.73, 0.73, 0.73); cairo_set_line_width (cr, 2); draw_boundary (cr); cairo_stroke (cr); } static void draw_background (cairo_t *cr) { cairo_save (cr); cairo_set_source_rgb (cr, 0.231, 0.502, 0.682); cairo_translate (cr, 3.5, 3.5); cairo_scale (cr, 0.887, 0.848); draw_boundary (cr); cairo_fill (cr); cairo_restore (cr); } static void draw_window (cairo_t *cr) { cairo_move_to (cr, -6.00, -7.125); cairo_line_to (cr, 6.00, -7.125); cairo_curve_to (cr, 8.00, -7.125, 9.00, -6.125, 9.00, -4.125); cairo_line_to (cr, 9.00, 4.125); cairo_curve_to (cr, 9.00, 6.125, 8.00, 7.125, 6.00, 7.125); cairo_line_to (cr, -6.00, 7.125); cairo_curve_to (cr, -8.00, 7.125, -9.00, 6.125, -9.00, 4.125); cairo_line_to (cr, -9.00, -4.125); cairo_curve_to (cr, -9.00, -6.125, -8.00, -7.125, -6.00, -7.125); cairo_close_path (cr); } static void draw_window_at (cairo_t *cr, double x, double y, double scale) { cairo_save (cr); { cairo_translate (cr, x, y); cairo_scale (cr, scale, scale); draw_window (cr); cairo_save (cr); { cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); } cairo_restore (cr); cairo_set_source_rgb (cr, 0.231, 0.502, 0.682); cairo_scale (cr, 1/scale, 1/scale); cairo_stroke (cr); } cairo_restore (cr); } static void draw_windows (cairo_t *cr) { cairo_save (cr); { cairo_move_to (cr, 18.00, 16.125); cairo_line_to (cr, 48.25, 20.375); cairo_line_to (cr, 30.25, 35.825); cairo_close_path (cr); cairo_set_source_rgba (cr, 1, 1, 1, 0.5); cairo_stroke (cr); } cairo_restore (cr); draw_window_at (cr, 18.00, 16.125, 1); draw_window_at (cr, 48.25, 20.375, 0.8); draw_window_at (cr, 30.25, 35.825, 0.5); } #define FDLOGO_ROT_X_FACTOR 1.086 #define FDLOGO_ROT_Y_FACTOR 1.213 #define FDLOGO_WIDTH (64 * FDLOGO_ROT_X_FACTOR) #define FDLOGO_HEIGHT (48 * FDLOGO_ROT_Y_FACTOR) void fdlogo_draw (cairo_t *cr, double width, double height) { double x_scale, y_scale, scale, x_off, y_off; cairo_save (cr); x_scale = width / FDLOGO_WIDTH; y_scale = height / FDLOGO_HEIGHT; scale = x_scale < y_scale ? x_scale : y_scale; x_off = (width - (scale * FDLOGO_WIDTH)) / 2; y_off = (height - (scale * FDLOGO_HEIGHT)) / 2; cairo_translate (cr, x_off, y_off); cairo_scale (cr, scale, scale); cairo_translate (cr, -2.5, 14.75); cairo_rotate (cr, -0.274990703529840); draw_outline (cr); draw_background (cr); draw_windows (cr); cairo_restore (cr); } fdclock-20071208/fdlogo.h000064400000000000000000000024661072637454000150250ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FDLOGO_H_ #define _FDLOGO_H_ #include #include void fdlogo_draw (cairo_t *cr, double width, double height); #endif /* _FDLOGO_H_ */ fdclock-20071208/findargb.c000064400000000000000000000035311072637454000153140ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #include "findargb.h" Visual * find_argb_visual (Display *dpy, int scr) { XVisualInfo *xvi; XVisualInfo template; int nvi; int i; XRenderPictFormat *format; Visual *visual; template.screen = scr; template.depth = 32; template.class = TrueColor; xvi = XGetVisualInfo (dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &template, &nvi); if (!xvi) return 0; visual = 0; for (i = 0; i < nvi; i++) { format = XRenderFindVisualFormat (dpy, xvi[i].visual); if (format->type == PictTypeDirect && format->direct.alphaMask) { visual = xvi[i].visual; break; } } XFree (xvi); return visual; } fdclock-20071208/findargb.h000064400000000000000000000024641072637454000153250ustar00rootroot00000000000000/* * $Id$ * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Keith Packard not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Keith Packard makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FINDARGB_H_ #define _FINDARGB_H_ #include #include Visual * find_argb_visual (Display *dpy, int scr); #endif