mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-07 18:36:09 +08:00
remove more
This commit is contained in:
parent
43f0646be6
commit
8ef66ed41c
@ -20,9 +20,7 @@
|
||||
@end
|
||||
|
||||
#if !defined(C_SDL2)
|
||||
extern "C" void* sdl1_hax_stock_osx_menu(void);
|
||||
extern "C" void sdl1_hax_stock_osx_menu_additem(NSMenu *modme);
|
||||
extern "C" NSWindow *sdl1_hax_get_window(void);
|
||||
#endif
|
||||
|
||||
void *sdl_hax_nsMenuItemFromTag(void *nsMenu, unsigned int tag) {
|
||||
@ -75,12 +73,6 @@ void sdl_hax_macosx_setmenu(void *nsMenu) {
|
||||
/* switch to the menu object given */
|
||||
[NSApp setMainMenu:((NSMenu*)nsMenu)];
|
||||
}
|
||||
else {
|
||||
#if !defined(C_SDL2)
|
||||
/* switch back to the menu SDL 1.x made */
|
||||
[NSApp setMainMenu:((NSMenu*)sdl1_hax_stock_osx_menu())];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void sdl_hax_nsMenuItemSetTag(void *nsMenuItem, unsigned int new_id) {
|
||||
@ -131,12 +123,6 @@ void sdl_hax_nsMenuAddApplicationMenu(void *nsMenu) {
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int pause_menu_item_tag;
|
||||
extern bool is_paused;
|
||||
extern void PushDummySDL(void);
|
||||
extern bool MAPPER_IsRunning(void);
|
||||
extern bool GUI_IsRunning(void);
|
||||
|
||||
static DOSBoxMenu *altMenu = NULL;
|
||||
|
||||
void menu_osx_set_menuobj(DOSBoxMenu *new_altMenu) {
|
||||
@ -149,341 +135,11 @@ void menu_osx_set_menuobj(DOSBoxMenu *new_altMenu) {
|
||||
@implementation NSApplication (DOSBoxX)
|
||||
- (void)DOSBoxXMenuAction:(id)sender
|
||||
{
|
||||
if (altMenu != NULL) {
|
||||
if (altMenu != NULL)
|
||||
altMenu->mainMenuAction([sender tag]);
|
||||
}
|
||||
else {
|
||||
if ((is_paused && pause_menu_item_tag != [sender tag]) || MAPPER_IsRunning() || GUI_IsRunning()) return;
|
||||
/* sorry! */
|
||||
else
|
||||
mainMenu.mainMenuAction([sender tag]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)DOSBoxXMenuActionMapper:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
if (is_paused || MAPPER_IsRunning() || GUI_IsRunning()) return;
|
||||
extern void MAPPER_Run(bool pressed);
|
||||
MAPPER_Run(false);
|
||||
}
|
||||
|
||||
- (void)DOSBoxXMenuActionCapMouse:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
if (is_paused || MAPPER_IsRunning() || GUI_IsRunning()) return;
|
||||
extern void MapperCapCursorToggle(void);
|
||||
MapperCapCursorToggle();
|
||||
}
|
||||
|
||||
- (void)DOSBoxXMenuActionCfgGUI:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
if (is_paused || MAPPER_IsRunning() || GUI_IsRunning()) return;
|
||||
extern void GUI_Run(bool pressed);
|
||||
GUI_Run(false);
|
||||
}
|
||||
|
||||
- (void)DOSBoxXMenuActionPause:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
extern bool unpause_now;
|
||||
extern void PauseDOSBox(bool pressed);
|
||||
|
||||
if (MAPPER_IsRunning() || GUI_IsRunning()) return;
|
||||
|
||||
if (is_paused) {
|
||||
PushDummySDL();
|
||||
unpause_now = true;
|
||||
}
|
||||
else {
|
||||
PauseDOSBox(true);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
bool has_touch_bar_support = false;
|
||||
|
||||
bool osx_detect_nstouchbar(void) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
return (has_touch_bar_support = (NSClassFromString(@"NSTouchBar") != nil));
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
# if !defined(C_SDL2)
|
||||
extern "C" void sdl1_hax_make_touch_bar_set_callback(NSTouchBar* (*newcb)(NSWindow*));
|
||||
# endif
|
||||
|
||||
static NSTouchBarItemIdentifier TouchBarCustomIdentifier = @"com.dosbox-x.touchbar.custom";
|
||||
static NSTouchBarItemIdentifier TouchBarMapperIdentifier = @"com.dosbox-x.touchbar.mapper";
|
||||
static NSTouchBarItemIdentifier TouchBarCFGGUIIdentifier = @"com.dosbox-x.touchbar.cfggui";
|
||||
static NSTouchBarItemIdentifier TouchBarHostKeyIdentifier = @"com.dosbox-x.touchbar.hostkey";
|
||||
static NSTouchBarItemIdentifier TouchBarPauseIdentifier = @"com.dosbox-x.touchbar.pause";
|
||||
static NSTouchBarItemIdentifier TouchBarCursorCaptureIdentifier = @"com.dosbox-x.touchbar.capcursor";
|
||||
|
||||
@interface DOSBoxXTouchBarDelegate : NSViewController
|
||||
@end
|
||||
|
||||
@interface DOSBoxXTouchBarDelegate () <NSTouchBarDelegate,NSTextViewDelegate>
|
||||
@end
|
||||
|
||||
@interface DOSBoxHostButton : NSButton
|
||||
@end
|
||||
#endif
|
||||
|
||||
extern void ext_signal_host_key(bool enable);
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
@implementation DOSBoxHostButton
|
||||
- (void)touchesBeganWithEvent:(NSEvent*)event
|
||||
{
|
||||
fprintf(stderr,"Host key down\n");
|
||||
ext_signal_host_key(true);
|
||||
[super touchesBeganWithEvent:event];
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent*)event
|
||||
{
|
||||
fprintf(stderr,"Host key up\n");
|
||||
ext_signal_host_key(false);
|
||||
[super touchesEndedWithEvent:event];
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent*)event
|
||||
{
|
||||
fprintf(stderr,"Host key cancelled\n");
|
||||
ext_signal_host_key(false);
|
||||
[super touchesEndedWithEvent:event];
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
@implementation DOSBoxXTouchBarDelegate
|
||||
- (void)onHostKey:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
fprintf(stderr,"HostKey\n");
|
||||
}
|
||||
|
||||
- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
|
||||
(void)touchBar;
|
||||
|
||||
if ([identifier isEqualToString:TouchBarMapperIdentifier]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:TouchBarMapperIdentifier];
|
||||
|
||||
item.view = [NSButton buttonWithTitle:@"Mapper" target:NSApp action:@selector(DOSBoxXMenuActionMapper:)];
|
||||
item.customizationLabel = TouchBarCustomIdentifier;
|
||||
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:TouchBarHostKeyIdentifier]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:TouchBarHostKeyIdentifier];
|
||||
|
||||
item.view = [DOSBoxHostButton buttonWithTitle:@"Host Key" target:self action:@selector(onHostKey:)];
|
||||
item.customizationLabel = TouchBarCustomIdentifier;
|
||||
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:TouchBarCFGGUIIdentifier]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:TouchBarCFGGUIIdentifier];
|
||||
|
||||
item.view = [NSButton buttonWithTitle:@"Cfg GUI" target:NSApp action:@selector(DOSBoxXMenuActionCfgGUI:)];
|
||||
item.customizationLabel = TouchBarCustomIdentifier;
|
||||
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:TouchBarPauseIdentifier]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:TouchBarPauseIdentifier];
|
||||
|
||||
item.view = [NSButton buttonWithImage:[NSImage imageNamed:NSImageNameTouchBarPauseTemplate] target:NSApp action:@selector(DOSBoxXMenuActionPause:)];
|
||||
item.customizationLabel = TouchBarCustomIdentifier;
|
||||
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:TouchBarCursorCaptureIdentifier]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:TouchBarCursorCaptureIdentifier];
|
||||
|
||||
item.view = [NSButton buttonWithTitle:@"CapMouse" target:NSApp action:@selector(DOSBoxXMenuActionCapMouse:)];
|
||||
item.customizationLabel = TouchBarCustomIdentifier;
|
||||
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"Touch bar warning, unknown item '%s'\n",[identifier UTF8String]);
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
void osx_reload_touchbar(void) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
NSWindow *wnd = nil;
|
||||
|
||||
# if !defined(C_SDL2)
|
||||
wnd = sdl1_hax_get_window();
|
||||
# endif
|
||||
|
||||
if (wnd != nil) {
|
||||
[wnd setTouchBar:nil];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
NSTouchBar* osx_on_make_touch_bar(NSWindow *wnd) {
|
||||
(void)wnd;
|
||||
|
||||
NSTouchBar* touchBar = [[NSTouchBar alloc] init];
|
||||
touchBar.delegate = [DOSBoxXTouchBarDelegate alloc];
|
||||
|
||||
touchBar.customizationIdentifier = TouchBarCustomIdentifier;
|
||||
if (GUI_IsRunning()) {
|
||||
touchBar.defaultItemIdentifiers = @[
|
||||
NSTouchBarItemIdentifierOtherItemsProxy
|
||||
];
|
||||
}
|
||||
else if (MAPPER_IsRunning()) {
|
||||
touchBar.defaultItemIdentifiers = @[
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge, // try to keep the user from hitting the ESC button accidentally when reaching for Host Key
|
||||
TouchBarHostKeyIdentifier,
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge,
|
||||
NSTouchBarItemIdentifierOtherItemsProxy
|
||||
];
|
||||
}
|
||||
else {
|
||||
touchBar.defaultItemIdentifiers = @[
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge, // try to keep the user from hitting the ESC button accidentally when reaching for Host Key
|
||||
TouchBarHostKeyIdentifier,
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge,
|
||||
TouchBarPauseIdentifier,
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge,
|
||||
TouchBarCursorCaptureIdentifier,
|
||||
NSTouchBarItemIdentifierFixedSpaceLarge,
|
||||
TouchBarMapperIdentifier,
|
||||
TouchBarCFGGUIIdentifier,
|
||||
NSTouchBarItemIdentifierOtherItemsProxy
|
||||
];
|
||||
}
|
||||
|
||||
touchBar.customizationAllowedItemIdentifiers = @[
|
||||
TouchBarHostKeyIdentifier,
|
||||
TouchBarMapperIdentifier,
|
||||
TouchBarCFGGUIIdentifier,
|
||||
TouchBarCursorCaptureIdentifier,
|
||||
TouchBarPauseIdentifier
|
||||
];
|
||||
|
||||
// Do not mark as principal, it just makes the button centered in the touch bar
|
||||
// touchBar.principalItemIdentifier = TouchBarMapperIdentifier;
|
||||
|
||||
return touchBar;
|
||||
}
|
||||
#endif
|
||||
|
||||
void osx_init_touchbar(void) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202/* touch bar interface appeared in 10.12.2+ according to Apple */
|
||||
# if !defined(C_SDL2)
|
||||
if (has_touch_bar_support)
|
||||
sdl1_hax_make_touch_bar_set_callback(osx_on_make_touch_bar);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(C_SDL2)
|
||||
extern "C" void sdl1_hax_set_dock_menu(NSMenu *menu);
|
||||
#endif
|
||||
|
||||
void osx_init_dock_menu(void) {
|
||||
#if !defined(C_SDL2)
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
{
|
||||
NSString *title = [[NSString alloc] initWithUTF8String: "Mapper"];
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(DOSBoxXMenuActionMapper:) keyEquivalent:@""];
|
||||
[menu addItem:item];
|
||||
[title release];
|
||||
[item release];
|
||||
}
|
||||
|
||||
{
|
||||
NSString *title = [[NSString alloc] initWithUTF8String: "Configuration GUI"];
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(DOSBoxXMenuActionCfgGUI:) keyEquivalent:@""];
|
||||
[menu addItem:item];
|
||||
[title release];
|
||||
[item release];
|
||||
}
|
||||
|
||||
{
|
||||
NSMenuItem *item = [NSMenuItem separatorItem];
|
||||
[menu addItem:item];
|
||||
[item release];
|
||||
}
|
||||
|
||||
{
|
||||
NSString *title = [[NSString alloc] initWithUTF8String: "Pause"];
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(DOSBoxXMenuActionPause:) keyEquivalent:@""];
|
||||
[menu addItem:item];
|
||||
[title release];
|
||||
[item release];
|
||||
}
|
||||
|
||||
sdl1_hax_set_dock_menu(menu);
|
||||
|
||||
[menu release];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(C_SDL2)
|
||||
extern "C" int sdl1_hax_macosx_window_to_monitor_and_update(CGDirectDisplayID *did);
|
||||
#endif
|
||||
|
||||
int my_quartz_match_window_to_monitor(CGDirectDisplayID *new_id,NSWindow *wnd);
|
||||
|
||||
int my_quartz_match_window_to_monitor(CGDirectDisplayID *new_id,NSWindow *wnd) {
|
||||
if (wnd != nil) {
|
||||
CGError err;
|
||||
uint32_t cnt = 1;
|
||||
CGDirectDisplayID did = 0;
|
||||
NSRect rct = [wnd frame];
|
||||
NSPoint pt = [wnd convertPointToScreen:NSMakePoint(rct.size.width / 2, rct.size.height / 2)];
|
||||
|
||||
{
|
||||
/* Eugh this ugliness wouldn't be necessary if we didn't have to fudge relative to primary display. */
|
||||
CGRect prct = CGDisplayBounds(CGMainDisplayID());
|
||||
pt.y = (prct.origin.y + prct.size.height) - pt.y;
|
||||
}
|
||||
|
||||
err = CGGetDisplaysWithPoint(pt,1,&did,&cnt);
|
||||
|
||||
/* This might happen if our window is so far off the screen that the center point does not match any monitor */
|
||||
if (err != kCGErrorSuccess) {
|
||||
err = kCGErrorSuccess;
|
||||
did = CGMainDisplayID(); /* Can't fail, eh, Apple? OK then. */
|
||||
}
|
||||
|
||||
if (err == kCGErrorSuccess) {
|
||||
*new_id = did;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !defined(C_SDL2)
|
||||
extern "C" int (*sdl1_hax_quartz_match_window_to_monitor)(CGDirectDisplayID *new_id,NSWindow *wnd);
|
||||
#endif
|
||||
|
||||
void qz_set_match_monitor_cb(void) {
|
||||
#if !defined(C_SDL2)
|
||||
sdl1_hax_quartz_match_window_to_monitor = my_quartz_match_window_to_monitor;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -339,11 +339,6 @@ static GUI::ScreenSDL *UI_Startup(GUI::ScreenSDL *screen) {
|
||||
render.src.bpp = 0;
|
||||
running = true;
|
||||
|
||||
#if defined(MACOSX)
|
||||
void osx_reload_touchbar(void);
|
||||
osx_reload_touchbar();
|
||||
#endif
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
@ -356,11 +351,6 @@ static void UI_Shutdown(GUI::ScreenSDL *screen) {
|
||||
DOSBox_SetMenu(mainMenu);
|
||||
#endif
|
||||
|
||||
#if defined(MACOSX)
|
||||
void osx_reload_touchbar(void);
|
||||
osx_reload_touchbar();
|
||||
#endif
|
||||
|
||||
#if defined(C_SDL2)
|
||||
// fade in
|
||||
// Jonathan C: do it FASTER!
|
||||
|
@ -3449,11 +3449,6 @@ void MAPPER_RunInternal() {
|
||||
DOSBox_SetMenu(mapperMenu);
|
||||
#endif
|
||||
|
||||
#if defined(MACOSX)
|
||||
void osx_reload_touchbar(void);
|
||||
osx_reload_touchbar();
|
||||
#endif
|
||||
|
||||
/* Go in the event loop */
|
||||
mapper.exit=false;
|
||||
mapper.redraw=true;
|
||||
@ -3524,11 +3519,6 @@ void MAPPER_RunInternal() {
|
||||
|
||||
mapper.running = false;
|
||||
|
||||
#if defined(MACOSX)
|
||||
void osx_reload_touchbar(void);
|
||||
osx_reload_touchbar();
|
||||
#endif
|
||||
|
||||
#ifdef DOSBOXMENU_EXTERNALLY_MANAGED
|
||||
DOSBox_SetMenu(mainMenu);
|
||||
#endif
|
||||
|
@ -138,9 +138,7 @@ typedef enum PROCESS_DPI_AWARENESS {
|
||||
#include "sdlmain.h"
|
||||
|
||||
#ifdef MACOSX
|
||||
extern bool has_touch_bar_support;
|
||||
bool osx_detect_nstouchbar(void);
|
||||
void osx_init_touchbar(void);
|
||||
#endif
|
||||
|
||||
SDL_Block sdl;
|
||||
@ -5893,20 +5891,6 @@ int main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT {
|
||||
Windows_DPI_Awareness_Init();
|
||||
#endif
|
||||
|
||||
#ifdef MACOSX
|
||||
osx_detect_nstouchbar();/*assigns to has_touch_bar_support*/
|
||||
if (has_touch_bar_support) {
|
||||
LOG_MSG("Mac OS X: NSTouchBar support detected in system");
|
||||
osx_init_touchbar();
|
||||
}
|
||||
|
||||
extern void osx_init_dock_menu(void);
|
||||
osx_init_dock_menu();
|
||||
|
||||
void qz_set_match_monitor_cb(void);
|
||||
qz_set_match_monitor_cb();
|
||||
#endif
|
||||
|
||||
/* -- SDL init */
|
||||
if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE) >= 0)
|
||||
sdl.inited = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user