FLTK 1.4.0
Loading...
Searching...
No Matches
x11.H
Go to the documentation of this file.
1//
2// X11 platform header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2022 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17// Do not directly include this file, instead use <FL/platform.H>. It will
18// include this file if FLTK_USE_X11 is defined. This is to encourage
19// portability of even the system-specific code...
20
21#ifdef FL_DOXYGEN
22
28extern Display *fl_x11_display();
34extern void fl_x11_use_display(Display *d);
36extern Window fl_x11_xid(const Fl_Window *win);
38extern Fl_Window *fl_x11_find(Window xid);
40extern GC fl_x11_gc();
42extern cairo_t* fl_cairo_gc();
43#else // ! FL_DOXYGEN
44
45#ifndef FL_PLATFORM_H
46# error "Never use <FL/x11.H> directly; include <FL/platform.H> instead."
47#endif // !FL_PLATFORM_H
48
49#include <FL/Enumerations.H>
50
51#if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
52# pragma set woff 3322
53#endif
54#include <X11/Xlib.h>
55#include <X11/Xutil.h>
56#if defined(_ABIN32) || defined(_ABI64)
57# pragma reset woff 3322
58#endif
59#include <X11/Xatom.h>
60
61typedef struct __GLXcontextRec *GLXContext;
62extern GLXContext fl_x11_glcontext(GLContext rc);
63
64// constant info about the X server connection:
65extern FL_EXPORT Display *fl_display;
66extern FL_EXPORT Display *fl_x11_display();
67extern FL_EXPORT void fl_x11_use_display(Display *);
68extern FL_EXPORT Window fl_x11_xid(const Fl_Window *win);
69extern FL_EXPORT Fl_Window *fl_x11_find(Window);
70extern FL_EXPORT int fl_screen;
71extern FL_EXPORT XVisualInfo *fl_visual;
72extern FL_EXPORT Colormap fl_colormap;
73
74// drawing functions:
75extern FL_EXPORT GC fl_gc;
76#if FLTK_USE_CAIRO
77 typedef struct _cairo cairo_t;
78 extern FL_EXPORT cairo_t* fl_cairo_gc();
79#endif
80extern FL_EXPORT GC fl_x11_gc();
81FL_EXPORT ulong fl_xpixel(Fl_Color i);
82FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
83
84// feed events into fltk:
85FL_EXPORT int fl_handle(const XEvent&);
86
87// you can use these in Fl::add_handler() to look at events:
88extern FL_EXPORT const XEvent* fl_xevent;
89extern FL_EXPORT ulong fl_event_time;
90
91#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
92extern FL_EXPORT Window fl_message_window;
93extern FL_EXPORT void *fl_xftfont;
94
95// access to core fonts:
96// This class provides a "smart pointer" that returns a pointer to an XFontStruct.
97// The global variable fl_xfont can be called wherever a bitmap "core" font is
98// needed, e.g. when rendering to a GL context under X11.
99// With Xlib / X11 fonts, fl_xfont will return the current selected font.
100// With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
101// similar to (usually the same as) the current XFT font.
102class FL_EXPORT Fl_XFont_On_Demand
103{
104public:
105 Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
106 Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
107 { ptr = x.ptr; return *this; }
108 Fl_XFont_On_Demand& operator=(XFontStruct* p)
109 { ptr = p; return *this; }
110 XFontStruct* value();
111 operator XFontStruct*() { return value(); }
112 XFontStruct& operator*() { return *value(); }
113 XFontStruct* operator->() { return value(); }
114 bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
115 bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
116private:
117 XFontStruct *ptr;
118};
119extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
120
121extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
122
123#endif // FL_LIBRARY || FL_INTERNALS
124
125#endif // FL_DOXYGEN
This file contains type definitions and general enumerations.
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
This widget produces an actual window.
Definition Fl_Window.H:55
unsigned char uchar
unsigned char
Definition fl_types.h:30
unsigned long ulong
unsigned long
Definition fl_types.h:32
struct opaque * GLContext
Pointer to a platform-specific structure representing the window's OpenGL rendering context.
Definition platform_types.h:66
GC fl_x11_gc()
Returns the X11-specific currently active graphics context.
Fl_Window * fl_x11_find(Window xid)
Returns the Fl_Window corresponding to the given Window reference.
cairo_t * fl_cairo_gc()
Returns the Cairo-specific currently active graphics context (FLTK_GRAPHICS_CAIRO=On)
Window fl_x11_xid(const Fl_Window *win)
Returns the Window reference for the given Fl_Window, or zero if not shown().
void fl_x11_use_display(Display *d)
Have FLTK use a pre-established X11 connection.
Display * fl_x11_display()
Returns the X11 Display in use.