mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Fix beeping anytime a key was pressed on cocoa backend
This commit is contained in:
parent
3bb930a35b
commit
61ccbdcaad
@ -1097,7 +1097,6 @@ struct LScreen* ResourcesScreen_MakeInstance(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------ServersScreen----------------------------------------------------*
|
*--------------------------------------------------------ServersScreen----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
17
src/Window.c
17
src/Window.c
@ -3692,8 +3692,10 @@ static void Window_WillClose(id self, SEL cmd, id notification) {
|
|||||||
Event_RaiseVoid(&WindowEvents.Closing);
|
Event_RaiseVoid(&WindowEvents.Closing);
|
||||||
}
|
}
|
||||||
|
|
||||||
static id Window_MakeDelegate(void) {
|
static void Window_KeyDown(id self, SEL cmd, id ev) { }
|
||||||
Class c = objc_allocateClassPair(objc_getClass("NSObject"), "CC_WindowFuncs", 0);
|
|
||||||
|
static Class Window_MakeClass(void) {
|
||||||
|
Class c = objc_allocateClassPair(objc_getClass("NSWindow"), "ClassiCube_Window", 0);
|
||||||
|
|
||||||
// TODO: derive from NSWindow and implement keydown so no beeps when pressing keys.
|
// TODO: derive from NSWindow and implement keydown so no beeps when pressing keys.
|
||||||
class_addMethod(c, sel_registerName("windowDidResize:"), Window_DidResize, "v@:@");
|
class_addMethod(c, sel_registerName("windowDidResize:"), Window_DidResize, "v@:@");
|
||||||
@ -3703,9 +3705,10 @@ static id Window_MakeDelegate(void) {
|
|||||||
class_addMethod(c, sel_registerName("windowDidMiniaturize:"), Window_DidMiniaturize, "v@:@");
|
class_addMethod(c, sel_registerName("windowDidMiniaturize:"), Window_DidMiniaturize, "v@:@");
|
||||||
class_addMethod(c, sel_registerName("windowDidDeminiaturize:"), Window_DidDeminiaturize, "v@:@");
|
class_addMethod(c, sel_registerName("windowDidDeminiaturize:"), Window_DidDeminiaturize, "v@:@");
|
||||||
class_addMethod(c, sel_registerName("windowWillClose:"), Window_WillClose, "v@:@");
|
class_addMethod(c, sel_registerName("windowWillClose:"), Window_WillClose, "v@:@");
|
||||||
|
class_addMethod(c, sel_registerName("keyDown:"), Window_KeyDown, "v@:@");
|
||||||
|
|
||||||
objc_registerClassPair(c);
|
objc_registerClassPair(c);
|
||||||
return objc_msgSend((id)c, sel_registerName("alloc"));
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Init(void) {
|
void Window_Init(void) {
|
||||||
@ -3720,8 +3723,8 @@ void Window_Init(void) {
|
|||||||
#define NSResizableWindowMask (1 << 3)
|
#define NSResizableWindowMask (1 << 3)
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
void Window_Create(int width, int height) {
|
||||||
|
Class winClass;
|
||||||
CGRect rect;
|
CGRect rect;
|
||||||
id funcs;
|
|
||||||
|
|
||||||
rect.origin.x = Display_CentreX(width);
|
rect.origin.x = Display_CentreX(width);
|
||||||
rect.origin.y = Display_CentreY(height);
|
rect.origin.y = Display_CentreY(height);
|
||||||
@ -3729,13 +3732,13 @@ void Window_Create(int width, int height) {
|
|||||||
rect.size.height = height;
|
rect.size.height = height;
|
||||||
// TODO: opentk seems to flip y?
|
// TODO: opentk seems to flip y?
|
||||||
|
|
||||||
winHandle = objc_msgSend((id)objc_getClass("NSWindow"), sel_registerName("alloc"));
|
winClass = Window_MakeClass();
|
||||||
|
winHandle = objc_msgSend(winClass, sel_registerName("alloc"));
|
||||||
objc_msgSend(winHandle, sel_registerName("initWithContentRect:styleMask:backing:defer:"), rect, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false);
|
objc_msgSend(winHandle, sel_registerName("initWithContentRect:styleMask:backing:defer:"), rect, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false);
|
||||||
|
|
||||||
// TODO: why is the menubar broken
|
// TODO: why is the menubar broken
|
||||||
Window_CommonCreate();
|
Window_CommonCreate();
|
||||||
funcs = Window_MakeDelegate();
|
objc_msgSend(winHandle, sel_registerName("setDelegate:"), winHandle);
|
||||||
objc_msgSend(winHandle, sel_registerName("setDelegate:"), funcs);
|
|
||||||
|
|
||||||
// TODO: move to setVisible
|
// TODO: move to setVisible
|
||||||
objc_msgSend(winHandle, sel_registerName("makeKeyAndOrderFront:"), appHandle);
|
objc_msgSend(winHandle, sel_registerName("makeKeyAndOrderFront:"), appHandle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user