mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 06:14:35 +00:00
Limit scope of some loop counters in C99 files
This commit is contained in:
parent
f4d0365a5a
commit
3d52f7e345
@ -75,7 +75,6 @@ static void changeToResourcesDirectory(void)
|
|||||||
//
|
//
|
||||||
static void createMenuBar(void)
|
static void createMenuBar(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
NSString* appName = nil;
|
NSString* appName = nil;
|
||||||
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
||||||
NSString* nameKeys[] =
|
NSString* nameKeys[] =
|
||||||
@ -87,7 +86,7 @@ static void createMenuBar(void)
|
|||||||
|
|
||||||
// Try to figure out what the calling application is called
|
// Try to figure out what the calling application is called
|
||||||
|
|
||||||
for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
|
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
|
||||||
{
|
{
|
||||||
id name = bundleInfo[nameKeys[i]];
|
id name = bundleInfo[nameKeys[i]];
|
||||||
if (name &&
|
if (name &&
|
||||||
@ -177,8 +176,6 @@ static void createMenuBar(void)
|
|||||||
//
|
//
|
||||||
static void createKeyTables(void)
|
static void createKeyTables(void)
|
||||||
{
|
{
|
||||||
int scancode;
|
|
||||||
|
|
||||||
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
||||||
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
||||||
|
|
||||||
@ -297,7 +294,7 @@ static void createKeyTables(void)
|
|||||||
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
||||||
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
||||||
|
|
||||||
for (scancode = 0; scancode < 256; scancode++)
|
for (int scancode = 0; scancode < 256; scancode++)
|
||||||
{
|
{
|
||||||
// Store the reverse translation for faster key name lookup
|
// Store the reverse translation for faster key name lookup
|
||||||
if (_glfw.ns.keycodes[scancode] >= 0)
|
if (_glfw.ns.keycodes[scancode] >= 0)
|
||||||
@ -403,9 +400,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
|
||||||
for (window = _glfw.windowListHead; window; window = window->next)
|
|
||||||
_glfwInputWindowCloseRequest(window);
|
_glfwInputWindowCloseRequest(window);
|
||||||
|
|
||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
@ -413,9 +408,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
|
||||||
for (window = _glfw.windowListHead; window; window = window->next)
|
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.client != GLFW_NO_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
@ -450,9 +443,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)applicationDidHide:(NSNotification *)notification
|
- (void)applicationDidHide:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||||
|
|
||||||
for (i = 0; i < _glfw.monitorCount; i++)
|
|
||||||
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,20 +96,18 @@ static CFComparisonResult compareElements(const void* fp,
|
|||||||
//
|
//
|
||||||
static void closeJoystick(_GLFWjoystick* js)
|
static void closeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
||||||
CFRelease(js->ns.axes);
|
CFRelease(js->ns.axes);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
|
||||||
CFRelease(js->ns.buttons);
|
CFRelease(js->ns.buttons);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
|
||||||
CFRelease(js->ns.hats);
|
CFRelease(js->ns.hats);
|
||||||
|
|
||||||
@ -127,7 +125,6 @@ static void matchCallback(void* context,
|
|||||||
int jid;
|
int jid;
|
||||||
char name[256];
|
char name[256];
|
||||||
char guid[33];
|
char guid[33];
|
||||||
CFIndex i;
|
|
||||||
CFTypeRef property;
|
CFTypeRef property;
|
||||||
uint32_t vendor = 0, product = 0, version = 0;
|
uint32_t vendor = 0, product = 0, version = 0;
|
||||||
_GLFWjoystick* js;
|
_GLFWjoystick* js;
|
||||||
@ -185,7 +182,7 @@ static void matchCallback(void* context,
|
|||||||
CFArrayRef elements =
|
CFArrayRef elements =
|
||||||
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(elements); i++)
|
for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
|
||||||
{
|
{
|
||||||
IOHIDElementRef native = (IOHIDElementRef)
|
IOHIDElementRef native = (IOHIDElementRef)
|
||||||
CFArrayGetValueAtIndex(elements, i);
|
CFArrayGetValueAtIndex(elements, i);
|
||||||
@ -290,9 +287,7 @@ static void removeCallback(void* context,
|
|||||||
void* sender,
|
void* sender,
|
||||||
IOHIDDeviceRef device)
|
IOHIDDeviceRef device)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
if (_glfw.joysticks[jid].ns.device == device)
|
if (_glfw.joysticks[jid].ns.device == device)
|
||||||
{
|
{
|
||||||
@ -386,9 +381,7 @@ GLFWbool _glfwInitJoysticksCocoa(void)
|
|||||||
|
|
||||||
void _glfwTerminateJoysticksCocoa(void)
|
void _glfwTerminateJoysticksCocoa(void)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
closeJoystick(_glfw.joysticks + jid);
|
closeJoystick(_glfw.joysticks + jid);
|
||||||
|
|
||||||
if (_glfw.ns.hidManager)
|
if (_glfw.ns.hidManager)
|
||||||
@ -403,9 +396,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
|||||||
{
|
{
|
||||||
if (mode & _GLFW_POLL_AXES)
|
if (mode & _GLFW_POLL_AXES)
|
||||||
{
|
{
|
||||||
CFIndex i;
|
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
||||||
CFArrayGetValueAtIndex(js->ns.axes, i);
|
CFArrayGetValueAtIndex(js->ns.axes, i);
|
||||||
@ -430,9 +421,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
|||||||
|
|
||||||
if (mode & _GLFW_POLL_BUTTONS)
|
if (mode & _GLFW_POLL_BUTTONS)
|
||||||
{
|
{
|
||||||
CFIndex i;
|
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
||||||
CFArrayGetValueAtIndex(js->ns.buttons, i);
|
CFArrayGetValueAtIndex(js->ns.buttons, i);
|
||||||
@ -441,7 +430,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
|||||||
_glfwInputJoystickButton(js, (int) i, state);
|
_glfwInputJoystickButton(js, (int) i, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||||
{
|
{
|
||||||
const int states[9] =
|
const int states[9] =
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
GLXFBConfig* nativeConfigs;
|
GLXFBConfig* nativeConfigs;
|
||||||
_GLFWfbconfig* usableConfigs;
|
_GLFWfbconfig* usableConfigs;
|
||||||
const _GLFWfbconfig* closest;
|
const _GLFWfbconfig* closest;
|
||||||
int i, nativeCount, usableCount;
|
int nativeCount, usableCount;
|
||||||
const char* vendor;
|
const char* vendor;
|
||||||
GLFWbool trustWindowBit = GLFW_TRUE;
|
GLFWbool trustWindowBit = GLFW_TRUE;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||||
usableCount = 0;
|
usableCount = 0;
|
||||||
|
|
||||||
for (i = 0; i < nativeCount; i++)
|
for (int i = 0; i < nativeCount; i++)
|
||||||
{
|
{
|
||||||
const GLXFBConfig n = nativeConfigs[i];
|
const GLXFBConfig n = nativeConfigs[i];
|
||||||
_GLFWfbconfig* u = usableConfigs + usableCount;
|
_GLFWfbconfig* u = usableConfigs + usableCount;
|
||||||
@ -253,7 +253,6 @@ static void destroyContextGLX(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
GLFWbool _glfwInitGLX(void)
|
GLFWbool _glfwInitGLX(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
const char* sonames[] =
|
const char* sonames[] =
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_GLX_LIBRARY)
|
#if defined(_GLFW_GLX_LIBRARY)
|
||||||
@ -270,7 +269,7 @@ GLFWbool _glfwInitGLX(void)
|
|||||||
if (_glfw.glx.handle)
|
if (_glfw.glx.handle)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
for (i = 0; sonames[i]; i++)
|
for (int i = 0; sonames[i]; i++)
|
||||||
{
|
{
|
||||||
_glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]);
|
_glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||||
if (_glfw.glx.handle)
|
if (_glfw.glx.handle)
|
||||||
|
@ -363,9 +363,7 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
|||||||
|
|
||||||
void _glfwTerminateJoysticksLinux(void)
|
void _glfwTerminateJoysticksLinux(void)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->present)
|
||||||
|
@ -886,10 +886,9 @@ static void registryHandleGlobalRemove(void *data,
|
|||||||
struct wl_registry *registry,
|
struct wl_registry *registry,
|
||||||
uint32_t name)
|
uint32_t name)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
|
|
||||||
for (i = 0; i < _glfw.monitorCount; ++i)
|
for (int i = 0; i < _glfw.monitorCount; ++i)
|
||||||
{
|
{
|
||||||
monitor = _glfw.monitors[i];
|
monitor = _glfw.monitors[i];
|
||||||
if (monitor->wl.name == name)
|
if (monitor->wl.name == name)
|
||||||
@ -910,8 +909,6 @@ static const struct wl_registry_listener registryListener = {
|
|||||||
//
|
//
|
||||||
static void createKeyTables(void)
|
static void createKeyTables(void)
|
||||||
{
|
{
|
||||||
int scancode;
|
|
||||||
|
|
||||||
memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
|
memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
|
||||||
memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
|
memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
|
||||||
|
|
||||||
@ -1033,7 +1030,7 @@ static void createKeyTables(void)
|
|||||||
_glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
|
_glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
|
||||||
_glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
|
_glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
|
||||||
|
|
||||||
for (scancode = 0; scancode < 256; scancode++)
|
for (int scancode = 0; scancode < 256; scancode++)
|
||||||
{
|
{
|
||||||
if (_glfw.wl.keycodes[scancode] > 0)
|
if (_glfw.wl.keycodes[scancode] > 0)
|
||||||
_glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
|
_glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
|
||||||
|
@ -144,9 +144,8 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
|||||||
int stride = image->width * 4;
|
int stride = image->width * 4;
|
||||||
int length = image->width * image->height * 4;
|
int length = image->width * image->height * 4;
|
||||||
void* data;
|
void* data;
|
||||||
int fd, i;
|
|
||||||
|
|
||||||
fd = createAnonymousFile(length);
|
const int fd = createAnonymousFile(length);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -169,7 +168,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
|||||||
close(fd);
|
close(fd);
|
||||||
unsigned char* source = (unsigned char*) image->pixels;
|
unsigned char* source = (unsigned char*) image->pixels;
|
||||||
unsigned char* target = data;
|
unsigned char* target = data;
|
||||||
for (i = 0; i < image->width * image->height; i++, source += 4)
|
for (int i = 0; i < image->width * image->height; i++, source += 4)
|
||||||
{
|
{
|
||||||
unsigned int alpha = source[3];
|
unsigned int alpha = source[3];
|
||||||
|
|
||||||
@ -347,7 +346,6 @@ static void resizeWindow(_GLFWwindow* window)
|
|||||||
static void checkScaleChange(_GLFWwindow* window)
|
static void checkScaleChange(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
int i;
|
|
||||||
int monitorScale;
|
int monitorScale;
|
||||||
|
|
||||||
// Check if we will be able to set the buffer scale or not.
|
// Check if we will be able to set the buffer scale or not.
|
||||||
@ -355,7 +353,7 @@ static void checkScaleChange(_GLFWwindow* window)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the scale factor from the highest scale monitor.
|
// Get the scale factor from the highest scale monitor.
|
||||||
for (i = 0; i < window->wl.monitorsCount; ++i)
|
for (int i = 0; i < window->wl.monitorsCount; ++i)
|
||||||
{
|
{
|
||||||
monitorScale = window->wl.monitors[i]->wl.scale;
|
monitorScale = window->wl.monitors[i]->wl.scale;
|
||||||
if (scale < monitorScale)
|
if (scale < monitorScale)
|
||||||
@ -397,10 +395,9 @@ static void surfaceHandleLeave(void *data,
|
|||||||
{
|
{
|
||||||
_GLFWwindow* window = data;
|
_GLFWwindow* window = data;
|
||||||
_GLFWmonitor* monitor = wl_output_get_user_data(output);
|
_GLFWmonitor* monitor = wl_output_get_user_data(output);
|
||||||
GLFWbool found;
|
GLFWbool found = GLFW_FALSE;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
|
for (int i = 0; i < window->wl.monitorsCount - 1; ++i)
|
||||||
{
|
{
|
||||||
if (monitor == window->wl.monitors[i])
|
if (monitor == window->wl.monitors[i])
|
||||||
found = GLFW_TRUE;
|
found = GLFW_TRUE;
|
||||||
@ -719,7 +716,7 @@ static void handleEvents(int timeout)
|
|||||||
{ _glfw.wl.cursorTimerfd, POLLIN },
|
{ _glfw.wl.cursorTimerfd, POLLIN },
|
||||||
};
|
};
|
||||||
ssize_t read_ret;
|
ssize_t read_ret;
|
||||||
uint64_t repeats, i;
|
uint64_t repeats;
|
||||||
|
|
||||||
while (wl_display_prepare_read(display) != 0)
|
while (wl_display_prepare_read(display) != 0)
|
||||||
wl_display_dispatch_pending(display);
|
wl_display_dispatch_pending(display);
|
||||||
@ -759,7 +756,7 @@ static void handleEvents(int timeout)
|
|||||||
|
|
||||||
if (_glfw.wl.keyboardFocus)
|
if (_glfw.wl.keyboardFocus)
|
||||||
{
|
{
|
||||||
for (i = 0; i < repeats; ++i)
|
for (uint64_t i = 0; i < repeats; ++i)
|
||||||
{
|
{
|
||||||
_glfwInputKey(_glfw.wl.keyboardFocus,
|
_glfwInputKey(_glfw.wl.keyboardFocus,
|
||||||
_glfw.wl.keyboardLastKey,
|
_glfw.wl.keyboardLastKey,
|
||||||
|
@ -209,7 +209,7 @@ static int translateKeySyms(const KeySym* keysyms, int width)
|
|||||||
//
|
//
|
||||||
static void createKeyTables(void)
|
static void createKeyTables(void)
|
||||||
{
|
{
|
||||||
int scancode, scancodeMin, scancodeMax;
|
int scancodeMin, scancodeMax;
|
||||||
|
|
||||||
memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
|
memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
|
||||||
memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
|
memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
|
||||||
@ -355,7 +355,7 @@ static void createKeyTables(void)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Find the X11 key code -> GLFW key code mapping
|
// Find the X11 key code -> GLFW key code mapping
|
||||||
for (scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
||||||
{
|
{
|
||||||
int key = GLFW_KEY_UNKNOWN;
|
int key = GLFW_KEY_UNKNOWN;
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ static void createKeyTables(void)
|
|||||||
scancodeMax - scancodeMin + 1,
|
scancodeMax - scancodeMin + 1,
|
||||||
&width);
|
&width);
|
||||||
|
|
||||||
for (scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
||||||
{
|
{
|
||||||
// Translate the un-translated key codes using traditional X11 KeySym
|
// Translate the un-translated key codes using traditional X11 KeySym
|
||||||
// lookups
|
// lookups
|
||||||
@ -1072,7 +1072,6 @@ void _glfwInputErrorX11(int error, const char* message)
|
|||||||
//
|
//
|
||||||
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot)
|
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
if (!_glfw.x11.xcursor.handle)
|
if (!_glfw.x11.xcursor.handle)
|
||||||
@ -1088,7 +1087,7 @@ Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot)
|
|||||||
unsigned char* source = (unsigned char*) image->pixels;
|
unsigned char* source = (unsigned char*) image->pixels;
|
||||||
XcursorPixel* target = native->pixels;
|
XcursorPixel* target = native->pixels;
|
||||||
|
|
||||||
for (i = 0; i < image->width * image->height; i++, target++, source += 4)
|
for (int i = 0; i < image->width * image->height; i++, target++, source += 4)
|
||||||
{
|
{
|
||||||
unsigned int alpha = source[3];
|
unsigned int alpha = source[3];
|
||||||
|
|
||||||
|
@ -788,7 +788,6 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
//
|
//
|
||||||
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
char* selectionString = NULL;
|
char* selectionString = NULL;
|
||||||
const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
|
const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
|
||||||
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
||||||
@ -831,14 +830,13 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
// Multiple conversions were requested
|
// Multiple conversions were requested
|
||||||
|
|
||||||
Atom* targets;
|
Atom* targets;
|
||||||
unsigned long i, count;
|
const unsigned long count =
|
||||||
|
_glfwGetWindowPropertyX11(request->requestor,
|
||||||
|
request->property,
|
||||||
|
_glfw.x11.ATOM_PAIR,
|
||||||
|
(unsigned char**) &targets);
|
||||||
|
|
||||||
count = _glfwGetWindowPropertyX11(request->requestor,
|
for (unsigned long i = 0; i < count; i += 2)
|
||||||
request->property,
|
|
||||||
_glfw.x11.ATOM_PAIR,
|
|
||||||
(unsigned char**) &targets);
|
|
||||||
|
|
||||||
for (i = 0; i < count; i += 2)
|
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
@ -896,7 +894,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
|
|
||||||
// Conversion to a data target was requested
|
// Conversion to a data target was requested
|
||||||
|
|
||||||
for (i = 0; i < formatCount; i++)
|
for (int i = 0; i < formatCount; i++)
|
||||||
{
|
{
|
||||||
if (request->target == formats[i])
|
if (request->target == formats[i])
|
||||||
{
|
{
|
||||||
@ -1588,7 +1586,7 @@ static void processEvent(XEvent *event)
|
|||||||
else if (event->xclient.message_type == _glfw.x11.XdndEnter)
|
else if (event->xclient.message_type == _glfw.x11.XdndEnter)
|
||||||
{
|
{
|
||||||
// A drag operation has entered the window
|
// A drag operation has entered the window
|
||||||
unsigned long i, count;
|
unsigned long count;
|
||||||
Atom* formats = NULL;
|
Atom* formats = NULL;
|
||||||
const GLFWbool list = event->xclient.data.l[1] & 1;
|
const GLFWbool list = event->xclient.data.l[1] & 1;
|
||||||
|
|
||||||
@ -1612,7 +1610,7 @@ static void processEvent(XEvent *event)
|
|||||||
formats = (Atom*) event->xclient.data.l + 2;
|
formats = (Atom*) event->xclient.data.l + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (formats[i] == _glfw.x11.text_uri_list)
|
if (formats[i] == _glfw.x11.text_uri_list)
|
||||||
{
|
{
|
||||||
@ -1718,12 +1716,12 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
int i, count;
|
int count;
|
||||||
char** paths = parseUriList(data, &count);
|
char** paths = parseUriList(data, &count);
|
||||||
|
|
||||||
_glfwInputDrop(window, count, (const char**) paths);
|
_glfwInputDrop(window, count, (const char**) paths);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
_glfw_free(paths[i]);
|
_glfw_free(paths[i]);
|
||||||
_glfw_free(paths);
|
_glfw_free(paths);
|
||||||
}
|
}
|
||||||
@ -2102,20 +2100,20 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag
|
|||||||
{
|
{
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
int i, j, longCount = 0;
|
int longCount = 0;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
longCount += 2 + images[i].width * images[i].height;
|
longCount += 2 + images[i].width * images[i].height;
|
||||||
|
|
||||||
long* icon = _glfw_calloc(longCount, sizeof(long));
|
long* icon = _glfw_calloc(longCount, sizeof(long));
|
||||||
long* target = icon;
|
long* target = icon;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
*target++ = images[i].width;
|
*target++ = images[i].width;
|
||||||
*target++ = images[i].height;
|
*target++ = images[i].height;
|
||||||
|
|
||||||
for (j = 0; j < images[i].width * images[i].height; j++)
|
for (int j = 0; j < images[i].width * images[i].height; j++)
|
||||||
{
|
{
|
||||||
*target++ = (images[i].pixels[j * 4 + 0] << 16) |
|
*target++ = (images[i].pixels[j * 4 + 0] << 16) |
|
||||||
(images[i].pixels[j * 4 + 1] << 8) |
|
(images[i].pixels[j * 4 + 1] << 8) |
|
||||||
@ -2537,7 +2535,6 @@ int _glfwWindowVisibleX11(_GLFWwindow* window)
|
|||||||
int _glfwWindowMaximizedX11(_GLFWwindow* window)
|
int _glfwWindowMaximizedX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Atom* states;
|
Atom* states;
|
||||||
unsigned long i;
|
|
||||||
GLFWbool maximized = GLFW_FALSE;
|
GLFWbool maximized = GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfw.x11.NET_WM_STATE ||
|
if (!_glfw.x11.NET_WM_STATE ||
|
||||||
@ -2553,7 +2550,7 @@ int _glfwWindowMaximizedX11(_GLFWwindow* window)
|
|||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
(unsigned char**) &states);
|
(unsigned char**) &states);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (unsigned long i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
|
if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
|
||||||
states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||||
@ -2651,18 +2648,19 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Atom* states = NULL;
|
Atom* states = NULL;
|
||||||
unsigned long i, count;
|
const unsigned long count =
|
||||||
|
_glfwGetWindowPropertyX11(window->x11.handle,
|
||||||
count = _glfwGetWindowPropertyX11(window->x11.handle,
|
_glfw.x11.NET_WM_STATE,
|
||||||
_glfw.x11.NET_WM_STATE,
|
XA_ATOM,
|
||||||
XA_ATOM,
|
(unsigned char**) &states);
|
||||||
(unsigned char**) &states);
|
|
||||||
|
|
||||||
// NOTE: We don't check for failure as this property may not exist yet
|
// NOTE: We don't check for failure as this property may not exist yet
|
||||||
// and that's fine (and we'll create it implicitly with append)
|
// and that's fine (and we'll create it implicitly with append)
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
|
unsigned long i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
||||||
@ -2680,20 +2678,16 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
}
|
}
|
||||||
else if (states)
|
else if (states)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; i++)
|
for (unsigned long i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
||||||
|
{
|
||||||
|
states[i] = states[count - 1];
|
||||||
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
|
PropModeReplace, (unsigned char*) states, count - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < count)
|
|
||||||
{
|
|
||||||
states[i] = states[count - 1];
|
|
||||||
count--;
|
|
||||||
|
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
|
||||||
PropModeReplace, (unsigned char*) states, count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user