2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / gnu / gcj / xlib / natWMSizeHints.cc
blob0724a5a0925c77f85923ac04ac5670c3bf0c63fd
1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 #include <X11/Xlib.h>
10 #include <X11/Xutil.h>
12 #include <gcj/cni.h>
13 #include <gnu/gcj/RawData.h>
14 #include <java/lang/OutOfMemoryError.h>
16 #include <gnu/gcj/xlib/Window.h>
17 #include <gnu/gcj/xlib/Display.h>
18 #include <gnu/gcj/xlib/WMSizeHints.h>
20 void gnu::gcj::xlib::WMSizeHints::init(WMSizeHints* copyFrom)
22 XSizeHints* hints = XAllocSizeHints();
23 if (hints == 0)
25 jstring errorMessage = JvNewStringLatin1("XAllocSizeHints failed");
26 throw new java::lang::OutOfMemoryError(errorMessage);
29 if (copyFrom != 0)
31 XSizeHints* from = (XSizeHints*) copyFrom->structure;
32 (*hints) = (*from);
34 else
36 // Is this necessary?
37 hints->flags = 0;
39 structure = reinterpret_cast<gnu::gcj::RawData*>(hints);
42 void gnu::gcj::xlib::WMSizeHints::finalize()
44 delete structure;
47 void gnu::gcj::xlib::WMSizeHints::applyNormalHints(gnu::gcj::xlib::Window* window)
49 Display* display = window->display;
50 ::Display* dpy = (::Display*) display->display;
51 ::Window win = window->getXID();
52 XSizeHints* hints = (XSizeHints*) structure;
54 XSetWMNormalHints(dpy, win, hints);
55 /* FIXME, alternative?
56 // X11 source reports XSetWMNormalHints() as an old routine. (?)
57 XSetWMSizeHints(dpy, win, hints, display->getAtom("WM_NORMAL_HINTS"));
61 void gnu::gcj::xlib::WMSizeHints::setMinSize(jint width, jint height)
63 XSizeHints* hints = (XSizeHints*) structure;
64 hints->min_width = width;
65 hints->min_height = height;
66 hints->flags = hints->flags | PMinSize;
69 void gnu::gcj::xlib::WMSizeHints::setMaxSize(jint width, jint height)
71 XSizeHints* hints = (XSizeHints*) structure;
72 hints->max_width = width;
73 hints->max_height = height;
74 hints->flags = hints->flags | PMaxSize;