コード例 #1
0
ファイル: func7.c プロジェクト: TomoMayumi/mypaint
void line(XEvent ev,Window *layer_expose,Window *layer,Window *mask,int num){
  int xs,ys,xe,ye;

  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, None, ShapeSet);//いったんマスクを解除
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, None, ShapeSet);

  XCopyArea( dis, layer[num], copy_pix[0], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );

  xs=ev.xbutton.x;
  ys=ev.xbutton.y;

  while( !(ev.type == ButtonRelease && ev.xbutton.button == 1) ){
    if(ev.type == MotionNotify){
      XCopyArea( dis, copy_pix[0], copy_pix[1], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );
      xe=ev.xbutton.x;
      ye=ev.xbutton.y;
      
      XDrawLine(dis, copy_pix[1], gc, xs, ys, xe, ye);
      XCopyArea( dis, copy_pix[1], layer[num], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );
      XFlush(dis);
    }
    XNextEvent( dis, &ev );
  }
  XDrawLine(dis, mask[num], mask_gc, xs, ys, xe, ye);
  XDrawLine(dis, layer_expose[num], gc, xs, ys, xe, ye);
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, mask[num], ShapeSet);
  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, mask[num], ShapeSet);

  addHistory(layer_expose,mask,num);//履歴に追加

}
コード例 #2
0
ファイル: x.c プロジェクト: Limsik/e17
static void
EShapeCombineMask(Win win, int dest, int x, int y, Pixmap pmap, int op)
{
   char                wasshaped = 0;

   if (!win)
      return;

   if (win->rects || win->num_rect < 0)
     {
	win->num_rect = 0;
	if (win->rects)
	   XFree(win->rects);
	win->rects = NULL;
	wasshaped = 1;
     }
#if DEBUG_SHAPE_OPS
   Eprintf("EShapeCombineMask %#lx %d,%d %dx%d mask=%#lx wassh=%d\n",
	   win->xwin, win->x, win->y, win->w, win->h, pmap, wasshaped);
#endif
   if (pmap)
     {
	XShapeCombineMask(disp, win->xwin, dest, x, y, pmap, op);
	EShapeUpdate(win);
     }
   else if (wasshaped)
      XShapeCombineMask(disp, win->xwin, dest, x, y, pmap, op);
}
コード例 #3
0
ファイル: func7.c プロジェクト: TomoMayumi/mypaint
void freeHand(XEvent ev,Window *layer_expose,Window *layer,Window *mask,int num){
  int x,y;
  int i;

  x=ev.xbutton.x;
  y=ev.xbutton.y;

  XSetForeground( dis, gc, current_color  );    // 図形の色を設定

  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, None, ShapeSet);//いったんマスクを解除
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, None, ShapeSet);
  
  XNextEvent( dis, &ev );
  while( !(ev.type == ButtonRelease && ev.xbutton.button == 1) ){
    if(ev.type == MotionNotify){
      XDrawLine( dis, layer_expose[num], gc, x, y, ev.xbutton.x, ev.xbutton.y );
      XDrawLine( dis, layer[num], gc, x, y, ev.xbutton.x, ev.xbutton.y );
      XDrawLine( dis, mask[num], mask_gc, x, y, ev.xbutton.x, ev.xbutton.y );
      XFlush( dis );
      
      x=ev.xbutton.x;
      y=ev.xbutton.y;
    }
    XNextEvent( dis, &ev );
    
  }
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, mask[num], ShapeSet);
  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, mask[num], ShapeSet);

  addHistory(layer_expose,mask,num);//履歴に追加

}
コード例 #4
0
ファイル: wmAppKill.c プロジェクト: d-torrance/dockapps
void CreateDock(int argc, char *argv[])    /* this part comes from http://www.linuxmag-france.org/ */
{
   Window root;
   XWMHints wmHints;
   XSizeHints sizeHints;
   XClassHint classHint;
   Pixmap pixmask;
   unsigned long p_blanc;
   unsigned long p_noir;
   unsigned int borderWidth = 2;
   char *wname = argv[0] ;

   dpy = XOpenDisplay(NULL) ;

   if(dpy == NULL)
	  {
	     fprintf(stderr, "Can't open display\n") ;
	     exit(1) ;
	  }

   root = RootWindow(dpy,screen);
   p_blanc = WhitePixel(dpy,screen) ;
   p_noir = BlackPixel(dpy,screen) ;
   gc = XDefaultGC(dpy,screen) ;
   XSetForeground(dpy, gc, p_noir);
   XSetBackground(dpy, gc,p_noir);

   sizeHints.x = 0 ;
   sizeHints.y = 0 ;
   sizeHints.width = 64 ;
   sizeHints.height = 64 ;

   win = XCreateSimpleWindow(dpy,root,sizeHints.x,sizeHints.y , sizeHints.width, sizeHints.height, borderWidth, p_noir,p_noir) ;
   iconWin = XCreateSimpleWindow(dpy,root,sizeHints.x,sizeHints.y,sizeHints.width, sizeHints.height, borderWidth, p_noir,p_noir ) ;

   sizeHints.flags = USSize | USPosition ;
   XSetWMNormalHints(dpy,win,&sizeHints) ;
   wmHints.initial_state = WithdrawnState ;
   wmHints.icon_window = iconWin ;
   wmHints.icon_x = sizeHints.x ;
   wmHints.icon_y = sizeHints.y ;
   wmHints.window_group = win ;
   wmHints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint ;
   XSetWMHints(dpy, win, &wmHints) ;
   classHint.res_name = wname ;
   classHint.res_class = wname ;

   XSetClassHint(dpy, win, &classHint) ;
   XSetCommand(dpy,win, argv, argc) ;

   pixmask = XCreateBitmapFromData(dpy,win,fond_bits, fond_width, fond_height) ;
   XShapeCombineMask(dpy,win,ShapeBounding,0,0,pixmask,ShapeSet) ;
   XShapeCombineMask(dpy,iconWin,ShapeBounding, 0, 0, pixmask, ShapeSet) ;
   XpmCreatePixmapFromData(dpy,root,wmAppKill_xpm, &XPM, NULL,NULL) ;

   XSelectInput(dpy,win, ExposureMask | ButtonPressMask) ;
   XSelectInput(dpy,iconWin, ExposureMask | ButtonPressMask) ;

   XMapWindow(dpy,win) ;
}
コード例 #5
0
static void
ShapeRectangle(Widget w)
{
  XShapeCombineMask(XtDisplay(w), XtWindow(w),
		    ShapeBounding, 0, 0, None, ShapeSet);
  XShapeCombineMask(XtDisplay(w), XtWindow(w),
		    ShapeClip, 0, 0, None, ShapeSet);
}
コード例 #6
0
ファイル: dockapp.c プロジェクト: yogsothoth/wmmp
void
dockapp_setshape(Pixmap mask, int x_ofs, int y_ofs)
{
    XShapeCombineMask(display, icon_window, ShapeBounding, -x_ofs, -y_ofs,
		      mask, ShapeSet);
    XShapeCombineMask(display, window, ShapeBounding, -x_ofs, -y_ofs,
		      mask, ShapeSet);
    XFlush(display);
}
コード例 #7
0
ファイル: startupid.cpp プロジェクト: fluxer/kde-workspace
void StartupId::update_startupid()
    {
    int yoffset = 0;
    if( blinking )
        {
        XSetWindowBackgroundPixmap( QX11Info::display(), startup_window,
            pixmaps[ color_to_pixmap[ color_index ]].handle());
        XClearWindow( QX11Info::display(), startup_window );
        if( ++color_index >= ( sizeof( color_to_pixmap ) / sizeof( color_to_pixmap[ 0 ] )))
            color_index = 0;
        }
    else if( bouncing )
        {
        yoffset = frame_to_yoffset[ frame ];
        QPixmap pixmap = pixmaps[ frame_to_pixmap[ frame ] ];
        XSetWindowBackgroundPixmap( QX11Info::display(), startup_window, pixmap.handle());
        XClearWindow( QX11Info::display(), startup_window );
        if ( !pixmap.mask().isNull() ) // set mask
            XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0,
                pixmap.mask().handle(), ShapeSet );
        else // clear mask
            XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0, None, ShapeSet );
        if ( ++frame >= ( sizeof( frame_to_yoffset ) / sizeof( frame_to_yoffset[ 0 ] ) ) )
            frame = 0;
        }
    Window dummy1, dummy2;
    int x, y;
    int dummy3, dummy4;
    unsigned int dummy5;
    if( !XQueryPointer( QX11Info::display(), QX11Info::appRootWindow(), &dummy1, &dummy2, &x, &y, &dummy3, &dummy4, &dummy5 ))
        {
        XUnmapWindow( QX11Info::display(), startup_window );
        update_timer.start( 100 );
        return;
        }
    QPoint c_pos( x, y );
    int cursor_size = 0;
#ifdef HAVE_XCURSOR
    cursor_size = XcursorGetDefaultSize( QX11Info::display());
#endif
    int X_DIFF;
    if( cursor_size <= 16 )
        X_DIFF = 8 + 7;
    else if( cursor_size <= 32 )
        X_DIFF = 16 + 7;
    else if( cursor_size <= 48 )
        X_DIFF = 24 + 7;
    else
        X_DIFF = 32 + 7;
    int Y_DIFF = X_DIFF;
    XMoveWindow( QX11Info::display(), startup_window, c_pos.x() + X_DIFF, c_pos.y() + Y_DIFF + yoffset );
    XMapWindow( QX11Info::display(), startup_window );
    XRaiseWindow( QX11Info::display(), startup_window );
    update_timer.start( bouncing ? 30 : 100 );
    QApplication::flush();
    }
コード例 #8
0
void
XawReshapeWidget(Widget w, XawPixmap *pixmap)
{
  if (!pixmap || pixmap->mask == None)
    XShapeCombineMask(XtDisplay(w), XtWindow(w), ShapeBounding, 0, 0,
		      None, ShapeSet);
  else
    XShapeCombineMask(XtDisplay(w), XtWindow(w), ShapeBounding, 0, 0,
		      pixmap->mask, ShapeSet);
}
コード例 #9
0
/* for reverting the visible shape of a window to an rectangular form */
void
SplashRevertShape(Splash * splash) {
    if (!shapeSupported)
        return;
    if (splash->maskRequired)
        return;

    XShapeCombineMask (splash->display, splash->window, ShapeClip,
                       0, 0, None, ShapeSet);
    XShapeCombineMask (splash->display, splash->window , ShapeBounding,
                       0, 0, None, ShapeSet);
}
コード例 #10
0
ファイル: func7.c プロジェクト: TomoMayumi/mypaint
void square(XEvent ev,Window *layer_expose,Window *layer,Window *mask,int num){
  int xs,ys,xe,ye;

  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, None, ShapeSet);//いったんマスクを解除
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, None, ShapeSet);

  XCopyArea( dis, layer[num], copy_pix[0], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );

  xs=ev.xbutton.x;
  ys=ev.xbutton.y;

  while( !(ev.type == ButtonRelease && ev.xbutton.button == 1) ){
    if(ev.type == MotionNotify){
      XCopyArea( dis, copy_pix[0], copy_pix[1], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );
      xe=ev.xbutton.x;
      ye=ev.xbutton.y;

      if(sub_state==0){
	XDrawRectangle(dis, copy_pix[1], gc,
		       (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		       abs(xe-xs), abs(ye-ys));
      }else{
	XFillRectangle(dis, copy_pix[1], gc,
		       (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		       abs(xe-xs), abs(ye-ys));
      }
      XCopyArea( dis, copy_pix[1], layer[num], gc, 0, 0, CANV_WIDTH, CANV_HEIGHT, 0, 0 );
      XFlush(dis);
    }
    XNextEvent( dis, &ev );
  }

  if(sub_state==0){
    XDrawRectangle(dis, mask[num], mask_gc,
		   (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		   abs(xe-xs), abs(ye-ys));
    XDrawRectangle(dis, layer_expose[num], gc,
		   (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		   abs(xe-xs), abs(ye-ys));
  }else{
    XFillRectangle(dis, mask[num], mask_gc,
		   (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		   abs(xe-xs), abs(ye-ys));
    XFillRectangle(dis, layer_expose[num], gc,
		   (xs<xe)?xs:xe, (ys<ye)?ys:ye,
		   abs(xe-xs), abs(ye-ys));
  }
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0, mask[num], ShapeSet);
  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0, mask[num], ShapeSet);
  addHistory(layer_expose,mask,num);//履歴に追加

}
コード例 #11
0
ファイル: historyb8.c プロジェクト: TomoMayumi/mypaint
void remapLayerLast(Window *layer_expose,Window *layer,Pixmap *mask,int num){
  XCopyArea( dis, last_pix[num], layer_expose[num],
	     hcopy_gc, 0, 0, width, height, 0, 0 );
  XCopyArea( dis, last_pix[num], layer[num],
	     hcopy_gc, 0, 0, width, height, 0, 0 );
  XCopyArea( dis, last_mask_pix[num], mask[num],
	     hmask_gc, 0, 0, width, height, 0, 0 );

  XShapeCombineMask( dis, layer[num], ShapeClip, 0, 0,
		     mask[num], ShapeSet);
  XShapeCombineMask( dis, layer[num], ShapeBounding, 0, 0,
		     mask[num], ShapeSet);
}
コード例 #12
0
ファイル: ws.c プロジェクト: NeeMeese/mplayer-ce
void wsSetShape( wsTWindow * win,char * data )
{
#ifdef CONFIG_XSHAPE
 if ( !wsUseXShape ) return;
 if ( data )
  {
   win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height );
   XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet );
   XFreePixmap( wsDisplay,win->Mask );
  }
  else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet );
#endif
}
コード例 #13
0
ファイル: historyb8.c プロジェクト: TomoMayumi/mypaint
void remapLayer(Window *layer_expose,Window *layer,Pixmap *mask,int num){
  int history_num_tmp=history_num[num];

  XCopyArea( dis, history_pix[num], layer_expose[history_num_tmp],
	     hcopy_gc, 0, 0, width, height, 0, 0 );
  XCopyArea( dis, history_pix[num], layer[history_num_tmp],
	     hcopy_gc, 0, 0, width, height, 0, 0 );
  XCopyArea( dis, history_mask_pix[num], mask[history_num_tmp],
	     hmask_gc, 0, 0, width, height, 0, 0 );

  XShapeCombineMask( dis, layer[history_num_tmp], ShapeClip, 0, 0,
		     mask[history_num_tmp], ShapeSet);
  XShapeCombineMask( dis, layer[history_num_tmp], ShapeBounding, 0, 0,
		     mask[history_num_tmp], ShapeSet);
}
コード例 #14
0
ファイル: windows.c プロジェクト: TheCodeJanitor/collisionWM
void ShapeFrame(UltimateContext *uc)
{
  int a, shaped, wbs, hbs;

  XShapeQueryExtents(disp,uc->win,&shaped,&a,&a,&wbs,&hbs,&a,&a,&a,&a,&a);
  if(uc->frame != None) {
    if(shaped){
      uc->flags |= SHAPED;
      XShapeCombineShape(disp, uc->frame, ShapeBounding, uc->BorderWidth,
                         uc->BorderWidth + TheScreen.TitleHeight, uc->win,
                         ShapeBounding, ShapeSet);
      if(uc->title.win != None)
        XShapeCombineShape(disp, uc->frame, ShapeBounding, uc->title.x,
                           uc->title.y , uc->title.win,
                           ShapeBounding, ShapeUnion);
      XUnmapWindow(disp, uc->border);
      UpdateName(uc);
    } else {
      if(uc->flags & SHAPED) {
        XShapeCombineMask(disp, uc->frame, ShapeBounding, 0, 0, None, ShapeSet);
      }
      uc->flags &= ~SHAPED;
      
      XMapWindow(disp, uc->border);
      UpdateName(uc);
    }
  }
}
コード例 #15
0
/* this is piece by piece taken from gtk+ 2.9.0 (CVS-head with a patch applied
regarding XShape's input-masks) so people without gtk+ >= 2.9.0 can compile and
run input_shape_test.c */
static void 
do_shape_combine_mask (GdkWindow* window, GdkBitmap* mask, gint x, gint y)
{
	Pixmap pixmap;
	int ignore;
	int maj;
	int min;

	if (!XShapeQueryExtension (GDK_WINDOW_XDISPLAY (window), &ignore, &ignore))
		return;

	if (!XShapeQueryVersion (GDK_WINDOW_XDISPLAY (window), &maj, &min))
		return;

	/* for shaped input we need at least XShape 1.1 */
	if (maj != 1 && min < 1)
		return;

	if (mask)
		pixmap = GDK_DRAWABLE_XID (mask);
	else
	{
		x = 0;
		y = 0;
		pixmap = None;
	}

	XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
					   GDK_DRAWABLE_XID (window),
					   ShapeInput,
					   x,
					   y,
					   pixmap,
					   ShapeSet);
}
コード例 #16
0
int
X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
    if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
        return -1;

#if SDL_VIDEO_DRIVER_X11_XSHAPE
    if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode))
        return -2;
    if(shape->w != shaper->window->w || shape->h != shaper->window->h)
        return -3;
    SDL_ShapeData *data = shaper->driverdata;
    
    /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
    SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
        
    SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata);
    Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
    
    XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
    XSync(windowdata->videodata->display,False);

    XFreePixmap(windowdata->videodata->display,shapemask);
#endif

    return 0;
}
コード例 #17
0
ファイル: dragsource.c プロジェクト: cneira/wmaker-crm
static Window makeDragIcon(WMScreen * scr, WMPixmap * pixmap)
{
	Window window;
	WMSize size;
	unsigned long flags;
	XSetWindowAttributes attribs;

	if (!pixmap) {
		pixmap = scr->defaultObjectIcon;
	}

	size = WMGetPixmapSize(pixmap);

	flags = CWSaveUnder | CWBackPixmap | CWOverrideRedirect | CWColormap;
	attribs.save_under = True;
	attribs.background_pixmap = pixmap->pixmap;
	attribs.override_redirect = True;
	attribs.colormap = scr->colormap;

	window = XCreateWindow(scr->display, scr->rootWin, 0, 0, size.width,
			       size.height, 0, scr->depth, InputOutput, scr->visual, flags, &attribs);

#ifdef USE_XSHAPE
	if (pixmap->mask) {
		XShapeCombineMask(scr->display, window, ShapeBounding, 0, 0, pixmap->mask, ShapeSet);
	}
#endif

	return window;
}
コード例 #18
0
/**
 * Sets the shape of the given window to that given by the pixmap @p mask.
 * @param   win  The given window.
 * @param   mask A 2-bit depth pixmap that provides the new shape of the
 *               window.
 * @ingroup Ecore_X_Window_Shape
 */
EAPI void
ecore_x_window_shape_mask_set(Ecore_X_Window win,
                              Ecore_X_Pixmap mask)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet);
} /* ecore_x_window_shape_mask_set */
コード例 #19
0
ファイル: Fl_Shaped_Window.cpp プロジェクト: edeproject/svn
void Fl_Shaped_Window::draw()
{
    if ((lw != w() || lh != h() || changed) && shape_)
    {
        // size of window has change since last time
        lw = w(); lh = h();
        Fl_Bitmap* mask = resize_bitmap(shape_, w(), h());
#ifdef _WIN32
        HRGN region = bitmap2region(mask);
        SetWindowRgn(fl_xid(this), region, TRUE);
#elif defined(__APPLE__)
        // not yet implemented for Apple
#else
        Pixmap pmask = XCreateBitmapFromData(fl_display, fl_xid(this),
                                             (const char*)mask->data(), mask->width(), mask->height());
        hide();
        XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0,
                          pmask, ShapeSet);
        show();
        if (pmask != None) XFreePixmap(fl_display, pmask);
#endif
        changed = 0;
    }
    Fl_Double_Window::draw();
}
コード例 #20
0
ファイル: x.c プロジェクト: Limsik/e17
int
EShapeUpdate(Win win)
{
   if (win->rects)
     {
	XFree(win->rects);
	win->num_rect = 0;
     }

   win->rects =
      XShapeGetRectangles(disp, win->xwin, ShapeBounding, &(win->num_rect),
			  &(win->ord));
   if (win->rects)
     {
	if (win->num_rect == 1)
	  {
	     if ((win->rects[0].x == 0) && (win->rects[0].y == 0)
		 && (win->rects[0].width == win->w)
		 && (win->rects[0].height == win->h))
	       {
		  win->num_rect = 0;
		  XFree(win->rects);
		  win->rects = NULL;
		  XShapeCombineMask(disp, win->xwin, ShapeBounding, 0, 0,
				    None, ShapeSet);
	       }
	  }
	else if (win->num_rect > 4096)
	  {
	     Eprintf("*** EShapeUpdate: nrect=%d - Not likely, ignoring.\n",
		     win->num_rect);
	     XShapeCombineMask(disp, win->xwin, ShapeBounding, 0, 0, None,
			       ShapeSet);
	     win->num_rect = 0;
	     XFree(win->rects);
	     win->rects = NULL;
	  }
     }
   else
     {
	win->num_rect = -1;
     }
#if DEBUG_SHAPE_OPS
   EShapeShow("EShapeUpdate", win->xwin, win->rects, win->num_rect);
#endif
   return win->num_rect != 0;
}
コード例 #21
0
ファイル: balloon.c プロジェクト: cneira/wmaker-crm
static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
{
	int width;
	int height;
	Pixmap pixmap;
	Pixmap mask;
	WMFont *font = scr->info_text_font;
	int side = 0;
	int ty;
	int bx, by;

	if (scr->balloon->contents)
		XFreePixmap(dpy, scr->balloon->contents);

	width = getMaxStringWidth(font, text) + 16;
	height = countLines(text) * WMFontHeight(font) + 4;

	if (height < 16)
		height = 16;
	if (width < height)
		width = height;

	if (x + width > scr->scr_width) {
		side = RIGHT;
		bx = x - width + w / 2;
		if (bx < 0)
			bx = 0;
	} else {
		side = LEFT;
		bx = x + w / 2;
	}
	if (bx + width > scr->scr_width)
		bx = scr->scr_width - width;

	if (y - (height + SPACE) < 0) {
		side |= TOP;
		by = y + h - 1;
		ty = SPACE;
	} else {
		side |= BOTTOM;
		by = y - (height + SPACE);
		ty = 0;
	}
	pixmap = makePixmap(scr, width, height, side, &mask);

	drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2, text, strlen(text));

	XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
	scr->balloon->contents = pixmap;

	XResizeWindow(dpy, scr->balloon->window, width, height + SPACE);
	XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask, ShapeSet);
	XFreePixmap(dpy, mask);
	XMoveWindow(dpy, scr->balloon->window, bx, by);
	XMapRaised(dpy, scr->balloon->window);

	scr->balloon->mapped = 1;
}
コード例 #22
0
ファイル: xf_floatbar.c プロジェクト: hendwolt/FreeRDP
static void xf_floatbar_event_expose(xfFloatbar* floatbar, XEvent* event)
{
	GC gc, shape_gc;
	Pixmap pmap;
	XPoint shape[5], border[5];
	int len;
	Display* display = floatbar->xfc->display;
	/* create the pixmap that we'll use for shaping the window */
	pmap = XCreatePixmap(display, floatbar->handle, floatbar->width, floatbar->height, 1);
	gc = XCreateGC(display, floatbar->handle, 0, 0);
	shape_gc = XCreateGC(display, pmap, 0, 0);
	/* points for drawing the floatbar */
	shape[0].x = 0;
	shape[0].y = 0;
	shape[1].x = floatbar->width;
	shape[1].y = 0;
	shape[2].x = shape[1].x - FLOATBAR_BORDER;
	shape[2].y = FLOATBAR_HEIGHT;
	shape[3].x = shape[0].x + FLOATBAR_BORDER;
	shape[3].y = FLOATBAR_HEIGHT;
	shape[4].x = shape[0].x;
	shape[4].y = shape[0].y;
	/* points for drawing the border of the floatbar */
	border[0].x = shape[0].x;
	border[0].y = shape[0].y - 1;
	border[1].x = shape[1].x - 1;
	border[1].y = shape[1].y - 1;
	border[2].x = shape[2].x;
	border[2].y = shape[2].y - 1;
	border[3].x = shape[3].x - 1;
	border[3].y = shape[3].y - 1;
	border[4].x = border[0].x;
	border[4].y = border[0].y;
	/* Fill all pixels with 0 */
	XSetForeground(display, shape_gc, 0);
	XFillRectangle(display, pmap, shape_gc, 0, 0, floatbar->width,
	               floatbar->height);
	/* Fill all pixels which should be shown with 1 */
	XSetForeground(display, shape_gc, 1);
	XFillPolygon(display, pmap, shape_gc, shape, 5, 0, CoordModeOrigin);
	XShapeCombineMask(display, floatbar->handle, ShapeBounding, 0, 0, pmap, ShapeSet);
	/* draw the float bar */
	XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND));
	XFillPolygon(display, floatbar->handle, gc, shape, 4, 0, CoordModeOrigin);
	/* draw an border for the floatbar */
	XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER));
	XDrawLines(display, floatbar->handle, gc, border, 5, CoordModeOrigin);
	/* draw the host name connected to */
	len = strlen(floatbar->title);
	XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND));
	XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15,
	            floatbar->title, len);
	XFreeGC(display, gc);
	XFreeGC(display, shape_gc);
}
コード例 #23
0
/**
 * Sets the input shape of the given window to that given by the pixmap @p mask.
 * @param   win  The given window.
 * @param   mask A 1-bit depth pixmap that provides the new input shape of the
 *               window.
 * @ingroup Ecore_X_Window_Shape
 */
EAPI void
ecore_x_window_shape_input_mask_set(Ecore_X_Window win,
                                    Ecore_X_Pixmap mask)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ShapeInput
   XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet);
#else /* ifdef ShapeInput */
   return;
   win = mask = 0;
#endif /* ifdef ShapeInput */
} /* ecore_x_window_shape_input_mask_set */
コード例 #24
0
ファイル: alltray-ctt-helper.c プロジェクト: darnyte/alltray
static void
set_ctt_window_shape_and_background(Display *dpy, Window ctt_window,
				    unsigned long ctt_attribute_mask,
				    XSetWindowAttributes *ctt_attributes) {
  Pixmap ctt_xpm, ctt_shape;
  XpmCreatePixmapFromData(dpy, ctt_window, atcttxpm, &ctt_xpm, &ctt_shape,
			  NULL /* Attributes; IIRC, we don't need this. */);
  ctt_attribute_mask |= CWBackPixmap;
  ctt_attributes->background_pixmap = ctt_xpm;
  XChangeWindowAttributes(dpy, ctt_window, ctt_attribute_mask, ctt_attributes);
  XShapeCombineMask(dpy, ctt_window, ShapeBounding, 0, 0, ctt_shape, ShapeSet);
}
コード例 #25
0
ファイル: gui_tray.c プロジェクト: chinese-opendesktop/oxim
static void DrawTray(winlist_t *win)
{
    XpmAttributes attributes;
    Pixmap tray, mask, shapemask;
    GC shapegc, traygc;
    attributes.valuemask = 0;
    XpmCreatePixmapFromData(gui->display, win->window,
			oxim_tray, &tray, &mask, &attributes);

    tray_w = attributes.width;
    tray_h = attributes.height;

    shapemask = XCreatePixmap(gui->display, win->window,
			win->width , win->height , 1);

    traygc = XCreateGC(gui->display, tray, 0, 0);
    shapegc = XCreateGC(gui->display, shapemask, 0, 0);

    XFillRectangle(gui->display, shapemask, shapegc, 0, 0,
		win->width, win->height);

    int sw = (win->width - tray_w) / 2;
    int sh = (win->height - tray_h) / 2;
    int new_x = (sw > 0) ? sw : 0;
    int new_y = (sh > 0) ? sh : 0;

    if (mask)
    {
	XCopyArea(gui->display, mask, shapemask, shapegc, 0, 0,
		tray_w, tray_h, new_x, new_y);
	XFreePixmap(gui->display, mask);
    }
    else
    {
	XSetForeground(gui->display, shapegc, 1);
	XFillRectangle(gui->display, shapemask, shapegc, new_x, new_y,
		tray_w, tray_h);
    }

    XShapeCombineMask(gui->display, win->window, ShapeBounding,
		0, 0, shapemask, ShapeSet);
/*    XShapeCombineMask(gui->display, win->window, ShapeClip,
		0, 0, shapemask, ShapeSet);*/
    XCopyArea(gui->display, tray, win->window, traygc, 0, 0,
		win->width, win->height, new_x, new_y);

    XpmFreeAttributes(&attributes);
    XFreePixmap(gui->display, tray);
    XFreePixmap(gui->display, shapemask);
    XFreeGC(gui->display, shapegc);
    XFreeGC(gui->display, traygc);    
}
コード例 #26
0
ファイル: main.c プロジェクト: epronk/xtickertape
/* Create the icon window */
static Window
create_icon(Widget shell)
{
    Display *display = XtDisplay(shell);
    Screen *screen = XtScreen(shell);
    Colormap colormap = XDefaultColormapOfScreen(screen);
    int depth = DefaultDepthOfScreen(screen);
    unsigned long black = BlackPixelOfScreen(screen);
    Window window;
    Pixmap pixmap, mask;
    XColor color;
    GC gc;
    XGCValues values;

    /* Create the actual icon window */
    window = XCreateSimpleWindow(
        display, RootWindowOfScreen(screen),
        0, 0, mask_width, mask_height, 0,
        CopyFromParent, CopyFromParent);

    /* Allocate the color red by name */
    XAllocNamedColor(display, colormap, "red", &color, &color);

    /* Create a pixmap from the red bitmap data */
    pixmap = XCreatePixmapFromBitmapData(
        display, window, (char *)red_bits, red_width, red_height,
        color.pixel, black, depth);

    /* Create a graphics context */
    values.function = GXxor;
    gc = XCreateGC(display, pixmap, GCFunction, &values);

    /* Create a pixmap for the white 'e' and paint it on top */
    mask = XCreatePixmapFromBitmapData(
        display, pixmap, (char *)white_bits, white_width, white_height,
        WhitePixelOfScreen(screen) ^ black, 0, depth);
    XCopyArea(display, mask, pixmap, gc, 0, 0,
              white_width, white_height, 0, 0);
    XFreePixmap(display, mask);
    XFreeGC(display, gc);

#ifdef HAVE_LIBXEXT
    /* Create a shape mask and apply it to the window */
    mask = XCreateBitmapFromData(display, pixmap, (char *)mask_bits,
                                 mask_width, mask_height);
    XShapeCombineMask(display, window, ShapeBounding, 0, 0, mask, ShapeSet);
#endif /* HAVE_LIBXEXT */

    /* Set the window's background to be the pixmap */
    XSetWindowBackgroundPixmap(display, window, pixmap);
    return window;
}
コード例 #27
0
ファイル: effects.c プロジェクト: flexiondotorg/marco
static void
update_wireframe_window (MetaDisplay         *display,
                         Window               xwindow,
                         const MetaRectangle *rect)
{
  XMoveResizeWindow (display->xdisplay,
                     xwindow,
                     rect->x, rect->y,
                     rect->width, rect->height);

#define OUTLINE_WIDTH 3

  if (rect->width > OUTLINE_WIDTH * 2 &&
      rect->height > OUTLINE_WIDTH * 2)
    {
      XRectangle xrect;
      Region inner_xregion;
      Region outer_xregion;

      inner_xregion = XCreateRegion ();
      outer_xregion = XCreateRegion ();

      xrect.x = 0;
      xrect.y = 0;
      xrect.width = rect->width;
      xrect.height = rect->height;

      XUnionRectWithRegion (&xrect, outer_xregion, outer_xregion);

      xrect.x += OUTLINE_WIDTH;
      xrect.y += OUTLINE_WIDTH;
      xrect.width -= OUTLINE_WIDTH * 2;
      xrect.height -= OUTLINE_WIDTH * 2;

      XUnionRectWithRegion (&xrect, inner_xregion, inner_xregion);

      XSubtractRegion (outer_xregion, inner_xregion, outer_xregion);

      XShapeCombineRegion (display->xdisplay, xwindow,
                           ShapeBounding, 0, 0, outer_xregion, ShapeSet);

      XDestroyRegion (outer_xregion);
      XDestroyRegion (inner_xregion);
    }
  else
    {
      /* Unset the shape */
      XShapeCombineMask (display->xdisplay, xwindow,
                         ShapeBounding, 0, 0, None, ShapeSet);
    }
}
コード例 #28
0
ファイル: amorwidget.cpp プロジェクト: Fat-Zer/tdetoys
//---------------------------------------------------------------------------
//
// Set the pixmap to display
//
void AmorWidget::setPixmap(const TQPixmap *pixmap)
{
    mPixmap = pixmap;

    if (mPixmap)
    {
        if (mPixmap->mask())
        {
            XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0,
                                mPixmap->mask()->handle(), ShapeSet );
            repaint(false);
        }
    
	update();
    }
}
コード例 #29
0
ファイル: edeskicon.cpp プロジェクト: edeproject/svn
MovableIcon::MovableIcon(Icon* i) : Fl_Window(i->x(), i->y(), i->w(), i->h()), icon(i)
{
	assert(icon != NULL);
	set_override();
	create();

	Fl_Image* img = icon->icon_image();
	if(img)
	{
#ifdef SHAPE
		Pixmap mask = img->create_mask(img->width(), img->height());
		XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);
#endif
		align(FL_ALIGN_INSIDE);
		image(img);
	}
}
コード例 #30
0
ファイル: edeskicon.cpp プロジェクト: GustavoMOG/ede12
MovableIcon::MovableIcon(Icon *i)
: Fl_Window(desktop->x()+i->x(), desktop->y()+i->y(), i->w(), i->h())
{
    icon = i;
    set_override();
    create();

    Fl_Image *im = i->icon_im;
    if(im)
    {
        Pixmap mask = im->create_mask(im->width(), im->height());
        XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);

        align(FL_ALIGN_INSIDE);
        image(im);
    }
}