JX Application Framework
|
#include <JXDisplay.h>
Classes | |
struct | WMBehavior |
class | XError |
class | XEventMessage |
Public Member Functions | |
~JXDisplay () override | |
bool | Close () |
operator Display * () const | |
const JString & | GetName () const |
Display * | GetXDisplay () const |
JXColorManager * | GetColorManager () const |
JSize | GetMaxStringByteCount () const |
bool | IsMacOS () const |
JFontManager * | GetFontManager () const |
JXFontManager * | GetXFontManager () const |
JXSelectionManager * | GetSelectionManager () const |
JXDNDManager * | GetDNDManager () const |
JXMenuManager * | GetMenuManager () const |
bool | GetWDManager (JXWDManager **mgr) const |
JXImageCache * | GetImageCache () const |
JCursorIndex | CreateBuiltInCursor (const JUtf8Byte *name, const unsigned int shape) |
JCursorIndex | CreateCustomCursor (const JUtf8Byte *name, const JXCursor &cursor) |
bool | GetCursor (const JUtf8Byte *name, JCursorIndex *index) const |
void | DisplayCursorInAllWindows (const JCursorIndex index) |
void | Beep () const |
void | RaiseAllWindows () |
void | HideAllWindows () |
void | UndockAllWindows () |
void | CloseAllOtherWindows (JXWindow *window) |
void | GetCurrentButtonKeyState (JXButtonStates *buttonStates, JXKeyModifiers *modifiers) const |
const JXButtonStates & | GetLatestButtonStates () const |
const JXKeyModifiers & | GetLatestKeyModifiers () const |
bool | KeysymToModifier (const KeySym keysym, JIndex *modifierIndex) const |
bool | KeycodeToModifier (const KeyCode keycode, JIndex *modifierIndex) const |
void | Flush () const |
void | Synchronize () const |
void | SendXEvent (const Window xWindow, XEvent *xEvent, const long mask=0) const |
bool | FindMouseContainer (JXContainer **obj, Window *xWindow=nullptr, JPoint *ptG=nullptr, JPoint *ptR=nullptr) const |
bool | FindMouseContainer (const JXContainer *coordOwner, const JPoint &pt, JXContainer **obj, Window *xWindow=nullptr, JPoint *ptG=nullptr, JPoint *ptR=nullptr) const |
void | HandleEvent (const XEvent &xEvent, const Time currentTime) |
void | Idle (const Time currentTime) |
void | Update () |
void | DispatchMouse () |
void | DispatchCursor () |
void | ShrinkDisplayBoundsToActiveScreen () |
void | RestoreDisplayBounds () |
void | WindowCreated (JXWindow *window, const Window xWindow) |
void | WindowDeleted (JXWindow *window) |
void | WindowNeedsUpdate (JXWindow *window) |
bool | GetMouseContainer (JXWindow **window) const |
void | SetMouseContainer (JXWindow *window) |
bool | GetMouseGrabber (JXWindow **window) const |
void | SetMouseGrabber (JXWindow *window) |
Cursor | GetXCursorID (const JCursorIndex index) const |
Atom | GetWMProtocolsXAtom () const |
Atom | GetWMClientMachineXAtom () const |
Atom | GetDeleteWindowXAtom () const |
Atom | GetWMPingXAtom () const |
Atom | GetWMPidXAtom () const |
Atom | GetWMUserTimeXAtom () const |
Atom | GetWMActiveWindowXAtom () const |
Atom | GetSaveYourselfXAtom () const |
Atom | GetWMStateXAtom () const |
Atom | GetWMDesktopXAtom () const |
Atom | GetWMCurrentDesktopXAtom () const |
Atom | GetWMWindowTypeXAtom () const |
Atom | GetWMWindowTypeXAtom (const JIndex type) const |
const WMBehavior & | GetWMBehavior () const |
void | SetWMBehavior (const WMBehavior &behavior) |
bool | SwitchDrag (JXContainer *fromObj, const JPoint &fromObjPt, const JXButtonStates &buttonStates, const JXKeyModifiers &modifiers, JXContainer *toObj) |
bool | GetKeyboardGrabber (JXWindow **window) const |
void | SetKeyboardGrabber (JXWindow *window) |
JXWDManager * | GetWDManager () const |
void | SetWDManager (JXWDManager *mgr) |
int | GetScreen () const |
Visual * | GetDefaultVisual () const |
JSize | GetDepth () const |
JSize | GetHorizResolution () const |
JSize | GetVertResolution () const |
Window | GetRootWindow () const |
JRect | GetBounds () const |
const JXGC * | GetDefaultGC () const |
Time | GetLastEventTime () const |
Atom | RegisterXAtom (const JUtf8Byte *name) |
void | RegisterXAtoms (const JSize count, const JUtf8Byte **name, Atom *atom) |
bool | FindXWindow (const Window xWindow, JXWindow **window) const |
const int * | GetJXKeyModifierMapping () const |
XIM | GetXIM () const |
![]() | |
JBroadcaster () | |
virtual | ~JBroadcaster () |
JBroadcaster & | operator= (const JBroadcaster &source) |
bool | HasSenders () const |
JSize | GetSenderCount () const |
bool | HasRecipients () const |
JSize | GetRecipientCount () const |
virtual JString | ToString () const |
template<class T > | |
void | ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f) |
Static Public Member Functions | |
static bool | Create (const JString &displayName, JXDisplay **display) |
static bool | WindowExists (JXDisplay *display, const Display *xDisplay, const Window xWindow) |
static void | CheckForXErrors () |
static int | JXErrorHandler (Display *xDisplay, XErrorEvent *error) |
Static Public Attributes | |
static const JUtf8Byte * | kXEventMessage = "XEventMessage::JXDisplay" |
static const JUtf8Byte * | kXError = "XError::JXDisplay" |
Protected Member Functions | |
JXDisplay (const JString &displayName, Display *xDisplay) | |
![]() | |
JBroadcaster (const JBroadcaster &source) | |
void | ListenTo (const JBroadcaster *sender) |
void | StopListening (const JBroadcaster *sender) |
void | ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember) |
void | StopListening (const JBroadcaster *sender, const std::type_info &messageType) |
template<class T > | |
void | Send (JBroadcaster *recipient, const T &message) |
template<class T > | |
void | Broadcast (const T &message) |
virtual void | Receive (JBroadcaster *sender, const Message &message) |
void | SendWithFeedback (JBroadcaster *recipient, Message *message) |
void | BroadcastWithFeedback (Message *message) |
virtual void | ReceiveWithFeedback (JBroadcaster *sender, Message *message) |
virtual void | ReceiveGoingAway (JBroadcaster *sender) |
Represents a single X Display. We consider a display to be an X server plus a particular screen. Since cursors should be the same on every display, but each X server will provide different cursor id's, we hide cursors behind JCursorIndex. Cursors are bulky and difficult to compare, so we require that each one be given a unique name. This way, every client that needs a particular cursor can use GetCursor() with only the name. Only if GetCursor() fails does one of the cursor creation routines need to be called. There are two such routines because X makes a distinction between the default cursor font and custom cursors. Cursor names can be anything, as long as they don't conflict. All objects that use a particular cursor must know the name. Since the X cursor font can be used by all objects, it is suggested that one uses the name of the associated XC_* constant as the cursor name. We cannot sort the cursor array because the indices that we give out must remain valid. Appending new items is the only option. This is not much of a problem, however, both because the most common cursors have predefined indices, and because looking up cursors only has to be done once in each constructor. Because we are receiving events over a network which introduces an arbitrary delay between the occurrence of an event and our processing of it, mouse and keyboard events can be reported for the wrong (original) window while we are switching a grab from one window to another. (e.g. The user releases the mouse so soon after we switch the grab that the server hasn't received our message and therefore thinks that the original window is still grabbing. We therefore get the ButtonRelease for the original window instead of for the new window.) Our solution is to tell JXDisplay about who has grabbed what so JXDisplay can re-route the message to the current grabber. This is what itsMouseGrabber and itsKeyboardGrabber are used for.
anonymous enum |
|
override |
We should only be deleted after all windows have been closed.
|
protected |
|
inline |
|
static |
void JXDisplay::CloseAllOtherWindows | ( | JXWindow * | window | ) |
Calls Close() on all windows except the given one.
By forcing everyone to use this function, we avoid having to worry about XOpenDisplay succeeding within the class itself.
Note that this prevents one from creating derived classes.
JCursorIndex JXDisplay::CreateBuiltInCursor | ( | const JUtf8Byte * | name, |
const unsigned int | shape | ||
) |
JCursorIndex JXDisplay::CreateCustomCursor | ( | const JUtf8Byte * | name, |
const JXCursor & | cursor | ||
) |
void JXDisplay::DispatchCursor | ( | ) |
void JXDisplay::DispatchMouse | ( | ) |
void JXDisplay::DisplayCursorInAllWindows | ( | const JCursorIndex | index | ) |
Displays the specified cursor in all windows on this display. Mainly useful for displaying the watch cursor or the inactive cursor.
bool JXDisplay::FindMouseContainer | ( | const JXContainer * | coordOwner, |
const JPoint & | pt, | ||
JXContainer ** | obj, | ||
Window * | xWindow = nullptr , |
||
JPoint * | ptG = nullptr , |
||
JPoint * | ptR = nullptr |
||
) | const |
bool JXDisplay::FindMouseContainer | ( | JXContainer ** | obj, |
Window * | xWindow = nullptr , |
||
JPoint * | ptG = nullptr , |
||
JPoint * | ptR = nullptr |
||
) | const |
Returns true if the mouse is in one of our windows.
Regardless of the return value, if xWindow is not nullptr, it is set to the id of the X window that the cursor is in. ptG is set to the mouse coordinates relative to xWindow, and ptR contains the mouse coordinates relative to the root window.
Returns true if the given xWindow is registered. Since the window list is sorted by xWindow, we use an O(log(N)) binary search.
We can't call it FindWindow() because Windows #define's FindWindow to FindWindowA.
|
inline |
JRect JXDisplay::GetBounds | ( | ) | const |
|
inline |
void JXDisplay::GetCurrentButtonKeyState | ( | JXButtonStates * | buttonStates, |
JXKeyModifiers * | modifiers | ||
) | const |
Call these if you need to get information more current than the latest event. This is useful if you need the state of the Shift key because pressing Shift doesn't generate an event.
buttonStates and/or modifiers can be nullptr.
bool JXDisplay::GetCursor | ( | const JUtf8Byte * | name, |
JCursorIndex * | index | ||
) | const |
Returns true if a cursor with the given name has been created.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
JFontManager * JXDisplay::GetFontManager | ( | ) | const |
Not inline to avoid including <JXFontManager.h> in header file.
JSize JXDisplay::GetHorizResolution | ( | ) | const |
Screen resolution in pixels/inch (25.4 mm = 1 inch)
|
inline |
|
inline |
|
inline |
Use these as a last resort if there is no other way to obtain the information. Most of the time, everything you need is passed to the event handler (e.g. HandleMouseDrag(), HandleKeyPress(), etc.)
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
JSize JXDisplay::GetVertResolution | ( | ) | const |
JXWDManager * JXDisplay::GetWDManager | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void JXDisplay::HandleEvent | ( | const XEvent & | xEvent, |
const Time | currentTime | ||
) |
JXSelectionManager handles all the selection events. All other events go to the appropriate window.
void JXDisplay::HideAllWindows | ( | ) |
Hide all windows on this display. Mainly useful when quitting.
void JXDisplay::Idle | ( | const Time | currentTime | ) |
Redraw our windows and send a fake motion event.
If the mouse is not pressed, we send idle events relatively slowly so that we don't hog CPU time.
When the mouse is pressed, we send one at every opportunity because the user presumably doesn't care how much CPU time we use.
|
inline |
|
static |
Converts an X keycode into an X modifier index.
Converts an X keysym into an X modifier index.
|
inline |
void JXDisplay::RaiseAllWindows | ( | ) |
Raises all visible, non-iconified windows and maintains the stacking order.
|
inline |
void JXDisplay::RestoreDisplayBounds | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
void JXDisplay::SetWDManager | ( | JXWDManager * | mgr | ) |
|
inline |
void JXDisplay::ShrinkDisplayBoundsToActiveScreen | ( | ) |
bool JXDisplay::SwitchDrag | ( | JXContainer * | fromObj, |
const JPoint & | fromObjPt, | ||
const JXButtonStates & | buttonStates, | ||
const JXKeyModifiers & | modifiers, | ||
JXContainer * | toObj | ||
) |
Switch the current mouse drag messages from one widget to another.
|
inline |
void JXDisplay::UndockAllWindows | ( | ) |
void JXDisplay::Update | ( | ) |
Give each window a chance to redraw itself. Since this routine is an idle task, we use a single flag to make sure that it doesn't do more work than it has to.
void JXDisplay::WindowCreated | ( | JXWindow * | window, |
const Window | xWindow | ||
) |
Insert the new window so that the list remains sorted by xWindow values.
void JXDisplay::WindowDeleted | ( | JXWindow * | window | ) |
|
static |
Returns true if the given window hasn't been deleted. Since we cannot assume that anything exists, everything that we need must be passed in.
|
inline |
|
static |
|
static |