bool isServerGeometry(const Geometry what)
	{
		const Geometry geometry(getSurfaceGeometry(*this));
		return geometry.width == what.width
			and geometry.height == what.height
			and geometry.x == what.x
			and geometry.y == what.y
		;
	}
Example #2
0
	void movePointer(const int32_t x, const int32_t y)
	{
		Geometry geometry(getSurfaceGeometry(surface_));
		setGlobalPointerPosition(geometry.x + x, geometry.y + y);
	}
	/**
	 * The assumption is that window fullscreening is honored by the window
	 * manager/compositor and fills the entire screen size when fullscreened.
	 * When unfullscreened, the window should restore to its initial size
	 * and position.
	 */
	void test()
	{
		gint width, height;
		GdkScreen *screen(gtk_window_get_screen(*this));
		Geometry fullscreen(
			0, 0,
			gdk_screen_get_width(screen),
			gdk_screen_get_height(screen)
		);
		const Geometry initial(getSurfaceGeometry(*this));

		std::cout << "...initial server geometry " << initial << std::endl;

		gtk_window_get_size(*this, &width, &height);

		std::cout << "...checking server size == client size" << std::endl;
		FAIL_UNLESS_EQUAL(width, initial.width);
		FAIL_UNLESS_EQUAL(height, initial.height);

		std::cout << "...checking client size != fullscreen size" << std::endl;
		FAIL_IF_EQUAL(width, fullscreen.width);
		FAIL_IF_EQUAL(height, fullscreen.height);

		isConfigured_ = false;

		std::cout << "...fullscreening client" << std::endl;
		gtk_window_fullscreen(*this);

		std::cout << "...checking for fullscreen state event" << std::endl;
		YIELD_UNTIL(isFullscreen_);

		std::cout << "...checking for configure event" << std::endl;
		YIELD_UNTIL(isConfigured_);

		std::cout << "...checking client size == fullscreen size" << std::endl;
		gtk_window_get_size(*this, &width, &height);
		FAIL_UNLESS_EQUAL(width, fullscreen.width);
		FAIL_UNLESS_EQUAL(height, fullscreen.height);

		std::cout << "...checking server geometry == fullscreen geometry" << std::endl;
		YIELD_UNTIL(isServerGeometry(fullscreen));

		isConfigured_ = false;
		std::cout << "...unfullscreening client" << std::endl;
		gtk_window_unfullscreen(*this);

		std::cout << "...checking for fullscreen state event" << std::endl;
		YIELD_UNTIL(not isFullscreen_);

		std::cout << "...checking for configure event" << std::endl;
		YIELD_UNTIL(isConfigured_);

		gtk_window_get_size(*this, &width, &height);

		std::cout << "...checking client size == initial size" << std::endl;
		FAIL_UNLESS_EQUAL(width, initial.width);
		FAIL_UNLESS_EQUAL(height, initial.height);

		std::cout << "...checking server geometry == initial geometry" << std::endl;
		YIELD_UNTIL(isServerGeometry(initial));
	}
Example #4
0
bool MMSLabelWidget::draw(bool *backgroundFilled) {
    int width, height, x, y;
    bool myBackgroundFilled = false;

    if(!surface)
        return false;

    if (backgroundFilled) {
        if (this->has_own_surface)
            *backgroundFilled = false;
    }
    else
        backgroundFilled = &myBackgroundFilled;

    // lock
    this->surface->lock();

    // draw widget basics
    if (MMSWidget::draw(backgroundFilled)) {
        // draw my things
        if (prepareText(&width, &height)) {
            // text is translated and font is set
            MMSFBRectangle surfaceGeom = getSurfaceGeometry();

            // save the width of the text
            this->slide_width = width;

            switch ((!this->swap_left_right) ? getAlignment() : swapAlignmentHorizontal(getAlignment())) {
            case MMSALIGNMENT_LEFT:
                x = surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_LEFT:
                x = surfaceGeom.x;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_BOTTOM_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            case MMSALIGNMENT_BOTTOM_LEFT:
                x = surfaceGeom.x;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            case MMSALIGNMENT_BOTTOM_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            default:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            }

            // get color
            MMSFBColor color;
            getForeground(&color);
            this->current_fgcolor   = color;
            this->current_fgset     = true;

            if (color.a) {
                // prepare for drawing
                this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(
                    color,
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM),
                    (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT),
                    getBrightness(), getOpacity());

                // draw the text
                this->surface->drawString(this->translated_text, -1, x - this->slide_offset, y);
            }
        }

        // update window surface with an area of surface
        updateWindowSurfaceWithSurface(!*backgroundFilled);
    }

    // unlock
    this->surface->unlock();

    // draw widgets debug frame
    return MMSWidget::drawDebug();
}