| 1 | /* melder.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2018,2020,2021,2024 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "melder.h" |
| 20 | |
| 21 | #include "enums_getText.h" |
| 22 | #include "melder_enums.h" |
| 23 | #include "enums_getValue.h" |
| 24 | #include "melder_enums.h" |
| 25 | |
| 26 | #include "../dwsys/NUMmachar.h" |
| 27 | #include "../external/gsl/gsl_errno.h" |
| 28 | #ifdef macintosh |
| 29 | #include <Carbon/Carbon.h> // Gestalt |
| 30 | #endif |
| 31 | |
| 32 | void Melder_init () { |
| 33 | NUMmachar (); |
| 34 | gsl_set_error_handler_off (); |
| 35 | NUMrandom_initializeSafelyAndUnpredictably (); |
| 36 | Melder_alloc_init (); |
| 37 | Melder_audiofiles_init (); |
| 38 | #ifdef macintosh |
| 39 | NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; |
| 40 | Melder_systemVersion = version. majorVersion * 10000 + version. minorVersion * 100 + version. patchVersion; |
| 41 | #endif |
| 42 | #ifdef linux |
| 43 | const char *gdkBackend = getenv ("GDK_BACKEND"); // this setting rules all the others; GDK typically supports wayland, x11, and broadway |
| 44 | if (gdkBackend) { |
| 45 | if (strequ (gdkBackend, "wayland")) |
| 46 | Melder_systemVersion = 'w'; |
| 47 | else |
| 48 | Melder_systemVersion = 0; |
| 49 | } else { |
| 50 | const char *waylandDisplay = getenv ("WAYLAND_DISPLAY"); |
| 51 | const char *gdkSessionType = getenv ("XDG_SESSION_TYPE"); // not set on Chrome (2021-11-12); typical values are wayland, x11 and tty |
| 52 | if (waylandDisplay || gdkSessionType && strstr (gdkSessionType, "wayland")) |
| 53 | Melder_systemVersion = 'w'; |
| 54 | else |
| 55 | Melder_systemVersion = 0; |
| 56 | } |
| 57 | #endif |
| 58 | } |
| 59 | |
| 60 | /* End of file melder.cpp */ |