source: trunk/gcc/libjava/gnu/gcj/xlib/natWindowAttributes.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.8 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 <gnu/gcj/xlib/Display.h>
15#include <gnu/gcj/xlib/Window.h>
16#include <gnu/gcj/xlib/WindowAttributes.h>
17#include <gnu/gcj/xlib/Pixmap.h>
18#include <gnu/gcj/xlib/XException.h>
19#include <gnu/gcj/xlib/Screen.h>
20#include <gnu/gcj/xlib/Visual.h>
21
22
23void gnu::gcj::xlib::WindowAttributes::initFromWindow(Window* from)
24{
25 display = from->getDisplay();
26 ::Display* dpy = (::Display*) display->display;
27 ::Window win = from->getXID();
28
29 XWindowAttributes* attributesIn = new XWindowAttributes;
30 in = reinterpret_cast<gnu::gcj::RawData*>(attributesIn);
31
32 Status status = XGetWindowAttributes(dpy, win, attributesIn);
33 if ((status == BadDrawable) | (status == BadWindow))
34 throw new XException(display, status);
35}
36
37
38void gnu::gcj::xlib::WindowAttributes::init(WindowAttributes* copyFrom)
39{
40 XSetWindowAttributes* attributes = new XSetWindowAttributes;
41
42 if (copyFrom != 0)
43 {
44 XSetWindowAttributes* from =
45 (XSetWindowAttributes*) copyFrom->out;
46 (*attributes) = (*from);
47 }
48
49 out = reinterpret_cast<gnu::gcj::RawData*>(attributes);
50}
51
52void gnu::gcj::xlib::WindowAttributes::finalize()
53{
54 delete in; in = 0;
55 delete out; out = 0;
56}
57
58void gnu::gcj::xlib::WindowAttributes::setBackground(jlong pixel)
59{
60 XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
61
62 attributes->background_pixel = pixel;
63 mask = mask | CWBackPixel;
64}
65
66void gnu::gcj::xlib::WindowAttributes::setBackground(Pixmap* pixmap)
67{
68 XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
69
70 attributes->background_pixmap = pixmap->getXID();
71 mask = mask | CWBackPixmap;
72}
73
74void gnu::gcj::xlib::WindowAttributes::setEventMask(jlong eventMask)
75{
76 XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
77
78 attributes->event_mask = eventMask;
79 mask = mask | CWEventMask;
80}
81
82gnu::gcj::xlib::Visual* gnu::gcj::xlib::WindowAttributes::getVisual()
83{
84 if (in == 0)
85 return 0;
86
87 XWindowAttributes* attributesIn = (XWindowAttributes*) in;
88
89 gnu::gcj::RawData* screenRef =
90 reinterpret_cast<gnu::gcj::RawData*>(attributesIn->screen);
91
92 Screen* screen = new Screen(display, screenRef);
93
94 gnu::gcj::RawData* visualRef =
95 reinterpret_cast<gnu::gcj::RawData*>(attributesIn->visual);
96
97 return new gnu::gcj::xlib::Visual(visualRef, screen, attributesIn->depth);
98}
99
100
101void gnu::gcj::xlib::WindowAttributes::apply(Window* window)
102{
103 ::Display* dpy = (::Display*) window->getDisplay()->display;
104 ::Window win = window->getXID();
105 XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
106
107 XChangeWindowAttributes(dpy, win, mask, attributes);
108}
109
Note: See TracBrowser for help on using the repository browser.