{"id":20950439,"url":"https://github.com/colleagueriley/mouse-and-window-icons","last_synced_at":"2026-06-29T18:32:04.851Z","repository":{"id":256643502,"uuid":"854307048","full_name":"ColleagueRiley/mouse-and-window-icons","owner":"ColleagueRiley","description":"A tutorial that explains how to set mouse and window icons for X11, WinAPI and Cocoa.","archived":false,"fork":false,"pushed_at":"2024-09-13T20:43:02.000Z","size":168,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T22:43:52.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ColleagueRiley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T23:14:04.000Z","updated_at":"2024-12-01T09:47:54.000Z","dependencies_parsed_at":"2024-09-14T11:44:51.325Z","dependency_job_id":null,"html_url":"https://github.com/ColleagueRiley/mouse-and-window-icons","commit_stats":null,"previous_names":["colleagueriley/mouse-and-window-icons-wip","colleagueriley/mouse-and-window-icons"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ColleagueRiley/mouse-and-window-icons","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColleagueRiley%2Fmouse-and-window-icons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColleagueRiley%2Fmouse-and-window-icons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColleagueRiley%2Fmouse-and-window-icons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColleagueRiley%2Fmouse-and-window-icons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ColleagueRiley","download_url":"https://codeload.github.com/ColleagueRiley/mouse-and-window-icons/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColleagueRiley%2Fmouse-and-window-icons/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34939227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T00:48:34.402Z","updated_at":"2026-06-29T18:32:04.816Z","avatar_url":"https://github.com/ColleagueRiley.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RGFW Under the Hood: Mouse and Window Icons\n## Introduction\nChanging the mouse and window icons can be annoying with low-level APIs. That's because you must load data structures specific to the API and load the bitmap using a format the API supports. It can also be unclear which functions must be used to update the icon. This tutorial aims to streamline the process and explain how to load mouse and window icons. \n\nThis tutorial is based on my experience in making RGFW and its source code. The repository can be found [here](https://github.com/ColleagueRiley/RGFW), if you would like to reference it.\n\n## Overview\n1) window icons\n2) mouse image icons\n3) default mouse icons\n\n## Window icons\n\n### X11\nFirst, allocate the array, it will hold our icon data converted for X11's BGR format.\n\nThe format will be in ints, which should be 32 bits on Linux. \nThe first two elements will be used for the size. So the array length will be the width * height + 2.\n\n```c\nint longCount = 2 + width * height;\n\nunsigned long* X11Icon = (unsigned long*) malloc(longCount * sizeof(unsigned long));\nunsigned long* target = X11Icon;\n\n*target++ = width;\n*target++ = height;\n```\n\n\nNow we can convert the icon to X11's format. This means manually casting the icon array into a 32-bit int in the BGRA format.\n\n```c\nunsigned int i;\n\nfor (i = 0; i \u003c width * height; i++) {\n    *target++ = ((icon[i * 4 + 2])) // b\n                ((icon[i * 4 + 1]) \u003c\u003c 8) // g\n                ((icon[i * 4 + 0]) \u003c\u003c 16) // r\n                ((icon[i * 4 + 3]) \u003c\u003c 24); // a \n}\n```\n\nNext, we'll load the X11 atom, `NET_WM_ICON`, using [`XInternAtom`](https://www.x.org/releases/X11R7.5/doc/man/man3/XInternAtom.3.html). This atom is used for the Window's Window Manager icon property. \n\nThen we'll use the [`XChangeProperty`](https://linux.die.net/man/3/xchangeproperty) function to change the icon property to the icon data.\n\n```c\nconst Atom NET_WM_ICON = XInternAtom((Display*) display, \"_NET_WM_ICON\", False);\n\nXChangeProperty((Display*) display, (Window) window,\n    NET_WM_ICON,\n    6, 32,\n    PropModeReplace,\n    (unsigned char*) X11Icon,\n    longCount);\n```\n\nUse [`XFlush`](https://www.x.org/releases/X11R7.5/doc/man/man3/XSync.3.html) to update the X11 server on the change.\n\n```c\nfree(X11Icon);\nXFlush((Display*) display);\n```\n\n### win32\n\nI'll start by creating a `loadHandleImage` function. This function will be used for mouse and window icons to load a bitmap image into a win32 icon handle.\n\n```c\nHICON loadHandleImage(unsigned char* src, unsigned int width, unsigned int height, BOOL icon) {\n``` \n\nWe'll start by creating a [`BITMAPV5HEADER`](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv5header) structure with the proper format to match how our data is stored.\n\n```c\n    BITMAPV5HEADER bi; \n    ZeroMemory(\u0026bi, sizeof(bi));\n    bi.bV5Size = sizeof(bi);\n    bi.bV5Width = width;\n    bi.bV5Height = -((LONG) height);\n    bi.bV5Planes = 1;\n    bi.bV5BitCount = 32;\n    bi.bV5Compression = BI_BITFIELDS;\n    bi.bV5RedMask = 0x00ff0000;\n    bi.bV5GreenMask = 0x0000ff00;\n    bi.bV5BlueMask = 0x000000ff;\n    bi.bV5AlphaMask = 0xff000000;\n```\n\nNext, we'll create a color section for the icon.\n\nFirst get the Drawing Context with [`GetDC`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc), next create the section with  [`CreateDIBSection`](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection).\n\nMake sure to release the Drawing Context with [`ReleaseDC`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-releasedc).\n\n```c\n    unsigned char* target = NULL;\n      \n    HDC dc = GetDC(NULL);\n    HBITMAP color = CreateDIBSection(dc,\n        (BITMAPINFO*) \u0026bi,\n        DIB_RGB_COLORS,\n        (void**) \u0026target,\n        NULL,\n        (DWORD) 0);\n    ReleaseDC(NULL, dc);\n```\n\nThen a win32 bitmap can be created with [`CreateBitmap`](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmap)\n\n```c\n    HBITMAP mask = CreateBitmap(width, height, 1, 1, NULL);\n```\n\nNow we'll load our image data into the bitmap.\n\n```c\n    unsigned char* source = src; \n    unsigned int i;\n    for (i = 0; i \u003c width * height; i++) {\n        target[0] = source[2];\n        target[1] = source[1];\n        target[2] = source[0];\n        target[3] = source[3];\n        target += 4;\n        source += 4;\n    }\n```\n\nNow we can create a [`ICONINFO`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-iconinfo) structure for updating the window icon.\n\n```c\n    ICONINFO ii;\n    ZeroMemory(\u0026ii, sizeof(ii));\n    ii.fIcon = icon;\n    ii.xHotspot = 0;\n    ii.yHotspot = 0;\n    ii.hbmMask = mask;\n    ii.hbmColor = color;\n```\n\nThen we'll create the icon handle with [`CreateIconIndirect`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createiconindirect). \n\n```c\n    HICON handle = CreateIconIndirect(\u0026ii);\n```\n\nFinally, we can free the object color and mask data and return the icon handle.\n\n[`DeleteObject`](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-deleteobject)\n\n```c\n    DeleteObject(color);\n    DeleteObject(mask);\n\n    return handle;\n}\n```\n\n#### part 2\n\nNow we can use our function to create an icon handle  \n\n```c\nHICON handle = loadHandleImage(buffer, width, height, TRUE);\n```\n\nThen we'll set the handle as the window icon via [`SetClassLongPtrA`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setclasslongptra)\n\n```c\nSetClassLongPtrA(hwnd, GCLP_HICON, (LPARAM) handle);\n```\n\nMake sure to free the icon handle now that we're done with it using [`DestroyIcon`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroyicon).\n\n```c\nDestroyIcon(handle);\n```\n\n### cocoa\n\nMake a bitmap representation with [`initWithBitmapData`](https://developer.apple.com/documentation/coreimage/ciimage/1437857-initwithbitmapdata) then copy the icon data to it using [`bitmapData`](https://developer.apple.com/documentation/appkit/nsbitmapimagerep/1395421-bitmapdata).\n\nI will also be using the NSString \"NSCalibratedRGBColorSpace\" for the colorSpaceName. This means it must be converted from a c-string.\n\n\n```c\nfunc = sel_registerName(\"initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:\");\n\nchar* NSCalibratedRGBColorSpace = ((id(*)(id, SEL, const char*))objc_msgSend) ((id)objc_getClass(\"NSString\"), sel_registerName(\"stringWithUTF8String:\"), \"NSCalibratedRGBColorSpace\"); \n\nvoid* representation = ((id(*)(id, SEL, unsigned char**, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, const char*, NSBitmapFormat, NSInteger, NSInteger))objc_msgSend)\n        (NSAlloc((id)objc_getClass(\"NSBitmapImageRep\")), func, NULL, width, height, 8, 4, true, false, NSCalibratedRGBColorSpace, 1 \u003c\u003c 1, width * channels, 8 * channels);\n```\n\nNext, create the image with the matching size via [`NSImage_init`](https://developer.apple.com/documentation/appkit/nsimage/1519860-init) and add the representation using [`addRepresentation`](https://developer.apple.com/documentation/appkit/nsimage/1519911-addrepresentation).\n\n```c\nvoid* dock_image = ((id(*)(id, SEL, NSSize))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSImage\")), sel_registerName(\"initWithSize:\"), (NSSize){width, height});\n\tobjc_msgSend_void_id(dock_image, sel_registerName(\"addRepresentation:\"), representation);\n```\n\nFinally, set the dock image to it using [`setApplicationIconImage`](https://developer.apple.com/documentation/appkit/nsapplication/1428744-applicationiconimage).\n\n```c\nobjc_msgSend_void_id(NSApp, sel_registerName(\"setApplicationIconImage:\"), dock_image);\n```\n\nFree the leftover data with `NSRelease`.\n```c\nNSRelease(dock_image);\nNSRelease(representation);\n```\n\n## mouse icon image\n\n### X11\nFirst, create an X11 cursor image using [`XcursorImageCreate`](https://linux.die.net/man/3/xcursorimagecreate).\n```c\nXcursorImage* native = XcursorImageCreate(width, height);\nnative-\u003exhot = 0;\nnative-\u003eyhot = 0;\n```\n\nThen we'll make a pointer to the pixel data and a pointer to the XCursor image's pointer data.\n\n```c\nunsigned char* source = (unsigned char*) image;\nXcursorPixel* target = native-\u003epixels;\n```\n\nNow we can convert the pixel data to the X11 format.\n\nThe X11 format uses BGRA with ints, we must reorganize the array, apply the opacity, and cast the data type manually.\n\n```c\nunsigned int i;\nfor (i = 0; i \u003c width * height; i++, target++, source += 4) {\n    unsigned char alpha = source[3];\n\n    *target = (((source[2] * alpha) / 255)) | // b \n                (((source[1] * alpha) / 255) \u003c\u003c 8)  | // g \n                ((source[0] * alpha) / 255) \u003c\u003c 16)) | // r \n                (alpha \u003c\u003c 24); // r\n}\n```\n\nNext, we'll create a cursor with the cursor image using [`XcursorImageLoadCursor`](https://man.archlinux.org/man/XcursorImageLoadCursor.3.en).\n\n```c\nCursor cursor = XcursorImageLoadCursor((Display*) display, native);\n```\n\nThen [`XDefineCursor`](https://www.x.org/releases/X11R7.5/doc/man/man3/XDefineCursor.3.html) sets the new cursor.\n\n```c\nXDefineCursor((Display*) display, (Window) window, (Cursor) cursor);\n```\n\nFinally, we can free the cursor and cursor image with [`XFreeCursor`](https://linux.die.net/man/3/xfreecursor) and [`XcursorImageDestroy`](https://linux.die.net/man/3/xcursorimagedestroy).\n\n```c\nXFreeCursor((Display*) display, (Cursor) cursor);\nXcursorImageDestroy(native);\n```\n\n### win32\n\nWe'll use the function I defined earlier to create a cursor icon handle. \n\n```c\nHCURSOR cursor = (HCURSOR) loadHandleImage(image, width, height, FALSE);\n```\n\nThen we can use  [`SetClassLongPtrA`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setclasslongptra) and [`SetCursor`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcursor) to change the cursor. \n\n```c\nSetClassLongPtrA(hwnd, GCLP_HCURSOR, (LPARAM) cursor);\nSetCursor(cursor);\n```\n\nFree the cursor via [`DestroyCursor`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroycursor).\n\n```c\nDestroyCursor(cursor);\n```\n\n### cocoa\n\nMake a bitmap representation with initWithBitmapData then copy the icon data to it using bitmapData.\n\n```c\nrepresentation = ((id(*)(id, SEL, unsigned char**, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, const char*, NSBitmapFormat, NSInteger, NSInteger))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSBitmapImageRep\")), func, NULL, width, height, 8, channels, true, false, NSCalibratedRGBColorSpace, 1 \u003c\u003c 1, width * channels, 8 * channels);\n\n\tmemcpy(((unsigned char* (*)(id, SEL))objc_msgSend)\n\t\t\t(representation, sel_registerName(\"bitmapData\")), \n\t\t\ticon, width * height * channels);\n```\n\nNext, create the image with the matching size via [`NSImage_init`](https://developer.apple.com/documentation/appkit/nsimage/1519860-init) and \nAdd the representation with [`addRepresentation`](https://developer.apple.com/documentation/appkit/nsimage/1519911-addrepresentation).\n\n```c\nvoid* cursor_image = ((id(*)(id, SEL, NSSize))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSImage\")), sel_registerName(\"initWithSize:\"), (NSSize){width, height});\n\tobjc_msgSend_void_id(cursor_image, sel_registerName(\"addRepresentation:\"), representation);\n\n\n```\n\nFinally, create the cursor icon using  [`initWithImage`](https://developer.apple.com/documentation/uikit/uiimageview/1621062-initwithimage) and set the cursor using [`set`](https://developer.apple.com/documentation/appkit/nscursor/1526148-set).\n\n```c\nvoid* cursor = ((id(*)(id, SEL, id, NSPoint))objc_msgSend)\n\t\t\t\t\t\t(NSAlloc(objc_getClass(\"NSCursor\")), sel_registerName(\"initWithImage:hotSpot:\"), \n\t\t\t\t\t\t cursor_image, (NSPoint){0.0, 0.0});\n\nobjc_msgSend_void(cursor, sel_registerName(\"set\"));\n```\n\nMake sure to free the leftover data with `NSRelease`\n\n```c\nNSRelease(cursor_image);\nNSRelease(representation);\n```\n\n## standard mouse icons\n### X11\n\nFirst, create a cursor for the standard cursor you want to use with [`XCreateFontCursor`](https://www.x.org/releases/X11R7.5/doc/man/man3/XCreateFontCursor.3.html).\n\nChange `mouse` to be an actual cursor macro (they can be found in `/usr/include/X11/cursorfont.h`)\n\n```c\nCursor cursor = XCreateFontCursor((Display*) display, mouse);\n```\n\nThen you can update the cursor with [`XDefineCursor`](https://www.x.org/releases/X11R7.5/doc/man/man3/XDefineCursor.3.html).\n\n```c\nXDefineCursor((Display*) display, (Window) window, (Cursor) cursor);\n```\n\nFree the cursor data with [`XFreeCursor`](https://tronche.com/gui/x/xlib/pixmap-and-cursor/XFreeCursor.html).\n\n```c\nXFreeCursor((Display*) display, (Cursor) cursor);\n```\n\n### win32\n\nFirst, create a cursor for the standard cursor you want to use with [`MAKEINTRESOURCEA`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makeintresourcea)\n\n```c\nchar* icon = MAKEINTRESOURCEA(mouse);\n```\n\nThen you can use  [`LoadCursorA`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadcursora) to load the cursor.\n\nThen use [`SetClassLongPtrA`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setclasslongptra) and [`SetCursor`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcursor) to update the current cursor.\n\n```c\nSetClassLongPtrA(hwnd, GCLP_HCURSOR, (LPARAM) LoadCursorA(NULL, icon));\nSetCursor(LoadCursorA(NULL, icon));\n```\n\n### cocoa\n\nFirst, find the cursor object you would like to use.\n\nFor example, [`arrowCursor`](https://developer.apple.com/documentation/appkit/nscursor/1527160-arrowcursor?changes=_1\u0026language=objc)\n\n```c \nvoid* mouse = objc_msgSend_id(objc_getClass(\"NSCursor\"), sel_registerName(\"arrowCursor\"));\n```\n\nThen you can use [`set`](https://developer.apple.com/documentation/appkit/nscursor/1526148-set) to set it as the current cursor.\n\n```c\nobjc_msgSend_void(mouse, sel_registerName(\"set\"));\n```\n\n\n## full examples\n\n### x11\n```c\n// this can be compiled with:\n// gcc x11.c -lX11 -lXcursor \n\n#include \u003cX11/Xlib.h\u003e\n#include \u003cX11/Xcursor/Xcursor.h\u003e\n#include \u003cX11/cursorfont.h\u003e\n\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n\nunsigned char icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};\n\nint main(void) {\n \n    Display* display = XOpenDisplay(NULL); \n    Window window = XCreateSimpleWindow(display, RootWindow(display, DefaultScreen(display)), 10, 10, 200, 200, 1,\n                                 BlackPixel(display, DefaultScreen(display)), WhitePixel(display, DefaultScreen(display)));\n    \n\tXSelectInput(display, window, ExposureMask | KeyPressMask | ButtonPressMask);\n    XMapWindow(display, window);\n\n\t// window icon\n\tint longCount = 2 + 3 * 3;\n\n\tunsigned long* X11Icon = (unsigned long*) malloc(longCount * sizeof(unsigned long));\n\tunsigned long* target = X11Icon;\n\n\t*target++ = 3;\n\t*target++ = 3;\n\n\tunsigned int i;\n\n\tfor (i = 0; i \u003c 3 * 3; i++) {\n\t\t*target++ = ((icon[i * 4 + 2])) | // g\n\t\t\t((icon[i * 4 + 1]) \u003c\u003c 8) | // b\n\t\t\t((icon[i * 4 + 0]) \u003c\u003c 16) | // r \n\t\t\t((icon[i * 4 + 3]) \u003c\u003c 24); // a\n\t}\n\n\tconst Atom NET_WM_ICON = XInternAtom((Display*) display, \"_NET_WM_ICON\", False);\n\n\tXChangeProperty((Display*) display, (Window) window,\n\t\tNET_WM_ICON,\n\t\t6, 32,\n\t\tPropModeReplace,\n\t\t(unsigned char*) X11Icon,\n\t\tlongCount);\n\n\tfree(X11Icon);\n\tXFlush((Display*) display);\n\n\t// mouse icon image\n\tXcursorImage* native = XcursorImageCreate(3, 3);\n\tnative-\u003exhot = 0;\n\tnative-\u003eyhot = 0;\n\n\tunsigned char* source = (unsigned char*) icon;\n\tXcursorPixel* icon_target = native-\u003epixels;\n\n\tfor (i = 0; i \u003c 3 * 3; i++, icon_target++, source += 4) {\n\t\tunsigned char alpha = 0xFF;\n\t\talpha = source[3];\n\n\t\t*icon_target = (alpha \u003c\u003c 24) | (((source[0] * alpha) / 255) \u003c\u003c 16) | (((source[1] * alpha) / 255) \u003c\u003c 8) | (((source[2] * alpha) / 255) \u003c\u003c 0);\n\t}\n\n\tCursor cursor = XcursorImageLoadCursor((Display*) display, native);\n\n\tXDefineCursor((Display*) display, (Window) window, (Cursor) cursor);\n\n\tXFreeCursor((Display*) display, (Cursor) cursor);\n\tXcursorImageDestroy(native);\n\n\n\t\n\n\tXEvent event;\n    \n\tfor (;;) {\n        XNextEvent(display, \u0026event);\n\t\t\n\t\tif (event.type == ButtonPress) {\n\t\t\tCursor cursor = XCreateFontCursor((Display*) display, XC_watch);\n\t\t\tXDefineCursor((Display*) display, (Window) window, (Cursor) cursor);\n\t\t\tXFreeCursor((Display*) display, (Cursor) cursor);\n\t\t}\n        if (event.type == KeyPress)\n            break;\n    }\n \n    XCloseDisplay(display);\n }\n```\n\n### winapi\n```c\n// This can be compiled with \n// gcc win32.c -lgdi32\n\n#include \u003cwindows.h\u003e\n\nunsigned char icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};\n\n\nHICON loadHandleImage(unsigned char* src, unsigned int width, unsigned int height, BOOL icon) {\n    BITMAPV5HEADER bi; \n    ZeroMemory(\u0026bi, sizeof(bi));\n    bi.bV5Size = sizeof(bi);\n    bi.bV5Width = width;\n    bi.bV5Height = -((LONG) height);\n    bi.bV5Planes = 1;\n    bi.bV5BitCount = 32;\n    bi.bV5Compression = BI_BITFIELDS;\n    bi.bV5RedMask = 0x00ff0000;\n    bi.bV5GreenMask = 0x0000ff00;\n    bi.bV5BlueMask = 0x000000ff;\n    bi.bV5AlphaMask = 0xff000000;\n    \n\tunsigned char* target = NULL;\n      \n    HDC dc = GetDC(NULL);\n    HBITMAP color = CreateDIBSection(dc,\n        (BITMAPINFO*) \u0026bi,\n        DIB_RGB_COLORS,\n        (void**) \u0026target,\n        NULL,\n        (DWORD) 0);\n    ReleaseDC(NULL, dc);\n\n    HBITMAP mask = CreateBitmap(width, height, 1, 1, NULL);\n\n    unsigned char* source = src; \n    unsigned int i;\n    for (i = 0; i \u003c width * height; i++) {\n        target[0] = source[2];\n        target[1] = source[1];\n        target[2] = source[0];\n        target[3] = source[3];\n        target += 4;\n        source += 4;\n    }\n\n    ICONINFO ii;\n    ZeroMemory(\u0026ii, sizeof(ii));\n    ii.fIcon = icon;\n    ii.xHotspot = 0;\n    ii.yHotspot = 0;\n    ii.hbmMask = mask;\n    ii.hbmColor = color;\n\n    HICON handle = CreateIconIndirect(\u0026ii);\n\n    DeleteObject(color);\n    DeleteObject(mask);\n\n    return handle;\n}\n\nint main() {\n\tWNDCLASS wc = {0};\n\twc.lpfnWndProc   = DefWindowProc; // Default window procedure\n\twc.hInstance     = GetModuleHandle(NULL);\n\twc.lpszClassName = \"SampleWindowClass\";\n\t\n\tRegisterClass(\u0026wc);\n\t\n\tHWND hwnd = CreateWindowA(wc.lpszClassName, \"Sample Window\", WS_CAPTION | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX,\n\t\t\t500, 500, 500, 500,\n\t\t\tNULL, NULL, wc.hInstance, NULL);\n\n\tShowWindow(hwnd, SW_SHOW);\n\tUpdateWindow(hwnd);\n\n\t// window icon \n\tHICON handle = loadHandleImage(icon, 3, 3, TRUE);\n\tSetClassLongPtrA(hwnd, GCLP_HICON, (LPARAM) handle);\n\tDestroyIcon(handle);\n\t\n\t// mouse icon image\n\tHCURSOR cursor = (HCURSOR) loadHandleImage(icon, 3, 3, FALSE);\n\n\tSetClassLongPtrA(hwnd, GCLP_HCURSOR, (LPARAM) cursor);\n\tSetCursor(cursor);\n\n\tDestroyCursor(cursor);\n\n\tMSG msg;\n\t\n\tBOOL running = TRUE;\n\t\n\twhile (running) {\n\t\tif (PeekMessageA(\u0026msg, hwnd, 0u, 0u, PM_REMOVE)) {\n\t\t\tif (msg.message == WM_KEYUP) {\n\t\t\t\tchar* icon = MAKEINTRESOURCEA(IDC_IBEAM);\n\t\t\t\t\n\t\t\t\tSetClassLongPtrA(hwnd, GCLP_HCURSOR, (LPARAM) LoadCursorA(NULL, icon));\n\t\t\t\tSetCursor(LoadCursorA(NULL, icon));\t\n\t\t\t}\n\t\t\tTranslateMessage(\u0026msg);\n\t\t\tDispatchMessage(\u0026msg);\n\t\t}\n\n\t\trunning = IsWindow(hwnd);\n\t}\n}\n```\n\n### cocoa\n```c\n// compile with:\n// gcc cocoa.c -lm -framework Foundation -framework AppKit -framework CoreVideo\n\n#include \u003cobjc/runtime.h\u003e\n#include \u003cobjc/message.h\u003e\n#include \u003cCoreVideo/CVDisplayLink.h\u003e\n#include \u003cApplicationServices/ApplicationServices.h\u003e\n\n#ifdef __arm64__\n/* ARM just uses objc_msgSend */\n#define abi_objc_msgSend_stret objc_msgSend\n#define abi_objc_msgSend_fpret objc_msgSend\n#else /* __i386__ */\n/* x86 just uses abi_objc_msgSend_fpret and (NSColor *)objc_msgSend_id respectively */\n#define abi_objc_msgSend_stret objc_msgSend_stret\n#define abi_objc_msgSend_fpret objc_msgSend_fpret\n#endif\n\ntypedef CGRect NSRect;\ntypedef CGPoint NSPoint;\ntypedef CGSize NSSize;\n\ntypedef void NSEvent;\ntypedef void NSString;\ntypedef void NSWindow;\t\ntypedef void NSApplication;\n\ntypedef unsigned long NSUInteger;\ntypedef long NSInteger;\n\n#define NS_ENUM(type, name) type name; enum \n\ntypedef NS_ENUM(NSUInteger, NSWindowStyleMask) {\n\tNSWindowStyleMaskBorderless = 0,\n\tNSWindowStyleMaskTitled = 1 \u003c\u003c 0,\n\tNSWindowStyleMaskClosable = 1 \u003c\u003c 1,\n\tNSWindowStyleMaskMiniaturizable = 1 \u003c\u003c 2,\n\tNSWindowStyleMaskResizable = 1 \u003c\u003c 3,\n\tNSWindowStyleMaskTexturedBackground = 1 \u003c\u003c 8, /* deprecated */\n\tNSWindowStyleMaskUnifiedTitleAndToolbar = 1 \u003c\u003c 12,\n\tNSWindowStyleMaskFullScreen = 1 \u003c\u003c 14,\n\tNSWindowStyleMaskFullSizeContentView = 1 \u003c\u003c 15,\n\tNSWindowStyleMaskUtilityWindow = 1 \u003c\u003c 4,\n\tNSWindowStyleMaskDocModalWindow = 1 \u003c\u003c 6,\n\tNSWindowStyleMaskNonactivatingPanel = 1 \u003c\u003c 7,\n\tNSWindowStyleMaskHUDWindow = 1 \u003c\u003c 13\n};\n\ntypedef NS_ENUM(NSUInteger, NSBackingStoreType) {\n\tNSBackingStoreRetained = 0,\n\tNSBackingStoreNonretained = 1,\n\tNSBackingStoreBuffered = 2\n};\n\ntypedef NS_ENUM(NSUInteger, NSEventType) {        /* various types of events */\n\tNSEventTypeLeftMouseDown             = 1,\n\tNSEventTypeLeftMouseUp               = 2,\n\tNSEventTypeRightMouseDown            = 3,\n\tNSEventTypeRightMouseUp              = 4,\n\tNSEventTypeMouseMoved                = 5,\n\tNSEventTypeLeftMouseDragged          = 6,\n\tNSEventTypeRightMouseDragged         = 7,\n\tNSEventTypeMouseEntered              = 8,\n\tNSEventTypeMouseExited               = 9,\n\tNSEventTypeKeyDown                   = 10,\n\tNSEventTypeKeyUp                     = 11,\n\tNSEventTypeFlagsChanged              = 12,\n\tNSEventTypeAppKitDefined             = 13,\n\tNSEventTypeSystemDefined             = 14,\n\tNSEventTypeApplicationDefined        = 15,\n\tNSEventTypePeriodic                  = 16,\n\tNSEventTypeCursorUpdate              = 17,\n\tNSEventTypeScrollWheel               = 22,\n\tNSEventTypeTabletPoint               = 23,\n\tNSEventTypeTabletProximity           = 24,\n\tNSEventTypeOtherMouseDown            = 25,\n\tNSEventTypeOtherMouseUp              = 26,\n\tNSEventTypeOtherMouseDragged         = 27,\n\t/* The following event types are available on some hardware on 10.5.2 and later */\n\tNSEventTypeGesture API_AVAILABLE(macos(10.5))       = 29,\n\tNSEventTypeMagnify API_AVAILABLE(macos(10.5))       = 30,\n\tNSEventTypeSwipe   API_AVAILABLE(macos(10.5))       = 31,\n\tNSEventTypeRotate  API_AVAILABLE(macos(10.5))       = 18,\n\tNSEventTypeBeginGesture API_AVAILABLE(macos(10.5))  = 19,\n\tNSEventTypeEndGesture API_AVAILABLE(macos(10.5))    = 20,\n\n\tNSEventTypeSmartMagnify API_AVAILABLE(macos(10.8)) = 32,\n\tNSEventTypeQuickLook API_AVAILABLE(macos(10.8)) = 33,\n\n\tNSEventTypePressure API_AVAILABLE(macos(10.10.3)) = 34,\n\tNSEventTypeDirectTouch API_AVAILABLE(macos(10.10)) = 37,\n\n\tNSEventTypeChangeMode API_AVAILABLE(macos(10.15)) = 38,\n};\n\ntypedef NS_ENUM(unsigned long long, NSEventMask) { /* masks for the types of events */\n\tNSEventMaskLeftMouseDown         = 1ULL \u003c\u003c NSEventTypeLeftMouseDown,\n\tNSEventMaskLeftMouseUp           = 1ULL \u003c\u003c NSEventTypeLeftMouseUp,\n\tNSEventMaskRightMouseDown        = 1ULL \u003c\u003c NSEventTypeRightMouseDown,\n\tNSEventMaskRightMouseUp          = 1ULL \u003c\u003c NSEventTypeRightMouseUp,\n\tNSEventMaskMouseMoved            = 1ULL \u003c\u003c NSEventTypeMouseMoved,\n\tNSEventMaskLeftMouseDragged      = 1ULL \u003c\u003c NSEventTypeLeftMouseDragged,\n\tNSEventMaskRightMouseDragged     = 1ULL \u003c\u003c NSEventTypeRightMouseDragged,\n\tNSEventMaskMouseEntered          = 1ULL \u003c\u003c NSEventTypeMouseEntered,\n\tNSEventMaskMouseExited           = 1ULL \u003c\u003c NSEventTypeMouseExited,\n\tNSEventMaskKeyDown               = 1ULL \u003c\u003c NSEventTypeKeyDown,\n\tNSEventMaskKeyUp                 = 1ULL \u003c\u003c NSEventTypeKeyUp,\n\tNSEventMaskFlagsChanged          = 1ULL \u003c\u003c NSEventTypeFlagsChanged,\n\tNSEventMaskAppKitDefined         = 1ULL \u003c\u003c NSEventTypeAppKitDefined,\n\tNSEventMaskSystemDefined         = 1ULL \u003c\u003c NSEventTypeSystemDefined,\n\tNSEventMaskApplicationDefined    = 1ULL \u003c\u003c NSEventTypeApplicationDefined,\n\tNSEventMaskPeriodic              = 1ULL \u003c\u003c NSEventTypePeriodic,\n\tNSEventMaskCursorUpdate          = 1ULL \u003c\u003c NSEventTypeCursorUpdate,\n\tNSEventMaskScrollWheel           = 1ULL \u003c\u003c NSEventTypeScrollWheel,\n\tNSEventMaskTabletPoint           = 1ULL \u003c\u003c NSEventTypeTabletPoint,\n\tNSEventMaskTabletProximity       = 1ULL \u003c\u003c NSEventTypeTabletProximity,\n\tNSEventMaskOtherMouseDown        = 1ULL \u003c\u003c NSEventTypeOtherMouseDown,\n\tNSEventMaskOtherMouseUp          = 1ULL \u003c\u003c NSEventTypeOtherMouseUp,\n\tNSEventMaskOtherMouseDragged     = 1ULL \u003c\u003c NSEventTypeOtherMouseDragged,\n};\n/* The following event masks are available on some hardware on 10.5.2 and later */\n#define NSEventMaskGesture API_AVAILABLE(macos(10.5))          (1ULL \u003c\u003c NSEventTypeGesture)\n#define NSEventMaskMagnify API_AVAILABLE(macos(10.5))          (1ULL \u003c\u003c NSEventTypeMagnify)\n#define NSEventMaskSwipe API_AVAILABLE(macos(10.5))            (1ULL \u003c\u003c NSEventTypeSwipe)\n#define NSEventMaskRotate API_AVAILABLE(macos(10.5))           (1ULL \u003c\u003c NSEventTypeRotate)\n#define NSEventMaskBeginGesture API_AVAILABLE(macos(10.5))     (1ULL \u003c\u003c NSEventTypeBeginGesture)\n#define NSEventMaskEndGesture API_AVAILABLE(macos(10.5))       (1ULL \u003c\u003c NSEventTypeEndGesture)\n\n/* Note: You can only use these event masks on 64 bit. In other words, you cannot setup a local, nor global, event monitor for these event types on 32 bit. Also, you cannot search the event queue for them (nextEventMatchingMask:...) on 32 bit. */\n#define NSEventMaskSmartMagnify API_AVAILABLE(macos(10.8)) (1ULL \u003c\u003c NSEventTypeSmartMagnify)\n#define NSEventMaskPressure API_AVAILABLE(macos(10.10.3)) (1ULL \u003c\u003c NSEventTypePressure)\n#define NSEventMaskDirectTouch API_AVAILABLE(macos(10.12.2)) (1ULL \u003c\u003c NSEventTypeDirectTouch)\n#define NSEventMaskChangeMode API_AVAILABLE(macos(10.15)) (1ULL \u003c\u003c NSEventTypeChangeMode)\n#define NSEventMaskAny              NSUIntegerMax\n\ntypedef NS_ENUM(NSUInteger, NSEventModifierFlags) {\n\tNSEventModifierFlagCapsLock           = 1 \u003c\u003c 16, // Set if Caps Lock key is pressed.\n\tNSEventModifierFlagShift              = 1 \u003c\u003c 17, // Set if Shift key is pressed.\n\tNSEventModifierFlagControl            = 1 \u003c\u003c 18, // Set if Control key is pressed.\n\tNSEventModifierFlagOption             = 1 \u003c\u003c 19, // Set if Option or Alternate key is pressed.\n\tNSEventModifierFlagCommand            = 1 \u003c\u003c 20, // Set if Command key is pressed.\n\tNSEventModifierFlagNumericPad         = 1 \u003c\u003c 21, // Set if any key in the numeric keypad is pressed.\n\tNSEventModifierFlagHelp               = 1 \u003c\u003c 22, // Set if the Help key is pressed.\n\tNSEventModifierFlagFunction           = 1 \u003c\u003c 23, // Set if any function key is pressed.\n};\n\n#define objc_msgSend_id\t\t\t\t((id (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_id_id\t\t\t((id (*)(id, SEL, id))objc_msgSend)\n#define objc_msgSend_id_rect\t\t((id (*)(id, SEL, NSRect))objc_msgSend)\n#define objc_msgSend_uint\t\t\t((NSUInteger (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_int\t\t\t((NSInteger (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_SEL\t\t\t((SEL (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_float\t\t\t((CGFloat (*)(id, SEL))abi_objc_msgSend_fpret)\n#define objc_msgSend_bool\t\t\t((BOOL (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_void\t\t\t((void (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_double\t\t\t((double (*)(id, SEL))objc_msgSend)\n#define objc_msgSend_void_id\t\t((void (*)(id, SEL, id))objc_msgSend)\n#define objc_msgSend_void_uint\t\t((void (*)(id, SEL, NSUInteger))objc_msgSend)\n#define objc_msgSend_void_int\t\t((void (*)(id, SEL, NSInteger))objc_msgSend)\n#define objc_msgSend_void_bool\t\t((void (*)(id, SEL, BOOL))objc_msgSend)\n#define objc_msgSend_void_float\t\t((void (*)(id, SEL, CGFloat))objc_msgSend)\n#define objc_msgSend_void_double\t((void (*)(id, SEL, double))objc_msgSend)\n#define objc_msgSend_void_SEL\t\t((void (*)(id, SEL, SEL))objc_msgSend)\n#define objc_msgSend_id_char_const\t((id (*)(id, SEL, char const *))objc_msgSend)\n\ntypedef enum NSApplicationActivationPolicy {\n\tNSApplicationActivationPolicyRegular,\n\tNSApplicationActivationPolicyAccessory,\n\tNSApplicationActivationPolicyProhibited\n} NSApplicationActivationPolicy;\n\ntypedef enum NSBitmapFormat {\n\tNSBitmapFormatAlphaFirst = 1 \u003c\u003c 0,       // 0 means is alpha last (RGBA, CMYKA, etc.)\n\tNSBitmapFormatAlphaNonpremultiplied = 1 \u003c\u003c 1,       // 0 means is premultiplied\n\tNSBitmapFormatFloatingPointSamples = 1 \u003c\u003c 2,  // 0 is integer\n\n\tNSBitmapFormatSixteenBitLittleEndian API_AVAILABLE(macos(10.10)) = (1 \u003c\u003c 8),\n\tNSBitmapFormatThirtyTwoBitLittleEndian API_AVAILABLE(macos(10.10)) = (1 \u003c\u003c 9),\n\tNSBitmapFormatSixteenBitBigEndian API_AVAILABLE(macos(10.10)) = (1 \u003c\u003c 10),\n\tNSBitmapFormatThirtyTwoBitBigEndian API_AVAILABLE(macos(10.10)) = (1 \u003c\u003c 11)\n} NSBitmapFormat;\n\n\n#define NSAlloc(nsclass) objc_msgSend_id((id)nsclass, sel_registerName(\"alloc\"))\n#define NSRelease(nsclass) objc_msgSend_id((id)nsclass, sel_registerName(\"release\"))\n\nunsigned char icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};\n\nbool running = true;\n\nunsigned int onClose(void* self) {\n\tNSWindow* win = NULL;\n\tobject_getInstanceVariable(self, \"NSWindow\", (void*)\u0026win);\n\tif (win == NULL)\n\t\treturn true;\n\n\trunning = false;\n\n\treturn true;\n}\n\n#include \u003cstring.h\u003e\n\nint main(int argc, char* argv[]) {\n\tclass_addMethod(objc_getClass(\"NSObject\"), sel_registerName(\"windowShouldClose:\"), (IMP) onClose, 0);\n\n\tNSApplication* NSApp = objc_msgSend_id((id)objc_getClass(\"NSApplication\"), sel_registerName(\"sharedApplication\"));\n\tobjc_msgSend_void_int(NSApp, sel_registerName(\"setActivationPolicy:\"), NSApplicationActivationPolicyRegular);\n\n\tNSBackingStoreType macArgs = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSBackingStoreBuffered | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;\n\n\tSEL func = sel_registerName(\"initWithContentRect:styleMask:backing:defer:\");\n\t\n\tNSWindow* window = ((id (*)(id, SEL, NSRect, NSWindowStyleMask, NSBackingStoreType, bool))objc_msgSend)\n\t\t\t(NSAlloc(objc_getClass(\"NSWindow\")), func, \n\t\t\t\t\t\t(NSRect){{200, 200}, {200, 200}}, \n\t\t\t\t\t\tmacArgs, macArgs, false);\n\n\tobjc_msgSend_void_bool(NSApp, sel_registerName(\"activateIgnoringOtherApps:\"), true);\n\t((id(*)(id, SEL, SEL))objc_msgSend)(window, sel_registerName(\"makeKeyAndOrderFront:\"), NULL);\n\tobjc_msgSend_void_bool(window, sel_registerName(\"setIsVisible:\"), true);\n\n\tobjc_msgSend_void(NSApp, sel_registerName(\"finishLaunching\"));\n\t// window icons\n\tfunc = sel_registerName(\"initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:\");\n\tchar* NSCalibratedRGBColorSpace = ((id(*)(id, SEL, const char*))objc_msgSend) ((id)objc_getClass(\"NSString\"), sel_registerName(\"stringWithUTF8String:\"), \"NSCalibratedRGBColorSpace\"); \n\tvoid* representation = ((id(*)(id, SEL, unsigned char**, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, const char*, NSBitmapFormat, NSInteger, NSInteger))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSBitmapImageRep\")), func, NULL, 3, 3, 8, 4, true, false, NSCalibratedRGBColorSpace, 1 \u003c\u003c 1, 3 * 4, 8 * 4);\n\n\tmemcpy(((unsigned char* (*)(id, SEL))objc_msgSend)\n\t\t\t(representation, sel_registerName(\"bitmapData\")), \n\t\t\ticon, 3 * 3 * 4);\n\t\n\tvoid* dock_image = ((id(*)(id, SEL, NSSize))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSImage\")), sel_registerName(\"initWithSize:\"), (NSSize){3, 3});\n\tobjc_msgSend_void_id(dock_image, sel_registerName(\"addRepresentation:\"), representation);\n\n\tobjc_msgSend_void_id(NSApp, sel_registerName(\"setApplicationIconImage:\"), dock_image);\n\n\tNSRelease(dock_image);\n\tNSRelease(representation);\n\n\t// mouse icon image\n\trepresentation = ((id(*)(id, SEL, unsigned char**, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, const char*, NSBitmapFormat, NSInteger, NSInteger))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSBitmapImageRep\")), func, NULL, 3, 3, 8, 4, true, false, NSCalibratedRGBColorSpace, 1 \u003c\u003c 1, 3 * 4, 8 * 4);\n\n\tmemcpy(((unsigned char* (*)(id, SEL))objc_msgSend)\n\t\t\t(representation, sel_registerName(\"bitmapData\")), \n\t\t\ticon, 3 * 3 * 4);\n\t\n\tvoid* cursor_image = ((id(*)(id, SEL, NSSize))objc_msgSend)\n\t\t\t(NSAlloc((id)objc_getClass(\"NSImage\")), sel_registerName(\"initWithSize:\"), (NSSize){3, 3});\n\tobjc_msgSend_void_id(cursor_image, sel_registerName(\"addRepresentation:\"), representation);\n\n\tvoid* cursor = ((id(*)(id, SEL, id, NSPoint))objc_msgSend)\n\t\t\t\t\t\t(NSAlloc(objc_getClass(\"NSCursor\")), sel_registerName(\"initWithImage:hotSpot:\"), \n\t\t\t\t\t\t cursor_image, (NSPoint){0.0, 0.0});\n\n\tobjc_msgSend_void(cursor, sel_registerName(\"set\"));\n\t\n\tNSRelease(cursor_image);\n\tNSRelease(representation);\n\n\n\twhile (running) {\n\t\tid pool = objc_msgSend_id(NSAlloc(objc_getClass(\"NSAutoreleasePool\")), sel_registerName(\"init\"));\n\n\t\tNSEvent* e = (NSEvent*) ((id(*)(id, SEL, NSEventMask, void*, NSString*, bool))objc_msgSend) (NSApp, sel_registerName(\"nextEventMatchingMask:untilDate:inMode:dequeue:\"), ULONG_MAX, NULL, ((id(*)(id, SEL, const char*))objc_msgSend) ((id)objc_getClass(\"NSString\"), sel_registerName(\"stringWithUTF8String:\"), \"kCFRunLoopDefaultMode\"), true);\n\t\n\t\tunsigned int type = objc_msgSend_uint(e, sel_registerName(\"type\"));  \n\t\t\n\t\tif (type == NSEventTypeLeftMouseUp) {\n\t\t\t// standard mouse icons\n\t\t\tvoid* mouse = objc_msgSend_id(objc_getClass(\"NSCursor\"), sel_registerName(\"IBeamCursor\"));\n\t\t\tobjc_msgSend_void(mouse, sel_registerName(\"set\"));\n\t\t}\n\n\t\tif (type == NSEventTypeRightMouseUp)\n\t\t\tobjc_msgSend_void(cursor, sel_registerName(\"set\"));\n\n\t\tobjc_msgSend_void_id(NSApp, sel_registerName(\"sendEvent:\"), e);\n\t\t((void(*)(id, SEL))objc_msgSend)(NSApp, sel_registerName(\"updateWindows\"));\n  \t\n\t\tNSRelease(pool);\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolleagueriley%2Fmouse-and-window-icons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolleagueriley%2Fmouse-and-window-icons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolleagueriley%2Fmouse-and-window-icons/lists"}