Ejemplo n.º 1
2
void MyWindow::setMousePenetrate(bool arg)
{
    if (m_mousePenetrate != arg) {
        m_mousePenetrate = arg;
#ifdef Q_OS_LINUX
        if(arg){
            XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0,
                    0, NULL, 0, ShapeSet, YXBanded);
        }else{
            XRectangle* myrect = new XRectangle;
            myrect->x = 0;
            myrect->y = 0;
            myrect->width = actualWidth ();
            myrect->height = actualHeight ();
            XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0,
                    0, myrect, 1, ShapeSet, YXBanded);
        }
#elif defined(Q_OS_OSX)
        qDebug()<<"mac os暂不支持鼠标穿透";
#elif defined(Q_OS_WIN)
        HWND my_hwnd = (HWND)this->winId ();
        if(arg){
            SetWindowLong(my_hwnd, GWL_EXSTYLE,
                         GetWindowLong(my_hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
        }else{
            SetWindowLong(my_hwnd, GWL_EXSTYLE,
                         GetWindowLong(my_hwnd, GWL_EXSTYLE)&(~WS_EX_TRANSPARENT));
        }
#endif
        emit mousePenetrateChanged(arg);
    }
}
Ejemplo n.º 2
0
void set_shape(client_t *c)
{
    int n, order;
    XRectangle temp, *rects;

    rects = XShapeGetRectangles(dpy, c->win, ShapeBounding, &n, &order);

    if (n > 1) {
        XShapeCombineShape(dpy, c->frame, ShapeBounding,
            0, frame_height(c), c->win, ShapeBounding, ShapeSet);
        temp.x = -BW(c);
        temp.y = -BW(c);
        temp.width = c->geom.w + 2*BW(c);
        temp.height = frame_height(c) + BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeBounding,
            0, 0, &temp, 1, ShapeUnion, YXBanded);
        temp.x = 0;
        temp.y = 0;
        temp.width = c->geom.w;
        temp.height = frame_height(c) - BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeClip,
            0, frame_height(c), &temp, 1, ShapeUnion, YXBanded);
        c->shaped = 1;
    } else if (c->shaped) {
        /* I can't find a ``remove all shaping'' function... */
        temp.x = -BW(c);
        temp.y = -BW(c);
        temp.width = c->geom.w + 2*BW(c);
        temp.height = c->geom.h + frame_height(c) + 2*BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeBounding,
            0, 0, &temp, 1, ShapeSet, YXBanded);
    }

    XFree(rects);
}
Ejemplo n.º 3
0
/* for changing the visible shape of a window to an nonrectangular form */
void
SplashUpdateShape(Splash * splash) {
    if (splash->currentFrame < 0 || !shapeSupported || !splash->maskRequired) {
        return;
    }
    XShapeCombineRectangles(splash->display, splash->window, ShapeClip, 0, 0,
            splash->frames[splash->currentFrame].rects,
            splash->frames[splash->currentFrame].numRects, ShapeSet, YXBanded);
    XShapeCombineRectangles(splash->display, splash->window, ShapeBounding,
            0, 0, splash->frames[splash->currentFrame].rects,
            splash->frames[splash->currentFrame].numRects, ShapeSet, YXBanded);
}
Ejemplo n.º 4
0
EAPI void
ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
                                    int x,
                                    int y,
                                    int w,
                                    int h)
{
   XRectangle rect;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   rect.x = x;
   rect.y = y;
   rect.width = w;
   rect.height = h;
   XShapeCombineRectangles(_ecore_x_disp,
                           win,
                           ShapeBounding,
                           0,
                           0,
                           &rect,
                           1,
                           ShapeIntersect,
                           Unsorted);
   if (_ecore_xlib_sync) ecore_x_sync();
}
Ejemplo n.º 5
0
EAPI void
ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
                                          int x,
                                          int y,
                                          int w,
                                          int h)
{
#ifdef ShapeInput
   XRectangle rect;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   rect.x = x;
   rect.y = y;
   rect.width = w;
   rect.height = h;
   XShapeCombineRectangles(_ecore_x_disp,
                           win,
                           ShapeInput,
                           0,
                           0,
                           &rect,
                           1,
                           ShapeIntersect,
                           Unsorted);
   if (_ecore_xlib_sync) ecore_x_sync();
#else
   return;
   win = x = y = w = h = 0;
#endif
}
Ejemplo n.º 6
0
EAPI void
ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
                                    Ecore_X_Rectangle *rects,
                                    int num)
{
   XRectangle *rect = NULL;
   int i;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   if (num > 0)
     {
        rect = malloc(sizeof(XRectangle) * num);
        if (!rect) return;
        for (i = 0; i < num; i++)
          {
             rect[i].x = rects[i].x;
             rect[i].y = rects[i].y;
             rect[i].width = rects[i].width;
             rect[i].height = rects[i].height;
          }
     }

   XShapeCombineRectangles(_ecore_x_disp,
                           win,
                           ShapeBounding,
                           0,
                           0,
                           rect,
                           num,
                           ShapeUnion,
                           Unsorted);
   if (_ecore_xlib_sync) ecore_x_sync();
   if (rect) free(rect);
}
Ejemplo n.º 7
0
void KDecorationPreview::setPreviewMask( const QRegion& reg, int mode, bool active )
    {
    QWidget *widget = active ? deco[Active]->widget() : deco[Inactive]->widget();

    // FRAME duped from client.cpp
    if( mode == Unsorted )
        {
        XShapeCombineRegion( qt_xdisplay(), widget->winId(), ShapeBounding, 0, 0,
            reg.handle(), ShapeSet );
        }
    else
        {
        QMemArray< QRect > rects = reg.rects();
        XRectangle* xrects = new XRectangle[ rects.count() ];
        for( unsigned int i = 0;
             i < rects.count();
             ++i )
            {
            xrects[ i ].x = rects[ i ].x();
            xrects[ i ].y = rects[ i ].y();
            xrects[ i ].width = rects[ i ].width();
            xrects[ i ].height = rects[ i ].height();
            }
        XShapeCombineRectangles( qt_xdisplay(), widget->winId(), ShapeBounding, 0, 0,
	    xrects, rects.count(), ShapeSet, mode );
        delete[] xrects;
        }
    if( active )
        mask = reg; // keep shape of the active window for unobscuredRegion()
    }
Ejemplo n.º 8
0
void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow,
                       RECTANGLE_16* rects, int nrects)
{
	int i;
	XRectangle* xrects;

	if (nrects < 1)
		return;

#ifdef WITH_XEXT
	xrects = (XRectangle*) calloc(nrects, sizeof(XRectangle));

	for (i = 0; i < nrects; i++)
	{
		xrects[i].x = rects[i].left;
		xrects[i].y = rects[i].top;
		xrects[i].width = rects[i].right - rects[i].left;
		xrects[i].height = rects[i].bottom - rects[i].top;
	}

	XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding, 0, 0,
	                        xrects, nrects, ShapeSet, 0);
	free(xrects);
#endif
}
Ejemplo n.º 9
0
/**
 * Initialize grabbing region window
 *
 * @param s x11_grab context
 */
static void
x11grab_region_win_init(struct x11_grab *s)
{
    Display *dpy = s->dpy;
    int screen;
    XSetWindowAttributes attribs;
    XRectangle rect;

    screen = DefaultScreen(dpy);
    attribs.override_redirect = True;
    s->region_win = XCreateWindow(dpy, RootWindow(dpy, screen),
                                  s->x_off  - REGION_WIN_BORDER,
                                  s->y_off  - REGION_WIN_BORDER,
                                  s->width  + REGION_WIN_BORDER * 2,
                                  s->height + REGION_WIN_BORDER * 2,
                                  0, CopyFromParent,
                                  InputOutput, CopyFromParent,
                                  CWOverrideRedirect, &attribs);
    rect.x = 0;
    rect.y = 0;
    rect.width  = s->width;
    rect.height = s->height;
    XShapeCombineRectangles(dpy, s->region_win,
                            ShapeBounding, REGION_WIN_BORDER, REGION_WIN_BORDER,
                            &rect, 1, ShapeSubtract, 0);
    XMapWindow(dpy, s->region_win);
    XSelectInput(dpy, s->region_win, ExposureMask | StructureNotifyMask);
    x11grab_draw_region_win(s);
}
Ejemplo n.º 10
0
void MyWindow::setMousePenetrateArea(QRect rect)
{
#ifdef Q_OS_LINUX
    XRectangle* myrect = new XRectangle;
    myrect->x = rect.x();
    myrect->y = rect.y();
    myrect->width = rect.width ();
    myrect->height = rect.height ();
    qDebug() << myrect->x << myrect->y << myrect->width << myrect->height;
    XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0,
            0, myrect, 1, ShapeSet, YXBanded);
#endif
}
Ejemplo n.º 11
0
Archivo: x.c Proyecto: Limsik/e17
static void
EShapeCombineRectangles(Win win, int dest, int x, int y,
			XRectangle * rect, int n_rects, int op, int ordering)
{
   if (!win)
      return;
#if DEBUG_SHAPE_OPS
   Eprintf("EShapeCombineRectangles %#lx %d\n", win->xwin, n_rects);
#endif

   if (n_rects == 1 && op == ShapeSet)
     {
	if ((rect[0].x == 0) && (rect[0].y == 0) &&
	    (rect[0].width == win->w) && (rect[0].height == win->h))
	  {
	     win->num_rect = 0;
	     XFree(win->rects);
	     win->rects = NULL;
	     XShapeCombineMask(disp, win->xwin, dest, x, y, None, op);
	     return;
	  }
     }
   XShapeCombineRectangles(disp, win->xwin, dest, x, y, rect, n_rects, op,
			   ordering);
   if (n_rects > 1)
     {
	/* Limit shape to window extents */
	XRectangle          r;

	r.x = r.y = 0;
	r.width = win->w;
	r.height = win->h;
	XShapeCombineRectangles(disp, win->xwin, ShapeBounding, 0, 0, &r,
				1, ShapeIntersect, Unsorted);
     }
   EShapeUpdate(win);
}
Ejemplo n.º 12
0
void Frame::reshape()
{
    qDebug() << "Frame reshaped:" << winId() << "Name:" << wm_name << "Client:" << c_win << "State:" << state;

    shaped = true;
    XShapeCombineShape(QX11Info::display(), winId(), ShapeBounding, 0, bottom_bdr_height, c_win, ShapeBounding, ShapeSet);

    XRectangle tr;

    tr.x = 0;
    tr.y = 0;
    tr.width = width();
    tr.height = bottom_bdr_height;
    XShapeCombineRectangles(QX11Info::display(), winId(), ShapeBounding, 0, 0, &tr, 1, ShapeUnion, Unsorted);
}
Ejemplo n.º 13
0
void frame_adjust_shape_kind(struct wm_frame *self, int kind)
{
	gint num;
	XRectangle xrect[2];
	gboolean shaped;
	shaped = (kind == ShapeBounding && self->client->shaped);
	shaped |= (kind == ShapeInput && self->client->shaped_input);
	if(!shaped) {
		XShapeCombineMask(t_display, self->window, kind, self->size.left, self->size.top, None, ShapeSet);
	} else {
		XShapeCombineShape(t_display, self->window, kind, self->size.left, self->size.top, self->client->window, kind,
			ShapeSet);
		num = 0;
		XShapeCombineRectangles(t_display, self->window, ShapeBounding, 0, 0, xrect, num, ShapeUnion,
			Unsorted);
	}
}
Ejemplo n.º 14
0
CursorWidget::CursorWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CursorWidget)
{
    ui->setupUi(this);

    //get the user device screen size
    int user_device_screen_width = QApplication::desktop()->width();
    int user_device_screen_height= QApplication::desktop()->height();

    //set window geometry size is full screen
    this->setGeometry(0, 0, user_device_screen_width, user_device_screen_height);

    //Translucent Background
    this->setAttribute(Qt::WA_TranslucentBackground, true);

    //set window flag are frameless and stay-on-top
    this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);

    //TRANSPARENT and LAYERED for Windows
    #ifdef Q_OS_WIN32
        SetWindowLong((HWND)winId(), GWL_EXSTYLE, GetWindowLong((HWND)winId(), GWL_EXSTYLE) |
                      WS_EX_TRANSPARENT | WS_EX_LAYERED);
    #endif

    //for Linux/X11
    #ifdef Q_OS_LINUX
        XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput,0,0, NULL, 0, ShapeSet, YXBanded);
    #endif

    //new timer named cursor_paint_timer, used to update display
    QTimer *cursor_paint_timer = new QTimer(this);
    connect(cursor_paint_timer,SIGNAL(timeout()),this,SLOT(update()));
    cursor_paint_timer->start(20);

    //set cursor color
    cursor_color = QColor(00, 160, 255, 200);

    //set cursor available
    available = true;

    //show auto
    this->show();
}
Ejemplo n.º 15
0
void DArrowRectangle::resizeWithContent()
{
    setFixedSize(getFixedSize());

    update();

#ifdef Q_OS_UNIX
    //Shadow Transparent For MouseEvents
    qreal delta = shadowBlurRadius() + shadowDistance();

    XRectangle m_contentXRect;
    m_contentXRect.x = 0;
    m_contentXRect.y = 0;
    m_contentXRect.width = width() - delta * 2;
    m_contentXRect.height = height() - delta * 2;
    XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput,
                            delta + shadowXOffset(),
                            delta + shadowYOffset(),
                            &m_contentXRect, 1, ShapeSet, YXBanded);
#endif
}
Ejemplo n.º 16
0
EAPI void
ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win,
                                          Ecore_X_Rectangle *rects,
                                          int num)
{
#ifdef ShapeInput
   XRectangle *rect = NULL;
   int i;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   if (!rects) return;
   if (num > 0)
     {
        rect = malloc(sizeof(XRectangle) * num);
        if (!rect) return;
        for (i = 0; i < num; i++)
          {
             rect[i].x = rects[i].x;
             rect[i].y = rects[i].y;
             rect[i].width = rects[i].width;
             rect[i].height = rects[i].height;
          }
     }
   XShapeCombineRectangles(_ecore_x_disp,
                           win,
                           ShapeInput,
                           0,
                           0,
                           rect,
                           num,
                           ShapeSet,
                           Unsorted);
   if (_ecore_xlib_sync) ecore_x_sync();
   if (rect) free(rect);
#else
   return;
   win = rects = num = 0;
#endif
}
Ejemplo n.º 17
0
void
desk_anim_shape_blocks (ScreenInfo * scr, Window cover, unsigned int steps)
{
#ifdef SHAPE
	XRectangle main_b = { 0, 0, scr->MyDisplayWidth, scr->MyDisplayHeight };
	struct ASDeskAniBlocks *data =
			safecalloc (1, sizeof (struct ASDeskAniBlocks));
	int y_dim = scr->MyDisplayHeight / steps;
	int i;

	for (i = 0; i < LEVELS_NUM; i++) {
		data->off_y[i] = (i - (LEVELS_NUM - 1)) * y_dim;
		data->stripes[i] = safecalloc (BLOCKS_NUM, 1);
	}

	XShapeCombineRectangles (dpy, cover, ShapeBounding, 0, 0, &main_b, 1,
													 ShapeSet, Unsorted);
	data->cover = cover;
	data->steps = steps;

	timer_new (20, do_anim_shape_blocks, data);
#endif
}
Ejemplo n.º 18
0
void SetMouseTransparent(QWidget *widget, bool on)
{
    Q_ASSERT(widget);

    const auto display = QX11Info::display();
    XRectangle XRect;
    XRect.x = 0;
    XRect.y = 0;
    int nRects = 0;

    if (on) {
        XRect.width = 0;
        XRect.height = 0;
        nRects = 0;
    } else {
        XRect.width = widget->width();
        XRect.height = widget->height();
        nRects = 1;
    }
    XShapeCombineRectangles(display, widget->winId(), ShapeInput,
                            0, 0,
                            &XRect, nRects, ShapeSet, YXBanded);
}
Ejemplo n.º 19
0
EAPI void
ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
                                   int            x,
                                   int            y,
                                   int            w,
                                   int            h)
{
   XRectangle rect;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   rect.x = x;
   rect.y = y;
   rect.width = w;
   rect.height = h;
   XShapeCombineRectangles(_ecore_x_disp,
                           win,
                           ShapeBounding,
                           0,
                           0,
                           &rect,
                           1,
                           ShapeUnion,
                           Unsorted);
} /* ecore_x_window_shape_rectangle_add */
Ejemplo n.º 20
0
Archivo: dock.c Proyecto: dkogan/notion
static void dock_reshape(WDock *dock)
{
    int outline_style;

    if(!ioncore_g.shape_extension)
        return;

    dock_get_outline_style(dock, &outline_style);

    switch(outline_style){
    case DOCK_OUTLINE_STYLE_NONE:
    case DOCK_OUTLINE_STYLE_EACH:
        {
            WDockApp *dockapp;

            /* Start with an empty set */
            XShapeCombineRectangles(ioncore_g.dpy, ((WWindow*)dock)->win,
                                    ShapeBounding, 0, 0, NULL, 0, ShapeSet, 0);

            /* Union with dockapp shapes */
            for(dockapp=dock->dockapps; dockapp!=NULL; dockapp=dockapp->next){
                WClientWin *cwin=OBJ_CAST(dockapp->reg, WClientWin);
                if(outline_style==DOCK_OUTLINE_STYLE_EACH
                   && dockapp->draw_border){
                    /* Union with border shape */
                    XRectangle tile_rect;

                    tile_rect.x=dockapp->border_geom.x;
                    tile_rect.y=dockapp->border_geom.y;
                    tile_rect.width=dockapp->border_geom.w;
                    tile_rect.height=dockapp->border_geom.h;
                    XShapeCombineRectangles(ioncore_g.dpy, ((WWindow*)dock)->win,
                                            ShapeBounding, 0, 0, &tile_rect, 1,
                                            ShapeUnion, 0);
                }else if(cwin!=NULL){
                    /* Union with dockapp shape */
                    int count;
                    int ordering;

                    XRectangle *rects=XShapeGetRectangles(ioncore_g.dpy, cwin->win,
                                                          ShapeBounding, &count,
                                                          &ordering);
                    if(rects!=NULL){
                        WRectangle dockapp_geom=REGION_GEOM(cwin);
                        XShapeCombineRectangles(ioncore_g.dpy, ((WWindow*)dock)->win,
                                                ShapeBounding,
                                                dockapp_geom.x, dockapp_geom.y,
                                                rects, count, ShapeUnion, ordering);
                        XFree(rects);
                    }
                }
            }
        }
        break;

    case DOCK_OUTLINE_STYLE_ALL:
        {
            WRectangle geom;
            XRectangle rect;

            geom=REGION_GEOM(dock);
            rect.x=0;
            rect.y=0;
            rect.width=geom.w;
            rect.height=geom.h;
            XShapeCombineRectangles(ioncore_g.dpy, ((WWindow*)dock)->win,
                                    ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0);
        }
        break;
    }

}
Ejemplo n.º 21
0
slop::GLSelectRectangle::GLSelectRectangle( int sx, int sy, int ex, int ey, int border, bool highlight, float r, float g, float b, float a ) {
    m_x = std::min( sx, ex );
    m_y = std::min( sy, ey );
    m_width = std::max( sx, ex ) - m_x;
    m_height = std::max( sy, ey ) - m_y;
    m_r = r;
    m_g = g;
    m_b = b;
    m_a = a;
    m_border = border;
    m_window = None;
    m_highlight = highlight;
    m_glassPixels = 64;
    m_glassx = xengine->m_mousex;
    m_glassy = xengine->m_mousey;
    m_realglassx = xengine->m_mousex;
    m_realglassy = xengine->m_mousey;
    m_glassSize = 4;
    m_glassBorder = 1;
    m_monitors = xengine->getCRTCS();
    m_themed = false;
    m_shader = "simple";
    m_time = 0;

    // If we don't have a border, we don't exist, so just die.
    if ( m_border == 0 ) {
        return;
    }

    if ( m_highlight ) {
        m_border = 0;
    }

    static int visdata[] = {
        GLX_RENDER_TYPE, GLX_RGBA_BIT,
        GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
        GLX_DOUBLEBUFFER, True,
        GLX_RED_SIZE, 8,
        GLX_GREEN_SIZE, 8,
        GLX_BLUE_SIZE, 8,
        GLX_ALPHA_SIZE, 8,
        GLX_DEPTH_SIZE, 16,
        None
    };

    int numfbconfigs = 0;
    GLXFBConfig* fbconfigs = glXChooseFBConfig( xengine->m_display,  DefaultScreen( xengine->m_display ), visdata, &numfbconfigs );
    m_fbconfig = 0;
    for ( int i=0; i<numfbconfigs; i++ ) {
        m_visual = (XVisualInfo*)glXGetVisualFromFBConfig( xengine->m_display, fbconfigs[i] );
        if ( !m_visual ) {
            continue;
        }
        m_pictFormat = XRenderFindVisualFormat( xengine->m_display, m_visual->visual );
        if ( !m_pictFormat ) {
            continue;
        }
        m_fbconfig = fbconfigs[i];
        if ( m_pictFormat->direct.alphaMask > 0 ) {
            break;
        }
    }

    if ( !m_fbconfig ) {
        fprintf( stderr, "Couldn't find a matching FB config for a transparent OpenGL window!\n");
    }

    m_cmap = XCreateColormap( xengine->m_display, xengine->m_root, m_visual->visual, AllocNone );

    XSetWindowAttributes attributes;
    attributes.colormap = m_cmap;
    attributes.background_pixmap = None;
    attributes.border_pixmap = None;
    attributes.border_pixel = 0;
    // Disable window decorations.
    attributes.override_redirect = True;
    // Make sure we know when we've been successfully destroyed later!
    attributes.event_mask = StructureNotifyMask;
    unsigned long valueMask = CWOverrideRedirect | CWEventMask | CWBackPixmap | CWColormap | CWBorderPixel;


    // Create the window
    m_window = XCreateWindow( xengine->m_display, xengine->m_root, 0, 0, xengine->getWidth(), xengine->getHeight(),
                              0, m_visual->depth, InputOutput,
                              m_visual->visual, valueMask, &attributes );

    if ( !m_window ) {
        fprintf( stderr, "Couldn't create a GL window!\n");
    }

    m_glxWindow = m_window;

    static char title[] = "OpenGL Slop";
    XWMHints* startup_state = XAllocWMHints();
    startup_state->initial_state = NormalState;
    startup_state->flags = StateHint;
    XTextProperty textprop;
    textprop.value = (unsigned char*)title;
    textprop.encoding = XA_STRING;
    textprop.format = 8;
    textprop.nitems = strlen( title );
    XSizeHints sizehints;
    sizehints.x = 0;
    sizehints.y = 0;
    sizehints.width = xengine->getWidth();
    sizehints.height = xengine->getHeight();
    sizehints.flags = USPosition | USSize;
    XClassHint classhints;
    char name[] = "slop";
    classhints.res_name = name;
    classhints.res_class = name;
    XSetClassHint( xengine->m_display, m_window, &classhints );
    XSetWMProperties( xengine->m_display, m_window, &textprop, &textprop, NULL, 0, &sizehints, startup_state, NULL );
    XFree( startup_state );

    // Make it so all input falls through
    XRectangle rect;
    rect.x = rect.y = rect.width = rect.height = 0;
    XShapeCombineRectangles( xengine->m_display, m_window, ShapeInput, 0, 0, &rect, 1, ShapeSet, 0);

    XMapWindow( xengine->m_display, m_window );

    int dummy;
    if ( !glXQueryExtension( xengine->m_display, &dummy, &dummy ) ) {
        fprintf( stderr, "OpenGL is not supported!\n" );
    }
    m_renderContext = glXCreateNewContext( xengine->m_display, m_fbconfig, GLX_RGBA_TYPE, 0, True );
    if ( !m_renderContext ) {
        fprintf( stderr, "Failed to create a GL context.\n" );
    }
    if ( !glXMakeContextCurrent( xengine->m_display, m_glxWindow, m_glxWindow, m_renderContext ) ) {
        fprintf( stderr, "Failed to attach GL context to window!\n" );
    }
    GLenum err = glewInit();
    if ( GLEW_OK != err ) {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
    }

    // Get an image of the entire desktop for use in shaders.
    XImage* image = XGetImage( xengine->m_display, xengine->m_root, 0, 0, xengine->getWidth(), xengine->getHeight(), 0xffffffff, ZPixmap );
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &m_desktop);
    glBindTexture(GL_TEXTURE_2D, m_desktop);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, xengine->getWidth(), xengine->getHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)(&(image->data[0])));
    XDestroyImage( image );

    glDisable(GL_TEXTURE_2D);
    m_framebuffer = new slop::Framebuffer( xengine->getWidth(), xengine->getHeight(), slop::Framebuffer::color, m_shader );
    m_framebuffer->bind();
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glClearColor( 0, 0, 0, 0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glXSwapBuffers( xengine->m_display, m_glxWindow );
    m_framebuffer->unbind();
}
Ejemplo n.º 22
0
void do_anim_shape_blocks (void *vdata)
{
#ifdef SHAPE
	struct ASDeskAniBlocks *data = (struct ASDeskAniBlocks *)vdata;
	XRectangle main_b = { 0, 0, Scr.MyDisplayWidth, Scr.MyDisplayHeight };
	unsigned int ratio = (unsigned long) MAX_MY_RND32 / LEVELS_NUM;
	int x_dim = Scr.MyDisplayWidth / BLOCKS_NUM;
	int y_dim = Scr.MyDisplayHeight / data->steps;
	int level;
	unsigned int th;
	unsigned char *tmp;

	if (y_dim < 2)
		y_dim = 2;


	th = MAX_MY_RND32;

	for (level = LEVELS_NUM - 1; level >= 0; level--) {
		int blocks_used;
		int i = 0;

		th -= ratio;
		if (data->off_y[level] < 0)
			continue;
		blocks_used = 0;

		tmp = data->stripes[level];
		for (i = 0; i < BLOCKS_NUM; i++) {
			if (tmp[i] == 0 && MY_RND32 () > th) {
				data->blocks[blocks_used].y = 0;
				data->blocks[blocks_used].x = i * x_dim;
				data->blocks[blocks_used].width = x_dim;
				data->blocks[blocks_used].height = y_dim;
				blocks_used++;
				tmp[i] = 1;
			}
		}
		XShapeCombineRectangles (dpy, data->cover, ShapeBounding, 0,
														 data->off_y[level], data->blocks, blocks_used,
														 ShapeSubtract, Unsorted);
		XFlush (dpy);
	}
	if (data->off_y[0] >= 0)
		data->open_height += y_dim;

	tmp = data->stripes[0];
	for (level = 0; level < LEVELS_NUM - 1; level++) {
		data->off_y[level] += y_dim;
		data->stripes[level] = data->stripes[level + 1];
	}
	data->off_y[LEVELS_NUM - 1] += y_dim;
	data->stripes[LEVELS_NUM - 1] = tmp;
	memset (tmp, 0x00, BLOCKS_NUM);

	main_b.height = data->open_height;
	if (main_b.height > 0)
		XShapeCombineRectangles (dpy, data->cover, ShapeBounding, 0, 0,
														 &main_b, 1, ShapeSubtract, Unsorted);

	++data->steps_done;
	if (data->steps_done >= data->steps) {
		for (level = 0; level < LEVELS_NUM; level++)
			free (data->stripes[level]);
		XDestroyWindow (dpy, data->cover);
		free (data);
	} else
		timer_new (20, do_anim_shape_blocks, vdata);
#endif
}
Ejemplo n.º 23
0
int tsmf_window_resize(TSMFGstreamerDecoder *decoder, int x, int y, int width,
					   int height, int nr_rects, RDP_RECT *rects)
{
	if (decoder->media_type != TSMF_MAJOR_TYPE_VIDEO)
		return -3;
	else
	{
#if GST_VERSION_MAJOR > 0
		GstVideoOverlay *overlay = GST_VIDEO_OVERLAY(decoder->outsink);
#else
		GstXOverlay *overlay = GST_X_OVERLAY(decoder->outsink);
#endif
		struct X11Handle *hdl = (struct X11Handle *)decoder->platform;
		DEBUG_TSMF("resize: x=%d, y=%d, w=%d, h=%d", x, y, width, height);
		assert(decoder);
		assert(hdl);
#if GST_VERSION_MAJOR > 0

		if (!gst_video_overlay_set_render_rectangle(overlay, 0, 0, width, height))
		{
			DEBUG_WARN("Could not resize overlay!");
		}

		gst_video_overlay_expose(overlay);
#else
		if (!gst_x_overlay_set_render_rectangle(overlay, 0, 0, width, height))
		{
			DEBUG_WARN("Could not resize overlay!");
		}

		gst_x_overlay_expose(overlay);
#endif

		if (hdl->subwin)
		{
			XMoveResizeWindow(hdl->disp, hdl->subwin, x, y, width, height);
#if defined(WITH_XEXT)

			if (hdl->has_shape)
			{
				int i;
				XRectangle *xrects = calloc(nr_rects, sizeof(XRectangle));

				for (i=0; i<nr_rects; i++)
				{
					xrects[i].x = rects[i].x - x;
					xrects[i].y = rects[i].y - y;
					xrects[i].width = rects[i].width;
					xrects[i].height = rects[i].height;
				}

				XShapeCombineRectangles(hdl->disp, hdl->subwin, ShapeBounding, x, y, xrects, nr_rects, ShapeSet, 0);
				free(xrects);
			}

#endif
			XSync(hdl->disp, FALSE);
		}

		return 0;
	}
}