summaryrefslogtreecommitdiff
path: root/src/test-fade.c.orig
blob: 894085ce3ffd0ef34a0e377fd9042e557414a823 (plain)
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * Authors: William Jon McCann <mccann@jhu.edu>
 *
 */

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>

#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>

#include "gs-fade.h"
#include "gs-debug.h"

#ifdef HAVE_XF86VMODE_GAMMA
# include <X11/extensions/xf86vmode.h>
#endif

#define XF86_VIDMODE_NAME "XFree86-VidModeExtension"

static void
test_fade (void)
{
    GSFade *fade;
    int     reps = 2;
    int     delay = 2;

    fade = gs_fade_new ();

    while (reps-- > 0)
    {

        g_print ("fading out...");
        gs_fade_sync (fade, 1000);
        g_print ("done.\n");

        g_print ("fading in...");
        gs_fade_reset (fade);
        g_print ("done.\n");

        if (delay)
        {
            sleep (delay);
        }
    }

    g_object_unref (fade);
}

int
main (int    argc,
      char **argv)
{
    GError *error = NULL;
    int     op, event, err;

#ifdef ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
    textdomain (GETTEXT_PACKAGE);
#endif

    if (error)
    {
        fprintf (stderr, "%s\n", error->message);
        exit (1);
    }

    if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
    {
        fprintf (stderr, "%s", error->message);
        g_error_free (error);
        exit (1);
    }

    if (! XQueryExtension (GDK_DISPLAY (), XF86_VIDMODE_NAME, &op, &event, &err))
    {
        g_message ("no " XF86_VIDMODE_NAME " extension");
    }
    else
    {
# ifdef HAVE_XF86VMODE_GAMMA
        int major;
        int minor;

        if (! XF86VidModeQueryVersion (GDK_DISPLAY (), &major, &minor))
        {
            g_message ("unable to get " XF86_VIDMODE_NAME " version");
        }
        else
        {
            g_message (XF86_VIDMODE_NAME " version %d.%d", major, minor);
        }
# else /* !HAVE_XF86VMODE_GAMMA */
        g_message ("no support for display's " XF86_VIDMODE_NAME " extension");
# endif /* !HAVE_XF86VMODE_GAMMA */
    }

    gs_debug_init (TRUE, FALSE);

    test_fade ();

    gs_debug_shutdown ();

    return 0;
}