Example #1
0
void
initcursors(void)
{
    sweep = XCreateFontCursor(_dpy, XC_sizing);
    crosshair = XCreateFontCursor(_dpy, XC_crosshair);
    pirate = XCreateFontCursor(_dpy, XC_pirate);
    watch = XCreateFontCursor(_dpy, XC_watch);
    defcursor = XCreateFontCursor(_dpy, XC_left_ptr);
}
Example #2
0
int
Rwm_init_frame_cursors(struct R_app *app)
{
    Rwm_frame_cursors[RWM_BOTTOM_FRAME] = XCreateFontCursor(app->display,
                                                            XC_bottom_side);
    Rwm_frame_cursors[RWM_RIGHT_FRAME] = XCreateFontCursor(app->display,
                                                           XC_right_side);

    return TRUE;
}
Example #3
0
void
gui_init(xccore_t *xccore)
{
    gui = oxim_malloc(sizeof(gui_t), True);

    if (! (gui->display = XOpenDisplay(xccore->display_name)))
    {
	oxim_perr(OXIMMSG_ERROR, N_("cannot open display: %s\n"),
			    xccore->display_name);
    }
    Atom oxim_atom = XInternAtom(gui->display, OXIM_ATOM, True);
    if (oxim_atom != None && XGetSelectionOwner(gui->display, oxim_atom) != None)
    {
	oxim_perr(OXIMMSG_WARNING, N_("OXIM already running!\n"));
	exit(0);
    }

    (void) XSetErrorHandler(errhandle);
    gui->screen = DefaultScreen(gui->display);
    gui->visual = DefaultVisual(gui->display, gui->screen);
    gui->colormap = DefaultColormap(gui->display, gui->screen);
    gui->display_width = DisplayWidth(gui->display, gui->screen);
    gui->display_height = DisplayHeight(gui->display, gui->screen);
    gui->root = RootWindow(gui->display, gui->screen);

    gui_cursor_hand = XCreateFontCursor(gui->display, XC_hand2);
    gui_cursor_move = XCreateFontCursor(gui->display, XC_fleur);
    gui_cursor_arrow = XCreateFontCursor(gui->display, XC_left_ptr);

    gui_init_xft();
    InitWindows(xccore);

    gui->xcin_style = False;
    if (strcasecmp("yes", oxim_get_config(XcinStyleEnabled)) == 0)
    {
	gui->xcin_style = True;
    }

    gui->onspot_enabled = False;
    if (strcasecmp("yes", oxim_get_config(OnSpotEnabled)) == 0)
    {
	gui->onspot_enabled = True;
    }

    xccore->display = gui->display;
    xccore->window  = gui->status_win->window;

    /* 利用計時中斷,偵測 WM 的 Tray Manager 是否 Ready */
    if(!xccore->hide_tray)
    {
	signal(SIGALRM, gui_tray_monitor);
	gui_tray_monitor(SIGALRM);
    }

}
Example #4
0
File: init.c Project: pierreN/wmfs
/** Init WMFS cursor
*/
static void
init_cursor(void)
{
     cursor[CurNormal]      = XCreateFontCursor(dpy, XC_left_ptr);
     cursor[CurResize]      = XCreateFontCursor(dpy, XC_sizing);
     cursor[CurRightResize] = XCreateFontCursor(dpy, XC_lr_angle);
     cursor[CurLeftResize]  = XCreateFontCursor(dpy, XC_ll_angle);
     cursor[CurMove]        = XCreateFontCursor(dpy, XC_fleur);

     return;
}
Example #5
0
void open_windows()
{
  int i; int scrap;
  XSetWindowAttributes attributes;
  XSizeHints *hints = XAllocSizeHints();

  attributes.backing_store = WhenMapped;
  attributes.cursor = XCreateFontCursor(display, XC_X_cursor);

  main_window = XCreateWindow(display, DefaultRootWindow(display),
                              w_x, w_y, w_width, w_height, 0,
                              CopyFromParent, InputOutput,
                              CopyFromParent, CWCursor | CWBackingStore,
                              &attributes);

  hints->flags = PPosition | PSize | PMinSize | PMaxSize | PWinGravity;
  hints->x = w_x; hints->y = w_y;
  hints->width = w_width; hints->height = w_height;
  hints->min_width = hints->max_width = w_width;
  hints->min_height = hints->max_height = w_height;
  hints->win_gravity = CenterGravity;
  XSetWMNormalHints(display, main_window, hints);

  XStoreName(display, main_window, "SSH Authentication Passphrase Request");

  /* This is a dialog box, I think. */
  XSetTransientForHint(display, main_window,
                       DefaultRootWindow(display));
  XFree(hints);

  cancel_button = XCreateWindow(display, main_window,
                                w_width - relief - margin - b_width,
                                w_height - relief - margin - b_height,
                                b_width, b_height,
                                0,
                                CopyFromParent, InputOutput,
                                CopyFromParent, CWCursor |
                                CWBackingStore,
                                &attributes);
  
  leds = (w_width - relief * 2 - margin * 2 + (led_width - led_i_width)) /
    led_width;
  scrap = (w_width - relief * 2 - margin * 2 + (led_width - led_i_width)) %
    led_width;
  leds_x = relief + margin + scrap/2;

  led_state = ssh_xmalloc(sizeof(int) * leds);
  for (i = 0; i < leds; i++) led_state[i] = 0;
  
  attributes.cursor = XCreateFontCursor(display, XC_top_left_arrow);
  XChangeWindowAttributes(display, cancel_button, CWCursor | CWBackingStore,
                          &attributes);
}
Example #6
0
int UIInquireVector(Widget widget, XEvent *event, int x0, int y0, int *x1, int *y1) {
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    static GC gc = (GC) NULL;
    static Cursor cursor[2] = {(Cursor) NULL, (Cursor) NULL};
    static int inLoop, cont, ret;

    if (cursor[0] == (Cursor) NULL) cursor[0] = XCreateFontCursor(XtDisplay(widget), XC_hand2);
    if (cursor[1] == (Cursor) NULL) cursor[1] = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow);
    if (gc == (GC) NULL) {
        xgcv.function = GXinvert;
        gc = XtGetGC(widget, GCFunction, &xgcv);
    }
    if (inLoop == false) {
        if (event->type != ButtonPress) return (false);
        inLoop = cont = true;
        ret = false;
        xswa.cursor = cursor[0];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        *x1 = event->xbutton.x;
        *y1 = event->xbutton.y;
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        do {
            XtAppNextEvent(UIApplicationContext(), event);
            XtDispatchEvent(event);
        } while (cont);
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        xswa.cursor = cursor[1];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        inLoop = false;
        return (ret);
    }
    else
        switch (event->type) {
            case ButtonRelease:
                xswa.cursor = cursor[1];
                XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
                ret = true;
                cont = false;
                break;
            case MotionNotify:
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                *x1 = event->xmotion.x;
                *y1 = event->xmotion.y;
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                break;
            case LeaveNotify:
                ret = false;
                cont = false;
                break;
        }
    return (false);
}
Example #7
0
void MotifUI::PointerShape(PointerCursor style)
{
   static Cursor left = (Cursor) 0L;
   static Cursor right = (Cursor) 0L;
   static Cursor watch = (Cursor) 0L;
   static Cursor hour_glass = (Cursor) 0L;
   static Cursor ibeam = (Cursor) 0L;
   static Cursor cross_hair = (Cursor) 0L;

   if (!_w)
      return;

   Cursor cursor;
   switch (pointer_style = style)
   {
   case LEFT_SLANTED_ARROW_CURSOR: 
      if (!left)
         left = XCreateFontCursor(display, XC_left_ptr);
      cursor = left;
      break;
   case RIGHT_SLANTED_ARROW_CURSOR:
      if (!right)
         right = XCreateFontCursor(display, XC_right_ptr);
      cursor = right;
      break;
   case WATCH_CURSOR:
      if (!watch)
         watch = XCreateFontCursor(display, XC_watch);
      cursor = watch;
      break;
   case HOUR_GLASS_CURSOR:
      if (!hour_glass)
         hour_glass = InitHourGlassCursor();
      cursor = hour_glass;
      break;
   case IBEAM_CURSOR:
      if (!ibeam)
         ibeam = XCreateFontCursor(display, XC_xterm);
      cursor = ibeam;
      break;
   case CROSS_HAIRS_CURSOR:
      if (!cross_hair)
         cross_hair = XCreateFontCursor(display, XC_crosshair);
      cursor = cross_hair;
      break;
   default: cursor = None; break;
   }

   if (XtIsRealized(_w))
      XDefineCursor(display, XtWindow(_w), cursor);
}
Example #8
0
static ECursor     *
ECursorRealize(ECursor * ec)
{
   Pixmap              pmap, mask;
   int                 xh, yh;
   unsigned int        w, h, ww, hh;
   char               *img, msk[FILEPATH_LEN_MAX];

   if (ec->file)
     {
	img = ThemeFileFind(ec->file, FILE_TYPE_CURSOR);
	_EFREE(ec->file);	/* Ok or not - we never need file again */
	if (!img)
	   goto done;

	Esnprintf(msk, sizeof(msk), "%s.mask", img);
	pmap = 0;
	mask = 0;
	xh = 0;
	yh = 0;
	XReadBitmapFile(disp, WinGetXwin(VROOT), msk, &w, &h, &mask, &xh, &yh);
	XReadBitmapFile(disp, WinGetXwin(VROOT), img, &w, &h, &pmap, &xh, &yh);
	XQueryBestCursor(disp, WinGetXwin(VROOT), w, h, &ww, &hh);
	if ((w <= ww) && (h <= hh) && (pmap))
	  {
	     if (xh < 0 || xh >= (int)w)
		xh = (int)w / 2;
	     if (yh < 0 || yh >= (int)h)
		yh = (int)h / 2;
	     ec->cursor =
		ECreatePixmapCursor(pmap, mask, w, h, xh, yh, ec->fg, ec->bg);
	  }

	if (ec->cursor == NoXID)
	  {
	     Eprintf("*** Failed to create cursor \"%s\" from %s,%s\n",
		     ec->name, img, msk);
	  }

	if (pmap)
	   EFreePixmap(pmap);
	if (mask)
	   EFreePixmap(mask);
	Efree(img);
     }
   else
     {
	ec->cursor = (ec->native_id == 999) ?
	   None : XCreateFontCursor(disp, ec->native_id);
     }

 done:
   if (ec->cursor == NoXID)
     {
	ECursorDestroy(ec);
	ec = NULL;
     }

   return ec;
}
Window
Select_Window( Display * dpy )
{                               /*{{{ */
  /*
   * Routine to let user select a window using the mouse
   * Taken from xfree86.
   */

  int status;
  Cursor cursor;
  XEvent event;
  Window target_win = None, root = DefaultRootWindow( dpy );
  int buttons = 0;
  int dummyi;
  unsigned int dummy;

  /* Make the target cursor */
  cursor = XCreateFontCursor( dpy, XC_crosshair );

  /* Grab the pointer using target cursor, letting it room all over */
  status = XGrabPointer( dpy, root, False, ButtonPressMask | ButtonReleaseMask, GrabModeSync, GrabModeAsync, root, cursor, CurrentTime );
  if ( status != GrabSuccess )
  {
    fputs( "ERROR: Cannot grab mouse.\n", stderr );
    return 0;
  }

  /* Let the user select a window... */
  while ( ( target_win == None ) || ( buttons != 0 ) )
  {
    /* allow one more event */
    XAllowEvents( dpy, SyncPointer, CurrentTime );
    XWindowEvent( dpy, root, ButtonPressMask | ButtonReleaseMask, &event );
    switch ( event.type )
    {
    case ButtonPress:
      if ( target_win == None )
      {
        target_win = event.xbutton.subwindow; /* window selected */
        if ( target_win == None )
          target_win = root;
      }
      buttons++;
      break;
    case ButtonRelease:
      if ( buttons > 0 )        /* there may have been some down before we started */
        buttons--;
      break;
    }
  }

  XUngrabPointer( dpy, CurrentTime ); /* Done with pointer */

  if ( XGetGeometry( dpy, target_win, &root, &dummyi, &dummyi, &dummy, &dummy, &dummy, &dummy ) && target_win != root )
  {
    target_win = XmuClientWindow( dpy, target_win );
  }

  return ( target_win );
}
Example #10
0
LinuxEnvironment::LinuxEnvironment(Display *display, Window window) : Environment()
{
	m_display = display;
	m_window = window;

	m_bCursorClipped = false;
	m_bCursorRequest = false;
	m_bCursorReset = false;
	m_bCursorVisible = true;
	m_bIsCursorInsideWindow = false;
	m_mouseCursor = XCreateFontCursor(m_display, XC_left_ptr);
	m_invisibleCursor = makeBlankCursor();
	m_cursorType = CURSORTYPE::CURSOR_NORMAL;

	m_atom_UTF8_STRING = XInternAtom(m_display, "UTF8_STRING", False);
	m_atom_CLIPBOARD = XInternAtom(m_display, "CLIPBOARD", False);
	m_atom_TARGETS = XInternAtom(m_display, "TARGETS", False);

	m_bFullScreen = false;

	m_bIsRestartScheduled = false;
	m_bResizeDelayHack = false;
	m_bPrevCursorHack = false;
	m_bFullscreenWasResizable = true;

	// TODO: init monitors
	if (m_vMonitors.size() < 1)
	{
		///debugLog("WARNING: No monitors found! Adding default monitor ...\n");

		const Vector2 windowSize = getWindowSize();
		m_vMonitors.push_back(McRect(0, 0, windowSize.x, windowSize.y));
	}
}
Example #11
0
/**********************************************************************
 * If no application window was indicated on the command line, prompt
 * the user to select one
 *********************************************************************/
Window
get_target_window ()
{
	XEvent eventp;
	int val = -10, trials;
	Window target = None;

	trials = 0;
	while ((trials < 100) && (val != GrabSuccess))
    {
		val = XGrabPointer (dpy, Scr.Root, True,
				  		   	ButtonReleaseMask,
			  				GrabModeAsync, GrabModeAsync, Scr.Root,
			  				XCreateFontCursor (dpy, XC_crosshair),
			  				CurrentTime);
      	if( val != GrabSuccess )
			sleep_a_little (100);
		trials++;
    }
  	if (val != GrabSuccess)
    {
    	show_error( "Couldn't grab the cursor!\n", MyName);
      	DeadPipe(0);
    }
  	XMaskEvent (dpy, ButtonReleaseMask, &eventp);
  	XUngrabPointer (dpy, CurrentTime);
  	ASSync(0);
  	target = eventp.xbutton.window;
	LOCAL_DEBUG_OUT( "window = %lX, root = %lX, subwindow = %lX", 
					 eventp.xbutton.window, eventp.xbutton.root, eventp.xbutton.subwindow );
  	if( eventp.xbutton.subwindow != None )
    	target = eventp.xbutton.subwindow;
	return target;
}
Example #12
0
/* _xwin_select_system_cursor:
 *  Select an OS native cursor 
 */
static int _xwin_select_system_cursor(AL_CONST int cursor)
{
   switch(cursor) {
      case MOUSE_CURSOR_ARROW:
         _xwin.cursor_shape = XC_left_ptr;
         break;
      case MOUSE_CURSOR_BUSY:
         _xwin.cursor_shape = XC_watch;
         break;
      case MOUSE_CURSOR_QUESTION:
         _xwin.cursor_shape = XC_question_arrow;
         break;
      case MOUSE_CURSOR_EDIT:
         _xwin.cursor_shape = XC_xterm;
         break;
      default:
         return 0;
   }

   XLOCK();

   if (_xwin.cursor != None) {
      XUndefineCursor(_xwin.display, _xwin.window);
      XFreeCursor(_xwin.display, _xwin.cursor);
   }

   _xwin.cursor = XCreateFontCursor(_xwin.display, _xwin.cursor_shape);
   XDefineCursor(_xwin.display, _xwin.window, _xwin.cursor);

   XUNLOCK();

   return cursor;
}
Example #13
0
int
ui_set_busy_cursor(
    Window	window,
    BOOL	on
)
{
    static Cursor  busy_cursor = NULL;
    static Display *dpy        = NULL;

    if (on) /* Turn ON busy cursor */
    {
	dpy = XtDisplay(AB_toplevel);

	if (busy_cursor == NULL)
	    busy_cursor = XCreateFontCursor(dpy, XC_watch);

        XDefineCursor(dpy, window, busy_cursor);
    }
    else if (dpy != NULL) /* Turn OFF busy cursor */
    {
	XUndefineCursor(dpy, window);
	dpy = NULL;
    }
    return 0;

}
Example #14
0
Window create_full_screen_window (Display *dpy, int screen, Colormap cmap)
{
  XSetWindowAttributes attrs;
  Window win;
  Visual *visual;
  Screen *screen_obj;
  unsigned long attrmask;
  int depth;

  screen_obj = ScreenOfDisplay (dpy, screen);
  visual = DefaultVisualOfScreen (screen_obj);
  depth = visual_depth (screen_obj, visual);

  attrmask = (CWOverrideRedirect | CWEventMask | CWBackingStore | CWColormap
              | CWCursor);
  attrs.override_redirect = True;
  attrs.event_mask = (ExposureMask | KeyPressMask | ButtonPressMask
                      | Button1MotionMask | ButtonReleaseMask);
  attrs.backing_store = NotUseful;
  attrs.colormap = cmap;
  attrs.cursor = XCreateFontCursor (dpy, XC_cross);

  win = XCreateWindow (dpy, RootWindowOfScreen (screen_obj),
                       0, 0, WidthOfScreen (screen_obj),
                       HeightOfScreen (screen_obj), 0,
                       depth, InputOutput, visual,
                       attrmask, &attrs);
  return win;
}
Example #15
0
void ui_create_window(int x, int y, int w, int h)
{
	ui->w[ui->cur].swa.override_redirect = True;
	ui->w[ui->cur].swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ButtonPressMask;
	ui->w[ui->cur].swa.colormap = XCreateColormap(ui->dpy, DefaultRootWindow(ui->dpy), ui->vinfo.visual, AllocNone);
	ui->w[ui->cur].swa.background_pixel = 0;
	ui->w[ui->cur].swa.border_pixel = 0;

	ui->w[ui->cur].win = XCreateWindow(ui->dpy, ui->root, x, y, w, h, 0,
					   ui->vinfo.depth, CopyFromParent,
					   ui->vinfo.visual,
					   CWOverrideRedirect | CWColormap |
					   CWBackPixel | CWEventMask |
					   CWBorderPixel,
					   &ui->w[ui->cur].swa);
	ui->w[ui->cur].xic = XCreateIC(ui->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
			    XNClientWindow, ui->w[ui->cur].win, XNFocusWindow, ui->w[ui->cur].win, NULL);

	ui->w[ui->cur].gc = XCreateGC(ui->dpy, ui->w[ui->cur].win, 0, NULL);

	XStoreName(ui->dpy, ui->w[ui->cur].win, "jgmenu");
	XSetIconName(ui->dpy, ui->w[ui->cur].win, "jgmenu");
	set_wm_class();

	/*
	 * XDefineCursor required to prevent blindly inheriting cursor from parent
	 * (e.g. hour-glass pointer set by tint2)
	 * Check this URL for cursor styles:
	 * http://tronche.com/gui/x/xlib/appendix/b/
	 */
	XDefineCursor(ui->dpy, ui->w[ui->cur].win, XCreateFontCursor(ui->dpy, 68));
}
Example #16
0
static Cursor
getFullCrosshairCursor(void)
{
#if !defined(WIN32)
  Cursor cursor;
  Atom crosshairAtom, actualType;
  int rc, actualFormat;
  unsigned long n, left;
  unsigned long *value;

  if (fullCrosshairCusor == None) {
    crosshairAtom = XInternAtom(__glutDisplay,
      "_SGI_CROSSHAIR_CURSOR", True);
    if (crosshairAtom != None) {
      value = 0;        /* Make compiler happy. */
      rc = XGetWindowProperty(__glutDisplay, __glutRoot,
        crosshairAtom, 0, 1, False, XA_CURSOR, &actualType,
        &actualFormat, &n, &left, (unsigned char **) &value);
      if (rc == Success && actualFormat == 32 && n >= 1) {
        cursor = value[0];
        XFree(value);
        return cursor;
      }
    }
  }
  return XCreateFontCursor(__glutDisplay, XC_crosshair);
#else
  /* we could kludge up an XGetWindowProperty, XInterAtom and
     XCreateFontCursor that worked for just this case, but I dunno if
     it is worth it, hence the #ifdefs instead. */
  return IDC_CROSS;
#endif /* !WIN32 */
}
Example #17
0
static void 
Realize(
        register Widget w,
        XtValueMask *p_valueMask,
        XSetWindowAttributes *attributes )
{
	XmDisplay   dd = (XmDisplay) XmGetXmDisplay(XtDisplay(w));
	Cursor SashCursor = 
		((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor;
	
	if (0L == SashCursor)
		{
		/* create some data shared among all instances on this 
		** display; the first one along can create it, and 
		** any one can remove it; note no reference count
		*/
        	SashCursor = 
		((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor = 
			XCreateFontCursor(XtDisplay(w), XC_crosshair);
		XtAddCallback((Widget)dd, XtNdestroyCallback, 
			SashDisplayDestroyCallback, (XtPointer) NULL);
		}

	attributes->cursor = SashCursor;
	XtCreateWindow (w, InputOutput, CopyFromParent, 
		*p_valueMask | CWCursor, attributes);
}
Example #18
0
/*****************************
 *
 * Routine to add an item to the dialog box
 * The pointer to the item is copied to the dlg struct,
 * the item itself may not be freed until the dlg is done with
 *
 ****************************/
void DoCreateDlg(t_dlg *dlg)
{
  XSizeHints           hints;
  XSetWindowAttributes attr;
  unsigned long Val;

  attr.border_pixel=dlg->x11->fg;
  attr.background_pixel=dlg->bg;
  attr.override_redirect=False;
  attr.save_under=True;
  attr.cursor=XCreateFontCursor(dlg->x11->disp,XC_hand2);
  Val=CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWSaveUnder |
    CWCursor;
  dlg->win.self=XCreateWindow(dlg->x11->disp,dlg->wDad,
			      dlg->win.x,dlg->win.y,
			      dlg->win.width,dlg->win.height,
			      dlg->win.bwidth,CopyFromParent,
			      InputOutput,CopyFromParent,
			      Val,&attr);
  dlg->x11->RegisterCallback(dlg->x11,dlg->win.self,dlg->wDad,
			     DlgCB,dlg);
  dlg->x11->SetInputMask(dlg->x11,dlg->win.self, 
			 ExposureMask | ButtonPressMask | KeyPressMask);

  if (!CheckWindow(dlg->win.self))
    exit(1);
  hints.x=dlg->win.x;
  hints.y=dlg->win.y;
  hints.flags=PPosition;
  XSetStandardProperties(dlg->x11->disp,dlg->win.self,dlg->title,
			 dlg->title,None,NULL,0,&hints);
}
Example #19
0
/***********************************************************************
 *		X11DRV_create_desktop
 *
 * Create the X11 desktop window for the desktop mode.
 */
BOOL CDECL X11DRV_create_desktop( UINT width, UINT height )
{
    XSetWindowAttributes win_attr;
    Window win;
    Display *display = thread_init_display();

    TRACE( "%u x %u\n", width, height );

    /* Create window */
    win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | EnterWindowMask |
                          PointerMotionMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask;
    win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );

    if (default_visual.visual != DefaultVisual( display, DefaultScreen(display) ))
        win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
                                             default_visual.visual, AllocNone );
    else
        win_attr.colormap = None;

    win = XCreateWindow( display, DefaultRootWindow(display),
                         0, 0, width, height, 0, default_visual.depth, InputOutput, default_visual.visual,
                         CWEventMask | CWCursor | CWColormap, &win_attr );
    if (!win) return FALSE;

    if (width == screen_width && height == screen_height)
    {
        TRACE("setting desktop to fullscreen\n");
        XChangeProperty( display, win, x11drv_atom(_NET_WM_STATE), XA_ATOM, 32,
                         PropModeReplace, (unsigned char*)&x11drv_atom(_NET_WM_STATE_FULLSCREEN),
                         1);
    }
    XFlush( display );
    X11DRV_init_desktop( win, width, height );
    return TRUE;
}
Example #20
0
void clViewport::RecreateViewport()
{
    if ( FWindow )
    {
        XDestroyWindow( FDisplay, *FWindow );
    }

    if ( FFullscreen )
    {
    }
    else
    {
    }

    static char EmptyData[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

    FBlackColor.red   = 0;
    FBlackColor.green = 0;
    FBlackColor.blue  = 0;

    FBitmapEmptyData = XCreateBitmapFromData( FDisplay, *FWindow, EmptyData, 8, 8 );

    FLeftArrowCursor = XCreateFontCursor( FDisplay, XC_left_ptr );
    FInvisibleCursor = XCreatePixmapCursor( FDisplay, FBitmapEmptyData, FBitmapEmptyData, &FBlackColor, &FBlackColor, 0, 0 );
}
Example #21
0
int loadCursor(char *path, int hotx, int hoty, float tail_dist, float angle) {
  if (buildCache(path) != 0) return 1;

  // create a cursor image and set it
  wormy.xci = XcursorImageCreate (2*wormy.radius, 2*wormy.radius);
  wormy.xci->xhot = (2.0*wormy.radius-wormy.width)/2 + hotx;
  wormy.xci->yhot = (2.0*wormy.radius-wormy.height)/2 + hoty;
  wormy.xci->pixels = wormy.cache[0];

  wormy.original = XCreateFontCursor(wormy.disp, XC_left_ptr);
  XDefineCursor(wormy.disp, DefaultRootWindow(wormy.disp), wormy.original);
  wormy.cursor = XcursorImageLoadCursor(wormy.disp, wormy.xci);
  XFixesChangeCursor(wormy.disp, wormy.cursor, wormy.original);

  // using cairo coordinates (inverted y axis)
  wormy.hot_a = atan2f(wormy.xci->yhot - wormy.radius,
                       wormy.xci->xhot - wormy.radius);
  wormy.hot_d = sqrt((wormy.xci->xhot - wormy.radius) *
                     (wormy.xci->xhot - wormy.radius) +
                     (wormy.xci->yhot - wormy.radius) *
                     (wormy.xci->yhot - wormy.radius));
  wormy.tail_d = tail_dist;
  wormy.angle = angle * M_PI / 180.0;

  return 0;
}
Example #22
0
struct Area *display_X11_select_window(void)
{
	Cursor cursor = XCreateFontCursor(disp, XC_left_ptr);

	if (XGrabPointer(disp, scr->root, False, ButtonPressMask, GrabModeAsync,
				GrabModeAsync, scr->root, cursor, CurrentTime) != GrabSuccess)
		return NULL;

	XEvent ev = {0};
	while (ev.type != ButtonPress)
		XNextEvent(disp, &ev);

	XUngrabPointer(disp, CurrentTime);
	XFreeCursor(disp, cursor);
	XSync(disp, True);

	struct Area *area = calloc(1, sizeof(*area));

	Window target = ev.xbutton.subwindow;
	XWindowAttributes attr;
	XGetWindowAttributes(disp, target, &attr);
	area->width = attr.width;
	area->height = attr.height;
	Window child;
	XTranslateCoordinates(disp, target, scr->root, 0, 0, &area->x, &area->y, &child);

	display_X11_area_sanitize(area);

	return area;
}
Example #23
0
void
SplashCreateWindow(Splash * splash) {
    XSizeHints sizeHints;

    XSetWindowAttributes attr;

    attr.backing_store = NotUseful;
    attr.colormap = XDefaultColormapOfScreen(splash->screen);
    attr.save_under = True;
    attr.cursor = splash->cursor = XCreateFontCursor(splash->display, XC_watch);
    attr.event_mask = ExposureMask;

    SplashCenter(splash);

    splash->window = XCreateWindow(splash->display, XRootWindowOfScreen(splash->screen),
        splash->x, splash->y, splash->width, splash->height, 0, CopyFromParent,
        InputOutput, CopyFromParent, CWColormap | CWBackingStore | CWSaveUnder | CWCursor | CWEventMask,
        &attr);
    SplashUpdateSizeHints(splash);


    splash->wmHints = XAllocWMHints();
    if (splash->wmHints) {
        splash->wmHints->flags = InputHint | StateHint;
        splash->wmHints->input = False;
        splash->wmHints->initial_state = NormalState;
        XSetWMHints(splash->display, splash->window, splash->wmHints);
    }
}
Example #24
0
static XID 
get_window_id(Display *dpy, int screen, int button, char *msg)
{
    Cursor cursor;		/* cursor to use when selecting */
    Window root;		/* the current root */
    Window retwin = None;	/* the window that got selected */
    int retbutton = -1;		/* button used to select window */
    int pressed = 0;		/* count of number of buttons pressed */

#define MASK (ButtonPressMask | ButtonReleaseMask)

    root = RootWindow (dpy, screen);
    cursor = XCreateFontCursor (dpy, XC_pirate);
    if (cursor == None) {
	fprintf (stderr, "%s:  unable to create selection cursor\n",
		 ProgramName);
	Exit (1);
    }

    printf ("Select %s with ", msg);
    if (button == -1)
      printf ("any button");
    else
      printf ("button %d", button);
    printf ("....\n");
    XSync (dpy, 0);			/* give xterm a chance */

    if (XGrabPointer (dpy, root, False, MASK, GrabModeSync, GrabModeAsync, 
    		      None, cursor, CurrentTime) != GrabSuccess) {
	fprintf (stderr, "%s:  unable to grab cursor\n", ProgramName);
	Exit (1);
    }

    /* from dsimple.c in xwininfo */
    while (retwin == None || pressed != 0) {
	XEvent event;

	XAllowEvents (dpy, SyncPointer, CurrentTime);
	XWindowEvent (dpy, root, MASK, &event);
	switch (event.type) {
	  case ButtonPress:
	    if (retwin == None) {
		retbutton = event.xbutton.button;
		retwin = ((event.xbutton.subwindow != None) ?
			  event.xbutton.subwindow : root);
	    }
	    pressed++;
	    continue;
	  case ButtonRelease:
	    if (pressed > 0) pressed--;
	    continue;
	}					/* end switch */
    }						/* end for */

    XUngrabPointer (dpy, CurrentTime);
    XFreeCursor (dpy, cursor);
    XSync (dpy, 0);

    return ((button == -1 || retbutton == button) ? retwin : None);
}
Example #25
0
_Delay::_Delay(Widget w):
    widget(w), old_cursor(0)
{
    if (widget == 0)
	return;

#if LOG_DELAY
    std::clog << "Setting " << XtName(widget) << " delay cursor\n";
#endif

    Display *display = XtDisplay(widget);

    if (current_cursor == 0)
    {
	// XC_left_ptr is the default cursor in OSF/Motif.
	// (How do we determine the current cursor? - FIXME)
	current_cursor = XCreateFontCursor(display, XC_left_ptr);
    }

    old_cursor = current_cursor;

    if (XtIsRealized(widget))
    {
	XDefineCursor(display, XtWindow(widget), hourglass_cursor());
	XFlush(display);
    }

    XtAddCallback(widget, XtNdestroyCallback, _Delay::DestroyCB, this);
}
Example #26
0
void
input_show_cursor(bool show)
{
	Cursor cur;
	Pixmap pix;
	XColor black;
	static char cursor_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
	black.red = black.green = black.blue = 0;

	if (show) {
		cur = XCreateFontCursor(x_display, XC_left_ptr);
		XDefineCursor(x_display, x11_active_window, cur);
		XFreeCursor(x_display, cur);

		cursor_state |= (uint8_t)1 << CURSOR_VISIBLE;
	} else {
		pix = XCreateBitmapFromData(x_display, x11_active_window,
			cursor_data, 8, 8);
		cur = XCreatePixmapCursor(x_display, pix, pix, &black, &black,
			0, 0);

		XDefineCursor(x_display, x11_active_window, cur);
		XFreeCursor(x_display, cur);
		XFreePixmap(x_display, pix);

		cursor_state &= ~((uint8_t)1 << CURSOR_VISIBLE);
	}

	XFlush(x_display);
}
Example #27
0
void
wl_help_context(Widget w, XtPointer closure, XtPointer call)
{
	XmAnyCallbackStruct	cbs;
	Cursor			qa;
	XEvent			ev;
	Widget			top;

	USEUP(closure); USEUP(call);

	top = wl_top(w);
	memset((void *)&ev,  '\0', sizeof(ev));
	qa = XCreateFontCursor(XtDisplay(top), XC_question_arrow);
	w  = XmTrackingEvent(top, qa, False, &ev);
	while(w != NULL) {
		if(XtHasCallbacks(w, XmNhelpCallback) != XtCallbackHasSome) {
			w = XtParent(w);
			continue;
		}
		memset((void *)&cbs, '\0', sizeof(cbs));
		cbs.reason = XmCR_HELP;
		cbs.event  = &ev;
		XtCallCallbacks(w, XmNhelpCallback, (XtPointer)&cbs);
		w = NULL;
	}

	/*
	 * XmTrackingEvent() will take care of resetting the cursor
	 */
	XFreeCursor(XtDisplay(top), qa);
}
Example #28
0
static void		cursor(t_env *e)
{
	Cursor	c;
	c = XCreateFontCursor(((t_xvar*)(e->mlx))->display, XC_crosshair);
	XDefineCursor(((t_xvar*)(e->mlx))->display\
			, ((t_xvar*)(e->mlx))->win_list->window, c);
}
Example #29
0
/*! Interpret one line of `[<comand>] <x> <y>'; ignores empy lines and
 * comments. */
static void command(char *line) {
	/* ignore empty lines and comments */
	if (line[0] == '\0' || line[0] == '\n' || line[0] == '#') return;
	int x=0, y=0;
	Bool isMove = False;
	/* line begins with digit; parse "<number> <number>" to x,y */
	if (line[0] >= '0' && line[0] <= '9') {
		sscanf(line,"%d %d",&x,&y);
		isMove = True;
	}
	/* otherwise, ignore leading command and parse x,y */
	else sscanf(line,"%*s %d %d",&x,&y);

	/* interpret command (actually only first character is used),
	 * call appropriate X function */
	if		(line[0] == 'p') XWarpPointer(dpy,None,root,0,0,0,0,sw,sh);
	else if (line[0] == 'b') press(x, True, True); /* press and release */
	else if (line[0] == 'h') press(x, True, False); /* press without release */
	else if (line[0] == 'r') press(x, False, True); /* release without press */
	else if (line[0] == 'm') XWarpPointer(dpy,None,None,0,0,0,0,x,y);
	else if (line[0] == 'c')
		XDefineCursor(dpy,root,XCreateFontCursor(dpy,x));
	else if (line[0] == 'q') running = False;
	else if (line[0] == 'e') running = False;
	else if (line[0] == 's') { sleep(x); usleep(y*1000); }
	else if (isMove == True) XWarpPointer(dpy,None,root,0,0,0,0,x,y);
	else fprintf(stderr, "unable to interpret command '%s'", line);
	XFlush(dpy);
}
Example #30
0
void grab_window_position(int *src_x, int *src_y, int *width, int *height)
{
   	Cursor cursor;		/* cursor to use when selecting */
    Window root;		/* the current root */
    Window retwin = None;	/* the window that got selected */
    int retbutton = -1;		/* button used to select window */
    int pressed = 0;		/* count of number of buttons pressed */

#define MASK (ButtonPressMask | ButtonReleaseMask)

    root = DefaultRootWindow(dpy);
    cursor = XCreateFontCursor(dpy, XC_pirate);
    if (cursor == None) {
		fprintf (stderr, "%s:  unable to create selection cursor\n", "grab_window_position");
		return;
    }

    XSync (dpy, 0);			/* give xterm a chance */

    if (XGrabPointer (dpy, root, False, MASK, GrabModeSync, GrabModeAsync, None, cursor, CurrentTime) != GrabSuccess) {
		fprintf (stderr, "%s:  unable to grab cursor\n", "grab_window_position");
		return;
    }

    /* from dsimple.c in xwininfo */
    while (retwin == None || pressed != 0) {
		XEvent event;

		XAllowEvents (dpy, SyncPointer, CurrentTime);
		XWindowEvent (dpy, root, MASK, &event);
		switch (event.type) {
	  		case ButtonPress:
	    		if (retwin == None) {
					retbutton = event.xbutton.button;
					retwin = ((event.xbutton.subwindow != None) ? event.xbutton.subwindow : root);
	    		}
	    		pressed++;
	    		continue;
	  		case ButtonRelease:
	    		if (pressed > 0) pressed--;
	    		continue;
		}					/* end switch */
    }						/* end for */
    XUngrabPointer (dpy, CurrentTime);
    XFreeCursor (dpy, cursor);
    XSync (dpy, 0);

	if (retwin != None) {
		XWindowAttributes attr;
		XGetWindowAttributes(dpy, retwin, &attr);
		*src_x = attr.x;
		*src_y = attr.y;
		*width = attr.width;
		*height = attr.height;
	}
	else {
		*src_x = *src_y = *width = *height = 0;
	}
}