XCore Class Reference

#include <xcore.h>

Inherits Singleton< XCore >.

Inheritance diagram for XCore:

Inheritance graph
[legend]
Collaboration diagram for XCore:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 XCore ()
 ~XCore ()
void setDisplay (Display *display)
Window createWindow (Window root, XSetWindowAttributes *attr, int x, int y, unsigned int w, unsigned int h, unsigned long mask)
void selectEvents (Window window, long mask)
void setInputFocus (Window window)
void show (Window window)
void showRaised (Window window)
void hide (Window window)
GC createGC (Window window, unsigned long mask, XGCValues *gcv)
void grabKeyboard (Window window)
void ungrabKeyboard ()
void free (void *data)
void sync (bool discard=False)
void setForeground (GC gc, unsigned long color)
void drawLines (Window window, GC gc, XPoint *points, unsigned int num)
void drawLine (Window window, GC gc, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
void drawRectangle (Window window, GC gc, int x, int y, unsigned int w, unsigned int h)
void drawRectangle (Window window, GC gc, Rectangle *rect)
void clearArea (Window window, Rectangle *rect)
void clearArea (Window window, int x, int y, unsigned int w, unsigned int h)
void clearWindow (Window window)
void fillRectangle (Window window, GC gc, Rectangle *rect)
void fillRectangle (Window window, GC gc, int x, int y, unsigned int w, unsigned int h)
XFontStruct * loadQueryFont (string name)
void drawText (Window window, GC gc, int x, int y, string text)
int textWidth (XFontStruct *font, string text)
string className (Window window)
string instanceName (Window window)
int state (Window window)
void setState (Window window, int state)
string atomValue (Window window, Atom atom)
void updateSize (Window window, unsigned int *minW, unsigned int *minH, unsigned int *maxW, unsigned int *maxH, bool *isCentered)
bool hasDecoration (Window window)
Window transient (Window window)
int property (Window window, Atom atom, Atom type, long length, unsigned char **prop)
void configure (Window window, XConfigureEvent *event)
int protocols (Window window)
void sendMessage (Window window, Atom atom, long value)
void kill (Window window, int protos)
void moveResize (Window window, Rectangle *rect)
void destroy (Window window)
void raise (Window window)
void lower (Window window)
void reparent (Window child, Window parent, int x, int y)
void grabKey (Window window, unsigned int modMask, KeyCode keycode)
void ungrabKey (Window window, unsigned int modMask, KeyCode keycode)
void grabButton (Window window, unsigned int modMask, unsigned int button)
void ungrabButton (Window window, unsigned int modMask, unsigned int button)
void grabServer ()
void ungrabServer ()
void grabPointer (Window window, unsigned int mask, Time time, Cursor cursor=None)
void ungrabPointer (Time time)
Atom internAtom (string atom)
Cursor createFontCursor (unsigned int cursor)
void setWindowAttributes (Window window, unsigned int mask, XSetWindowAttributes *attr)
void windowAttributes (Window window, XWindowAttributes *attr)
KeyCode stringToKeyCode (string key)
string keyCodeToString (KeyCode keyCode)
KeySym keyCodeToKeySym (KeyCode keyCode)
string atomName (Atom atom)
void nextEvent (XEvent *event)
bool checkMaskEvent (long mask, XEvent *event)
void translateCoordinates (Window child, Window parent, int srcX, int srcY, int *destX, int *destY)
bool allocNamedColor (Colormap colormap, string name, XColor *color)
void installColormap (Colormap colormap)
Colormap defaultColormap (unsigned int id)
void queryTree (Window root, Window **windows, unsigned int *num)
KeySym lookupNextKeySym (XKeyEvent *event, int *count, char *buffer)
bool textProperty (Window window, Atom atom, string *value)
void stringListToTextProperty (string text, XTextProperty *textProperty)
void setTextProperty (Display *display, Window window, XTextProperty *textProperty, Atom atom)
void configureWindow (Window window, unsigned int mask, XWindowChanges *wc)
XModifierKeymap * modifierMapping ()
void freeModifierMapping (XModifierKeymap *modmap)
void addToSaveSet (Window window)
void removeFromSaveSet (Window window)
void sizeHints (Window window, XSizeHints *sizeHints)
void warpPointer (Window window, int x, int y)
void freeCursor (Cursor cursor)
void maskEvent (unsigned long mask, XEvent *event)
void sendEvent (Window window, unsigned long mask, XEvent *event)
XWMHints * getWMHints (Window window)

Static Public Member Functions

static int handleErrors (Display *display, XErrorEvent *e)

Private Attributes

Display * display_

Detailed Description

This class provides an abstraction layer for graphical user interfaces such as X11 or maybe Y in future.

Definition at line 46 of file xcore.h.


Constructor & Destructor Documentation

XCore::XCore (  ) 

Constructs new kernel instance.

Definition at line 24 of file xcore.cpp.

XCore::~XCore (  ) 

Definition at line 26 of file xcore.cpp.


Member Function Documentation

void XCore::setDisplay ( Display *  display  ) 

Definition at line 28 of file xcore.cpp.

References display_.

Window XCore::createWindow ( Window  root,
XSetWindowAttributes *  attr,
int  x,
int  y,
unsigned int  w,
unsigned int  h,
unsigned long  mask 
)

Creates new window.

Definition at line 32 of file xcore.cpp.

References display_.

void XCore::selectEvents ( Window  window,
long  mask 
)

Selects events specified by mask for window.

Definition at line 49 of file xcore.cpp.

References display_.

void XCore::setInputFocus ( Window  window  ) 

Input focus setting.

Definition at line 467 of file xcore.cpp.

References display_.

void XCore::show ( Window  window  ) 

Shows the specified window. (map)

Definition at line 53 of file xcore.cpp.

References display_.

void XCore::showRaised ( Window  window  ) 

Shows the specified window raised. (map raised)

Definition at line 57 of file xcore.cpp.

References display_.

void XCore::hide ( Window  window  ) 

Hides the window. (unmap)

Definition at line 61 of file xcore.cpp.

References display_.

GC XCore::createGC ( Window  window,
unsigned long  mask,
XGCValues *  gcv 
)

Creates new GC for the specified window, with gcv masked values.

Definition at line 65 of file xcore.cpp.

References display_.

void XCore::grabKeyboard ( Window  window  ) 

Grabs the keyboard for the specific window.

Definition at line 74 of file xcore.cpp.

References display_.

void XCore::ungrabKeyboard (  ) 

Ungrabs the keyboard.

Definition at line 79 of file xcore.cpp.

References display_.

void XCore::free ( void *  data  ) 

Frees the data by X request.

Definition at line 83 of file xcore.cpp.

Referenced by atomValue(), hasDecoration(), property(), protocols(), state(), and textProperty().

void XCore::sync ( bool  discard = False  ) 

Syncs with X.

Definition at line 91 of file xcore.cpp.

References display_.

void XCore::setForeground ( GC  gc,
unsigned long  color 
)

Sets foreground color.

Definition at line 95 of file xcore.cpp.

References display_.

void XCore::drawLines ( Window  window,
GC  gc,
XPoint *  points,
unsigned int  num 
)

Draws lines performantly.

Definition at line 99 of file xcore.cpp.

References display_.

void XCore::drawLine ( Window  window,
GC  gc,
unsigned int  x1,
unsigned int  y1,
unsigned int  x2,
unsigned int  y2 
)

Draws a line.

Definition at line 116 of file xcore.cpp.

References display_.

void XCore::drawRectangle ( Window  window,
GC  gc,
int  x,
int  y,
unsigned int  w,
unsigned int  h 
)

Draws rectangle.

Definition at line 105 of file xcore.cpp.

References display_.

void XCore::drawRectangle ( Window  window,
GC  gc,
Rectangle rect 
)

Draws rectangle.

Definition at line 111 of file xcore.cpp.

References display_, Rectangle::height(), Rectangle::width(), Rectangle::x(), and Rectangle::y().

Here is the call graph for this function:

void XCore::clearArea ( Window  window,
Rectangle rect 
)

Clears the specific area within specified window.

Definition at line 122 of file xcore.cpp.

References display_, Rectangle::height(), Rectangle::width(), Rectangle::x(), and Rectangle::y().

Here is the call graph for this function:

void XCore::clearArea ( Window  window,
int  x,
int  y,
unsigned int  w,
unsigned int  h 
)

Clears the specific area within specified window.

Definition at line 127 of file xcore.cpp.

References display_.

void XCore::clearWindow ( Window  window  ) 

Clears the specified window.

Definition at line 131 of file xcore.cpp.

References display_.

void XCore::fillRectangle ( Window  window,
GC  gc,
Rectangle rect 
)

Fills the specific window with rectangle.

Definition at line 135 of file xcore.cpp.

References display_, Rectangle::height(), Rectangle::width(), Rectangle::x(), and Rectangle::y().

Here is the call graph for this function:

void XCore::fillRectangle ( Window  window,
GC  gc,
int  x,
int  y,
unsigned int  w,
unsigned int  h 
)

Fills the specific window with rectangle.

Definition at line 140 of file xcore.cpp.

References display_.

XFontStruct * XCore::loadQueryFont ( string  name  ) 

Loads the font specified by name.

Definition at line 146 of file xcore.cpp.

References display_.

void XCore::drawText ( Window  window,
GC  gc,
int  x,
int  y,
string  text 
)

Draws a string at (x, y) to the specific window.

Definition at line 150 of file xcore.cpp.

References display_.

int XCore::textWidth ( XFontStruct *  font,
string  text 
)

Returns text width for the given values.

Definition at line 157 of file xcore.cpp.

string XCore::className ( Window  window  ) 

Returns class name for the specific window.

Definition at line 224 of file xcore.cpp.

References display_.

string XCore::instanceName ( Window  window  ) 

Returns instance name for the specific window.

Definition at line 233 of file xcore.cpp.

References display_.

int XCore::state ( Window  window  ) 

Returns state for the specific window.

Definition at line 242 of file xcore.cpp.

References display_, free(), property(), and Atoms::WM_STATE.

Here is the call graph for this function:

void XCore::setState ( Window  window,
int  state 
)

Sets the state for the specific window.

Definition at line 266 of file xcore.cpp.

References display_, and Atoms::WM_STATE.

string XCore::atomValue ( Window  window,
Atom  atom 
)

Returns value of the specific atom as string.

Definition at line 277 of file xcore.cpp.

References free(), and property().

Here is the call graph for this function:

void XCore::updateSize ( Window  window,
unsigned int *  minW,
unsigned int *  minH,
unsigned int *  maxW,
unsigned int *  maxH,
bool *  isCentered 
)

Updates size infos for the specific window.

Definition at line 299 of file xcore.cpp.

References display_, and sizeHints().

Here is the call graph for this function:

bool XCore::hasDecoration ( Window  window  ) 

Returns true if the specific window has MWM decoration.

Definition at line 337 of file xcore.cpp.

References free(), Atoms::MWM_HINTS, MWM_HINTS_DECORATIONS, and property().

Here is the call graph for this function:

Window XCore::transient ( Window  window  ) 

Returns transient for the specific window.

Definition at line 354 of file xcore.cpp.

References display_.

int XCore::property ( Window  window,
Atom  atom,
Atom  type,
long  length,
unsigned char **  prop 
)

Returns property for specific values.

Definition at line 363 of file xcore.cpp.

References display_, and free().

Referenced by atomValue(), handleErrors(), hasDecoration(), protocols(), state(), and textProperty().

Here is the call graph for this function:

void XCore::configure ( Window  window,
XConfigureEvent *  event 
)

Sends configuration to the specific window.

Definition at line 393 of file xcore.cpp.

References display_.

int XCore::protocols ( Window  window  ) 

Returns protocols for the specific window.

Definition at line 399 of file xcore.cpp.

References free(), PDELETE, property(), PTAKEFOCUS, Atoms::WM_DELETE, Atoms::WM_PROTOCOLS, and Atoms::WM_TAKE_FOCUS.

Here is the call graph for this function:

void XCore::sendMessage ( Window  window,
Atom  atom,
long  value 
)

Sends a message to the specific window.

Definition at line 422 of file xcore.cpp.

References display_.

Referenced by kill().

void XCore::kill ( Window  window,
int  protos 
)

Kills the client with the specific window.

Definition at line 436 of file xcore.cpp.

References display_, PDELETE, sendMessage(), Atoms::WM_DELETE, and Atoms::WM_PROTOCOLS.

Here is the call graph for this function:

void XCore::moveResize ( Window  window,
Rectangle rect 
)

Resizes the specific window.

Definition at line 446 of file xcore.cpp.

References display_, Rectangle::height(), Rectangle::width(), Rectangle::x(), and Rectangle::y().

Here is the call graph for this function:

void XCore::destroy ( Window  window  ) 

Destroys the window.

Definition at line 451 of file xcore.cpp.

References display_.

void XCore::raise ( Window  window  ) 

Raises the specific window.

Definition at line 455 of file xcore.cpp.

References display_.

void XCore::lower ( Window  window  ) 

Lowers the specific window.

Definition at line 459 of file xcore.cpp.

References display_.

void XCore::reparent ( Window  child,
Window  parent,
int  x,
int  y 
)

Reparents the specific window.

Definition at line 463 of file xcore.cpp.

References display_.

void XCore::grabKey ( Window  window,
unsigned int  modMask,
KeyCode  keycode 
)

Grabs the key for the specified window.

Definition at line 471 of file xcore.cpp.

References display_.

void XCore::ungrabKey ( Window  window,
unsigned int  modMask,
KeyCode  keycode 
)

Ungrabs key.

Definition at line 69 of file xcore.cpp.

References display_.

void XCore::grabButton ( Window  window,
unsigned int  modMask,
unsigned int  button 
)

Grabs button.

Definition at line 476 of file xcore.cpp.

References display_.

void XCore::ungrabButton ( Window  window,
unsigned int  modMask,
unsigned int  button 
)

Ungrabs button.

Definition at line 482 of file xcore.cpp.

References display_.

void XCore::grabServer (  ) 

Grabs the server.

Definition at line 541 of file xcore.cpp.

References display_.

void XCore::ungrabServer (  ) 

Ungrabs the server.

Definition at line 545 of file xcore.cpp.

References display_.

void XCore::grabPointer ( Window  window,
unsigned int  mask,
Time  time,
Cursor  cursor = None 
)

Grabs the pointer.

Definition at line 549 of file xcore.cpp.

References display_.

void XCore::ungrabPointer ( Time  time  ) 

Ungrabs pointer.

Definition at line 558 of file xcore.cpp.

References display_.

Atom XCore::internAtom ( string  atom  ) 

Returns specified atom.

Definition at line 498 of file xcore.cpp.

References display_.

Cursor XCore::createFontCursor ( unsigned int  cursor  ) 

Returns new font cursor specified by cursor.

Definition at line 503 of file xcore.cpp.

References display_.

void XCore::setWindowAttributes ( Window  window,
unsigned int  mask,
XSetWindowAttributes *  attr 
)

Set window attributes.

Definition at line 486 of file xcore.cpp.

References display_.

void XCore::windowAttributes ( Window  window,
XWindowAttributes *  attr 
)

Writes window attributes to attr.

Definition at line 492 of file xcore.cpp.

References display_.

KeyCode XCore::stringToKeyCode ( string  key  ) 

Returns KeyCode for string.

Definition at line 521 of file xcore.cpp.

References display_.

string XCore::keyCodeToString ( KeyCode  keyCode  ) 

Returns string for KeyCode.

Definition at line 533 of file xcore.cpp.

References display_.

KeySym XCore::keyCodeToKeySym ( KeyCode  keyCode  ) 

Returns KeySym for KeyCode.

Definition at line 529 of file xcore.cpp.

References display_.

string XCore::atomName ( Atom  atom  ) 

Returns name of atom.

Definition at line 508 of file xcore.cpp.

References display_.

void XCore::nextEvent ( XEvent *  event  ) 

Writes next event back to event.

Definition at line 513 of file xcore.cpp.

References display_.

bool XCore::checkMaskEvent ( long  mask,
XEvent *  event 
)

Checks for events specified by mask, returns true if matched.

Definition at line 517 of file xcore.cpp.

References display_.

void XCore::translateCoordinates ( Window  child,
Window  parent,
int  srcX,
int  srcY,
int *  destX,
int *  destY 
)

Translates Coordinates given by srcX and srcY absoluted to child window into destX and destY coordinates absoluted to parent to window.

Definition at line 562 of file xcore.cpp.

References display_.

bool XCore::allocNamedColor ( Colormap  colormap,
string  name,
XColor *  color 
)

Returns true if color could be allocated, otherwise false.

Definition at line 571 of file xcore.cpp.

References display_.

void XCore::installColormap ( Colormap  colormap  ) 

Installs colormap.

Definition at line 576 of file xcore.cpp.

References display_.

Colormap XCore::defaultColormap ( unsigned int  id  ) 

Definition at line 658 of file xcore.cpp.

References display_.

void XCore::queryTree ( Window  root,
Window **  windows,
unsigned int *  num 
)

Queries a window tree.

Definition at line 603 of file xcore.cpp.

References display_.

KeySym XCore::lookupNextKeySym ( XKeyEvent *  event,
int *  count,
char *  buffer 
)

Returns KeySym for next char by this XKeyEvent.

Definition at line 580 of file xcore.cpp.

bool XCore::textProperty ( Window  window,
Atom  atom,
string *  value 
)

Writes back text property value for window and specified atom.

Definition at line 586 of file xcore.cpp.

References display_, free(), and property().

Here is the call graph for this function:

void XCore::stringListToTextProperty ( string  text,
XTextProperty *  textProperty 
)

Converts string to XTextProperty.

Definition at line 652 of file xcore.cpp.

void XCore::setTextProperty ( Display *  display,
Window  window,
XTextProperty *  textProperty,
Atom  atom 
)

Definition at line 646 of file xcore.cpp.

int XCore::handleErrors ( Display *  display,
XErrorEvent *  e 
) [static]

Default error handler.

Definition at line 612 of file xcore.cpp.

References Kernel::defaultRootWindow(), Kernel::display(), Logger::error(), Singleton< Kernel >::instance(), Singleton< Logger >::instance(), Atoms::NCWM_STATUSTEXT, property(), Kernel::runlevel(), Kernel::START, and Logger::warning().

Referenced by Kernel::start().

Here is the call graph for this function:

void XCore::configureWindow ( Window  window,
unsigned int  mask,
XWindowChanges *  wc 
)

Definition at line 388 of file xcore.cpp.

References display_.

XModifierKeymap * XCore::modifierMapping (  ) 

NumLock/ScrollLock modifier detection.

Definition at line 662 of file xcore.cpp.

References display_.

void XCore::freeModifierMapping ( XModifierKeymap *  modmap  ) 

Definition at line 666 of file xcore.cpp.

void XCore::addToSaveSet ( Window  window  ) 

Definition at line 672 of file xcore.cpp.

References display_.

void XCore::removeFromSaveSet ( Window  window  ) 

Definition at line 676 of file xcore.cpp.

References display_.

void XCore::sizeHints ( Window  window,
XSizeHints *  sizeHints 
)

Fetches size hints.

Definition at line 293 of file xcore.cpp.

References display_.

Referenced by updateSize().

void XCore::warpPointer ( Window  window,
int  x,
int  y 
)

Definition at line 680 of file xcore.cpp.

References display_.

void XCore::freeCursor ( Cursor  cursor  ) 

Definition at line 87 of file xcore.cpp.

References display_.

void XCore::maskEvent ( unsigned long  mask,
XEvent *  event 
)

Definition at line 45 of file xcore.cpp.

References display_.

void XCore::sendEvent ( Window  window,
unsigned long  mask,
XEvent *  event 
)

Definition at line 41 of file xcore.cpp.

References display_.

XWMHints * XCore::getWMHints ( Window  window  ) 

Definition at line 684 of file xcore.cpp.

References display_.


Member Data Documentation

Display* XCore::display_ [private]

Definition at line 325 of file xcore.h.

Referenced by addToSaveSet(), allocNamedColor(), atomName(), checkMaskEvent(), className(), clearArea(), clearWindow(), configure(), configureWindow(), createFontCursor(), createGC(), createWindow(), defaultColormap(), destroy(), drawLine(), drawLines(), drawRectangle(), drawText(), fillRectangle(), freeCursor(), getWMHints(), grabButton(), grabKey(), grabKeyboard(), grabPointer(), grabServer(), hide(), installColormap(), instanceName(), internAtom(), keyCodeToKeySym(), keyCodeToString(), kill(), loadQueryFont(), lower(), maskEvent(), modifierMapping(), moveResize(), nextEvent(), property(), queryTree(), raise(), removeFromSaveSet(), reparent(), selectEvents(), sendEvent(), sendMessage(), setDisplay(), setForeground(), setInputFocus(), setState(), setWindowAttributes(), show(), showRaised(), sizeHints(), state(), stringToKeyCode(), sync(), textProperty(), transient(), translateCoordinates(), ungrabButton(), ungrabKey(), ungrabKeyboard(), ungrabPointer(), ungrabServer(), updateSize(), warpPointer(), and windowAttributes().


The documentation for this class was generated from the following files:
Generated on Thu May 24 15:20:34 2007 for ncwm by  doxygen 1.5.1