Qt 4.8
Public Functions | Properties | List of all members
QDirectFBScreenCursor Class Reference
Inheritance diagram for QDirectFBScreenCursor:
QScreenCursor

Public Functions

virtual void hide ()
 Hides the cursor from the screen. More...
 
virtual void move (int x, int y)
 Moves the mouse cursor to the given position, i.e., (x, y). More...
 
 QDirectFBScreenCursor ()
 
virtual void set (const QImage &image, int hotx, int hoty)
 Sets the cursor's image to be the given image. More...
 
virtual void show ()
 Shows the mouse cursor. More...
 
- Public Functions inherited from QScreenCursor
QRect boundingRect () const
 Returns the cursor's bounding rectangle. More...
 
QImage image () const
 Returns the cursor's image. More...
 
bool isAccelerated () const
 Returns true if the cursor is accelerated; otherwise false. More...
 
bool isVisible () const
 Returns true if the cursor is visible; otherwise false. More...
 
 QScreenCursor ()
 Constructs a screen cursor. More...
 
bool supportsAlphaCursor () const
 
virtual ~QScreenCursor ()
 Destroys the screen cursor. More...
 

Properties

IDirectFBDisplayLayer * layer
 

Additional Inherited Members

- Static Public Functions inherited from QScreenCursor
static bool enabled ()
 
static void initSoftwareCursor ()
 Initializes the screen cursor. More...
 
static QScreenCursorinstance ()
 
- Protected Variables inherited from QScreenCursor
QImage cursor
 
uint enable: 1
 
QPoint hotspot
 
uint hwaccel: 1
 
QPoint pos
 
QSize size
 
uint supportsAlpha: 1
 

Detailed Description

Definition at line 532 of file qdirectfbscreen.cpp.

Constructors and Destructors

◆ QDirectFBScreenCursor()

QDirectFBScreenCursor::QDirectFBScreenCursor ( )

Definition at line 549 of file qdirectfbscreen.cpp.

550 {
551  IDirectFB *fb = QDirectFBScreen::instance()->dfb();
552  if (!fb)
553  qFatal("QDirectFBScreenCursor: DirectFB not initialized");
554 
556  Q_ASSERT(layer);
557 
558  enable = false;
559  hwaccel = true;
560  supportsAlpha = true;
561 #ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
562  window = 0;
563  DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
564  if (result != DFB_OK) {
565  DirectFBError("QDirectFBScreenCursor::hide: "
566  "Unable to set cooperative level", result);
567  }
568  result = layer->SetCursorOpacity(layer, 0);
569  if (result != DFB_OK) {
570  DirectFBError("QDirectFBScreenCursor::hide: "
571  "Unable to set cursor opacity", result);
572  }
573 
574  result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
575  if (result != DFB_OK) {
576  DirectFBError("QDirectFBScreenCursor::hide: "
577  "Unable to set cooperative level", result);
578  }
579 #endif
580 }
IDirectFBDisplayLayer * dfbDisplayLayer()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
NSWindow * window
IDirectFB * dfb()
IDirectFBDisplayLayer * layer
Q_CORE_EXPORT void qFatal(const char *,...)
uint supportsAlpha
Definition: qscreen_qws.h:166
static QDirectFBScreen * instance()

Functions

◆ hide()

void QDirectFBScreenCursor::hide ( )
virtual

Hides the cursor from the screen.

See also
show()

Reimplemented from QScreenCursor.

Definition at line 655 of file qdirectfbscreen.cpp.

656 {
657  if (enable) {
658  enable = false;
659  DFBResult result;
660 #ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
661  result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
662  if (result != DFB_OK) {
663  DirectFBError("QDirectFBScreenCursor::hide: "
664  "Unable to set cooperative level", result);
665  }
666  result = layer->SetCursorOpacity(layer, 0);
667  if (result != DFB_OK) {
668  DirectFBError("QDirectFBScreenCursor::hide: "
669  "Unable to set cursor opacity", result);
670  }
671  result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
672  if (result != DFB_OK) {
673  DirectFBError("QDirectFBScreenCursor::hide: "
674  "Unable to set cooperative level", result);
675  }
676 #else
677  if (window) {
678  result = window->SetOpacity(window, 0);
679  if (result != DFB_OK) {
680  DirectFBError("QDirectFBScreenCursor::hide: "
681  "Unable to set window opacity", result);
682  }
683  }
684 #endif
685  }
686 }
NSWindow * window
IDirectFBDisplayLayer * layer

◆ move()

void QDirectFBScreenCursor::move ( int  x,
int  y 
)
virtual

Moves the mouse cursor to the given position, i.e., (x, y).

Note that the given position defines the top-left corner of the cursor's image, i.e., not the cursor's hot spot (the position of the associated mouse events).

See also
set()

Reimplemented from QScreenCursor.

Definition at line 639 of file qdirectfbscreen.cpp.

640 {
641  pos = QPoint(x, y);
642 #ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
643  if (window) {
644  const QPoint p = pos - hotspot;
645  DFBResult result = window->MoveTo(window, p.x(), p.y());
646  if (result != DFB_OK) {
647  DirectFBError("QDirectFBScreenCursor::move: Unable to move window", result);
648  }
649  }
650 #else
651  layer->WarpCursor(layer, x, y);
652 #endif
653 }
QPoint hotspot
Definition: qscreen_qws.h:163
NSWindow * window
IDirectFBDisplayLayer * layer
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ set()

void QDirectFBScreenCursor::set ( const QImage image,
int  hotx,
int  hoty 
)
virtual

Sets the cursor's image to be the given image.

The hotx and hoty parameters define the cursor's hot spot, i.e., the point within the cursor's image that will be the position of the associated mouse events.

See also
move()

Reimplemented from QScreenCursor.

Definition at line 726 of file qdirectfbscreen.cpp.

727 {
729  if (!screen)
730  return;
731 
732  if (image.isNull()) {
733  cursor = QImage();
734  hide();
735  } else {
736  cursor = image.convertToFormat(screen->alphaPixmapFormat());
737  size = cursor.size();
738  hotspot = QPoint(hotx, hoty);
739  DFBResult result = DFB_OK;
740  IDirectFBSurface *surface = screen->createDFBSurface(cursor, screen->alphaPixmapFormat(),
742  if (!surface) {
743  DirectFBError("QDirectFBScreenCursor::set: Unable to create surface", result);
744  return;
745  }
746 #ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
747  result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
748  if (result != DFB_OK) {
749  DirectFBError("QDirectFBScreenCursor::show: "
750  "Unable to set cooperative level", result);
751  }
752  result = layer->SetCursorShape(layer, surface, hotx, hoty);
753  if (result != DFB_OK) {
754  DirectFBError("QDirectFBScreenCursor::show: "
755  "Unable to set cursor shape", result);
756  }
757  result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
758  if (result != DFB_OK) {
759  DirectFBError("QDirectFBScreenCursor::show: "
760  "Unable to set cooperative level", result);
761  }
762 #else
763  if (window || createWindow()) {
764  QSize windowSize;
765  result = window->GetSize(window, &windowSize.rwidth(), &windowSize.rheight());
766  if (result != DFB_OK) {
767  DirectFBError("QDirectFBScreenCursor::set: "
768  "Unable to get window size", result);
769  }
770  result = window->Resize(window, size.width(), size.height());
771  if (result != DFB_OK) {
772  DirectFBError("QDirectFBScreenCursor::set: Unable to resize window", result);
773  }
774 
775  IDirectFBSurface *windowSurface;
776  result = window->GetSurface(window, &windowSurface);
777  if (result != DFB_OK) {
778  DirectFBError("QDirectFBScreenCursor::set: Unable to get window surface", result);
779  } else {
780  result = windowSurface->Clear(windowSurface, 0, 0, 0, 0);
781  if (result != DFB_OK) {
782  DirectFBError("QDirectFBScreenCursor::set: Unable to clear surface", result);
783  }
784 
785  result = windowSurface->Blit(windowSurface, surface, 0, 0, 0);
786  if (result != DFB_OK) {
787  DirectFBError("QDirectFBScreenCursor::set: Unable to blit to surface", result);
788  }
789  }
790  result = windowSurface->Flip(windowSurface, 0, DSFLIP_NONE);
791  if (result != DFB_OK) {
792  DirectFBError("QDirectFBScreenCursor::set: Unable to flip window", result);
793  }
794 
795  windowSurface->Release(windowSurface);
796  }
797 #endif
798  surface->Release(surface);
799  show();
800  }
801 
802 }
IDirectFBSurface * createDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options, DFBResult *result=0)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QPoint hotspot
Definition: qscreen_qws.h:163
virtual void show()
Shows the mouse cursor.
QImage::Format alphaPixmapFormat() const
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
IDirectFBDisplayLayer * layer
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static QDirectFBScreen * instance()
virtual void hide()
Hides the cursor from the screen.
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141

◆ show()

void QDirectFBScreenCursor::show ( )
virtual

Shows the mouse cursor.

See also
hide()

Reimplemented from QScreenCursor.

Definition at line 688 of file qdirectfbscreen.cpp.

689 {
690  if (!enable) {
691  enable = true;
692  DFBResult result;
693  result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
694  if (result != DFB_OK) {
695  DirectFBError("QDirectFBScreenCursor::show: "
696  "Unable to set cooperative level", result);
697  }
698  result = layer->SetCursorOpacity(layer,
699 #ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
700  0
701 #else
702  255
703 #endif
704  );
705  if (result != DFB_OK) {
706  DirectFBError("QDirectFBScreenCursor::show: "
707  "Unable to set cursor shape", result);
708  }
709  result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
710  if (result != DFB_OK) {
711  DirectFBError("QDirectFBScreenCursor::show: "
712  "Unable to set cooperative level", result);
713  }
714 #ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
715  if (window) {
716  DFBResult result = window->SetOpacity(window, 255);
717  if (result != DFB_OK) {
718  DirectFBError("QDirectFBScreenCursor::show: "
719  "Unable to set window opacity", result);
720  }
721  }
722 #endif
723  }
724 }
NSWindow * window
IDirectFBDisplayLayer * layer

Properties

◆ layer

IDirectFBDisplayLayer* QDirectFBScreenCursor::layer
private

Definition at line 546 of file qdirectfbscreen.cpp.


The documentation for this class was generated from the following file: