| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program 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 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * 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 program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef LNXAPP_H |
| 20 | #define LNXAPP_H |
| 21 | |
| 22 | #if defined(POSIX) |
| 23 | #include "linux_fix.h" |
| 24 | #endif |
| 25 | |
| 26 | // if no-display/input specifier is given, it will use defaults |
| 27 | #define APPFLAG_USESERVICE 0x00000100 // console (run no output/input) |
| 28 | #define APPFLAG_USESVGA 0x00000200 // console (use svgalib for input/output. NOTE: not used in code) |
| 29 | #define APPFLAG_NOMOUSECAPTURE 0x00000400 // don't capture the mouse in x-win |
| 30 | #define APPFLAG_NOSHAREDMEMORY 0x00000800 // force no-shared memory |
| 31 | #define APPFLAG_WINDOWEDMODE 0x00001000 // run in a window |
| 32 | #define APPFLAG_DGAMOUSE 0x00002000 // use DGA for Mouse |
| 33 | |
| 34 | /* Basic Application Linux data types */ |
| 35 | |
| 36 | // This structure is used to retrieve and set |
| 37 | struct tLnxAppInfo { |
| 38 | unsigned flags; // Application Flags |
| 39 | int wnd_x, wnd_y, wnd_w, wnd_h; // Window dimensions |
| 40 | }; |
| 41 | |
| 42 | /* Linux Application Object |
| 43 | This object entails initialization and cleanup of all operating system |
| 44 | elements, as well as data that libraries may need to initialize their |
| 45 | systems. |
| 46 | |
| 47 | We also allow the option of setting these handles from outside the Application object. |
| 48 | */ |
| 49 | |
| 50 | /* Callbacks return a 0 if we don't want to call the default action for the message, otherwise return 1 |
| 51 | */ |
| 52 | // typedef int (*tOELnxMsgCallback)(HWnd,unsigned,unsigned,unsigned); |
| 53 | |
| 54 | class oeLnxApplication : public oeApplication { |
| 55 | bool m_WasCreated; // Tells us if this app set graphics or not. |
| 56 | void (*m_DeferFunc)(bool idle); // function to call when deffering to OS |
| 57 | static bool os_initialized; // is the OS check initialized? |
| 58 | static bool first_time; // first time init? |
| 59 | public: |
| 60 | // Creates the application object |
| 61 | oeLnxApplication(unsigned flags); |
| 62 | // Create object with a premade info |
| 63 | oeLnxApplication(tLnxAppInfo *appinfo); |
| 64 | virtual ~oeLnxApplication(); |
| 65 | // initializes the object |
| 66 | virtual void init(); |
| 67 | // Function to retrieve information from object through a platform defined structure. |
| 68 | virtual void get_info(void *appinfo); |
| 69 | // defer returns some flags. essentially this function defers program control to OS. |
| 70 | virtual unsigned defer(); |
| 71 | virtual const char *get_window_name(void); |
| 72 | virtual void clear_window(void); |
| 73 | // set a function to run when deferring to OS. |
| 74 | virtual void set_defer_handler(void (*func)(bool isactive)); |
| 75 | // delays app for a certain amount of time |
| 76 | virtual void delay(float secs); |
| 77 | // Sizes the displayable region of the app (the window) |
| 78 | void set_sizepos(int x, int y, int w, int h); |
| 79 | |
| 80 | virtual int flags(void) const; |
| 81 | |
| 82 | unsigned m_Flags; |
| 83 | int m_X, m_Y, m_W, m_H; // window dimensions. |
| 84 | private: |
| 85 | void os_init(); // initializes OS components. |
| 86 | }; |
| 87 | |
| 88 | #endif |