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); }
void Edit::on_hover() { if(Mouse::is_over(get_position(), get_size())) { // change mouse cursor to I-beam WINDOW * window = WINDOW::get_active(); if(window != nullptr) { #ifdef __windows__ HCURSOR ibeam = LoadCursor(nullptr, IDC_IBEAM); SetClassLong(window->get_handle(), GCL_HCURSOR, (DWORD)ibeam); // DWORD = unsigned long #endif #ifdef __gnu_linux__ Cursor cursor = XCreateFontCursor(window->get_display(), XC_xterm); XDefineCursor(window->get_display(), window->get_handle(), cursor); XFreeCursor(window->get_display(), cursor); #endif } } else { // revert back to original mouse cursor WINDOW * window = WINDOW::get_active(); if(window != nullptr) { #ifdef __windows__ HCURSOR arrow = LoadCursor(nullptr, IDC_ARROW); SetClassLong(window->get_handle(), GCL_HCURSOR, (DWORD)arrow); #endif #ifdef __gnu_linux__ Cursor cursor = XCreateFontCursor(window->get_display(), XC_left_ptr); XDefineCursor(window->get_display(), window->get_handle(), cursor); XFreeCursor(window->get_display(), cursor); #endif } } }
ResizeScreen::~ResizeScreen () { Display *dpy = screen->dpy (); if (logic.leftCursor) XFreeCursor (dpy, logic.leftCursor); if (logic.rightCursor) XFreeCursor (dpy, logic.rightCursor); if (logic.upCursor) XFreeCursor (dpy, logic.upCursor); if (logic.downCursor) XFreeCursor (dpy, logic.downCursor); if (logic.middleCursor) XFreeCursor (dpy, logic.middleCursor); if (logic.upLeftCursor) XFreeCursor (dpy, logic.upLeftCursor); if (logic.upRightCursor) XFreeCursor (dpy, logic.upRightCursor); if (logic.downLeftCursor) XFreeCursor (dpy, logic.downLeftCursor); if (logic.downRightCursor) XFreeCursor (dpy, logic.downRightCursor); delete logic.mScreen; delete logic.cScreen; delete logic.gScreen; delete logic.resizeInformationAtom; }
/* Apply the cursor to the Chromium OS X11 server. * Adapted from the XcursorImageLoadCursor implementation in libXcursor, * copyright 2002 Keith Packard. */ static void apply_cursor(Display* d, Window w, XFixesCursorImage *image) { static Cursor cur_cursor = 0; XImage ximage; Pixmap pixmap; Picture picture; GC gc; XRenderPictFormat *format; Cursor cursor; /* Unset the current cursor if no image is passed. */ if (!image) { if (cur_cursor) { XUndefineCursor(d, w); XFreeCursor(d, cur_cursor); cur_cursor = 0; } return; } ximage.width = image->width; ximage.height = image->height; ximage.xoffset = 0; ximage.format = ZPixmap; ximage.data = (char *) image->pixels; ximage.byte_order = LSBFirst; ximage.bitmap_unit = 32; ximage.bitmap_bit_order = ximage.byte_order; ximage.bitmap_pad = 32; ximage.depth = 32; ximage.bits_per_pixel = 32; ximage.bytes_per_line = image->width * 4; ximage.red_mask = 0xff0000; ximage.green_mask = 0x00ff00; ximage.blue_mask = 0x0000ff; ximage.obdata = 0; if (!XInitImage(&ximage)) { puts("failed to init image"); return; } pixmap = XCreatePixmap(d, w, image->width, image->height, 32); gc = XCreateGC(d, pixmap, 0, 0); XPutImage(d, pixmap, gc, &ximage, 0, 0, 0, 0, image->width, image->height); XFreeGC(d, gc); format = XRenderFindStandardFormat(d, PictStandardARGB32); picture = XRenderCreatePicture(d, pixmap, format, 0, 0); XFreePixmap(d, pixmap); cursor = XRenderCreateCursor(d, picture, image->xhot, image->yhot); XRenderFreePicture(d, picture); XDefineCursor(d, w, cursor); XFlush(d); if (cur_cursor) XFreeCursor(d, cur_cursor); cur_cursor = cursor; }
static void cleanup(void) { close(STDIN_FILENO); while(stack) { resize(stack, True); unmanage(stack); } XUngrabKey(dpy, AnyKey, AnyModifier, root); XFreeCursor(dpy, cursor[CurNormal]); XFreeCursor(dpy, cursor[CurResize]); XFreeCursor(dpy, cursor[CurMove]); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); }
void X11Window::terminate() { if(m_cursor != None) { XUndefineCursor(m_display, m_window); m_cursor = None; } if(m_hiddenCursor) { XFreeCursor(m_display, m_hiddenCursor); m_hiddenCursor = 0; } for(Cursor cursor : m_cursors) XFreeCursor(m_display, cursor); m_cursors.clear(); if(m_window) { XDestroyWindow(m_display, m_window); m_window = 0; } if(m_colormap) { XFreeColormap(m_display, m_colormap); m_colormap = 0; } internalDestroyGLContext(); if(m_visual) { XFree(m_visual); m_visual = 0; } if(m_xic) { XDestroyIC(m_xic); m_xic = 0; } if(m_xim) { XCloseIM(m_xim); m_xim = 0; } if(m_display) { XCloseDisplay(m_display); m_display = 0; } m_visible = false; }
void win_close(win_t *win) { if (!win || !win->xwin) return; XFreeCursor(win->env.dpy, carrow); XFreeCursor(win->env.dpy, cnone); XFreeCursor(win->env.dpy, chand); XFreeCursor(win->env.dpy, cwatch); XFreeGC(win->env.dpy, gc); XDestroyWindow(win->env.dpy, win->xwin); XCloseDisplay(win->env.dpy); }
int xlib_free() { Target *trg; int i; for (i = 0; i < show->ntargets; i++) { trg = &show->target[i]; cairo_destroy(trg->ctx); XDestroyWindow(dpy, trg->win); } free(show->target); XFreeCursor(dpy, invisible_cursor); XFreeCursor(dpy, crosshair_cursor); XCloseDisplay(dpy); return 0; }
void showCursor(Display *dpy, Window win, int show) { if(!show) { Pixmap bm_no; Colormap cmap; Cursor no_ptr; XColor black, dummy; char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; cmap = DefaultColormap(dpy, DefaultScreen(dpy)); XAllocNamedColor(dpy, cmap, "black", &black, &dummy); bm_no = XCreateBitmapFromData(dpy, win, bm_no_data, 8, 8); no_ptr = XCreatePixmapCursor(dpy, bm_no, bm_no, &black, &black, 0, 0); XDefineCursor(dpy, win, no_ptr); XFreeCursor(dpy, no_ptr); XFreePixmap(dpy, bm_no); XFreeColors(dpy, cmap, &black.pixel, 1, 0); } else { XDefineCursor(dpy, win, 0); } }
Bool xnestUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen)); free(xnestGetCursorPriv(pCursor, pScreen)); return True; }
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); }
static void free_eyes(Display * display, EyeScrInfo * ep) { if (ep->flyGC != None) { XFreeGC(display, ep->flyGC); ep->flyGC = None; } if (ep->eyeGC != None) { XFreeGC(display, ep->eyeGC); ep->eyeGC = None; } if (ep->flypix != None) { XFreePixmap(display, ep->flypix); ep->flypix = None; } #ifdef XBM_GRELB if (ep->fly2pix != None) { XFreePixmap(display, ep->fly2pix); ep->fly2pix = None; } #endif freePairsOfEyes(display, ep); if (ep->cursor != None) { XFreeCursor(display, ep->cursor); ep->cursor = None; } }
void drw_cur_free(Drw *drw, Cur *cursor) { if(!drw || !cursor) return; XFreeCursor(drw->dpy, cursor->cursor); free(cursor); }
void wsDestroyWindow(wsTWindow *win) { int l; l = wsSearch(win->WindowID); wsWindowList[l] = NULL; if (win->wsCursor != None) { XFreeCursor(wsDisplay, win->wsCursor); win->wsCursor = None; } XFreeGC(wsDisplay, win->wGC); XUnmapWindow(wsDisplay, win->WindowID); wsDestroyImage(win); XDestroyWindow(wsDisplay, win->WindowID); #if 0 win->ReDraw = NULL; win->ReSize = NULL; win->Idle = NULL; win->MouseHandler = NULL; win->KeyHandler = NULL; win->Visible = 0; win->Focused = 0; win->Mapped = 0; win->Rolled = 0; #endif }
win::~win() { if (icon) XFreePixmap(disp, icon); if (w) XDestroyWindow(disp,w); if (null_cursor) XFreeCursor(disp, null_cursor); if (null_bm) XFreePixmap(disp, null_bm); }
bool CWinSystemX11::DestroyWindow() { if (!m_mainWindow) return true; if (m_invisibleCursor) { XUndefineCursor(m_dpy, m_mainWindow); XFreeCursor(m_dpy, m_invisibleCursor); m_invisibleCursor = 0; } CWinEventsX11Imp::Quit(); XUnmapWindow(m_dpy, m_mainWindow); XDestroyWindow(m_dpy, m_glWindow); XDestroyWindow(m_dpy, m_mainWindow); m_glWindow = 0; m_mainWindow = 0; if (m_icon) XFreePixmap(m_dpy, m_icon); return true; }
void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) { xfInfo* xfi = ((xfContext*) context)->xfi; if (((xfPointer*) pointer)->cursor != 0) XFreeCursor(xfi->display, ((xfPointer*) pointer)->cursor); }
int _glfwPlatformTerminate(void) { if (_glfwLibrary.X11.cursor) { XFreeCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.cursor); _glfwLibrary.X11.cursor = (Cursor) 0; } _glfwTerminateGammaRamp(); terminateDisplay(); _glfwTerminateJoysticks(); // Unload libGL.so if necessary #ifdef _GLFW_DLOPEN_LIBGL if (_glfwLibrary.GLX.libGL != NULL) { dlclose(_glfwLibrary.GLX.libGL); _glfwLibrary.GLX.libGL = NULL; } #endif // Free clipboard memory if (_glfwLibrary.X11.selection.string) free(_glfwLibrary.X11.selection.string); return GL_TRUE; }
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); }
void wsWindowDestroy(wsWindow *win) { int l; l = wsWindowListSearch(win->WindowID); if (l != -1) wsWindowList[l] = NULL; win->DrawHandler = NULL; win->MouseHandler = NULL; win->KeyHandler = NULL; win->DNDHandler = NULL; if (win->wsCursor != None) { XFreeCursor(wsDisplay, win->wsCursor); win->wsCursor = None; } XFreeGC(wsDisplay, win->wGC); XUnmapWindow(wsDisplay, win->WindowID); wsImageDestroy(win); XDestroyWindow(wsDisplay, win->WindowID); #if 0 win->Visible = wsNo; win->Focused = wsNo; win->Mapped = wsNo; win->Rolled = wsNo; #endif }
void xf_pointer_free(rdpUpdate* update, xfPointer* pointer) { xfInfo* xfi = GET_XFI(update); if (pointer->cursor != 0) XFreeCursor(xfi->display, pointer->cursor); }
/* _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; }
static void _eiw_render_loop(Window win, EImage * im, EiwData * d) { int w, h; XRenderPictFormat *pictfmt; Pixmap pmap; Picture pict; EImageGetSize(im, &w, &h); pictfmt = XRenderFindStandardFormat(disp, PictStandardARGB32); pmap = XCreatePixmap(disp, WinGetXwin(VROOT), w, h, 32); imlib_context_set_image(im); imlib_context_set_drawable(pmap); imlib_render_image_on_drawable(0, 0); pict = XRenderCreatePicture(disp, pmap, pictfmt, 0, 0); XFreePixmap(disp, pmap); if (d->curs != None) XFreeCursor(disp, d->curs); d->curs = XRenderCreateCursor(disp, pict, w / 2, h / 2); XRenderFreePicture(disp, pict); XDefineCursor(disp, win, d->curs); }
void xdk_display_free_cursor(XdkDisplay * self, Cursor cursor) { g_return_if_fail(self); g_return_if_fail(None != cursor); XFreeCursor(self->priv->peer, cursor); }
/** * @brief Show the cursor on a window of type Ecore_X_Window. * @param win The window for which the cursor will be showed. * @param show Enables the show of the cursor on the window if equals EINA_TRUE, disables if equals EINA_FALSE. */ EAPI void ecore_x_window_cursor_show(Ecore_X_Window win, Eina_Bool show) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (win == 0) win = DefaultRootWindow(_ecore_x_disp); if (!show) { Cursor c; XColor cl; Pixmap p, m; GC gc; XGCValues gcv; p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1); m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1); gc = XCreateGC(_ecore_x_disp, m, 0, &gcv); XSetForeground(_ecore_x_disp, gc, 0); XDrawPoint(_ecore_x_disp, m, gc, 0, 0); XFreeGC(_ecore_x_disp, gc); c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0); XDefineCursor(_ecore_x_disp, win, c); XFreeCursor(_ecore_x_disp, c); XFreePixmap(_ecore_x_disp, p); XFreePixmap(_ecore_x_disp, m); } else XDefineCursor(_ecore_x_disp, win, 0); }
void _glfwPlatformTerminate(void) { if (_glfw.x11.cursor) { XFreeCursor(_glfw.x11.display, _glfw.x11.cursor); _glfw.x11.cursor = (Cursor) 0; } free(_glfw.x11.clipboardString); if (_glfw.x11.im) { XCloseIM(_glfw.x11.im); _glfw.x11.im = NULL; } _glfwTerminateJoysticks(); _glfwTerminateContextAPI(); if (_glfw.x11.display) { XCloseDisplay(_glfw.x11.display); _glfw.x11.display = NULL; } }
void _xsetcursor(Cursor *c) { XColor fg, bg; XCursor xc; Pixmap xsrc, xmask; int i; uchar src[2*16], mask[2*16]; if(c == nil){ xcursorarrow(); return; } for(i=0; i<2*16; i++){ src[i] = revbyte(c->set[i]); mask[i] = revbyte(c->set[i] | c->clr[i]); } fg = _x.map[0]; bg = _x.map[255]; xsrc = XCreateBitmapFromData(_x.display, _x.drawable, (char*)src, 16, 16); xmask = XCreateBitmapFromData(_x.display, _x.drawable, (char*)mask, 16, 16); xc = XCreatePixmapCursor(_x.display, xsrc, xmask, &fg, &bg, -c->offset.x, -c->offset.y); if(xc != 0) { XDefineCursor(_x.display, _x.drawable, xc); if(_x.cursor != 0) XFreeCursor(_x.display, _x.cursor); _x.cursor = xc; } XFreePixmap(_x.display, xsrc); XFreePixmap(_x.display, xmask); XFlush(_x.display); }
void WMScreenAbortDrag(W_Screen *screen) { if (!screen || !screen->dragInfo.sourceInfo) return; W_DragSourceInfo *source = screen->dragInfo.sourceInfo; W_DragSourceStopTimer(); // inform the other client if (source->destinationWindow) W_SendDnDClientMessage(screen->display, source->destinationWindow, screen->xdndLeaveAtom, WMViewXID(source->sourceView), 0, 0, 0, 0); WMDeleteSelectionHandler(source->sourceView, screen->xdndSelectionAtom, CurrentTime); wfree(source->selectionProcs); if (source->sourceView->dragSourceProcs->endedDrag) source->sourceView->dragSourceProcs->endedDrag(source->sourceView, &source->imageLocation, False); if (source->icon) XDestroyWindow(screen->display, source->icon); if (source->dragCursor != None) { XDefineCursor(screen->display, screen->rootWin, screen->defaultCursor); XFreeCursor(screen->display, source->dragCursor); } wfree(source); screen->dragInfo.sourceInfo = NULL; }
void _glfwPlatformTerminate(void) { if (_glfw.x11.cursor) { XFreeCursor(_glfw.x11.display, _glfw.x11.cursor); _glfw.x11.cursor = (Cursor) 0; } free(_glfw.x11.clipboardString); if (_glfw.x11.im) { XCloseIM(_glfw.x11.im); _glfw.x11.im = NULL; } if (_glfw.x11.display) { XCloseDisplay(_glfw.x11.display); _glfw.x11.display = NULL; } // NOTE: This needs to be done after XCloseDisplay, as libGL registers // cleanup callbacks that get called by it _glfwTerminateContextAPI(); _glfwTerminateJoysticks(); }
gboolean cb_hide_pointer(GtkWidget *widget, GdkEvent *event, gpointer data) { static Cursor cursor = 0; XColor colour; Pixmap cursorPixmap; colour.pixel = WhitePixel(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), DefaultScreen(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window))); XQueryColor(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), DefaultColormap(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), DefaultScreen(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window))), &colour); if(cursor) { XFreeCursor(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), cursor); } cursorPixmap = XCreatePixmap(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), GDK_WINDOW_XWINDOW(GTK_WIDGET(widget)->window), 1, 1, 1); cursor = XCreatePixmapCursor(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), cursorPixmap, cursorPixmap, &colour, &colour, 0, 0); if(cursorPixmap) { XFreePixmap(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), cursorPixmap); } XDefineCursor(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), GDK_WINDOW_XWINDOW(GTK_WIDGET(widget)->window), cursor); return TRUE; }