~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to ddd/grabtest.C

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: grabtest.C,v 1.3 1999/08/19 11:28:37 andreas Exp $
2
 
// Simple grab tester -- debug this with DDD and `checkGrab' enabled.
3
 
 
4
 
// Copyright (C) 1998 Technische Universitaet Braunschweig, Germany.
5
 
// Written by Andreas Zeller <zeller@gnu.org>.
6
 
// 
7
 
// This file is part of DDD.
8
 
// 
9
 
// DDD is free software; you can redistribute it and/or
10
 
// modify it under the terms of the GNU General Public
11
 
// License as published by the Free Software Foundation; either
12
 
// version 2 of the License, or (at your option) any later version.
13
 
// 
14
 
// DDD is distributed in the hope that it will be useful,
15
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
 
// See the GNU General Public License for more details.
18
 
// 
19
 
// You should have received a copy of the GNU General Public
20
 
// License along with DDD -- see the file COPYING.
21
 
// If not, write to the Free Software Foundation, Inc.,
22
 
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
 
// 
24
 
// DDD is the data display debugger.
25
 
// For details, see the DDD World-Wide-Web page, 
26
 
// `http://www.gnu.org/software/ddd/',
27
 
// or send a mail to the DDD developers <ddd@gnu.org>.
28
 
 
29
 
 
30
 
#include <X11/Xlib.h>
31
 
#include <unistd.h>             // sleep()
32
 
#include <stdlib.h>             // atoi()
33
 
#include <sys/types.h>
34
 
#include <iostream.h>
35
 
#include <signal.h>
36
 
 
37
 
int main(int argc, char *argv[])
38
 
{
39
 
    Display *display = XOpenDisplay((char *)0);
40
 
    if (display == 0)
41
 
    {
42
 
        cerr << "Cannot open display\n";
43
 
        exit(1);
44
 
    }
45
 
    Window window = DefaultRootWindow(display);
46
 
 
47
 
    int seconds = 5;
48
 
    if (argc > 1 && atoi(argv[1]) > 0)
49
 
        seconds = atoi(argv[1]);
50
 
    
51
 
    cout << "Grabbing...";
52
 
    cout.flush();
53
 
 
54
 
    // We pass GrabModeAsync for the keyboard such that it will keep
55
 
    // on working.
56
 
    int grab_result = XGrabPointer(display, window,
57
 
                                   True, 0, GrabModeSync, GrabModeAsync,
58
 
                                   None, None, CurrentTime);
59
 
 
60
 
    // Placing a breakpoint
61
 
    //
62
 
    // <====== here
63
 
    //
64
 
    // will interrupt this function while the pointer is grabbed.
65
 
    // Rely on DDD `checkGrab' to ungrab it.
66
 
 
67
 
    switch (grab_result)
68
 
    {
69
 
    case GrabSuccess:
70
 
        cout << "GrabSuccess\n";
71
 
        cout << "Sleeping for " << seconds << " seconds...";
72
 
        cout.flush();
73
 
 
74
 
        sleep(seconds);
75
 
        XUngrabPointer(display, CurrentTime);
76
 
        XFlush(display);
77
 
 
78
 
        cout << "done.\n";
79
 
        break;
80
 
 
81
 
    case GrabNotViewable:
82
 
        cout << "GrabNotViewable\n";
83
 
        break;
84
 
 
85
 
    case AlreadyGrabbed:
86
 
        cout << "AlreadyGrabbed\n";
87
 
        break;
88
 
 
89
 
    case GrabFrozen:
90
 
        cout << "GrabFrozen\n";
91
 
        break;
92
 
 
93
 
    case GrabInvalidTime:
94
 
        cout << "GrabInvalidTime\n";
95
 
        break;
96
 
 
97
 
    default:
98
 
        cout << grab_result << "\n";
99
 
        break;
100
 
    }
101
 
 
102
 
    exit(0);
103
 
}