예제 #1
0
파일: dcscreen.cpp 프로젝트: Duion/Torsion
wxScreenDC::wxScreenDC()
{
    m_ok = FALSE;
    
    m_display = (WXDisplay *) wxGlobalDisplay();
    
    int screen = DefaultScreen( (Display*) m_display );
    m_cmap = (WXColormap) DefaultColormap( (Display*) m_display, screen );
    
    m_window = (WXWindow) RootWindow( (Display*) m_display, screen );

    m_isScreenDC = TRUE;

#if wxUSE_UNICODE
    m_context = wxTheApp->GetPangoContext();
    m_fontdesc = wxNORMAL_FONT->GetNativeFontInfo()->description;
#endif

    SetUpDC();

    XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors );
    XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, IncludeInferiors );
    XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, IncludeInferiors );
    XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, IncludeInferiors );
}
예제 #2
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemEraseAccent(Widget			item,
					   unsigned char	accent_type,
					   Dimension		offset_left,
					   Dimension		offset_right,
					   Dimension		shadow_thickness,
					   Dimension		accent_thickness)
{
	Widget		pw;
	GC			gc;
	XGCValues	values;
	int			subwindow_mode;

	/* duh */
	if (accent_type == XmACCENT_NONE)
	{
		return;
	}

	assert( _XfeIsAlive(item) );
	assert( XmIsPushButton(item) || XmIsCascadeButton(item) );

	pw = _XfeParent(item);

	assert( XmIsRowColumn(pw) );

	gc = _XfemBackgroundGC(pw);

	/* Remember the old wubwindow mode values */
	XGetGCValues(XtDisplay(item),gc,GCSubwindowMode,&values);

	subwindow_mode = values.subwindow_mode;

	/* Force the subwindow mode to IncludeInferiors */
	XSetSubwindowMode(XtDisplay(item),gc,IncludeInferiors);

	switch(accent_type)
	{
	case XmACCENT_BOTTOM:
		AccentBottom(item,gc,None,offset_left,offset_right,
					 shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_ALL:
		AccentAll(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_TOP:
		AccentTop(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	default:
		break;
	}

	/* Restore the old subwindow mode */
	XSetSubwindowMode(XtDisplay(item),gc,subwindow_mode);
}
예제 #3
0
int tc_x11source_acquire(TCX11Source *handle, uint8_t *data, int maxdata)
{
    int size = -1;

    if (handle == NULL || data == NULL || maxdata <= 0) {
        tc_log_error(__FILE__, "x11source_acquire: wrong (NULL) parameters");
        return size;
    }

    XLockDisplay(handle->dpy);
    /* OK, let's hack a bit our GraphicContext */
    XSetSubwindowMode(handle->dpy, handle->gc, IncludeInferiors);
    /* don't catch areas of windows covered by children windows */
    XCopyArea(handle->dpy, handle->root, handle->pix, handle->gc,
              0, 0, handle->width, handle->height, 0, 0);

    XSetSubwindowMode(handle->dpy, handle->gc, ClipByChildren);
    /* but draw such areas if windows are opaque */
    
    size = handle->acquire_image(handle, data, maxdata);
    if (size > 0) {
        handle->acquire_cursor(handle, data, maxdata); /* cannot fail */
    }
    XUnlockDisplay(handle->dpy);
    return size;
}
예제 #4
0
파일: dcscreen.cpp 프로젝트: Duion/Torsion
wxScreenDC::~wxScreenDC()
{
    XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren );
    XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, ClipByChildren );
    XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, ClipByChildren );
    XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, ClipByChildren );

    EndDrawingOnTop();
}
예제 #5
0
void Painter::SetOverwrite(boolean children) {
    if (rep->overwrite != children) {
	XDisplay* dpy = rep->display->rep()->display_;
	rep->overwrite = children;
	XSetSubwindowMode(
	    dpy, rep->fillgc, children ? IncludeInferiors : ClipByChildren
	);
	XSetSubwindowMode(
	    dpy, rep->dashgc, children ? IncludeInferiors : ClipByChildren
	);
    }
}
예제 #6
0
Painter::Painter(Painter* copy) {
    rep = new PainterRep;
    XDisplay* dpy = rep->display->rep()->display_;
    rep->fillbg = copy->rep->fillbg;
    rep->overwrite = copy->rep->overwrite;
    Copy(copy);
    if (copy->rep->iv_xor) {
	Begin_xor();
    }
    rep->iv_xor = copy->rep->iv_xor;
    if (rep->overwrite) {
	XSetSubwindowMode(dpy, rep->fillgc, IncludeInferiors);
	XSetSubwindowMode(dpy, rep->dashgc, IncludeInferiors);
    }
}
예제 #7
0
MyPixmap::MyPixmap(Pixmap pp, int w, int h)
        : QPixmap(w, h)
{
    data->uninit = false;
#if QT_VERSION >= 300
    Screen *screen =  XDefaultScreenOfDisplay(dd);
    int scr = XScreenNumberOfScreen(screen);
    x11SetScreen(scr);
    GC gc = qt_xget_temp_gc( scr, FALSE );
#else
GC gc = qt_xget_temp_gc( FALSE );
#endif
    XSetSubwindowMode( dd, gc, IncludeInferiors );
    XCopyArea( dd, pp, handle(), gc, 0, 0, w, h, 0, 0 );
    XSetSubwindowMode( dd, gc, ClipByChildren );
}
예제 #8
0
void
JXGC::SetSubwindowMode
	(
	const int mode
	)
{
	if (mode != itsLastSubwindowMode)
		{
		itsLastSubwindowMode = mode;
		XSetSubwindowMode(*itsDisplay, itsXGC, mode);
		}
}
예제 #9
0
Pixmap
take_snapshot(Aosd* aosd)
{
  Display* dsp = aosd->display;
  Window root_win = aosd->root_win, win = aosd->win;
  int width = aosd->width, height = aosd->height;
  int scr = aosd->screen_num;
  Pixmap pixmap;
  GC gc;

  /* create a pixmap to hold the screenshot */
  pixmap = XCreatePixmap(dsp, win, width, height, DefaultDepth(dsp, scr));

  /* then copy the screen into the pixmap */
  gc = XCreateGC(dsp, pixmap, 0, NULL);
  XSetSubwindowMode(dsp, gc, IncludeInferiors);
  XCopyArea(dsp, root_win, pixmap, gc, aosd->x, aosd->y, width, height, 0, 0);
  XSetSubwindowMode(dsp, gc, ClipByChildren);
  XFreeGC(dsp, gc);

  return pixmap;
}
예제 #10
0
static X11DRV_PDEVICE *create_x11_physdev( Drawable drawable )
{
    X11DRV_PDEVICE *physDev;

    InitOnceExecuteOnce( &init_once, device_init, NULL, NULL );

    if (!(physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) ))) return NULL;

    physDev->drawable = drawable;
    physDev->gc = XCreateGC( gdi_display, drawable, 0, NULL );
    XSetGraphicsExposures( gdi_display, physDev->gc, False );
    XSetSubwindowMode( gdi_display, physDev->gc, IncludeInferiors );
    XFlush( gdi_display );
    return physDev;
}
예제 #11
0
static PyObject *
PaxGC_SetSubwindowMode(PaxGCObject *self, PyObject*args)
{
	int arg1;
	if (self->shared) {
		PyErr_SetString(PyExc_TypeError, "can't modify shared GC");
		return NULL;
	}
	if (!PyArg_ParseTuple(args, "i",
			&arg1))
		return NULL;
XSetSubwindowMode(self->display, self->gc,
			arg1);
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #12
0
/**********************************************************************
 *	     X11DRV_CreateDC
 */
BOOL X11DRV_CreateDC( HDC hdc, X11DRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR device,
                      LPCWSTR output, const DEVMODEW* initData )
{
    X11DRV_PDEVICE *physDev;

    if (!device_init_done) device_init();

    physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) );
    if (!physDev) return FALSE;

    *pdev = physDev;
    physDev->hdc = hdc;

    if (GetObjectType( hdc ) == OBJ_MEMDC)
    {
        if (!BITMAP_stock_phys_bitmap.hbitmap)
            BITMAP_stock_phys_bitmap.hbitmap = GetCurrentObject( hdc, OBJ_BITMAP );
        physDev->bitmap    = &BITMAP_stock_phys_bitmap;
        physDev->drawable  = BITMAP_stock_phys_bitmap.pixmap;
        physDev->depth     = 1;
        SetRect( &physDev->drawable_rect, 0, 0, 1, 1 );
        physDev->dc_rect = physDev->drawable_rect;
    }
    else
    {
        physDev->bitmap    = NULL;
        physDev->drawable  = root_window;
        physDev->depth     = screen_depth;
        physDev->drawable_rect = virtual_screen_rect;
        SetRect( &physDev->dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left,
                 virtual_screen_rect.bottom - virtual_screen_rect.top );
    }
    physDev->region = CreateRectRgn( 0, 0, 0, 0 );

    wine_tsx11_lock();
    physDev->gc = XCreateGC( gdi_display, physDev->drawable, 0, NULL );
    XSetGraphicsExposures( gdi_display, physDev->gc, False );
    XSetSubwindowMode( gdi_display, physDev->gc, IncludeInferiors );
    XFlush( gdi_display );
    wine_tsx11_unlock();
    return TRUE;
}
예제 #13
0
파일: x.c 프로젝트: kengonakajima/snippets
void	InitX(void)
{
	int	screen, dum;
	Pixmap	check;

	display = XOpenDisplay("");
	screen = DefaultScreen(display);
	cmap = DefaultColormap(display, screen);

	white = WhitePixel(display, screen);
	black = BlackPixel(display, screen);
	
	XGetGeometry(display, DefaultRootWindow(display),
		     &root, &dum, &dum, &width, &height, (unsigned int *)&dum, &depth);
	
	rootmap = XCreatePixmap(display, root, width, height, depth);
	cutmap = XCreatePixmap(display, root, width, height, depth);
	
	scratch = XCreateWindow(display, root, 0, 0, WINW, WINH, 0, depth,
			    InputOutput, CopyFromParent, 0, NULL);
	XSelectInput(display, scratch,
		     ExposureMask | KeyPressMask | PointerMotionMask |
		     ButtonPressMask | ButtonReleaseMask);
	XMapRaised(display, scratch);
	scratchmap = XCreatePixmap(display, root, WINW, WINH, depth);
	
	gc = XCreateGC(display, root, 0, 0);
	XSetSubwindowMode(display, gc, IncludeInferiors);
	
	shadow_gc = XCreateGC(display, root, 0, 0);
	XSetFillStyle(display, shadow_gc, FillStippled);
	check = XCreateBitmapFromData(display, root, check_bits, check_width, check_height);
	XSetStipple(display, shadow_gc, check);

	XGrabButton(display, Button1, Mod1Mask, DefaultRootWindow(display), False,
		    PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
		    GrabModeAsync, GrabModeAsync, DefaultRootWindow(display), None);
}
예제 #14
0
/**********************************************************************
 *           ExtEscape  (X11DRV.@)
 */
INT X11DRV_ExtEscape( X11DRV_PDEVICE *physDev, INT escape, INT in_count, LPCVOID in_data,
                      INT out_count, LPVOID out_data )
{
    switch(escape)
    {
    case QUERYESCSUPPORT:
        if (in_data)
        {
            switch (*(const INT *)in_data)
            {
            case DCICOMMAND:
                return DD_HAL_VERSION;
            case X11DRV_ESCAPE:
                return TRUE;
            }
        }
        break;

    case DCICOMMAND:
        if (in_data)
        {
            const DCICMD *lpCmd = in_data;
            if (lpCmd->dwVersion != DD_VERSION) break;
            return X11DRV_DCICommand(in_count, lpCmd, out_data);
        }
        break;

    case X11DRV_ESCAPE:
        if (in_data && in_count >= sizeof(enum x11drv_escape_codes))
        {
            switch(*(const enum x11drv_escape_codes *)in_data)
            {
            case X11DRV_GET_DISPLAY:
                if (out_count >= sizeof(Display *))
                {
                    *(Display **)out_data = gdi_display;
                    return TRUE;
                }
                break;
            case X11DRV_GET_DRAWABLE:
                if (out_count >= sizeof(Drawable))
                {
                    *(Drawable *)out_data = physDev->drawable;
                    return TRUE;
                }
                break;
            case X11DRV_GET_FONT:
                if (out_count >= sizeof(Font))
                {
                    fontObject* pfo = XFONT_GetFontObject( physDev->font );
		    if (pfo == NULL) return FALSE;
                    *(Font *)out_data = pfo->fs->fid;
                    return TRUE;
                }
                break;
            case X11DRV_SET_DRAWABLE:
                if (in_count >= sizeof(struct x11drv_escape_set_drawable))
                {
                    const struct x11drv_escape_set_drawable *data = (const struct x11drv_escape_set_drawable *)in_data;
                    if(physDev->xrender) X11DRV_XRender_UpdateDrawable( physDev );
                    physDev->dc_rect = data->dc_rect;
                    physDev->drawable = data->drawable;
                    physDev->drawable_rect = data->drawable_rect;
                    physDev->current_pf = pixelformat_from_fbconfig_id( data->fbconfig_id );
                    physDev->gl_drawable = data->gl_drawable;
                    physDev->pixmap = data->pixmap;
                    physDev->gl_copy = data->gl_copy;
                    wine_tsx11_lock();
                    XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
                    wine_tsx11_unlock();
                    TRACE( "SET_DRAWABLE hdc %p drawable %lx gl_drawable %lx pf %u dc_rect %s drawable_rect %s\n",
                           physDev->hdc, physDev->drawable, physDev->gl_drawable, physDev->current_pf,
                           wine_dbgstr_rect(&physDev->dc_rect), wine_dbgstr_rect(&physDev->drawable_rect) );
                    return TRUE;
                }
                break;
            case X11DRV_START_EXPOSURES:
                wine_tsx11_lock();
                XSetGraphicsExposures( gdi_display, physDev->gc, True );
                wine_tsx11_unlock();
                physDev->exposures = 0;
                return TRUE;
            case X11DRV_END_EXPOSURES:
                if (out_count >= sizeof(HRGN))
                {
                    HRGN hrgn = 0, tmp = 0;

                    wine_tsx11_lock();
                    XSetGraphicsExposures( gdi_display, physDev->gc, False );
                    wine_tsx11_unlock();
                    if (physDev->exposures)
                    {
                        for (;;)
                        {
                            XEvent event;

                            wine_tsx11_lock();
                            XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
                            wine_tsx11_unlock();
                            if (event.type == NoExpose) break;
                            if (event.type == GraphicsExpose)
                            {
                                int x = event.xgraphicsexpose.x - physDev->dc_rect.left;
                                int y = event.xgraphicsexpose.y - physDev->dc_rect.top;

                                TRACE( "got %d,%d %dx%d count %d\n", x, y,
                                       event.xgraphicsexpose.width,
                                       event.xgraphicsexpose.height,
                                       event.xgraphicsexpose.count );

                                if (!tmp) tmp = CreateRectRgn( 0, 0, 0, 0 );
                                SetRectRgn( tmp, x, y,
                                            x + event.xgraphicsexpose.width,
                                            y + event.xgraphicsexpose.height );
                                if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR );
                                else
                                {
                                    hrgn = tmp;
                                    tmp = 0;
                                }
                                if (!event.xgraphicsexpose.count) break;
                            }
                            else
                            {
                                ERR( "got unexpected event %d\n", event.type );
                                break;
                            }
                        }
                        if (tmp) DeleteObject( tmp );
                    }
                    *(HRGN *)out_data = hrgn;
                    return TRUE;
                }
                break;
            case X11DRV_GET_DCE:
            case X11DRV_SET_DCE:
                FIXME( "%x escape no longer supported\n", *(const enum x11drv_escape_codes *)in_data );
                break;
            case X11DRV_GET_GLX_DRAWABLE:
                if (out_count >= sizeof(Drawable))
                {
                    *(Drawable *)out_data = get_glxdrawable(physDev);
                    return TRUE;
                }
                break;
            case X11DRV_SYNC_PIXMAP:
                if(physDev->bitmap)
                {
                    X11DRV_CoerceDIBSection(physDev, DIB_Status_GdiMod);
                    return TRUE;
                }
                return FALSE;
            case X11DRV_FLUSH_GL_DRAWABLE:
                flush_gl_drawable(physDev);
                return TRUE;
            }
        }
        break;
    }
    return 0;
}
예제 #15
0
파일: CrGC.c 프로젝트: ghaerr/microwindows
static void
setupGC(Display * dpy, GC gc, unsigned long valuemask, XGCValues * values)
{
	if (valuemask & GCFunction)
		XSetFunction(dpy, gc, values->function);

	if (valuemask & GCForeground)
		XSetForeground(dpy, gc, values->foreground);

	if (valuemask & GCBackground)
		XSetBackground(dpy, gc, values->background);

	//FIXME add save gc->ext_data values for each of these...
	if (valuemask & GCFont)
		XSetFont(dpy, gc, values->font);

	if (valuemask & GCGraphicsExposures)
		XSetGraphicsExposures(dpy, gc, values->graphics_exposures);

	if ((valuemask & GCClipXOrigin) && (valuemask & GCClipYOrigin))
		XSetClipOrigin(dpy, gc, values->clip_x_origin,
		    values->clip_y_origin);

	if (valuemask & GCClipMask)
		XSetClipMask(dpy, gc, values->clip_mask);

	if (valuemask & GCFillStyle)
		XSetFillStyle(dpy, gc, values->fill_style);

	if ((valuemask & GCTileStipXOrigin) && (valuemask & GCTileStipYOrigin))
		XSetTSOrigin(dpy, gc, values->ts_x_origin, values->ts_y_origin);

	// FIXME
	if (valuemask & (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle))
		XSetLineAttributes(dpy, gc, values->line_width,
		    values->line_style, values->cap_style, values->join_style);

	if (valuemask & GCFillRule)
		XSetFillStyle(dpy, gc, values->fill_rule);

	if (valuemask & GCTile)
		XSetTile(dpy, gc, values->tile);

	if (valuemask & GCStipple)
		XSetStipple(dpy, gc, values->stipple);

	if (valuemask & (GCDashOffset | GCDashList)) {
		// FIXME is this correct for values->dashes?
		if (values->dashes) {
			char d[2];
			d[0] = d[1] = values->dashes;
			XSetDashes(dpy, gc, values->dash_offset, d, 2);
		}
	}

	if (valuemask & GCSubwindowMode)
		XSetSubwindowMode(dpy, gc, values->subwindow_mode);

	if (valuemask & GCPlaneMask)
		DPRINTF("XCreateGC: GCPlaneMask not implemented\n");

	if (valuemask & GCArcMode)
		DPRINTF("XCreateGC: GCArcMode not implemented\n");
}
예제 #16
0
파일: Stroke.c 프로젝트: idunham/dtextra
static void Input (Widget W, StrokeStatePtr State, XEvent *event)
{
	/*
	   fprintf(stderr, "Input(%s,%i) - %s %i %i %i %i\n",
	   XtName(State->widget),
	   event->xany.type,
	   XtName(W),
	   event->xbutton.x,
	   event->xbutton.y,
	   event->xbutton.x_root,
	   event->xbutton.y_root);
	 */
	switch (event->xany.type)
	{
	case KeyRelease:
	case ButtonRelease:
		if (State->InStroke)
		{
			int i;

			if (!State->Debug)
			{
				for (i = 1; i < State->npoints; i++)
				{
					XDrawLine(XtDisplay(W),
						  event->xbutton.root,
						  State->gc,
						  State->points[i - 1].x,
						  State->points[i - 1].y,
						  State->points[i].x,
						  State->points[i].y);
					/*
					   XDrawRectangle(XtDisplay(State->widget),
					   XtWindow(State->widget),
					   State->gc,
					   State->points[State->npoints].x - 2,
					   State->points[State->npoints].y - 2,
					   4,
					   4);
					 */
				}
			}
			XtUngrabPointer(W, event->xbutton.time);
			XUngrabServer(XtDisplay(W));
			DoStroke(event, State);
			State->InStroke = False;
			State->npoints = 0;
		}
		break;
	case KeyPress:
	case ButtonPress:
		if (!State->InStroke)
		{
			State->widget = W;
			State->npoints = 0;
			AllocatePoints(State);
			/*
			   TranslateCoords(W, State->widget,
			   &((XButtonPressedEvent *)event)->x,
			   &((XButtonPressedEvent *)event)->y);
			 */
			State->points[State->npoints].x = event->xbutton.x_root;
			State->points[State->npoints].y = event->xbutton.y_root;
			State->xmin = State->points[State->npoints].x;
			State->ymin = State->points[State->npoints].y;
			State->xmax = State->points[State->npoints].x;
			State->ymax = State->points[State->npoints].y;
			State->npoints++;
			State->InStroke = True;
			XGrabServer(XtDisplay(W));
			XtGrabPointer(W, 
				False,
				ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
				GrabModeAsync, GrabModeAsync, None, None, event->xbutton.time);
		}
		break;
	case MotionNotify:
		if (State->gc == (GC)NULL)
		{
			Pixel Background;

			State->gc = XCreateGC(XtDisplay(State->widget),
					      XtWindow(State->widget),
					      0, NULL);
			XtVaGetValues(State->widget,
				      XtNbackground, &Background,
				      NULL);
			XSetForeground(XtDisplay(State->widget),
				       State->gc,
				       Background);
			XSetFunction(XtDisplay(State->widget), State->gc, GXxor);
			XSetSubwindowMode(XtDisplay(State->widget), State->gc, IncludeInferiors);
		}
		if (State->InStroke)
		{
			int dx = State->points[State->npoints - 1].x - event->xmotion.x_root;
			int dy = State->points[State->npoints - 1].y - event->xmotion.y_root;

			if (dx * dx + dy * dy > State->slop)
			{
				AllocatePoints(State);
				State->points[State->npoints].x = event->xmotion.x_root;
				State->points[State->npoints].y = event->xmotion.y_root;
				XDrawLine(XtDisplay(State->widget),
					  event->xmotion.root,
					  State->gc,
					  State->points[State->npoints - 1].x,
					  State->points[State->npoints - 1].y,
					  State->points[State->npoints].x,
					  State->points[State->npoints].y);
				State->xmin = State->xmin < State->points[State->npoints].x ? State->xmin : State->points[State->npoints].x;
				State->xmax = State->xmax > State->points[State->npoints].x ? State->xmax : State->points[State->npoints].x;
				State->ymin = State->ymin < State->points[State->npoints].y ? State->ymin : State->points[State->npoints].y;
				State->ymax = State->ymax > State->points[State->npoints].y ? State->ymax : State->points[State->npoints].y;
				State->npoints++;
			}
		}
		break;
	default:
		fprintf(stderr, "%s(%i): Input(%s) - %s Unknown event type %i\n",
			__FILE__,
			__LINE__,
			XtName(State->widget),
			XtName(W),
			event->type);
	}
}
예제 #17
0
/**********************************************************************
 *           ExtEscape  (X11DRV.@)
 */
static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data,
                      INT out_count, LPVOID out_data )
{
    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );

    switch(escape)
    {
    case QUERYESCSUPPORT:
        if (in_data && in_count >= sizeof(DWORD))
        {
            switch (*(const INT *)in_data)
            {
            case X11DRV_ESCAPE:
                return TRUE;
            }
        }
        break;

    case X11DRV_ESCAPE:
        if (in_data && in_count >= sizeof(enum x11drv_escape_codes))
        {
            switch(*(const enum x11drv_escape_codes *)in_data)
            {
            case X11DRV_SET_DRAWABLE:
                if (in_count >= sizeof(struct x11drv_escape_set_drawable))
                {
                    const struct x11drv_escape_set_drawable *data = in_data;
                    physDev->dc_rect = data->dc_rect;
                    physDev->drawable = data->drawable;
                    XFreeGC( gdi_display, physDev->gc );
                    physDev->gc = XCreateGC( gdi_display, physDev->drawable, 0, NULL );
                    XSetGraphicsExposures( gdi_display, physDev->gc, False );
                    XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
                    TRACE( "SET_DRAWABLE hdc %p drawable %lx dc_rect %s\n",
                           dev->hdc, physDev->drawable, wine_dbgstr_rect(&physDev->dc_rect) );
                    return TRUE;
                }
                break;
            case X11DRV_GET_DRAWABLE:
                if (out_count >= sizeof(struct x11drv_escape_get_drawable))
                {
                    struct x11drv_escape_get_drawable *data = out_data;
                    data->drawable = physDev->drawable;
                    data->dc_rect = physDev->dc_rect;
                    return TRUE;
                }
                break;
            case X11DRV_FLUSH_GL_DRAWABLE:
                if (in_count >= sizeof(struct x11drv_escape_flush_gl_drawable))
                {
                    const struct x11drv_escape_flush_gl_drawable *data = in_data;
                    RECT rect = physDev->dc_rect;

                    OffsetRect( &rect, -physDev->dc_rect.left, -physDev->dc_rect.top );
                    /* The GL drawable may be lagged behind if we don't flush first, so
                     * flush the display make sure we copy up-to-date data */
                    XFlush( gdi_display );
                    XSetFunction( gdi_display, physDev->gc, GXcopy );
                    XCopyArea( gdi_display, data->gl_drawable, physDev->drawable, physDev->gc,
                               0, 0, rect.right, rect.bottom,
                               physDev->dc_rect.left, physDev->dc_rect.top );
                    add_device_bounds( physDev, &rect );
                    return TRUE;
                }
                break;
            case X11DRV_START_EXPOSURES:
                XSetGraphicsExposures( gdi_display, physDev->gc, True );
                physDev->exposures = 0;
                return TRUE;
            case X11DRV_END_EXPOSURES:
                if (out_count >= sizeof(HRGN))
                {
                    HRGN hrgn = 0, tmp = 0;

                    XSetGraphicsExposures( gdi_display, physDev->gc, False );
                    if (physDev->exposures)
                    {
                        for (;;)
                        {
                            XEvent event;

                            XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
                            if (event.type == NoExpose) break;
                            if (event.type == GraphicsExpose)
                            {
                                RECT rect;

                                rect.left   = event.xgraphicsexpose.x - physDev->dc_rect.left;
                                rect.top    = event.xgraphicsexpose.y - physDev->dc_rect.top;
                                rect.right  = rect.left + event.xgraphicsexpose.width;
                                rect.bottom = rect.top + event.xgraphicsexpose.height;
                                if (GetLayout( dev->hdc ) & LAYOUT_RTL)
                                    mirror_rect( &physDev->dc_rect, &rect );

                                TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect),
                                       event.xgraphicsexpose.count );

                                if (!tmp) tmp = CreateRectRgnIndirect( &rect );
                                else SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom );
                                if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR );
                                else
                                {
                                    hrgn = tmp;
                                    tmp = 0;
                                }
                                if (!event.xgraphicsexpose.count) break;
                            }
                            else
                            {
                                ERR( "got unexpected event %d\n", event.type );
                                break;
                            }
                        }
                        if (tmp) DeleteObject( tmp );
                    }
                    *(HRGN *)out_data = hrgn;
                    return TRUE;
                }
                break;
            default:
                break;
            }
        }
        break;
    }
    return 0;
}
예제 #18
0
파일: init.c 프로젝트: lucianolorenti/wine
/**********************************************************************
 *           ExtEscape  (X11DRV.@)
 */
static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data,
                      INT out_count, LPVOID out_data )
{
    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );

    switch(escape)
    {
    case QUERYESCSUPPORT:
        if (in_data)
        {
            switch (*(const INT *)in_data)
            {
            case DCICOMMAND:
                return DD_HAL_VERSION;
            case X11DRV_ESCAPE:
                return TRUE;
            }
        }
        break;

    case X11DRV_ESCAPE:
        if (in_data && in_count >= sizeof(enum x11drv_escape_codes))
        {
            switch(*(const enum x11drv_escape_codes *)in_data)
            {
            case X11DRV_SET_DRAWABLE:
                if (in_count >= sizeof(struct x11drv_escape_set_drawable))
                {
                    const struct x11drv_escape_set_drawable *data = in_data;
                    physDev->dc_rect = data->dc_rect;
                    physDev->drawable = data->drawable;
                    wine_tsx11_lock();
                    XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
                    wine_tsx11_unlock();
                    TRACE( "SET_DRAWABLE hdc %p drawable %lx dc_rect %s\n",
                           dev->hdc, physDev->drawable, wine_dbgstr_rect(&physDev->dc_rect) );
                    return TRUE;
                }
                break;
            case X11DRV_GET_DRAWABLE:
                if (out_count >= sizeof(struct x11drv_escape_get_drawable))
                {
                    struct x11drv_escape_get_drawable *data = out_data;
                    data->drawable = physDev->drawable;
                    return TRUE;
                }
                break;
            case X11DRV_START_EXPOSURES:
                wine_tsx11_lock();
                XSetGraphicsExposures( gdi_display, physDev->gc, True );
                wine_tsx11_unlock();
                physDev->exposures = 0;
                return TRUE;
            case X11DRV_END_EXPOSURES:
                if (out_count >= sizeof(HRGN))
                {
                    HRGN hrgn = 0, tmp = 0;

                    wine_tsx11_lock();
                    XSetGraphicsExposures( gdi_display, physDev->gc, False );
                    wine_tsx11_unlock();
                    if (physDev->exposures)
                    {
                        for (;;)
                        {
                            XEvent event;

                            wine_tsx11_lock();
                            XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
                            wine_tsx11_unlock();
                            if (event.type == NoExpose) break;
                            if (event.type == GraphicsExpose)
                            {
                                RECT rect;

                                rect.left   = event.xgraphicsexpose.x - physDev->dc_rect.left;
                                rect.top    = event.xgraphicsexpose.y - physDev->dc_rect.top;
                                rect.right  = rect.left + event.xgraphicsexpose.width;
                                rect.bottom = rect.top + event.xgraphicsexpose.height;
                                if (GetLayout( dev->hdc ) & LAYOUT_RTL)
                                    mirror_rect( &physDev->dc_rect, &rect );

                                TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect),
                                       event.xgraphicsexpose.count );

                                if (!tmp) tmp = CreateRectRgnIndirect( &rect );
                                else SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom );
                                if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR );
                                else
                                {
                                    hrgn = tmp;
                                    tmp = 0;
                                }
                                if (!event.xgraphicsexpose.count) break;
                            }
                            else
                            {
                                ERR( "got unexpected event %d\n", event.type );
                                break;
                            }
                        }
                        if (tmp) DeleteObject( tmp );
                    }
                    *(HRGN *)out_data = hrgn;
                    return TRUE;
                }
                break;
            default:
                break;
            }
        }
        break;
    }
    return 0;
}
예제 #19
0
void
gui_move_window(winlist_t *win)
{
    xccore_t *xccore = (xccore_t *)win->data;
    int event_x, event_y;
    int offset_x, offset_y;
    int move_x, move_y;
    GC  moveGC;
    int draw_flag = False;
    int workarea_x, workarea_y;
    int workarea_x2, workarea_y2;
    unsigned int workarea_width, workarea_height;

    gui_get_workarea(&workarea_x, &workarea_y,
			&workarea_width, &workarea_height);

    workarea_x2 = workarea_x + workarea_width;
    workarea_y2 = workarea_y + workarea_height;

    gui_get_mouse_xy(&event_x, &event_y);
    offset_x = event_x - win->pos_x;
    offset_y = event_y - win->pos_y;

    moveGC = XCreateGC(gui->display, gui->root, 0, NULL);
    XSetSubwindowMode(gui->display, moveGC, IncludeInferiors);
    XSetForeground(gui->display, moveGC, BlackPixel(gui->display, gui->screen));
    XSetFunction(gui->display, moveGC, GXxor);

    XChangeActivePointerGrab(gui->display,
                PointerMotionMask | ButtonMotionMask | ButtonReleaseMask |
                OwnerGrabButtonMask, None, CurrentTime);

    XGrabServer(gui->display);

    XEvent myevent;
    while(1)
    {
	XNextEvent(gui->display, &myevent);
	switch(myevent.type)
	{
	    case ButtonRelease:
		if(myevent.xbutton.button == Button1)
		{
		    if (draw_flag)
		    {
			gui_draw_xor_box(moveGC, move_x - offset_x, move_y - offset_y, win->width, win->height);
		    }
		    XFreeGC(gui->display, moveGC);
		    gui_get_mouse_xy(&move_x, &move_y);
		    win->pos_x = move_x - offset_x;
		    win->pos_y = move_y - offset_y;

		    /* */
		    if (win->pos_x < workarea_x)
			win->pos_x = workarea_x;
		    if (win->pos_y < workarea_y)
			win->pos_y = workarea_y;
		    if (win->pos_x + win->width > workarea_x2)
			win->pos_x = workarea_x2 - win->width - 2;
		    if (win->pos_y + win->height > workarea_y2)
			win->pos_y = workarea_y2 - win->height - 2;

		    XMoveWindow(gui->display, win->window,
				 win->pos_x, win->pos_y);
		    XUngrabServer(gui->display);
		    gui_save_window_pos(); /* 儲存視窗位置 */
		    return;
		}
		break;

	    case MotionNotify:
		if (draw_flag)
		{
		    gui_draw_xor_box(moveGC, move_x - offset_x, move_y - offset_y, win->width, win->height);
		}
		gui_get_mouse_xy(&move_x, &move_y);
		gui_draw_xor_box(moveGC, move_x - offset_x, move_y - offset_y, win->width, win->height);
		draw_flag = True;
		break;
	    default:
		break;
	}
    }
}
예제 #20
0
파일: main.c 프로젝트: arievanleyen/xpen
int set_full_screen(Display *dpy) {
    signal(SIGUSR1, fake_right_button);
    fulldisplay = dpy;
    Window curwin, rootw;
    Cursor hand_cursor;
    int x1, y1, winx, winy;
    unsigned int mask;
    XEvent ev;
    int screen_num;

    if (!dpy) {
        fprintf(stderr, "WTPEN : cannot get default display\n");
        exit(1);
    }

    /* style for line */
    unsigned int line_width = 8;
    int line_style = LineSolid;
    int cap_style  = CapRound;
    int join_style = JoinRound;

    screen_num = DefaultScreen(dpy);
    rootw = DefaultRootWindow(dpy);

    if (rootw == None) {
        fprintf(stderr, "WTPEN : full screen mode cannot get root window\n");
        exit(1);
    }

    hand_cursor = XCreateFontCursor(dpy, XC_hand2);

    drawgc = XCreateGC(dpy, rootw, 0, NULL);			// hier wordt getekend (met xor)
    XSetSubwindowMode(dpy, drawgc, IncludeInferiors);
    XSetForeground(dpy, drawgc,
                   WhitePixel(dpy, screen_num)
                   ^ BlackPixel(dpy, screen_num));
    XSetLineAttributes(dpy, drawgc, line_width, line_style,
                       cap_style, join_style);
    XSetFunction(dpy, drawgc, GXandInverted);
    //XSetFunction(dpy, drawgc, GXxor);

    fprintf(stderr, "full screen mode grab button\n");
    XGrabButton(dpy, AnyButton, 0, rootw, False,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | OwnerGrabButtonMask,
                GrabModeSync, GrabModeAsync, None, hand_cursor);

	while (1) {
		fprintf (stderr, "fullscreen\n");	// wordt bij tekenen aangeroepen
        XAllowEvents(dpy, SyncPointer, CurrentTime);
        XWindowEvent(dpy, rootw, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, &ev);

        switch(ev.type) {
        case ButtonPress:
            kill(getppid(), SIGUSR2);
            if(ev.xbutton.button != Button1) {
                int num;
                XUngrabButton(dpy, AnyButton, 0, rootw);
                XFlush(dpy);
                record_coordinate(0xff, 0xff);
                clear_draw_area(dpy, rootw, drawgc);
                num = get_coordinates_num();
                return num;
            }
            XQueryPointer(dpy, rootw,
                          &rootw, &curwin,
                          &x1, &y1,	//root x, root y
                          &winx, &winy,
                          &mask);
            record_coordinate(x1, y1);
            break;
        case ButtonRelease:
            if (ev.xbutton.button == Button1) {
                if (get_coordinates_num() == 2) {
                    free_coordinates();
                    XUngrabButton(dpy, AnyButton, 0, rootw);
                    forward_click_event(dpy, &ev);
                    XFlush(dpy);
                    return 0;
                }
                record_coordinate(0xff, 0x00);
                kill(getppid(), SIGALRM);
            }
            break;
        case MotionNotify:
            if (ev.xmotion.state & Button1MotionMask) {
                CoordinateList *cl_end;
                XQueryPointer(dpy, rootw,
                              &rootw, &curwin,
                              &x1, &y1,	//root x, root y
                              &winx, &winy,
                              &mask);
                cl_end = coordinate_list_end();
                if (cl_end) {
                    if (!(cl_end->x == 0xff && cl_end->y == 0x00)) {
                        XDrawLine(dpy, rootw,
                                  drawgc,
                                  x1,
                                  y1,
                                  cl_end->x,
                                  cl_end->y);
                        record_coordinate(x1, y1);
                    }
                } else {
                    record_coordinate(x1, y1);
                }
            }
            break;
        default:
            break;
        }
    }
    fprintf(stderr, "exit fullscreen\n");		// wordt nooit bereikt
    return 1;
}
예제 #21
0
static void *
zoom_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  XGCValues gcv;
  XWindowAttributes xgwa;
  Colormap cmap;
  unsigned long bg;
  long gcflags;
  int nblocksx, nblocksy;

  st->dpy = dpy;
  st->window = window;
  XGetWindowAttributes(st->dpy, st->window, &xgwa);
  st->screen = xgwa.screen;
  st->sizex = xgwa.width;
  st->sizey = xgwa.height;
  cmap = xgwa.colormap;
  bg = get_pixel_resource(st->dpy, cmap, "background", "Background");

  st->delay = get_integer_resource(st->dpy, "delay", "Integer");
  if (st->delay < 1)
    st->delay = 1;
  st->duration = get_integer_resource (st->dpy, "duration", "Seconds");
  if (st->duration < 1)
    st->duration = 1;
  st->pixwidth = get_integer_resource(st->dpy, "pixwidth", "Integer");
  if (st->pixwidth < 1)
    st->pixwidth = 1;
  st->pixheight = get_integer_resource(st->dpy, "pixheight", "Integer");
  if (st->pixheight < 1)
    st->pixheight = 1;
  st->pixspacex = get_integer_resource(st->dpy, "pixspacex", "Integer");
  if (st->pixspacex < 0)
    st->pixspacex = 0;
  st->pixspacey = get_integer_resource(st->dpy, "pixspacey", "Integer");
  if (st->pixspacey < 0)
    st->pixspacey = 0;
  st->lenses = get_boolean_resource(st->dpy, "lenses", "Boolean");
  st->lensoffsetx = get_integer_resource(st->dpy, "lensoffsetx", "Integer");
  st->lensoffsetx = MAX(0, MIN(st->pixwidth, st->lensoffsetx));
  st->lensoffsety = get_integer_resource(st->dpy, "lensoffsety", "Integer");
  st->lensoffsety = MAX(0, MIN(st->pixwidth, st->lensoffsety));

  gcv.function = GXcopy;
  gcv.subwindow_mode = IncludeInferiors;
  gcflags = GCForeground|GCFunction;
  gcv.foreground = bg;
  if (!st->lenses && use_subwindow_mode_p(xgwa.screen, st->window))       /* see grabscreen.c */
    gcflags |= GCSubwindowMode;
  st->window_gc = XCreateGC(st->dpy, st->window, gcflags, &gcv);


  st->orig_map = NULL;
  st->pm = XCreatePixmap(st->dpy, st->window, st->sizex, st->sizey, xgwa.depth);

  XFillRectangle(st->dpy, st->window, st->window_gc, 0, 0, st->sizex, st->sizey);
  XSetWindowBackground(st->dpy, st->window, bg);

  st->start_time = time ((time_t) 0);
  st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
                                            st->pm, 0, 0);

  /* We might have needed this to grab the image, but if we leave this set
     to GCSubwindowMode, then we'll *draw* right over subwindows too. */
  XSetSubwindowMode (st->dpy, st->window_gc, ClipByChildren);


  nblocksx = (int)ceil((double)st->sizex / (double)(st->pixwidth + st->pixspacex));
  nblocksy = (int)ceil((double)st->sizey / (double)(st->pixheight + st->pixspacey));
  if (st->lenses)
    st->s = MAX((nblocksx - 1) * st->lensoffsetx + st->pixwidth, 
	    (nblocksy - 1) * st->lensoffsety + st->pixheight) * 2;
  else
    st->s = MAX(nblocksx, nblocksy) * 2;

  st->sinusoid_offset = random();

  return st;
}
예제 #22
0
int grab_rectangle (Display * display, Window root, XRectangle * xrect)
{
    Cursor cursor_start, cursor_finis;
    unsigned int x, y, rootx, rooty;
    int rx, ry, rw = 0, rh = 0;
    int drawn = False;
    XEvent event;
    GC gc;

    /* get some cursors for rectangle formation */
    // cursor_start = XCreateFontCursor (display, XC_ul_angle);
    // cursor_finis = XCreateFontCursor (display, XC_lr_angle);
    cursor_start = XCreateFontCursor (display, XC_pencil);
    cursor_finis = XCreateFontCursor (display, XC_pencil);
    
    /* grab the pointer */
    if (GrabSuccess != XGrabPointer (display, root, False, ButtonPressMask,
            GrabModeAsync, GrabModeAsync, root, cursor_start, CurrentTime))
    return 1;

    /* create a graphics context to draw with */
    gc = XCreateGC (display, root, 0, NULL);
    if (!gc)
        return 2;
    XSetSubwindowMode (display, gc, IncludeInferiors);
    XSetForeground (display, gc, 255);
    XSetFunction (display, gc, GXxor);

    /* get a button-press and pull out the root location */
    XMaskEvent (display, ButtonPressMask, &event);
    rootx = rx = event.xbutton.x_root;
    rooty = ry = event.xbutton.y_root;

    /* get pointer motion events */
    XChangeActivePointerGrab (display, ButtonMotionMask | ButtonReleaseMask,
                                cursor_finis, CurrentTime);

    /* MAKE_RECT converts the original root coordinates and the event root
     * coordinates into a rectangle in xrect */
#define MAKE_RECT(etype)            \
x = event.etype.x_root;           \
y = event.etype.y_root;           \
rw = x - rootx;               \
vecx = rw;                    \
if (rw  < 0) rw  = -rw;           \
rh = y - rooty;               \
vecy = -rh;                    \
if (rh  < 0) rh  = -rh;           \
rx = x < rootx ? x : rootx;           \
ry = y < rooty ? y : rooty

    /* loop to let the user drag a rectangle */
    while (1)
    {
        XNextEvent (display, &event);
        
        switch (event.type)
        {
            case ButtonRelease:
                if (drawn)
                {
                  XDrawRectangle (display, root, gc, rx, ry, rw, rh);
                  drawn = 0;
                }
                XFlush (display);
                /* record the final location */
                MAKE_RECT (xbutton);
                /* release resources */
                XFreeGC (display, gc);
                XFreeCursor (display, cursor_start);
                XFreeCursor (display, cursor_finis);
                xrect->x = rx;
                xrect->y = ry;
                xrect->width = rw;
                xrect->height = rh;
                XUngrabPointer (display, CurrentTime);
                XSync (display, 0);
                return 1;
            case MotionNotify:
                if (drawn)
                {
                  XDrawRectangle (display, root, gc, rx, ry, rw, rh);
                  drawn = 0;
                }
                while (XCheckTypedEvent (display, MotionNotify, &event))
                {}
                MAKE_RECT (xmotion);
                XDrawRectangle (display, root, gc, rx, ry, rw, rh);
                drawn = 1;
                break;
        }
    }

    return 0;
}