Esempio n. 1
0
static void *
lcdscrub_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  XGCValues gcv;
  st->dpy = dpy;
  st->window = window;
  st->delay  = get_integer_resource (st->dpy, "delay",  "Integer");
  st->spread = get_integer_resource (st->dpy, "spread", "Integer");
  st->cycles = get_integer_resource (st->dpy, "cycles", "Integer");

  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
  gcv.foreground = BlackPixelOfScreen (st->xgwa.screen);
  gcv.background = WhitePixelOfScreen (st->xgwa.screen);
  st->bg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  gcv.foreground = WhitePixelOfScreen (st->xgwa.screen);
  gcv.background = BlackPixelOfScreen (st->xgwa.screen);
  st->fg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);

#ifdef HAVE_COCOA
  jwxyz_XSetAntiAliasing (st->dpy, st->fg, False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg, False);
#endif

  return st;
}
Esempio n. 2
0
static void *
lcdscrub_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  XGCValues gcv;
  st->dpy = dpy;
  st->window = window;
  //st->delay  = get_integer_resource (st->dpy, "delay",  "Integer");
  //st->spread = get_integer_resource (st->dpy, "spread", "Integer");
  //st->cycles = get_integer_resource (st->dpy, "cycles", "Integer");
  st->delay  = delay;
  st->spread = spread;
  st->cycles = cycles;

  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
  gcv.foreground = BlackPixelOfScreen (st->xgwa.screen);
  gcv.background = WhitePixelOfScreen (st->xgwa.screen);
  st->bg  = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  st->bg2 = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  gcv.foreground = WhitePixelOfScreen (st->xgwa.screen);
  gcv.background = BlackPixelOfScreen (st->xgwa.screen);
  st->fg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);

#ifdef HAVE_COCOA
  jwxyz_XSetAntiAliasing (st->dpy, st->fg,  False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg,  False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg2, False);
#endif

  st->enabled_mask = 0;
#if 1
	# define PREF(R,F) \
	   if (R) st->enabled_mask |= (1 << F)
#else
	# define PREF(R,F) \
	   if (get_boolean_resource (st->dpy, R, "Mode")) st->enabled_mask |= (1 << F)
#endif
  PREF("modeHW", HORIZ_W);
  PREF("modeHB", HORIZ_B);
  PREF("modeVW", VERT_W);
  PREF("modeVB", VERT_B);
  PREF("modeDW", DIAG_W);
  PREF("modeDB", DIAG_B);
  PREF("modeW",  WHITE);
  PREF("modeB",  BLACK);
  PREF("modeRGB", RGB);
# undef PREF
  if (! st->enabled_mask) 
    {
      fprintf (stderr, "%s: no modes enabled\n", progname);
      exit (1);
    }

  pick_mode (st);

  return st;
}
Esempio n. 3
0
bool KXMessages::sendMessageX( Display* disp, WId w_P, const char* msg_type_P,
    const QString& message_P, bool obsolete_P )
    {
    if( disp == NULL )
        return false;
    Atom a2 = XInternAtom( disp, msg_type_P, false );
    Atom a1 = obsolete_P ? a2 : XInternAtom( disp, QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
    Window win = XCreateSimpleWindow( disp, DefaultRootWindow( disp ), 0, 0, 1, 1,
        0, BlackPixelOfScreen( DefaultScreenOfDisplay( disp )),
        BlackPixelOfScreen( DefaultScreenOfDisplay( disp )));
    send_message_internal( w_P, message_P, 0, disp, a1, a2, win );
    XDestroyWindow( disp, win );
    return true;
    }
Esempio n. 4
0
IMAGE_CONTEXT *new_window( char *wnd_name, int x, int y, int width, int height )
{
    IMAGE_CONTEXT *img_ctx;
    img_ctx = new IMAGE_CONTEXT;

    g_width = width;
    g_height = height;

    // First we are creating the window
    if ( ( img_ctx->display = XOpenDisplay(NULL) ) == NULL )
    {
        printf("Error: XOpenDisplay failed.\n");
        exit(1);
    }

    img_ctx->screenNumber = DefaultScreen( img_ctx->display );
    img_ctx->screen = XScreenOfDisplay( img_ctx->display, img_ctx->screenNumber );


    img_ctx->window = XCreateSimpleWindow (
			img_ctx->display,
			RootWindowOfScreen( img_ctx->screen ),
			0,
			0,
			g_width,
			g_height,
			0,
			BlackPixelOfScreen( img_ctx->screen ),
			BlackPixelOfScreen( img_ctx->screen )
    );


    img_ctx->xImage = NULL;
    if( image_create( img_ctx, g_width, g_height ) < 0 )
    {
        printf("Error: image_create() failed\n");
        exit(1);
    }

    XSelectInput( img_ctx->display, img_ctx->window, ButtonPressMask | KeyPressMask );
    XMapRaised( img_ctx->display, img_ctx->window );
    XStoreName( img_ctx->display, img_ctx->window, wnd_name );
	XGetWindowAttributes( img_ctx->display, img_ctx->window, &(img_ctx->windowAttributes ) );

	XMoveWindow( img_ctx->display, img_ctx->window, x, y );


    return img_ctx;
}
Esempio n. 5
0
HelloWorld::HelloWorld(Display* display) :
    _game() {

    _display = display;
    _screen = XDefaultScreenOfDisplay(display);

    _blackColor = BlackPixelOfScreen(_screen);
    _whiteColor = WhitePixelOfScreen(_screen);
    _font = XLoadFont(_display, WINDOW_FONT);

    int screenWidth = XWidthOfScreen(_screen);
    int screenHeight = XHeightOfScreen(_screen);

    int windowWidth = MIN_CELL_SIZE * 3;
    int windowHeight = MIN_CELL_SIZE * 3 + STRING_HEIGHT * 3;
    int windowX = (screenWidth + windowWidth) / 2;
    int windowY = (screenHeight + windowHeight) / 2;
    _window = XCreateSimpleWindow(_display, XRootWindowOfScreen(_screen),
            windowX, windowY, windowWidth, windowHeight, 1, _blackColor,
            _whiteColor);

    long eventMask = ButtonPressMask | ExposureMask | KeyPressMask;
    XSelectInput(_display, _window, eventMask);

    draw();
}
Esempio n. 6
0
File: image.c Progetto: juddy/edcde
void
drawimage(perwindow *pwin)
{
    imagestruct *ip;
    int         i;

    ip = (imagestruct *)pwin->data;
    XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
    for (i = 0; i < ip->iconcount; i++) {
	if (!ip->iconmode)
	    XFillRectangle(dsp, pwin->w, pwin->gc,
			   ip->xb + xlogo_width * ip->icons[i].x,
			   ip->yb + xlogo_height * ip->icons[i].y,
			   xlogo_width, xlogo_height);

	ip->icons[i].x = random() % ip->ncols;
	ip->icons[i].y = random() % ip->nrows;
    }
    if (pwin->perscreen->npixels == 2)
      XSetForeground(dsp, pwin->gc, WhitePixelOfScreen(pwin->perscreen->screen));
    for (i = 0; i < ip->iconcount; i++) {
	if (pwin->perscreen->npixels > 2)
	    XSetForeground(dsp, pwin->gc,
		 pwin->perscreen->pixels[random() % pwin->perscreen->npixels]);

	XPutImage(dsp, pwin->w, pwin->gc, &logo,
		  0, 0,
		  ip->xb + xlogo_width * ip->icons[i].x,
		  ip->yb + xlogo_height * ip->icons[i].y,
		  xlogo_width, xlogo_height);
    }
}
Esempio n. 7
0
File: image.c Progetto: juddy/edcde
void
initimage(perwindow *pwin)
{
    XWindowAttributes xgwa;
    imagestruct *ip;

    if (pwin->data) free(pwin->data);
    pwin->data = (void *)malloc(sizeof(imagestruct));
    memset(pwin->data, '\0', sizeof(imagestruct));
    ip = (imagestruct *)pwin->data;
    ip->startTime = seconds();

    logo.data = (char *) xlogo_bits;
    logo.width = xlogo_width;
    logo.height = xlogo_height;
    logo.bytes_per_line = (xlogo_width + 7) / 8;

    XGetWindowAttributes(dsp, pwin->w, &xgwa);
    ip->width = xgwa.width;
    ip->height = xgwa.height;
    ip->ncols = ip->width / xlogo_width;
    ip->nrows = ip->height / xlogo_height;
    ip->iconmode = (ip->ncols < 2 || ip->nrows < 2);
    if (ip->iconmode) {
	ip->xb = 0;
	ip->yb = 0;
	ip->iconcount = 1;	/* icon mode */
    } else {
	ip->xb = (ip->width - xlogo_width * ip->ncols) / 2;
	ip->yb = (ip->height - xlogo_height * ip->nrows) / 2;
	ip->iconcount = batchcount;
    }
    XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
    XFillRectangle(dsp, pwin->w, pwin->gc, 0, 0, ip->width, ip->height);
}
Esempio n. 8
0
/*
** BeginWait/EndWait
**
** Display/Remove a watch cursor over topCursorWidget and its descendents
*/
void BeginWait(Widget topCursorWidget)
{
    Display *display = XtDisplay(topCursorWidget);
    Pixmap pixmap;
    Pixmap maskPixmap;
    XColor xcolors[2];
    static Cursor  waitCursor = 0;
    
    /* if the watch cursor hasn't been created yet, create it */
    if (!waitCursor) {
	pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
		(char *)watch_bits, watch_width, watch_height);

	maskPixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
		(char *)watch_mask_bits, watch_width, watch_height);

	xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(display));
	xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(display));

	XQueryColors(display, DefaultColormapOfScreen(
		DefaultScreenOfDisplay(display)), xcolors, 2);
	waitCursor = XCreatePixmapCursor(display, pixmap, maskPixmap,
		&xcolors[0], &xcolors[1], watch_x_hot, watch_y_hot);
	XFreePixmap(display, pixmap);
	XFreePixmap(display, maskPixmap);
    }

    /* display the cursor */
    XDefineCursor(display, XtWindow(topCursorWidget), waitCursor);
}
Esempio n. 9
0
Window create_window(Display *dsp, Screen *screen) {
	Window window;
	int x, y;
	int width, height;
	int depth;
	XSetWindowAttributes winAttrib;
	XWindowAttributes window_attributes;
	
	x = 30;
	y = 60;
	width = 200;
	height = 300;
	winAttrib.background_pixel = BlackPixelOfScreen(screen);
	winAttrib.border_pixel = WhitePixelOfScreen(screen);
	winAttrib.backing_store = Always/*NotUseful*/;
	winAttrib.override_redirect = False;
	winAttrib.bit_gravity = NorthWestGravity;
	winAttrib.win_gravity = NorthWestGravity;
	depth = DefaultDepthOfScreen(screen);
	if (XGetWindowAttributes(dsp, RootWindowOfScreen(screen), &window_attributes) == 0)
	{
		fprintf(stderr, "xf_get_pixmap_info: XGetWindowAttributes failed\n");
		return 1;
	}
	window = XCreateWindow(dsp, RootWindowOfScreen(screen),
						x, y,
						width, height,
						0,
						depth,
						InputOutput, /*window_attributes.visual*/DefaultVisual(dsp, 0),
						0, &winAttrib);
	setWindowDecorations(dsp, window, 0);	//设置后没有Ubuntu自带的关闭、最小和最大这三个键
	return window;
}
Esempio n. 10
0
static void *
t3d_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  st->dpy = dpy;
  st->window = window;
  st->dpy = dpy;
  st->window = window;
  initialize(st);
  
  initColor(st,st->r,st->g,st->b);
  init_3d(st);
  st->zeit=(struct tm *)malloc(sizeof(struct tm));
  init_kugel(st);
  
  st->startx=st->scrnWidth/2;
  st->starty=st->scrnHeight/2;
  st->scrnH2=st->startx;
  st->scrnW2=st->starty;
  st->vspeed=0;
  
  
  vektorprodukt(st->x,st->y,st->v);
  viewpoint(st/*m,v*/);
  
  setink (BlackPixelOfScreen(st->xgwa.screen));
  XFillRectangle (st->dpy, st->window, st->gc, 0, 0, st->scrnWidth, st->scrnHeight);
  XQueryPointer (st->dpy, st->window, &st->junk_win, &st->junk_win, &st->junk, &st->junk,
		 &st->px, &st->py, &st->kb);
  
  return st;
}
Esempio n. 11
0
static void detectorToSegment(SpaceWindow *window, SpinSegment *segdt, 
					SpinSegment *seg)
{
	int i,j;
	Pixel black;
        Screen *screen;
        
        screen = XtScreen(window->shell);
        black = BlackPixelOfScreen(screen);	 
	seg->pixel = black;
	seg->x1 = window->currentLongToTr * segdt->x1;
	seg->y1 = window->currentLongToTr * segdt->y1;
	seg->z1 = segdt->z1;
	seg->x2 = window->currentLongToTr * segdt->x2;
	seg->y2 = window->currentLongToTr * segdt->y2;
	seg->z2 = segdt->z2;
    	/*
    	** Now translate 
    	*/
    	seg->x1 = seg->x1 + 
    	       window->currentLongToTr * window->currentTransl[0];
    	seg->y1 = seg->y1 + 
    	       window->currentLongToTr * window->currentTransl[1];
    	seg->z1 = seg->z1 + 
    	       window->currentTransl[2];
    	seg->x2 = seg->x2 + 
    	       window->currentLongToTr * window->currentTransl[0];
    	seg->y2 = seg->y2 + 
    	       window->currentLongToTr * window->currentTransl[1];
    	seg->z2 = seg->z2 + 
    	       window->currentTransl[2];
     	return;
}
Esempio n. 12
0
static void
InitPointerBlank(Widget w)
{
    DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
    DtTermPrimData tpd = tw->term.tpd;
    XColor fg = { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 };
    XColor bg = { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 };
    Pixmap noPointerBitmap;

    /*
    ** set a pointer motion handler...
    */
    tpd->pointerTimeoutID = 0 ;
    tpd->pointerFrozen = True ;
    fg.pixel = bg.pixel = BlackPixelOfScreen(XtScreen(w));
    noPointerBitmap = XCreateBitmapFromData(XtDisplay(w),XtWindow(tw),
                                whiteBits, whiteW, whiteH);

    tpd->noPointer   = XCreatePixmapCursor(XtDisplay(tw),
                                   noPointerBitmap,  /* source bitmap    */
                                   noPointerBitmap,  /* mask bitmap      */
                                   &fg, &bg,	     /* Do not care	 */
				   0, 0);	     /* hotspot		 */

    XFreePixmap(XtDisplay(w), noPointerBitmap);
    XtAddEventHandler((Widget)tw, PointerMotionMask, FALSE, PointerMoved, 
                                       (XtPointer)NULL);

    tpd->pointerFirst = False ;
}
Esempio n. 13
0
static void *
distort_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
	XGCValues gcv;
	long gcflags;

    st->dpy = dpy;
    st->window = window;

    distort_reset (st);

	st->black_pixel = BlackPixelOfScreen( st->xgwa.screen );

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

    /* On MacOS X11, XGetImage on a Window often gets an inexplicable BadMatch,
       possibly due to the window manager having occluded something?  It seems
       nondeterministic. Loading the image into a pixmap instead fixes it. */
    if (st->pm) XFreePixmap (st->dpy, st->pm);
    st->pm = XCreatePixmap (st->dpy, st->window,
                            st->xgwa.width, st->xgwa.height, st->xgwa.depth);

    st->img_loader = load_image_async_simple (0, st->xgwa.screen, st->window,
                                              st->pm, 0, 0);
    st->start_time = time ((time_t *) 0);
    return st;
}
Esempio n. 14
0
File: UxXt.c Progetto: nagyistge/ctn
static Pixmap
ConvertPixmap(char *file_name, int depth)
#endif
{
    XrmValue fg_from,
        fg_to,
        bg_from,
        bg_to;
    Pixel fg,
        bg;

    fg_from.size = strlen(XtDefaultForeground);
    fg_from.addr = XtDefaultForeground;
    fg_to.addr = (XPointer) & fg;
    bg_from.size = strlen(XtDefaultBackground);
    bg_from.addr = XtDefaultBackground;
    bg_to.addr = (XPointer) & bg;
    if (!XtConvertAndStore
	(UxTopLevel, XtRString, &bg_from, XtRPixel, &bg_to)
	|| !XtConvertAndStore
	(UxTopLevel, XtRString, &fg_from, XtRPixel, &fg_to)
	|| (fg == bg)) {
	fg = WhitePixelOfScreen(XtScreen(UxTopLevel));
	bg = BlackPixelOfScreen(XtScreen(UxTopLevel));
    }
    if (depth)
	return (XmGetPixmapByDepth
		(XtScreen(UxTopLevel), file_name, fg, bg, depth));

    else
	return (XmGetPixmap(XtScreen(UxTopLevel), file_name, fg, bg));
}
Esempio n. 15
0
/**
@pre      display is valid, themes is valid, cursors is valid.
@pre      all widgets are zero'd.
@pre      themes is valid and has loaded at least a background for the popup_menu_parent. 
@post     Menu with borders and background but no items is created but not mapped.
@brief    This function is used to create a blank and generic menu.  Items must be added by caller.
@return   void
**/
void 
create_popup_menu(Display *display, struct Popup_menu *menu, struct Themes *themes, struct Cursors *cursors) {

  XSetWindowAttributes set_attributes;
  Window root = DefaultRootWindow(display);
  Screen* screen = DefaultScreenOfDisplay(display);
  int black = BlackPixelOfScreen(screen);
  
  const int width = menu->inner_width + themes->popup_menu[popup_l_edge].w + themes->popup_menu[popup_r_edge].w;
  const int height = menu->inner_height + themes->popup_menu[popup_t_edge].h + themes->popup_menu[popup_b_edge].h;
  
  menu->widgets[popup_menu_parent].widget = XCreateSimpleWindow(display, root
  , 0, 0
  , width, height, 0, black, black);

  XDefineCursor(display, menu->widgets[popup_menu_parent].widget, cursors->normal);
  XSetWindowBackgroundPixmap(display, menu->widgets[popup_menu_parent].widget
  , themes->popup_menu[popup_menu_parent].state_p[normal]);
   
  //Currently, this is the "base" of the popup menu.
  //A similar loop will be needed for the actual menu items but not in this function
  for(int i = popup_t_edge; i < popup_menu_parent; i++) { //popup_menu_parent already done

    int x = themes->popup_menu[i].x;
    int y = themes->popup_menu[i].y;
    int w = themes->popup_menu[i].w;
    int h = themes->popup_menu[i].h;
    
    if(x < 0)  x += width;
    if(y < 0)  y += height; 
    if(w <= 0) w += width;
    if(h <= 0) h += height;
  
    menu->widgets[i].widget = XCreateSimpleWindow(display
    , menu->widgets[popup_menu_parent].widget
    , x, y, w, h, 0, black, black);
    
    if(themes->popup_menu[i].w <= 0) w = XWidthOfScreen(screen);
    if(themes->popup_menu[i].h <= 0) h = XWidthOfScreen(screen);    
    for(int j = 0; j <= inactive; j++) {
      if(themes->popup_menu[i].state_p[j]) {
        menu->widgets[i].state[j] = XCreateSimpleWindow(display, menu->widgets[i].widget
        , 0, 0, w, h, 0, black, black);
        XSetWindowBackgroundPixmap(display, menu->widgets[i].state[j]
        , themes->popup_menu[i].state_p[j]);
        if(j == normal) XMapWindow(display, menu->widgets[i].state[j]);
      }
    }

    XMapWindow(display, menu->widgets[i].widget);
  } 

  set_attributes.override_redirect = True; 
  XChangeWindowAttributes(display, menu->widgets[popup_menu_parent].widget, CWOverrideRedirect, &set_attributes);

//  XMapWindow(display, menu->widgets[popup_menu_parent].widget);
  XFlush(display);


}
Esempio n. 16
0
Pixmap XbrGfxLoadBitmap(Widget w, char *bits, int width, int height, int inherit)
{
    XGCValues vals;
    Pixmap pixmap;
    GC gc;
    Display *display = XtDisplay(w);
    Screen *screen = XtScreen(w);
    Window root = RootWindowOfScreen(screen);
  
    /* Get the foreground and background colours of the widget */
    if(inherit) {
        XtVaGetValues(w, XmNforeground, &vals.foreground, XmNbackground,
          &vals.background, NULL);
    } else {
        vals.foreground = BlackPixelOfScreen(screen);
	vals.background = WhitePixelOfScreen(screen);
    }

    /* Create a GC for drawing the pixmap */
    gc = XCreateGC(display, root, GCForeground|GCBackground, &vals);

    /* Change the bitmap to a pixmap */
    pixmap = XbrGfxReadBitmap(display, screen, gc, bits, width, height);

    /* Free GC we have finished with */
    XFreeGC(display, gc);

    /* Return the pixmap */
    return(pixmap);
}
Esempio n. 17
0
Cursor _Delay::hourglass_cursor()
{
    if (hourglass_cache != 0)
	return hourglass_cache;

    Display *display = XtDisplay(widget);

#if SMALL_HOURGLASS_CURSOR || LARGE_HORGLASS_CURSOR
    Screen *screen = XtScreen(widget);
    Window rootWindow = RootWindowOfScreen(screen);

    unsigned char *cursor_bits      = time16_bits;
    unsigned char *cursor_mask_bits = time16m_bits;
    unsigned int cursor_width       = time16_width;
    unsigned int cursor_height      = time16_height;
    unsigned int cursor_x_hot       = time16_x_hot;
    unsigned int cursor_y_hot       = time16_y_hot;

#if LARGE_HOURGLASS_CURSOR
    // Fetch cursor shape
    unsigned int width, height;
    XQueryBestCursor(display, rootWindow, 32, 32, &width, &height);
    Boolean largeCursors = (width >= 32 && height >= 32);
    if (largeCursors)
    {
	cursor_bits      = time32_bits;
	cursor_mask_bits = time32m_bits;
	cursor_width     = time32_width;
	cursor_height    = time32_height;
	cursor_x_hot     = time32_x_hot;
	cursor_y_hot     = time32_y_hot;
    }
#endif

    Pixmap cursor_pixmap = 
	XCreateBitmapFromData(display, rootWindow, (char *)cursor_bits,
			      cursor_width, cursor_height);
    Pixmap cursor_mask_pixmap = 
	XCreateBitmapFromData(display, rootWindow, (char *)cursor_mask_bits,
			      cursor_width, cursor_height);
    
    XColor cursor_colors[2];
    cursor_colors[0].pixel = BlackPixelOfScreen(screen);
    cursor_colors[1].pixel = WhitePixelOfScreen(screen);

    XQueryColors(display, DefaultColormapOfScreen(screen), 
		 cursor_colors, 2);

    hourglass_cache = 
	XCreatePixmapCursor(display, cursor_pixmap, cursor_mask_pixmap,
			    cursor_colors, cursor_colors + 1, 
			    cursor_x_hot, cursor_y_hot);
#else // Watch cursor
    hourglass_cache = 
	XCreateFontCursor(display, XC_watch);
#endif

    return hourglass_cache;
}
Esempio n. 18
0
/* drawing setup- colors, lines, etc*/
void CreateDrawTools ( Widget parent )
{
    MainCanvas = parent;

    gcv.foreground = BlackPixelOfScreen (XtScreen (MainCanvas));
    gc = XCreateGC (XtDisplay (MainCanvas), RootWindowOfScreen (XtScreen (MainCanvas)), GCForeground, &gcv);
    XtVaSetValues (MainCanvas, XmNuserData, gc, NULL);
}
Esempio n. 19
0
static void
monoColormap(Screen * scr, ScreenInfo * si, char *foreground, char *background)
{
	si->black_pixel = BlackPixelOfScreen(scr);
	si->white_pixel = WhitePixelOfScreen(scr);
	if (strcmp(foreground, "White") == 0 || strcmp(foreground, "white") == 0 ||
	    strcmp(background, "Black") == 0 || strcmp(background, "black") == 0) {
		si->fg_pixel = WhitePixelOfScreen(scr);
		si->bg_pixel = BlackPixelOfScreen(scr);
	} else {
		si->fg_pixel = BlackPixelOfScreen(scr);
		si->bg_pixel = WhitePixelOfScreen(scr);
	}
	si->pixels[0] = WhitePixelOfScreen(scr);
	si->pixels[1] = BlackPixelOfScreen(scr);
	si->npixels = 2;
}
Esempio n. 20
0
static void 
create_gc(Widget w)
{
	XGCValues       values;
	XmFontList      fontlist;
	XFontStruct    *font, **font_struct_list;
	XFontSet        fontset;
	char          **font_name_list, *tag;
	XtPointer       t;
	XmFontContext   context;
	XmFontListEntry first_entry, entry;
	XmFontType      font_type;
	int             font_count;

	if (gc)
		return;

	/* Assume parent is Shell or BulletinBoard */
	XtVaGetValues(XtParent(w), XmNlabelFontList, &fontlist, NULL);
	if (fontlist)
		if (XmFontListInitFontContext(&context, fontlist)) {
			/* Get first entry */
			entry = XmFontListNextEntry(context);
			first_entry = entry;
			/* Walk down list looking for "Drawing" */
			while (entry) {
				tag = XmFontListEntryGetTag(entry);
				if (strcmp(tag, "Drawing") == 0) {
					XtFree(tag);
					break;
				}
				XtFree(tag);
				entry = XmFontListNextEntry(context);
			}
			XmFontListFreeFontContext(context);
			/* If we didn't find it use first entry */
			if (!entry)
				entry = first_entry;
			/* Get the font */
			t = XmFontListEntryGetFont(entry, &font_type);
			if (font_type == XmFONT_IS_FONT)
				font = (XFontStruct *) t;
			else {
				/*
				 * It's a font set - use the first one in the
				 * set
				 */
				fontset = (XFontSet) t;
				font_count = XFontsOfFontSet(fontset, &font_struct_list,
							   &font_name_list);
				font = font_struct_list[0];
			}
			values.font = font->fid;
			values.foreground = BlackPixelOfScreen(XtScreen(w));
			gc = XCreateGC(XtDisplay(w), XtWindow(w),
				       GCFont | GCForeground, &values);
		}
}
Esempio n. 21
0
// Convert String to Pixmap (using XmGetPixmap)
// A Pixmap will be read in as bitmap file
// 1 and 0 values are set according to the widget's 
// foreground/background colors.
static Boolean CvtStringToPixmap(Display *display, 
				 XrmValue *args, Cardinal *num_args, 
				 XrmValue *fromVal, XrmValue *toVal,
				 XtPointer *)
{
    // Default parameters
    Screen *screen   = DefaultScreenOfDisplay(display);
    Pixel background = WhitePixelOfScreen(screen);
    Pixel foreground = BlackPixelOfScreen(screen);

    if (*num_args >= 1)
    {
	// convert first arg into widget
	Widget w = *(Widget *) args[0].addr;
	background = w->core.background_pixel;
	
	screen = XtScreen(w);
	
	if (XtIsWidget(w) && XmIsPrimitive(w))
	{
	    // Get foreground color from widget
	    foreground = XmPrimitiveWidget(w)->primitive.foreground;
	}
	else
	{
	    // Ask Motif for a default foreground color
	    Pixel newfg, newtop, newbot, newselect;
	    XmGetColors(screen, w->core.colormap, background,
			&newfg, &newtop, &newbot, &newselect);
	    foreground = newfg;
	}
    }

    // Get pixmap
    Pixmap p = XmUNSPECIFIED_PIXMAP;

    string value = str(fromVal, false);

    // Some Motif versions use `unspecified_pixmap' and `unspecified pixmap'
    // as values for XmUNSPECIFIED_PIXMAP.  Check for this.
    string v = downcase(value);
    v.gsub(" ", "_");
    if (v.contains("xm", 0))
	v = v.after("xm");
    if (v != "unspecified_pixmap")
    {
	p = XmGetPixmap(screen, XMST(value.chars()), foreground, background);

	if (p == XmUNSPECIFIED_PIXMAP)
	{
	    XtDisplayStringConversionWarning(display, fromVal->addr, 
					     XmRPixmap);
	    return False;
	}
    }

    done(Pixmap, p);
}
Esempio n. 22
0
int initXconnection()
{
    x11Display = XOpenDisplay(NULL);
    if (x11Display != 0L)
    {
        XSetIOErrorHandler(xio_errhandler);
        XCreateSimpleWindow(x11Display, DefaultRootWindow(x11Display),
                            0, 0, 1, 1, 0,
                            BlackPixelOfScreen(DefaultScreenOfDisplay(x11Display)),
                            BlackPixelOfScreen(DefaultScreenOfDisplay(x11Display)));
        return XConnectionNumber(x11Display);
    } else
    {
        kdWarning(1205) << "Can't connect to the X Server.\n";
        kdWarning(1205) << "Might not terminate at end of session.\n";
        return -1;
    }
}
Esempio n. 23
0
int main(int argc, char *argv[])
{
    theDisplay = XOpenDisplay(NULL);
    XSynchronize(theDisplay, True);
    theScreen = DefaultScreenOfDisplay(theDisplay);
    theWindow = XCreateSimpleWindow(theDisplay, RootWindowOfScreen(theScreen),
                                    0, 0,
                                    WINDOW_SIZE, WINDOW_SIZE, 0,
                                    BlackPixelOfScreen(theScreen),
                                    WhitePixelOfScreen(theScreen));
    theGC = XCreateGC(theDisplay, theWindow, 0L, NULL);
    XSetForeground(theDisplay, theGC, BlackPixelOfScreen(theScreen));
    XMapWindow(theDisplay, theWindow);
    /* more stuff to come here... */
    tortoise_reset();
    gh_enter(argc, argv, inner_main);
    return 0; /* never reached */
}
Esempio n. 24
0
void MAOpenGLInitCb(
  Widget 	w, 
  XtPointer	clientData,
  XtPointer	callData)
{
  static String xFontStr = "-*-courier-*-*-*-*-14-*-*-*-*-*-*-*";
  Font		xFont;
  WlzDVertex3	tVtx, orgVtx;
  Display	*dpy = XtDisplay( w );
 
  (void )HGUglwCreateCanvasGlxContext(w, NULL);
  HGUglwCanvasGlxMakeCurrent(w, NULL);
  xFont = XLoadFont(XtDisplay(w), xFontStr);
  if(xFont)
  {
    threeDFont = HGUglTextFontCreate(xFont);
  }
  glShadeModel(GL_FLAT);
  glEnable(GL_DEPTH_TEST);
  if( globals.toplDepth == 24 ){
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glEnable(GL_FOG);
    glFogf(GL_FOG_MODE, GL_LINEAR);
  }
  else {
    glClearIndex( (GLfloat) BlackPixelOfScreen(XtScreen(w)) );
  }

  /* set the initial transform - should be from resources */
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glRotated( (GLdouble) 90.0, (GLdouble) 1.0, (GLdouble) 0.0, (GLdouble) 0.0);
  glRotated((GLdouble) -40.0, (GLdouble) 0.0, (GLdouble) 0.0, (GLdouble) 1.0);
  glRotated( (GLdouble) 20.0, (GLdouble) 0.6, (GLdouble) 0.4, (GLdouble) 0.0);
  glGetDoublev(GL_MODELVIEW_MATRIX, &initial_rot[0][0]);

  /* create the default 3D display  DisplayList */
  globals.ref_display_list = glGenLists( (GLsizei) 1 );
  glNewList( globals.ref_display_list, GL_COMPILE );
  WLZ_VTX_3_SET(tVtx, 10.0, 10.0, 10.0);
  WLZ_VTX_3_SET(orgVtx, 5.0, 5.0, 5.0);
  if( globals.toplDepth == 24 ){
    glColor3d((GLdouble) 1.0, (GLdouble) 1.0, (GLdouble) 1.0);
  }
  else {
    glIndexi( HGU_XGetColorPixel(dpy, globals.cmap, 1.0, 1.0, 1.0) );
  }
  HGUglShapeWireCube(tVtx, orgVtx);

  glEndList();

  WLZ_VTX_3_SET(globals.bbox_vtx, -2.0, -2.0, -2.0);
  WLZ_VTX_3_SET(globals.bbox_size, 14.0, 14.0, 14.0);

  return;
}
Esempio n. 25
0
/* Loads an image into the Drawable, returning once the image is loaded.
 */
static void
load_random_image_android (Screen *screen, Window window, Drawable drawable,
                           void (*callback) (Screen *, Window, Drawable,
                                             const char *name,
                                             XRectangle *geom, void *closure),
                           void *closure)
{
  Display *dpy = DisplayOfScreen (screen);
  XWindowAttributes xgwa;
  XRectangle geom;
  char *name = 0;
  char *data = 0;
  int width  = 0;
  int height = 0;
  
  if (!drawable) abort();

  XGetWindowAttributes (dpy, window, &xgwa);
  {
    Window r;
    int x, y;
    unsigned int w, h, bbw, d;
    XGetGeometry (dpy, drawable, &r, &x, &y, &w, &h, &bbw, &d);
    xgwa.width = w;
    xgwa.height = h;
  }

  geom.x = 0;
  geom.y = 0;
  geom.width  = xgwa.width;
  geom.height = xgwa.height;

  data = jwxyz_load_random_image (dpy, &width, &height, &name);
  if (! data)
    draw_colorbars (screen, xgwa.visual, drawable, xgwa.colormap,
                    0, 0, xgwa.width, xgwa.height);
  else
    {
      XImage *img = XCreateImage (dpy, xgwa.visual, 32,
                                  ZPixmap, 0, data, width, height, 0, 0);
      XGCValues gcv;
      GC gc;
      gcv.foreground = BlackPixelOfScreen (screen);
      gc = XCreateGC (dpy, drawable, GCForeground, &gcv);
      XFillRectangle (dpy, drawable, gc, 0, 0, xgwa.width, xgwa.height);
      XPutImage (dpy, drawable, gc, img, 0, 0, 
                 (xgwa.width  - width) / 2,
                 (xgwa.height - height) / 2,
                 width, height);
      XDestroyImage (img);
      XFreeGC (dpy, gc);
    }

  callback (screen, window, drawable, name, &geom, closure);
  if (name) free (name);
}
Esempio n. 26
0
void xf_create_window(xfContext* xfc)
{
	XEvent xevent;
	int width, height;
	char* windowTitle;

	ZeroMemory(&xevent, sizeof(xevent));

	width = xfc->width;
	height = xfc->height;

	if (!xfc->remote_app)
	{
		xfc->attribs.background_pixel = BlackPixelOfScreen(xfc->screen);
		xfc->attribs.border_pixel = WhitePixelOfScreen(xfc->screen);
		xfc->attribs.backing_store = xfc->primary ? NotUseful : Always;
		xfc->attribs.override_redirect = xfc->grab_keyboard ? xfc->fullscreen : False;
		xfc->attribs.colormap = xfc->colormap;
		xfc->attribs.bit_gravity = NorthWestGravity;
		xfc->attribs.win_gravity = NorthWestGravity;

		if (xfc->instance->settings->WindowTitle)
		{
			windowTitle = _strdup(xfc->instance->settings->WindowTitle);
		}
		else if (xfc->instance->settings->ServerPort == 3389)
		{
			windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname));
			sprintf(windowTitle, "FreeRDP: %s", xfc->instance->settings->ServerHostname);
		}
		else
		{
			windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname) + sizeof(":00000"));
			sprintf(windowTitle, "FreeRDP: %s:%i", xfc->instance->settings->ServerHostname, xfc->instance->settings->ServerPort);
		}

		printf ("xfc->settings->Decorations=%d\n", xfc->settings->Decorations);

		xfc->window = xf_CreateDesktopWindow(xfc, windowTitle, width, height, xfc->settings->Decorations);
		free(windowTitle);

		if (xfc->fullscreen)
			xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);

		xfc->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

		XSetWMProtocols(xfc->display, xfc->window->handle, &(xfc->WM_DELETE_WINDOW), 1);
		xfc->drawable = xfc->window->handle;
	}
	else
	{
		xfc->drawable = DefaultRootWindow(xfc->display);
	}
}
Esempio n. 27
0
Pixmap
makepixmap(Widget toplevel, char bits[], int width, int height)
{
  return (Pixmap)XCreatePixmapFromBitmapData(XtDisplay(toplevel),
			   DefaultRootWindow(XtDisplay(toplevel)),
                           bits,
                           width,
                           height,
                           BlackPixelOfScreen(XtScreen(toplevel)),
                           WhitePixelOfScreen(XtScreen(toplevel)),
                           DefaultDepthOfScreen(XtScreen(toplevel)));
}
Esempio n. 28
0
/**
@brief    Creates the mode menu which can be used by all windows in all workspaces.  The main even loop uses the windows and events to determine if a mode menu item was clicked or interacted with in some way.
@return   void
**/
void 
create_mode_menu(Display *display, struct Mode_menu *mode_menu
, struct Themes *themes, struct Cursors *cursors) {

  Screen* screen = DefaultScreenOfDisplay(display);
  int black = BlackPixelOfScreen(screen);

  mode_menu->menu.inner_width = DEFAULT_MENU_ITEM_WIDTH;
  mode_menu->menu.inner_height = themes->popup_menu[menu_item_mid].h * (hidden + 1);
  
  create_popup_menu(display, &mode_menu->menu, themes, cursors);

  //Create the menu items
  for(int i = 0; i <= hidden; i++) {

    mode_menu->items[i].item = XCreateSimpleWindow(display, mode_menu->menu.widgets[popup_menu_parent].widget
    , themes->popup_menu[popup_l_edge].w, themes->popup_menu[popup_t_edge].h + themes->popup_menu[menu_item_mid].h * i
    , mode_menu->menu.inner_width, themes->popup_menu[menu_item_mid].h, 0, black, black);

    XSelectInput(display, mode_menu->items[i].item,  ButtonReleaseMask | EnterWindowMask | LeaveWindowMask);
    for(int j = 0; j <= inactive; j++) {
      if(themes->popup_menu[i].state_p[j]) {
        char *label = NULL;
        char Floating[] = "Floating";
        char Tiling[] = "Tiling";
        char Hidden[] = "Hidden";
        char Desktop[] = "Desktop";

        switch(i) {
          case floating: label = Floating;
          break;
          case tiling: label = Tiling;
          break;
          case hidden: label = Hidden;
          break;
          case desktop: label = Desktop;
          break;
        }

        mode_menu->items[i].state[j] = XCreateSimpleWindow(display, mode_menu->items[i].item
        , 0, 0, mode_menu->menu.inner_width, themes->popup_menu[menu_item_mid].h, 0, black, black);

        create_text_background(display, mode_menu->items[i].state[j], label, &themes->font_theme[j]
        , themes->popup_menu[menu_item_mid].state_p[j]
        , themes->popup_menu[menu_item_mid].w, themes->popup_menu[menu_item_mid].h);
        XMapWindow(display, mode_menu->items[i].state[j]);
      }
//      else printf("Warning:  Skipping state pixmap\n");
    }
    XMapWindow(display, mode_menu->items[i].item);
  }

}
Esempio n. 29
0
void xf_create_window(xfInfo* xfi)
{
	XEvent xevent;
	char* win_title;
	int width, height;

	width = xfi->width;
	height = xfi->height;

	xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen);
	xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen);
	xfi->attribs.backing_store = xfi->primary ? NotUseful : Always;
	xfi->attribs.override_redirect = xfi->fullscreen;
	xfi->attribs.colormap = xfi->colormap;
	xfi->attribs.bit_gravity = ForgetGravity;
	xfi->attribs.win_gravity = StaticGravity;

	if (xfi->instance->settings->window_title != NULL)
	{
		win_title = xstrdup(xfi->instance->settings->window_title);
	}
	else if (xfi->instance->settings->port == 3389)
	{
		win_title = xmalloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname));
		sprintf(win_title, "FreeRDP: %s", xfi->instance->settings->hostname);
	}
	else
	{
		win_title = xmalloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname) + sizeof(":00000"));
		sprintf(win_title, "FreeRDP: %s:%i", xfi->instance->settings->hostname, xfi->instance->settings->port);
	}

	xfi->window = xf_CreateDesktopWindow(xfi, win_title, width, height, xfi->decorations);
	xfree(win_title);

	if (xfi->parent_window)
		XReparentWindow(xfi->display, xfi->window->handle, xfi->parent_window, 0, 0);

	if (xfi->fullscreen)
		xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

	/* wait for VisibilityNotify */
	do
	{
		XMaskEvent(xfi->display, VisibilityChangeMask, &xevent);
	}
	while (xevent.type != VisibilityNotify);

	xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

	XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1);
	xfi->drawable = xfi->window->handle;
}
Esempio n. 30
0
/* 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;
}