[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: faster opaque drag
From: aviv bergman <avivb () actcom ! co ! il>
Date: 2002-07-21 19:31:05
[Download RAW message or body]
(see "opaque drag/XGrabPointer latency/kwin patch" message for explanation)
here's the second version of the patch - a bit cleaner, and doesn't break
magnetic borders/workspace as the previous one. it also applies the hack to
resize.
aviv
["kwin.patch" (text/x-diff)]
Common subdirectories: kwin.orig/.deps and kwin/.deps
diff -U 3 -H -b -B -d -N -a -- kwin.orig/client.cpp kwin/client.cpp
--- kwin.orig/client.cpp Sun Jul 21 22:04:10 2002
+++ kwin/client.cpp Sun Jul 21 21:56:01 2002
@@ -34,6 +34,8 @@
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
+#include "main.h"
+#include <kapp.h>
// Needed for --enable-final
// XIconincState is defined in workspace.cpp
@@ -593,11 +595,11 @@
{
moveResizeMode = true;
workspace()->setClientIsMoving(this);
- grabMouse( cursor() );
- grabKeyboard();
if ( ( isMove() && options->moveMode != Options::Opaque )
|| ( isResize() && options->resizeMode != Options::Opaque ) )
XGrabServer( qt_xdisplay() );
+ else
+ ((Application*)kapp)->startTrack(this);
}
void Client::stopMoveResize()
@@ -605,8 +607,6 @@
if ( ( isMove() && options->moveMode != Options::Opaque )
|| ( isResize() && options->resizeMode != Options::Opaque ) )
XUngrabServer( qt_xdisplay() );
- releaseKeyboard();
- releaseMouse();
workspace()->setClientIsMoving(0);
moveResizeMode = false;
}
@@ -1611,6 +1612,7 @@
QPoint mp( geometry().right() - mpsize.width() + 1,
geometry().bottom() - mpsize.height() + 1 );
+
geom = geometry();
switch ( mode ) {
case TopLeft:
@@ -1648,6 +1650,7 @@
QRect desktopArea = workspace()->clientArea(e->globalPos());
int marge = 5;
+
if ( isResize() && geom.size() != size() ) {
if (geom.bottom() < desktopArea.top()+marge)
geom.setBottom(desktopArea.top()+marge);
diff -U 3 -H -b -B -d -N -a -- kwin.orig/client.h kwin/client.h
--- kwin.orig/client.h Sun Jul 21 22:04:10 2002
+++ kwin/client.h Sun Jul 21 20:54:19 2002
@@ -102,6 +102,8 @@
QPixmap icon() const;
QPixmap miniIcon() const;
+ void fakeReleaseEvent(QMouseEvent *e) { mouseReleaseEvent(e);}
+ void fakeMoveEvent(QMouseEvent *e) { mouseMoveEvent(e); }
// is the window in withdrawn state?
bool isWithdrawn(){
diff -U 3 -H -b -B -d -N -a -- kwin.orig/main.cpp kwin/main.cpp
--- kwin.orig/main.cpp Sun Jul 21 22:04:10 2002
+++ kwin/main.cpp Sun Jul 21 21:56:12 2002
@@ -34,6 +34,9 @@
#include <kaboutdata.h>
#include <klocale.h>
#include <kcrash.h>
+#include <qevent.h>
+#include "client.h"
+
using namespace KWinInternal;
@@ -113,6 +116,7 @@
kwin_screen_number = DefaultScreen(qt_xdisplay());
initting = TRUE; // startup....
+ m_pTrackWin = NULL;
// install X11 error handler
XSetErrorHandler( x11ErrorHandler );
@@ -130,6 +134,19 @@
syncX(); // trigger possible errors, there's still a chance to abort
initting = FALSE; // startup done, we are up and running now.
+
+ unsigned long attr_mask = CWEventMask;
+ XSetWindowAttributes attributes;
+ attributes.event_mask = ButtonMotionMask;
+ m_EventWindow = XCreateWindow(qt_xdisplay(),
+ RootWindow(qt_xdisplay(), \
DefaultScreen(qt_xdisplay())), + 0, 0,
+ QApplication::desktop()->width(), \
QApplication::desktop()->height(), + 0,
+ 0,InputOnly,CopyFromParent,
+ attr_mask,&attributes);
+
+
dcopClient()->send( "ksplash", "", "upAndRunning(QString)", \
QString("wm started"));
if ( isSessionRestored() )
@@ -144,11 +161,48 @@
}
+void Application::startTrack(KWinInternal::Client *pWin)
+{
+ m_pTrackWin = pWin;
+
+ XMapRaised(qt_xdisplay(),m_EventWindow);
+ XGrabPointer(qt_xdisplay(),m_EventWindow,FALSE,ButtonMotionMask|ButtonReleaseMask,
+ GrabModeAsync,GrabModeAsync,m_EventWindow,None,CurrentTime);
+}
+
bool Application::x11EventFilter( XEvent *e )
{
if ( Workspace::self()->workspaceEvent( e ) )
return TRUE;
+
+ if (e->xany.window == m_EventWindow) {
+
+ if (m_pTrackWin == NULL) {
+ // report error
+ return TRUE;
+ }
+
+ QPoint global_pos(((XMotionEvent*)e)->x,((XMotionEvent*)e)->y);
+ QPoint pos(((XMotionEvent*)e)->x - m_pTrackWin->x(),((XMotionEvent*)e)->y \
- m_pTrackWin->y()); +
+ if (e->type == ButtonRelease) {
+ QMouseEvent fake(QEvent::MouseButtonRelease,pos,global_pos,0,0);
+ m_pTrackWin->fakeReleaseEvent(&fake);
+ XUngrabPointer(qt_xdisplay(),CurrentTime);
+ XUnmapWindow(qt_xdisplay(),m_EventWindow);
+ m_pTrackWin = NULL;
+ return TRUE;
+ }
+
+ if (e->type == MotionNotify) {
+ QMouseEvent fake(QEvent::MouseMove,pos,global_pos,0,0);
+ m_pTrackWin->fakeMoveEvent(&fake);
+ return TRUE;
+ }
+ }
+
+
return KApplication::x11EventFilter( e );
}
diff -U 3 -H -b -B -d -N -a -- kwin.orig/main.h kwin/main.h
--- kwin.orig/main.h Sun Jul 21 22:04:10 2002
+++ kwin/main.h Sun Jul 21 20:58:06 2002
@@ -8,6 +8,9 @@
#include <kapplication.h>
#include "workspace.h"
+#include <qwidget.h>
+
+class KWinInternal::Client;
class Application : public KApplication
{
@@ -15,8 +18,13 @@
Application();
~Application();
+ void startTrack(KWinInternal::Client *pWin);
+
protected:
bool x11EventFilter( XEvent * );
+
+ Window m_EventWindow;
+ KWinInternal::Client* m_pTrackWin;
};
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic