Esempio n. 1
0
Application::Application() : KApplication(), owner(screen_number)
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if(!config()->isImmutable() && args->isSet("lock"))
    {
        config()->setReadOnly(true);
        config()->reparseConfiguration();
    }

    if(screen_number == -1)
        screen_number = DefaultScreen(qt_xdisplay());

    if(!owner.claim(args->isSet("replace"), true))
    {
        fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
        ::exit(1);
    }
    connect(&owner, SIGNAL(lostOwnership()), SLOT(lostSelection()));

    // if there was already kwin running, it saved its configuration after loosing the selection -> reread
    config()->reparseConfiguration();

    initting = TRUE; // startup....

    // install X11 error handler
    XSetErrorHandler(x11ErrorHandler);

    // check  whether another windowmanager is running
    XSelectInput(qt_xdisplay(), qt_xrootwin(), SubstructureRedirectMask);
    syncX(); // trigger error now

    options = new Options;
    atoms = new Atoms;

    // create workspace.
    (void)new Workspace(isSessionRestored());

    syncX(); // trigger possible errors, there's still a chance to abort

    DCOPRef ref("kded", "kded");
    ref.send("unloadModule", QCString("kdetrayproxy"));

    initting = FALSE; // startup done, we are up and running now.

    dcopClient()->send("ksplash", "", "upAndRunning(QString)", QString("wm started"));
    XEvent e;
    e.xclient.type = ClientMessage;
    e.xclient.message_type = XInternAtom(qt_xdisplay(), "_KDE_SPLASH_PROGRESS", False);
    e.xclient.display = qt_xdisplay();
    e.xclient.window = qt_xrootwin();
    e.xclient.format = 8;
    strcpy(e.xclient.data.b, "wm started");
    XSendEvent(qt_xdisplay(), qt_xrootwin(), False, SubstructureNotifyMask, &e);
}
bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
#ifdef Q_WS_WIN
    Q_D(QRasterWindowSurface);

    if (!d->image || !d->image->hdc)
        return false;

    QRect rect = area.boundingRect();
    BitBlt(d->image->hdc, rect.x()+dx, rect.y()+dy, rect.width(), rect.height(),
           d->image->hdc, rect.x(), rect.y(), SRCCOPY);

    return true;
#else
    Q_D(QRasterWindowSurface);

    if (!d->image || d->image->image.isNull())
        return false;

#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
    syncX();
#endif

    const QVector<QRect> rects = area.rects();
    for (int i = 0; i < rects.size(); ++i)
        qt_scrollRectInImage(d->image->image, rects.at(i), QPoint(dx, dy));

    return true;
#endif
}
void QRasterWindowSurface::beginPaint(const QRegion &rgn)
{
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
    syncX();
#endif

#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || defined(Q_WS_WIN)
    if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {

#if defined(Q_WS_WIN)
        if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied)
            prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
#endif

        QPainter p(&d_ptr->image->image);
        p.setCompositionMode(QPainter::CompositionMode_Source);
        const QVector<QRect> rects = rgn.rects();
        const QColor blank = Qt::transparent;
        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
            p.fillRect(*it, blank);
        }
    }
#else
    Q_UNUSED(rgn);
#endif
}
void RKWardApplication::startWindowCreationDetection () {
	RK_TRACE (APP);
	RK_ASSERT (!detect_x11_creations);

	created_window = 0;
	detect_x11_creations = true;

	XSelectInput (qt_xdisplay (), qt_xrootwin (), SubstructureNotifyMask);
	syncX ();	// this is to make sure we don't miss out on the window creation (if it happens very early). Testing shows, we really need this.
}
Esempio n. 5
0
//BEGIN class RectangularOverlay
RectangularOverlay::RectangularOverlay( Item *parent, int xsnap, int ysnap )
	: ResizeOverlay(parent)
{
	connect( parent, SIGNAL(resized()), this, SLOT(slotUpdateResizeHandles()) );
	connect( parent, SIGNAL(movedBy(double, double )), this, SLOT(slotMoveAllResizeHandles(double, double )) );
	
	m_tl = createResizeHandle( ResizeHandle::rhp_topLeft,		ResizeHandle::dt_resize_backwardsDiagonal,	xsnap, ysnap );
	m_tm = createResizeHandle( ResizeHandle::rhp_topMiddle,		ResizeHandle::dt_resize_vertical,			xsnap, ysnap );
	m_tr = createResizeHandle( ResizeHandle::rhp_topRight,		ResizeHandle::dt_resize_forwardsDiagonal,	xsnap, ysnap );
	m_mr = createResizeHandle( ResizeHandle::rhp_middleRight,	ResizeHandle::dt_resize_horizontal,			xsnap, ysnap );
	m_br = createResizeHandle( ResizeHandle::rhp_bottomRight,	ResizeHandle::dt_resize_backwardsDiagonal,	xsnap, ysnap );
	m_bm = createResizeHandle( ResizeHandle::rhp_bottomMiddle,	ResizeHandle::dt_resize_vertical,			xsnap, ysnap );
	m_bl = createResizeHandle( ResizeHandle::rhp_bottomLeft,	ResizeHandle::dt_resize_forwardsDiagonal,	xsnap, ysnap );
	m_ml = createResizeHandle( ResizeHandle::rhp_middleLeft,	ResizeHandle::dt_resize_horizontal,			xsnap, ysnap );
	
	syncX( m_tl, m_ml, m_bl );
	syncX( m_tr, m_mr, m_br );
	syncY( m_tl, m_tm, m_tr );
	syncY( m_bl, m_bm, m_br );
	
	slotUpdateResizeHandles();
}
Esempio n. 6
0
void RKWardApplication::startWindowCreationDetection () {
	RK_TRACE (APP);
	RK_ASSERT (!detect_x11_creations);

	created_window = 0;
	detect_x11_creations = true;

#ifdef Q_WS_WIN
	RKWardApplicationPrivate::updateToplevelWindowList ();
#elif defined Q_WS_X11
	XSelectInput (QX11Info::display (), QX11Info::appRootWindow (), SubstructureNotifyMask);
	syncX ();	// this is to make sure we don't miss out on the window creation (if it happens very early). Testing shows, we really need this.
#endif
}
WId RKWardApplication::endWindowCreationDetection () {
	RK_TRACE (APP);
	RK_ASSERT (detect_x11_creations);

	if (!created_window) {
		// we did not see the window, yet? Maybe the event simply hasn't been processed, yet.
		syncX ();
		processEvents ();
	}

	detect_x11_creations = false;
	XSelectInput (qt_xdisplay (), qt_xrootwin (), NoEventMask);
	return created_window;
}
Esempio n. 8
0
WId RKWardApplication::endWindowCreationDetection () {
	RK_TRACE (APP);
	RK_ASSERT (detect_x11_creations);

#ifdef Q_WS_WIN
	QList<WId> old_windows = RKWardApplicationPrivate::toplevel_windows;
	RKWardApplicationPrivate::updateToplevelWindowList ();
	QList<WId> candidate_windows = RKWardApplicationPrivate::toplevel_windows;

	detect_x11_creations = false;

	// remove all windows that existed before the call to startWindowCreationDetection
	for (int i = 0; i < old_windows.size (); ++i) {
		candidate_windows.removeAll (old_windows[i]);
	}
	// ideally we have a single candidate remaining, now, but sometimes, additional
	// invisible windows are created somehow (probably by R's graphapp)
	for (int i = 0; i < candidate_windows.size (); ++i) {
		HWND hwnd = candidate_windows[i];
		if ((!IsWindow(hwnd)) || (!IsWindowVisible(hwnd))) {
			 candidate_windows.removeAt (i);
			 --i;
		}
	}

	// we could do some more checking, e.g. based on whether the window belongs to our
	// own process, and whether it appears to be of a sane size, but for now, we keep
	// things simple.

	if (candidate_windows.size ()) {
		RK_ASSERT (candidate_windows.size () < 2);
		return candidate_windows[0];
	}
	return 0;
#elif defined Q_WS_X11
	if (!created_window) {
		// we did not see the window, yet? Maybe the event simply hasn't been processed, yet.
		syncX ();
		processEvents ();
	}

	detect_x11_creations = false;
	XSelectInput (QX11Info::display (), QX11Info::appRootWindow (), NoEventMask);
	return created_window;
#else
	return 0;
#endif
}
Esempio n. 9
0
void ResizeOverlay::syncX( ResizeHandle *rh1, ResizeHandle *rh2, ResizeHandle *rh3 )
{
	syncX( rh1, rh2 );
	syncX( rh1, rh3 );
	syncX( rh2, rh3 );
}