[PyKDE] borderless window : tips

Yannick Gingras ygingras at kubiktech.com
Tue Sep 24 18:19:01 BST 2002


You can also have problems with moving your borderless window around, the
folowing events may help you :

MIN_MOVE_REDRAW_MAGNITUDE = 4

    def mousePressEvent(self, event):
        # TODO handle the right click
        print "mouse press"
        self.isDraged = 1
        self.dragOrigin = QPoint( event.globalPos() )
        mappedPoint = addOffset( event.pos(),
                                 pointOffset( self.geometry().topLeft(),
                                              self.frameGeometry().topLeft()))
        self.lastMovePos = mappedPoint
        self.clickPos = mappedPoint
        self.moved = 0
        self.grabMouse()

    def mouseMoveEvent(self, event):
        mappedPoint = addOffset( event.pos(),
                                 pointOffset( self.geometry().topLeft(),
                                              self.frameGeometry().topLeft()))
        if self.isDraged:
            offset = pointOffset( mappedPoint,
                                  self.clickPos )
            if MIN_MOVE_REDRAW_MAGNITUDE <= getMagnitude(offset):
                self.move( pointOffset( event.globalPos(), self.lastMovePos ))
                self.moved = 1

    def mouseReleaseEvent(self, event):
        self.isDraged = 0
        if not self.moved :
            self.toggleActivation()
            self.update()
        self.releaseMouse()


The MIN_MOVE_REDRAW_MAGNITUDE value is used here to prevet redraw for every
pixels but your app may be fast to redraw and you can forget about this part
of the code.  What is important is to remap the position for the global X
server coordinate system.

I found a lot of interesting code in Noatun, the KDE multi-media player.
Noatun support the KJofol skins which are borderless.  The code is in C++ but
by now you should be able to translate.  The interestions stuff is in the
kjofol-skin directory.  They only support rectangle clipping area so you may
have to play with QRegions if you want finer grainend control.  They only use
a QWidget and populate it with KJWidgets wich are not childs of QWidget but
only place holders inside a QWidget.

Have fun !

--
Yannick Gingras
Coder for OBB : Overexcited Broadloom Bathrobe
http://OpenBeatBox.org




More information about the PyQt mailing list