OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [xlib/] [natWindow.cc] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2000  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
8
 
9
// Needed to avoid linking in libstdc++
10
#ifndef __STL_USE_EXCEPTIONS
11
#   include <java/lang/OutOfMemoryError.h>
12
#   define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError()
13
#endif
14
 
15
#include <vector>
16
 
17
#include <X11/Xlib.h>
18
#include <gcj/cni.h>
19
#include <java/awt/Rectangle.h>
20
#include <gnu/gcj/xlib/Display.h>
21
#include <gnu/gcj/xlib/Window.h>
22
#include <gnu/gcj/xlib/WindowAttributes.h>
23
#include <gnu/gcj/xlib/Visual.h>
24
#include <gnu/gcj/xlib/XException.h>
25
 
26
jint gnu::gcj::xlib::Window::createChildXID(::java::awt::Rectangle* bounds,
27
                                        jint borderWidth,
28
                                        WindowAttributes* attributes,
29
                                        jint windowIOClass,
30
                                        Visual* visual)
31
{
32
  ::Window parentXID = xid;
33
 
34
  int x      = bounds->x;
35
  int y      = bounds->y;
36
  int width  = bounds->width;
37
  int height = bounds->height;
38
 
39
  long mask = attributes->mask;
40
  XSetWindowAttributes* attr = (XSetWindowAttributes*)
41
    attributes->getXSetWindowAttributesStructure();
42
 
43
  ::Visual* vis = CopyFromParent;
44
  int depth = CopyFromParent;
45
  if (visual != 0)
46
    {
47
      vis = (::Visual*) visual->getVisualStructure();
48
      depth = visual->getDepth();
49
    }
50
 
51
  ::Window childXID = XCreateWindow((::Display*) (display->display),
52
                                    parentXID,
53
                                    x, y, width, height,
54
                                    borderWidth, depth, windowIOClass,
55
                                    vis,
56
                                    mask, attr);
57
  // no fast fail
58
  return childXID;
59
}
60
 
61
void gnu::gcj::xlib::Window::destroy()
62
{
63
  ::Display* dpy = (::Display*) (display->display);
64
  ::Window window = xid;
65
  XDestroyWindow(dpy, window);
66
  // no fast fail
67
}
68
 
69
void gnu::gcj::xlib::Window::setAttributes(WindowAttributes* attributes)
70
{
71
  ::Display* dpy = (::Display*) (display->display);
72
  ::Window window = xid;
73
  ::XSetWindowAttributes* attr = (::XSetWindowAttributes*)
74
      attributes->getXSetWindowAttributesStructure();
75
 
76
  XChangeWindowAttributes(dpy, window, attributes->mask, attr);
77
  // no fast fail
78
}
79
 
80
void gnu::gcj::xlib::Window::toBack()
81
{
82
  ::Display* dpy = (::Display*) (display->display);
83
  ::Window window = xid;
84
  XLowerWindow(dpy, window);
85
}
86
 
87
void gnu::gcj::xlib::Window::toFront()
88
{
89
  ::Display* dpy = (::Display*) (display->display);
90
  ::Window window = xid;
91
  XRaiseWindow(dpy, window);
92
}
93
 
94
void gnu::gcj::xlib::Window::map()
95
{
96
  ::Display* dpy = (::Display*) (display->display);
97
  ::Window window = xid;
98
  XMapWindow(dpy, window);
99
  // no fast fail
100
}
101
 
102
void gnu::gcj::xlib::Window::unmap()
103
{
104
  ::Display* dpy = (::Display*) (display->display);
105
  ::Window window = xid;
106
  XUnmapWindow(dpy, window);
107
  // no fast fail
108
}
109
 
110
void gnu::gcj::xlib::Window::setProperty(jint nameAtom, jint typeAtom,
111
                                         jbyteArray data)
112
{
113
  ::Display* dpy = (::Display*) (display->display);
114
  int format = 8;
115
  int mode = PropModeReplace;
116
  unsigned char* pData = (unsigned char*) elements(data);
117
  int len = data->length;
118
 
119
  XChangeProperty(dpy, xid, nameAtom, typeAtom, format, mode,
120
                  pData, len);
121
  // no fast fail
122
}
123
 
124
void gnu::gcj::xlib::Window::setWMProtocols(jintArray atoms)
125
{
126
  ::Display* dpy = (::Display*) (display->display);
127
 
128
  size_t length = atoms->length;
129
  jint* atomsBegin = elements(atoms);
130
  jint* atomsEnd   = atomsBegin + length;
131
 
132
  // Avoid confusion between Xlib.h and Atom.java "Atom" types.
133
  typedef ::Atom XLibAtom;
134
 
135
  std::vector<XLibAtom> atomVector(atomsBegin, atomsEnd);
136
  XLibAtom* atomsArray = &(atomVector.front());
137
 
138
  XSetWMProtocols(dpy, xid, atomsArray, length);
139
  // no fail fast
140
}
141
 
142
jintArray gnu::gcj::xlib::Window::getWMProtocols()
143
{
144
  ::Display* dpy = (::Display*) (display->display);
145
 
146
  ::Atom* protocolsReturn;
147
  int countReturn;
148
 
149
  Status success = XGetWMProtocols(dpy, xid, &protocolsReturn,
150
                                   &countReturn);
151
 
152
  if (!success)
153
    throw new XException(JvNewStringLatin1("cannot get "
154
                                           "WM protocols "));
155
 
156
  jintArray atoms;
157
  try
158
    {
159
      ::Atom* protocolsBegin = protocolsReturn;
160
      ::Atom* protocolsEnd = protocolsBegin + countReturn;
161
 
162
      atoms = JvNewIntArray(countReturn);
163
      jint* atomsBegin = elements(atoms);
164
 
165
      std::copy(protocolsBegin, protocolsEnd, atomsBegin);
166
 
167
    }
168
  catch (...)
169
    {
170
      XFree(protocolsReturn);
171
      throw;
172
    }
173
  XFree(protocolsReturn);
174
 
175
  return atoms;
176
}
177
 
178
void gnu::gcj::xlib::Window::setBounds(jint x, jint y,
179
                                       jint width, jint height)
180
{
181
  ::Display* dpy = (::Display*) (display->display);
182
 
183
  XMoveResizeWindow(dpy, xid, x, y, width, height);
184
  // no fast fail
185
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.