source: trunk/gcc/libjava/gnu/gcj/xlib/natXAnyEvent.cc

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1/* Copyright (C) 2000 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9#include <X11/Xlib.h>
10
11#include <gcj/cni.h>
12#include <gnu/gcj/RawData.h>
13
14#include <java/lang/RuntimeException.h>
15
16#include <java/lang/System.h>
17#include <java/io/PrintStream.h>
18
19#include <gnu/gcj/xlib/Display.h>
20#include <gnu/gcj/xlib/Window.h>
21#include <gnu/gcj/xlib/XAnyEvent.h>
22#include <gnu/gcj/xlib/XExposeEvent.h>
23#include <gnu/gcj/xlib/XException.h>
24
25void gnu::gcj::xlib::XAnyEvent::init()
26{
27 ::XEvent* event = new ::XEvent;
28 structure = reinterpret_cast<gnu::gcj::RawData*>(event);
29}
30
31void gnu::gcj::xlib::XAnyEvent::finalize()
32{
33 delete structure;
34 structure = 0;
35}
36
37void gnu::gcj::xlib::XAnyEvent::loadNext()
38{
39 ::Display* dpy = (::Display*) display->display;
40 ::XEvent* evt = (::XEvent*) structure;
41 XNextEvent(dpy, evt);
42 // What does XNextEvent return?
43}
44
45jint gnu::gcj::xlib::XAnyEvent::getType()
46{
47 ::XEvent* event = (::XEvent*) structure;
48 return event->type;
49}
50
51void gnu::gcj::xlib::XAnyEvent::setType(jint type)
52{
53 ::XEvent* event = (::XEvent*) structure;
54 event->type = type;
55}
56
57gnu::gcj::xlib::Window* gnu::gcj::xlib::XAnyEvent::getWindow()
58{
59 ::XEvent* event = (::XEvent*) structure;
60 return display->getWindow(event->xany.window);
61}
62
63void gnu::gcj::xlib::XAnyEvent::setWindow(gnu::gcj::xlib::Window* window)
64{
65 ::XEvent* event = (::XEvent*) structure;
66 event->xany.window = window->getXID();
67}
68
69jlong gnu::gcj::xlib::XAnyEvent::getSerial()
70{
71 ::XEvent* event = (::XEvent*) structure;
72 return event->xany.serial;
73}
74
75void gnu::gcj::xlib::XAnyEvent::send(gnu::gcj::xlib::Window* destination,
76 jboolean propagate, jlong mask)
77{
78 ::Display* dpy = (::Display*) display->display;
79 ::XEvent* event = (::XEvent*) structure;
80
81 Status status =
82 XSendEvent(dpy, destination->getXID(), propagate ? True : False,
83 mask, event);
84
85 switch (status)
86 {
87 case 0:
88 throw new XException(JvNewStringLatin1("conversion to wire "
89 "protocol failed"));
90 case BadWindow:
91 case BadValue:
92 throw new XException(display, status);
93
94 default:
95 /* All other return values indicate success. Ie. (status ==
96 1) indicates success, not BadRequest. */
97 ; // NOP
98 }
99}
Note: See TracBrowser for help on using the repository browser.