Fix obvious indenting errors after removal of old code

... by commit e0405d2135
This commit is contained in:
Albrecht Schlosser 2026-02-01 18:17:13 +01:00
parent e0405d2135
commit 26387c3538
3 changed files with 117 additions and 117 deletions

View File

@ -1950,17 +1950,17 @@ static int input_method_startup()
static int retval = -1; // -1: not initialized, 0: not usable, 1: ready for use
if (retval == -1) {
fl_open_display();
// These symbols require 10.5. They are no longer visible in Apple doc.
// They do exist in Carbon.framework --> HIToolbox.framework --> TextServices.h
TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_Darwin_System_Driver::get_carbon_function("TSMGetActiveDocument");
TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMSetDocumentProperty");
TSMRemoveDocumentProperty = (TSMRemoveDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMRemoveDocumentProperty");
// These symbols are no longer visible in Apple doc.
// They do exist in Carbon.framework --> HIToolbox.framework --> TextInputSources.h
TISCreateInputSourceList = (TISCreateInputSourceList_type)Fl_Darwin_System_Driver::get_carbon_function("TISCreateInputSourceList");
kTISTypeKeyboardLayout = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISTypeKeyboardLayout");
kTISPropertyInputSourceType = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISPropertyInputSourceType");
retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateInputSourceList && kTISTypeKeyboardLayout && kTISPropertyInputSourceType ? 1 : 0);
// These symbols require 10.5. They are no longer visible in Apple doc.
// They do exist in Carbon.framework --> HIToolbox.framework --> TextServices.h
TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_Darwin_System_Driver::get_carbon_function("TSMGetActiveDocument");
TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMSetDocumentProperty");
TSMRemoveDocumentProperty = (TSMRemoveDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMRemoveDocumentProperty");
// These symbols are no longer visible in Apple doc.
// They do exist in Carbon.framework --> HIToolbox.framework --> TextInputSources.h
TISCreateInputSourceList = (TISCreateInputSourceList_type)Fl_Darwin_System_Driver::get_carbon_function("TISCreateInputSourceList");
kTISTypeKeyboardLayout = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISTypeKeyboardLayout");
kTISPropertyInputSourceType = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISPropertyInputSourceType");
retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateInputSourceList && kTISTypeKeyboardLayout && kTISPropertyInputSourceType ? 1 : 0);
}
return retval;
}
@ -1970,8 +1970,8 @@ void Fl_Cocoa_Screen_Driver::enable_im() {
im_enabled = 1;
((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL;
[NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate]
((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL;
[NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate]
}
void Fl_Cocoa_Screen_Driver::disable_im() {
@ -1979,8 +1979,8 @@ void Fl_Cocoa_Screen_Driver::disable_im() {
im_enabled = 0;
((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL;
[NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate]
((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL;
[NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate]
}
@ -4246,41 +4246,41 @@ static void createAppleMenu(void)
[print_with_titlebar_item setState:NSControlStateValueOn];
[print_with_titlebar_item setEnabled:YES];
[appleMenu addItem:[NSMenuItem separatorItem]];
}
// Services Menu
services = [[NSMenu alloc] initWithTitle:@""];
menuItem = [appleMenu
addItemWithTitle:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::services], nil)
action:nil
keyEquivalent:@""];
[appleMenu setSubmenu:services forItem:menuItem];
[appleMenu addItem:[NSMenuItem separatorItem]];
// Hide AppName
title = [NSString stringWithFormat:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::hide],nil), nsappname];
[appleMenu addItemWithTitle:title
action:@selector(hide:)
keyEquivalent:@"h"];
// Hide Others
menuItem = [appleMenu
addItemWithTitle:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::hide_others] , nil)
action:@selector(hideOtherApplications:)
}
// Services Menu
services = [[NSMenu alloc] initWithTitle:@""];
menuItem = [appleMenu
addItemWithTitle:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::services], nil)
action:nil
keyEquivalent:@""];
[appleMenu setSubmenu:services forItem:menuItem];
[appleMenu addItem:[NSMenuItem separatorItem]];
// Hide AppName
title = [NSString stringWithFormat:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::hide],nil), nsappname];
[appleMenu addItemWithTitle:title
action:@selector(hide:)
keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
// Show All
[appleMenu addItemWithTitle:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::show], nil)
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
// Quit AppName
title = [NSString stringWithFormat:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::quit], nil),
nsappname];
menuItem = [appleMenu addItemWithTitle:title
action:@selector(terminate:)
keyEquivalent:@"q"];
[menuItem setTarget:about];
// Hide Others
menuItem = [appleMenu
addItemWithTitle:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::hide_others] , nil)
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
// Show All
[appleMenu addItemWithTitle:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::show], nil)
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
// Quit AppName
title = [NSString stringWithFormat:NSLocalizedString(
[NSString stringWithUTF8String:Fl_Mac_App_Menu::quit], nil),
nsappname];
menuItem = [appleMenu addItemWithTitle:title
action:@selector(terminate:)
keyEquivalent:@"q"];
[menuItem setTarget:about];
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
@ -4483,25 +4483,25 @@ static NSBitmapImageRep *scale_nsbitmapimagerep(NSBitmapImageRep *img, float sca
static void write_bitmap_inside(NSBitmapImageRep *to, int to_width, NSBitmapImageRep *from,
int to_x, int to_y)
/* Copies in bitmap "to" the bitmap "from" with its top-left angle at coordinates to_x, to_y
On retina displays both bitmaps have double width and height
to_width is the width in screen units of "to". On retina, its pixel width is twice that.
*/
/* Copies in bitmap "to" the bitmap "from" with its top-left angle at coordinates to_x, to_y
On retina displays both bitmaps have double width and height
to_width is the width in screen units of "to". On retina, its pixel width is twice that.
*/
{
const uchar *from_data = [from bitmapData];
// 10.4 required by the bitmapFormat message
if (([to bitmapFormat] & NSBitmapFormatAlphaFirst) &&
!([from bitmapFormat] & NSBitmapFormatAlphaFirst) ) {
// "to" is ARGB and "from" is RGBA --> convert "from" to ARGB
// it is enough to read "from" starting one byte earlier, because A is always 0xFF:
// RGBARGBA becomes (A)RGBARGB
from_data--;
} else if ( !([to bitmapFormat] & NSBitmapFormatAlphaFirst) && ([from bitmapFormat] & NSBitmapFormatAlphaFirst) ) {
// "from" is ARGB and "to" is RGBA --> convert "from" to RGBA
// it is enough to offset reading by one byte because A is always 0xFF
// so ARGBARGB becomes RGBARGB(A) as needed
from_data++;
}
if (([to bitmapFormat] & NSBitmapFormatAlphaFirst) &&
!([from bitmapFormat] & NSBitmapFormatAlphaFirst) ) {
// "to" is ARGB and "from" is RGBA --> convert "from" to ARGB
// it is enough to read "from" starting one byte earlier, because A is always 0xFF:
// RGBARGBA becomes (A)RGBARGB
from_data--;
} else if ( !([to bitmapFormat] & NSBitmapFormatAlphaFirst) && ([from bitmapFormat] & NSBitmapFormatAlphaFirst) ) {
// "from" is ARGB and "to" is RGBA --> convert "from" to RGBA
// it is enough to offset reading by one byte because A is always 0xFF
// so ARGBARGB becomes RGBARGB(A) as needed
from_data++;
}
int to_w = (int)[to pixelsWide]; // pixel width of "to"
int from_w = (int)[from pixelsWide]; // pixel width of "from"
int from_h = (int)[from pixelsHigh]; // pixel height of "from"
@ -4675,16 +4675,16 @@ static void nsbitmapProviderReleaseData (void *info, const void *data, size_t si
}
CGImageRef Fl_Cocoa_Window_Driver::CGImage_from_window_rect(int x, int y, int w, int h, bool capture_subwins)
/* Returns a capture of a rectangle of a mapped window as a CGImage.
With retina displays, the returned image has twice the width and height.
CFRelease the returned CGImageRef after use
*/
{
/* Returns a capture of a rectangle of a mapped window as a CGImage.
With retina displays, the returned image has twice the width and height.
CFRelease the returned CGImageRef after use
*/
CGImageRef img;
NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep_subwins(pWindow, x, y, w, h, capture_subwins);
img = (CGImageRef)[bitmap performSelector:@selector(CGImage)]; // requires Mac OS 10.5
CGImageRetain(img);
[bitmap release];
img = (CGImageRef)[bitmap performSelector:@selector(CGImage)]; // requires Mac OS 10.5
CGImageRetain(img);
[bitmap release];
return img;
}

View File

@ -478,18 +478,18 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int
if (factor != 1) {
w *= factor; h *= factor; x *= factor; y *= factor;
}
NSWindow *nswin = (NSWindow*)fl_mac_xid(pWindow);
CGImageRef img_full = Fl_Cocoa_Window_Driver::capture_decorated_window_10_5(nswin);
int bt = [nswin frame].size.height - [[nswin contentView] frame].size.height;
bt *= (factor / Fl_Graphics_Driver::default_driver().scale());
CGRect cgr = CGRectMake(x, y + bt, w, h); // add vertical offset to bypass titlebar
CGImageRef cgimg = CGImageCreateWithImageInRect(img_full, cgr); // 10.4
CGImageRelease(img_full);
Fl_RGB_Image *rgb = cgimage_to_rgb4(cgimg);
CGImageRelease(cgimg);
return rgb;
NSWindow *nswin = (NSWindow*)fl_mac_xid(pWindow);
CGImageRef img_full = Fl_Cocoa_Window_Driver::capture_decorated_window_10_5(nswin);
int bt = [nswin frame].size.height - [[nswin contentView] frame].size.height;
bt *= (factor / Fl_Graphics_Driver::default_driver().scale());
CGRect cgr = CGRectMake(x, y + bt, w, h); // add vertical offset to bypass titlebar
CGImageRef cgimg = CGImageCreateWithImageInRect(img_full, cgr); // 10.4
CGImageRelease(img_full);
Fl_RGB_Image *rgb = cgimage_to_rgb4(cgimg);
CGImageRelease(cgimg);
return rgb;
[(NSOpenGLContext*)glw->context() makeCurrentContext];
// to capture also the overlay and for directGL demo
// to capture also the overlay and for directGL demo
[(NSOpenGLContext*)glw->context() flushBuffer];
// Read OpenGL context pixels directly.
// For extra safety, save & restore OpenGL states that are changed

View File

@ -107,40 +107,41 @@ int Fl_Cocoa_Printer_Driver::begin_job (int pagecount, int *frompage, int *topag
OSStatus status = 0;
fl_open_display();
Fl_Cocoa_Window_Driver::q_release_context();
NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];
NSPrintPanel *panel = [NSPrintPanel printPanel];
//from 10.5
[panel setOptions:NSPrintPanelShowsCopies | NSPrintPanelShowsPageRange |
NSPrintPanelShowsPageSetupAccessory | NSPrintPanelShowsOrientation | NSPrintPanelShowsPaperSize];
NSInteger retval = -1;
Fl_Window *top = Fl::first_window();
NSWindow *main = (top ? (NSWindow*)fl_xid(top->top_window()) : nil);
if (main) {
[panel beginSheetWithPrintInfo:info
modalForWindow:main
delegate:[[[print_panel_delegate alloc] init] autorelease]
didEndSelector:@selector(printPanelDidEnd:returnCode:contextInfo:)
contextInfo:&retval];
while (retval < 0) Fl::wait(100);
[main makeKeyAndOrderFront:nil];
} else
retval = [panel runModalWithPrintInfo:info]; //from 10.5
NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];
NSPrintPanel *panel = [NSPrintPanel printPanel];
//from 10.5
[panel setOptions:NSPrintPanelShowsCopies | NSPrintPanelShowsPageRange |
NSPrintPanelShowsPageSetupAccessory | NSPrintPanelShowsOrientation | NSPrintPanelShowsPaperSize];
NSInteger retval = -1;
Fl_Window *top = Fl::first_window();
NSWindow *main = (top ? (NSWindow*)fl_xid(top->top_window()) : nil);
if (main) {
[panel beginSheetWithPrintInfo:info
modalForWindow:main
delegate:[[[print_panel_delegate alloc] init] autorelease]
didEndSelector:@selector(printPanelDidEnd:returnCode:contextInfo:)
contextInfo:&retval];
while (retval < 0) Fl::wait(100);
[main makeKeyAndOrderFront:nil];
} else {
retval = [panel runModalWithPrintInfo:info]; //from 10.5
}
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
const NSInteger NSModalResponseOK = NSOKButton;
const NSInteger NSModalResponseOK = NSOKButton;
#endif
if (retval != NSModalResponseOK) return 1;
printSession = (PMPrintSession)[info PMPrintSession];//from 10.5
pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5
printSettings = (PMPrintSettings)[info PMPrintSettings];//from 10.5
UInt32 from32, to32;
PMGetFirstPage(printSettings, &from32);
if (frompage) *frompage = (int)from32;
PMGetLastPage(printSettings, &to32);
if (topage) {
*topage = (int)to32;
if (*topage > pagecount && pagecount > 0) *topage = pagecount;
}
status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);//from 10.4
if (retval != NSModalResponseOK) return 1;
printSession = (PMPrintSession)[info PMPrintSession]; //from 10.5
pageFormat = (PMPageFormat)[info PMPageFormat]; //from 10.5
printSettings = (PMPrintSettings)[info PMPrintSettings];//from 10.5
UInt32 from32, to32;
PMGetFirstPage(printSettings, &from32);
if (frompage) *frompage = (int)from32;
PMGetLastPage(printSettings, &to32);
if (topage) {
*topage = (int)to32;
if (*topage > pagecount && pagecount > 0) *topage = pagecount;
}
status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);//from 10.4
if (status != noErr) {
if (perr_message) {
@ -167,8 +168,7 @@ void Fl_Cocoa_Printer_Driver::margins(int *left, int *top, int *right, int *bott
if (top) *top = (int)(margins.top / scale_y + 0.5);
if (right) *right = (int)(margins.right / scale_x + 0.5);
if (bottom) *bottom = (int)(margins.bottom / scale_y + 0.5);
}
else {
} else {
if (left) *left = (int)(margins.top / scale_x + 0.5);
if (top) *top = (int)(margins.left / scale_y + 0.5);
if (right) *right = (int)(margins.bottom / scale_x + 0.5);