├── .editorconfig ├── .gitignore ├── DirectWindowTest ├── LICENSE ├── README.md ├── Test.cpp ├── Test.h ├── Test.rdef ├── TestWindow.cpp ├── TestWindow.h ├── makefile └── screenshot.png ├── DragDrop ├── DragDrop.cpp ├── Makefile ├── README.md └── screenshot.png ├── EGLTest ├── EGLTest.c ├── README.md ├── Window.cpp └── makefile ├── EGLTest2 ├── BitmapHook.h ├── BitmapHookView.cpp ├── BitmapHookView.h ├── GlApp.cpp ├── GlApp.h ├── MinApp.cpp ├── MinApp.h └── meson.build ├── Editor ├── Makefile ├── MinApp.cpp ├── README.md └── screenshot.png ├── Handles ├── Handles.cpp ├── Makefile ├── README.md └── screenshot.png ├── I2cTabletDevice ├── README.md ├── TabletDevice.cpp ├── TabletDevice.h ├── _APP_ ├── devices └── makefile ├── LICENSE ├── MenuDynItems ├── Makefile └── MenuDynItems.cpp ├── MinApp ├── Makefile ├── MinApp.cpp ├── README.md └── screenshot.png ├── MsgDump ├── Fields ├── MsgDump.cpp ├── MsgDump.h ├── MsgDump.rdef ├── README.md ├── makefile └── screenshot.png ├── OSMesaDriver ├── README.md ├── SoftwareRenderer.cpp ├── SoftwareRenderer.h ├── makefile └── opengl ├── OpenGLTest ├── OpenGLTest.rdef ├── README.md ├── SampleGLApp.cpp ├── SampleGLApp.h ├── SampleGLView.cpp ├── SampleGLView.h ├── SampleGLWindow.cpp ├── SampleGLWindow.h ├── makefile └── screenshot.png ├── OpenGLTest2 ├── OpenGLTest.rdef ├── README.md ├── SampleGLApp.cpp ├── SampleGLApp.h ├── SampleGLView.cpp ├── SampleGLView.h ├── SampleGLWindow.cpp ├── SampleGLWindow.h ├── makefile └── screenshot.png ├── PictureDump ├── Makefile ├── PictureDump.cpp └── README.md ├── PictureDumpJson ├── PictureDump.cpp ├── README.md └── meson.build ├── PictureView ├── Makefile ├── PictureView.cpp ├── PictureView.rdef ├── Placeholder ├── README.md └── screenshot.png ├── Promises ├── CredentialsApp.cpp ├── CredentialsWindow.cpp ├── CredentialsWindow.h ├── Promises.cpp ├── Promises.h ├── README.md ├── Tests.cpp ├── meson.build └── screenshot.png ├── README.md ├── ScreenKeyboard ├── KeyboardDevice.cpp ├── KeyboardDevice.h ├── KeyboardHandler.cpp ├── KeyboardHandler.h ├── KeyboardWindow.cpp ├── KeyboardWindow.h ├── README.md ├── ToggleKeyboard ├── Translation.cpp ├── _APP_ ├── devices ├── makefile └── screenshot.png ├── Services ├── Icons │ ├── Delete │ ├── Pause │ ├── Restart │ ├── Start │ └── Stop ├── Makefile ├── README.md ├── Resources.h ├── Services.cpp ├── Services.rdef └── screenshot.png ├── StackTrace ├── Makefile ├── README.md └── StackTrace.cpp ├── SystemManager ├── Docu ├── Errors.cpp ├── Errors.h ├── Makefile ├── Old.cpp ├── README.md ├── Screenshot.png ├── ScreenshotStack.png ├── ScreenshotTeam.png ├── StackWindow.cpp ├── StackWindow.h ├── SystemManager.cpp ├── SystemManager.rdef ├── TeamWindow.cpp ├── TeamWindow.h ├── UIUtils.cpp ├── UIUtils.h ├── Utils.cpp └── Utils.h ├── TabbedWindows ├── Makefile ├── MinApp.cpp ├── README.md └── screenshot.png ├── TraverseApps ├── README.md ├── TraverseApps.cpp └── makefile ├── TraverseApps2 ├── HighlightRect.cpp ├── HighlightRect.h ├── Icons │ ├── Highlight │ └── Target ├── Makefile ├── README.md ├── Resources.h ├── ScriptingUtils.cpp ├── ScriptingUtils.h ├── SuiteEditor.cpp ├── SuiteEditor.h ├── TraverseApps.cpp ├── TraverseApps.rdef └── screenshot.png ├── Users ├── GroupForm.cpp ├── GroupForm.h ├── Icons │ ├── Add.hvif │ ├── Edit.hvif │ ├── Remove.hvif │ └── Settings.hvif ├── Makefile ├── PasswordForm.cpp ├── PasswordForm.h ├── README.md ├── Resources.h ├── UIUtils.cpp ├── UIUtils.h ├── UserDB.cpp ├── UserDB.h ├── UserForm.cpp ├── UserForm.h ├── Users.cpp ├── Users.rdef └── screenshot.png ├── VideoEncoder ├── Makefile ├── README.md ├── VideoEncoder.cpp └── output.mp4 ├── libGL ├── GLRenderer.cpp ├── GLRenderer.h ├── GLRendererRoster.cpp ├── GLRendererRoster.h ├── GLView.cpp ├── GLView.h └── Makefile └── libGL2 ├── GLRenderer.cpp ├── GLRenderer.h ├── GLView.cpp ├── GLView.h ├── Makefile └── README.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = tab 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | objects.* 2 | build.* 3 | *.log 4 | -------------------------------------------------------------------------------- /DirectWindowTest/LICENSE: -------------------------------------------------------------------------------- 1 | ---------------------- 2 | Be Sample Code License 3 | ---------------------- 4 | 5 | Copyright 1991-1999, Be Incorporated. 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright 13 | notice, this list of conditions, and the following disclaimer. 14 | 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions, and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | 3. The name of the author may not be used to endorse or promote products 20 | derived from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 23 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 | OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /DirectWindowTest/README.md: -------------------------------------------------------------------------------- 1 | DirectWindowTest 2 | 3 | Based on game_kit/Stars of Be sample code. 4 | Tests BDirectWindow output. 5 | 6 | Keyboard shortcuts: 7 | 8 | Alt+F: full screen 9 | 10 | 1: no synchronization 11 | 12 | 2: 60 Hz timer 13 | 14 | 3: vsync 15 | 16 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/DirectWindowTest/screenshot.png) 17 | -------------------------------------------------------------------------------- /DirectWindowTest/Test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Test.cpp 4 | 5 | by Pierre Raynaud-Richard. 6 | 7 | */ 8 | 9 | /* 10 | Copyright 1999, Be Incorporated. All Rights Reserved. 11 | This file may be used under the terms of the Be Sample Code License. 12 | */ 13 | 14 | #include "TestWindow.h" 15 | #include "Test.h" 16 | 17 | int main() 18 | { 19 | TestApp myApplication; 20 | 21 | if (!myApplication.abort_required) 22 | myApplication.Run(); 23 | return 0; 24 | } 25 | 26 | TestApp::TestApp() : BApplication("application/x-vnd.Test-DirectWindow") 27 | { 28 | abort_required = false; 29 | aWindow = new TestWindow(BRect(120, 150, 120 + 512, 150 + 512), "DirectWindow Test"); 30 | // showing the window will also start the direct connection. If you 31 | // Sync() after the show, the direct connection will be established 32 | // when the Sync() return (as far as any part of the content area of 33 | // the window is visible after the show). 34 | if (!abort_required) 35 | aWindow->Show(); 36 | } 37 | -------------------------------------------------------------------------------- /DirectWindowTest/Test.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Test.h 4 | 5 | by Pierre Raynaud-Richard. 6 | 7 | */ 8 | 9 | /* 10 | Copyright 1999, Be Incorporated. All Rights Reserved. 11 | This file may be used under the terms of the Be Sample Code License. 12 | */ 13 | 14 | #ifndef TEST_H 15 | #define TEST_H 16 | 17 | #include 18 | #include "TestWindow.h" 19 | 20 | class TestApp : public BApplication { 21 | public: 22 | TestApp(); 23 | bool abort_required; 24 | private: 25 | TestWindow *aWindow; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /DirectWindowTest/Test.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Test-DirectWindow"; 2 | 3 | resource app_version { 4 | major = 0, 5 | middle = 0, 6 | minor = 0, 7 | 8 | variety = B_APPV_DEVELOPMENT, 9 | internal = 0, 10 | 11 | short_info = "", 12 | long_info = "" 13 | }; 14 | 15 | resource app_flags B_SINGLE_LAUNCH; 16 | -------------------------------------------------------------------------------- /DirectWindowTest/TestWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TestWindow.h 4 | 5 | by Pierre Raynaud-Richard. 6 | 7 | */ 8 | 9 | /* 10 | Copyright 1999, Be Incorporated. All Rights Reserved. 11 | This file may be used under the terms of the Be Sample Code License. 12 | */ 13 | 14 | #ifndef TEST_WINDOW_H 15 | #define TEST_WINDOW_H 16 | 17 | #include 18 | 19 | #include 20 | 21 | 22 | class TestWindow : public BDirectWindow { 23 | public: 24 | // standard constructor and destrcutor 25 | TestWindow(BRect frame, const char *name); 26 | virtual ~TestWindow(); 27 | 28 | // standard window member 29 | virtual bool QuitRequested(); 30 | virtual void MessageReceived(BMessage *message); 31 | 32 | // this is the hook controling direct screen connection 33 | virtual void DirectConnected(direct_buffer_info *info); 34 | 35 | private: 36 | // this function is used to inforce a direct access context 37 | // modification. 38 | void SwitchContext(direct_buffer_info *info); 39 | 40 | void FillRect(int32 l, int32 t, int32 r, int32 b, int32 c); 41 | 42 | static status_t DrawingThread(void *data); 43 | void DrawFrame(); 44 | 45 | enum { 46 | noSync = 1, 47 | timerSync = 2, 48 | vSync = 3, 49 | // used for the local copy of the clipping region 50 | MAX_CLIPPING_RECT_COUNT = 256 51 | }; 52 | 53 | 54 | // flag used to force the drawing thread to quit. 55 | bool kill_my_thread; 56 | // the drawing thread doing the star animation. 57 | thread_id my_thread; 58 | // used to synchronise the star animation drawing. 59 | sem_id drawing_lock; 60 | 61 | int32 syncMode; 62 | 63 | // the pixel drawing can be done in 3 depth : 8, 16 or 32. 64 | int32 pixel_depth; 65 | 66 | void *bits; 67 | // base pointer of the screen, one per pixel_depth 68 | uint8 *draw_ptr8; 69 | uint16 *draw_ptr16; 70 | uint32 *draw_ptr32; 71 | 72 | // offset, in bytes, between two lines of the frame buffer. 73 | int32 stride; 74 | 75 | // clipping region, defined as a list of rectangle, including the 76 | // smaller possible bounding box. This application will draw only 77 | // in the 64 first rectangles of the region. Region more complex 78 | // than that won't be completly used. This is a valid approximation 79 | // with the current clipping architecture. If a region more complex 80 | // than that is passed to your application, that just means that 81 | // the user is doing something really, really weird. 82 | clipping_rect window_bound; 83 | clipping_rect clipping_bound; 84 | clipping_rect clipping_list[MAX_CLIPPING_RECT_COUNT]; 85 | uint32 clipping_list_count; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /DirectWindowTest/makefile: -------------------------------------------------------------------------------- 1 | ## BeOS Generic Makefile v2.0 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## makefile-engine will do all of the hard work for you. This handles both 5 | ## Intel and PowerPC builds of the BeOS. 6 | 7 | ## Application Specific Settings --------------------------------------------- 8 | 9 | # specify the name of the binary 10 | NAME= DirectWindowTest 11 | 12 | # specify the type of binary 13 | # APP: Application 14 | # SHARED: Shared library or add-on 15 | # STATIC: Static library archive 16 | # DRIVER: Kernel Driver 17 | TYPE= APP 18 | 19 | # specify the source files to use 20 | # full paths or paths relative to the makefile can be included 21 | # all files, regardless of directory, will have their object 22 | # files created in the common object directory. 23 | # Note that this means this makefile will not work correctly 24 | # if two source files with the same name (source.c or source.cpp) 25 | # are included from different directories. Also note that spaces 26 | # in folder names do not work well with this makefile. 27 | SRCS= Test.cpp \ 28 | TestWindow.cpp 29 | 30 | # specify the resource files to use 31 | # full path or a relative path to the resource file can be used. 32 | RDEFS= Test.rdef 33 | 34 | # specify additional libraries to link against 35 | # there are two acceptable forms of library specifications 36 | # - if your library follows the naming pattern of: 37 | # libXXX.so or libXXX.a you can simply specify XXX 38 | # library: libbe.so entry: be 39 | # 40 | # - if your library does not follow the standard library 41 | # naming scheme you need to specify the path to the library 42 | # and it's name 43 | # library: my_lib.a entry: my_lib.a or path/my_lib.a 44 | LIBS= $(STDCPPLIBS) be game 45 | 46 | # specify additional paths to directories following the standard 47 | # libXXX.so or libXXX.a naming scheme. You can specify full paths 48 | # or paths relative to the makefile. The paths included may not 49 | # be recursive, so include all of the paths where libraries can 50 | # be found. Directories where source files are found are 51 | # automatically included. 52 | LIBPATHS= 53 | 54 | # additional paths to look for system headers 55 | # thes use the form: #include
56 | # source file directories are NOT auto-included here 57 | SYSTEM_INCLUDE_PATHS = 58 | 59 | # additional paths to look for local headers 60 | # thes use the form: #include "header" 61 | # source file directories are automatically included 62 | LOCAL_INCLUDE_PATHS = 63 | 64 | # specify the level of optimization that you desire 65 | # NONE, SOME, FULL 66 | OPTIMIZE= 67 | 68 | # specify any preprocessor symbols to be defined. The symbols 69 | # will be set to a value of 1. For example specify DEBUG if you want 70 | # DEBUG=1 to be set when compiling. 71 | DEFINES= 72 | 73 | # specify special warning levels 74 | # if unspecified default warnings will be used 75 | # NONE = supress all warnings 76 | # ALL = enable all warnings 77 | WARNINGS = ALL 78 | 79 | # specify whether image symbols will be created 80 | # so that stack crawls in the debugger are meaningful 81 | # if TRUE symbols will be created 82 | SYMBOLS = 83 | 84 | # specify debug settings 85 | # if TRUE will allow application to be run from 86 | # a source-level debugger 87 | DEBUGGER = TRUE 88 | 89 | # specify additional compiler flags for all files 90 | COMPILER_FLAGS = 91 | 92 | # specify additional linker flags 93 | LINKER_FLAGS = 94 | 95 | 96 | ## include the makefile-engine 97 | DEVEL_DIRECTORY := \ 98 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 99 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 100 | 101 | -------------------------------------------------------------------------------- /DirectWindowTest/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/DirectWindowTest/screenshot.png -------------------------------------------------------------------------------- /DragDrop/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = DragDrop 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = App 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = DragDrop.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | 133 | run :: default 134 | $(TARGET) 135 | -------------------------------------------------------------------------------- /DragDrop/README.md: -------------------------------------------------------------------------------- 1 | DragDrop 2 | 3 | Sample application demonstrating drag&drop support. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/DragDrop/screenshot.png) 6 | -------------------------------------------------------------------------------- /DragDrop/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/DragDrop/screenshot.png -------------------------------------------------------------------------------- /EGLTest/EGLTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern EGLNativeWindowType createNativeWindow(void); 7 | 8 | static EGLint const attribute_list[] = { 9 | EGL_RED_SIZE, 1, 10 | EGL_GREEN_SIZE, 1, 11 | EGL_BLUE_SIZE, 1, 12 | EGL_NONE 13 | }; 14 | 15 | status_t RenderThread(void *arg) 16 | { 17 | EGLDisplay display; 18 | EGLConfig config; 19 | EGLContext context; 20 | EGLSurface surface; 21 | NativeWindowType native_window; 22 | EGLint num_config; 23 | 24 | /* get an EGL display connection */ 25 | display = eglGetDisplay(EGL_DEFAULT_DISPLAY); 26 | 27 | /* initialize the EGL display connection */ 28 | eglInitialize(display, NULL, NULL); 29 | 30 | /* get an appropriate EGL frame buffer configuration */ 31 | eglChooseConfig(display, attribute_list, &config, 1, &num_config); 32 | 33 | /* create an EGL rendering context */ 34 | context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL); 35 | 36 | /* create a native window */ 37 | native_window = createNativeWindow(); 38 | 39 | /* create an EGL window surface */ 40 | surface = eglCreateWindowSurface(display, config, native_window, NULL); 41 | 42 | /* connect the context to the surface */ 43 | eglMakeCurrent(display, surface, surface, context); 44 | 45 | /* clear the color buffer */ 46 | glClearColor(1.0, 1.0, 0.0, 1.0); 47 | glClear(GL_COLOR_BUFFER_BIT); 48 | glFlush(); 49 | 50 | eglSwapBuffers(display, surface); 51 | 52 | sleep(10); 53 | 54 | exit(0); 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /EGLTest/README.md: -------------------------------------------------------------------------------- 1 | EGLTest 2 | 3 | Based on https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglIntro.xhtml. -------------------------------------------------------------------------------- /EGLTest/Window.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern "C" status_t RenderThread(void *arg); 8 | 9 | class TestWindow: public BWindow 10 | { 11 | public: 12 | TestWindow(BRect frame): BWindow(frame, "EGLTest", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 13 | { 14 | } 15 | 16 | void Quit() 17 | { 18 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 19 | BWindow::Quit(); 20 | } 21 | 22 | }; 23 | 24 | extern "C" EGLNativeWindowType createNativeWindow(void) 25 | { 26 | TestWindow* wnd = new TestWindow(BRect(0, 0, 255, 255).OffsetByCopy(64, 64)); 27 | wnd->Show(); 28 | return (EGLNativeWindowType)wnd; 29 | } 30 | 31 | class TestApplication: public BApplication 32 | { 33 | private: 34 | thread_id fThread; 35 | public: 36 | TestApplication(): BApplication("application/x-vnd.test.app") 37 | { 38 | } 39 | 40 | void ReadyToRun() { 41 | fThread = spawn_thread(RenderThread, "render thread", B_NORMAL_PRIORITY, this); 42 | resume_thread(fThread); 43 | } 44 | }; 45 | 46 | 47 | int main() 48 | { 49 | TestApplication app; 50 | app.Run(); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /EGLTest/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = EGLTest 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | SRCS = EGLTest.c Window.cpp 27 | 28 | # Specify the resource definition files to use. Full or relative paths can be 29 | # used. 30 | RDEFS = 31 | 32 | # Specify the resource files to use. Full or relative paths can be used. 33 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 34 | RSRCS = 35 | 36 | # End Pe/Eddie support. 37 | # @<-src@ 38 | #%} 39 | 40 | # Specify libraries to link against. 41 | # There are two acceptable forms of library specifications: 42 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 43 | # you can simply specify XXX for the library. (e.g. the entry for 44 | # "libtracker.so" would be "tracker") 45 | # 46 | # - for GCC-independent linking of standard C++ libraries, you can use 47 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 48 | # 49 | # - if your library does not follow the standard library naming scheme, 50 | # you need to specify the path to the library and it's name. 51 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 52 | LIBS = $(STDCPPLIBS) be EGL GLESv2 53 | 54 | # Specify additional paths to directories following the standard libXXX.so 55 | # or libXXX.a naming scheme. You can specify full paths or paths relative 56 | # to the Makefile. The paths included are not parsed recursively, so 57 | # include all of the paths where libraries must be found. Directories where 58 | # source files were specified are automatically included. 59 | LIBPATHS = 60 | 61 | # Additional paths to look for system headers. These use the form 62 | # "#include
". Directories that contain the files in SRCS are 63 | # NOT auto-included here. 64 | SYSTEM_INCLUDE_PATHS = 65 | 66 | # Additional paths paths to look for local headers. These use the form 67 | # #include "header". Directories that contain the files in SRCS are 68 | # automatically included. 69 | LOCAL_INCLUDE_PATHS = 70 | 71 | # Specify the level of optimization that you want. Specify either NONE (O0), 72 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 73 | OPTIMIZE := 74 | 75 | # Specify the codes for languages you are going to support in this 76 | # application. The default "en" one must be provided too. "make catkeys" 77 | # will recreate only the "locales/en.catkeys" file. Use it as a template 78 | # for creating catkeys for other languages. All localization files must be 79 | # placed in the "locales" subdirectory. 80 | LOCALES = 81 | 82 | # Specify all the preprocessor symbols to be defined. The symbols will not 83 | # have their values set automatically; you must supply the value (if any) to 84 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 85 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 86 | # "-DDEBUG" on the compiler's command line. 87 | DEFINES = 88 | 89 | # Specify the warning level. Either NONE (suppress all warnings), 90 | # ALL (enable all warnings), or leave blank (enable default warnings). 91 | WARNINGS = 92 | 93 | # With image symbols, stack crawls in the debugger are meaningful. 94 | # If set to "TRUE", symbols will be created. 95 | SYMBOLS := 96 | 97 | # Includes debug information, which allows the binary to be debugged easily. 98 | # If set to "TRUE", debug info will be created. 99 | DEBUGGER := 100 | 101 | # Specify any additional compiler flags to be used. 102 | COMPILER_FLAGS = 103 | 104 | # Specify any additional linker flags to be used. 105 | LINKER_FLAGS = 106 | 107 | # Specify the version of this binary. Example: 108 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 109 | # This may also be specified in a resource. 110 | APP_VERSION := 111 | 112 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 113 | # location in the /dev hierarchy. Example: 114 | # DRIVER_PATH = video/usb 115 | # will instruct the "driverinstall" rule to place a symlink to your driver's 116 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 117 | # appear at /dev/video/usb when loaded. The default is "misc". 118 | DRIVER_PATH = 119 | 120 | ## Include the Makefile-Engine 121 | DEVEL_DIRECTORY := \ 122 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 123 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 124 | 125 | run :: default 126 | $(TARGET) 127 | -------------------------------------------------------------------------------- /EGLTest2/BitmapHook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | class BBitmap; 7 | 8 | class BitmapHook { 9 | public: 10 | virtual ~BitmapHook() {}; 11 | virtual void GetSize(uint32_t &width, uint32_t &height) = 0; 12 | virtual BBitmap *SetBitmap(BBitmap *bmp) = 0; 13 | }; 14 | -------------------------------------------------------------------------------- /EGLTest2/BitmapHookView.cpp: -------------------------------------------------------------------------------- 1 | #include "BitmapHookView.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | void BitmapHookView::ViewBitmapHook::GetSize(uint32_t &width, uint32_t &height) 11 | { 12 | PthreadMutexLocker lock(&View()->fLock); 13 | width = (uint32_t)View()->fSize.Width() + 1; 14 | height = (uint32_t)View()->fSize.Height() + 1; 15 | } 16 | 17 | BBitmap *BitmapHookView::ViewBitmapHook::SetBitmap(BBitmap *bmp) 18 | { 19 | //printf("ViewBitmapHook::SetBitmap(%p)\n", bmp); 20 | PthreadMutexLocker lock(&View()->fLock); 21 | BBitmap* oldBmp = View()->fBmp.Detach(); 22 | View()->fBmp.SetTo(bmp); 23 | BMessenger(View()).SendMessage(B_INVALIDATE); 24 | return oldBmp; 25 | } 26 | 27 | 28 | void BitmapHookView::Init() 29 | { 30 | fSize = Frame().Size(); 31 | SetViewColor(B_TRANSPARENT_COLOR); 32 | SetLowColor(0, 0, 0); 33 | } 34 | 35 | BitmapHookView::BitmapHookView(const char *name, uint32 flags, BLayout *layout): 36 | BView(name, flags | B_WILL_DRAW | B_FRAME_EVENTS, layout) 37 | { 38 | Init(); 39 | } 40 | 41 | BitmapHookView::BitmapHookView(BRect frame, const char *name, uint32 resizingMode, uint32 flags): 42 | BView(frame, name, resizingMode, flags | B_WILL_DRAW | B_FRAME_EVENTS) 43 | { 44 | Init(); 45 | } 46 | 47 | void BitmapHookView::FrameResized(float newWidth, float newHeight) 48 | { 49 | PthreadMutexLocker lock(&fLock); 50 | fSize.Set(newWidth, newHeight); 51 | } 52 | 53 | void BitmapHookView::Draw(BRect dirty) 54 | { 55 | BRegion region(dirty); 56 | PthreadMutexLocker lock(&fLock); 57 | if (fBmp.IsSet()) { 58 | DrawBitmap(fBmp.Get(), B_ORIGIN); 59 | region.Exclude(fBmp->Bounds()); 60 | } 61 | FillRegion(®ion, B_SOLID_LOW); 62 | } 63 | -------------------------------------------------------------------------------- /EGLTest2/BitmapHookView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BitmapHook.h" 4 | #include 5 | #include 6 | #include 7 | 8 | class BitmapHookView: public BView 9 | { 10 | private: 11 | class ViewBitmapHook: public BitmapHook { 12 | private: 13 | inline BitmapHookView *View() {return (BitmapHookView*)((char*)this - offsetof(BitmapHookView, fHook));} 14 | 15 | public: 16 | virtual ~ViewBitmapHook() {}; 17 | void GetSize(uint32_t &width, uint32_t &height) override; 18 | BBitmap *SetBitmap(BBitmap *bmp) override; 19 | }; 20 | 21 | pthread_mutex_t fLock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; 22 | BSize fSize; 23 | ObjectDeleter fBmp; 24 | ViewBitmapHook fHook; 25 | 26 | void Init(); 27 | 28 | public: 29 | BitmapHookView(const char *name, uint32 flags, BLayout *layout = NULL); 30 | BitmapHookView(BRect frame, const char* name, uint32 resizingMode, uint32 flags); 31 | virtual ~BitmapHookView() {} 32 | 33 | BitmapHook *Hook() {return &fHook;} 34 | 35 | void FrameResized(float newWidth, float newHeight) override; 36 | void Draw(BRect dirty) override; 37 | }; 38 | -------------------------------------------------------------------------------- /EGLTest2/GlApp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include "MinApp.h" 8 | #include "GlApp.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | static void 15 | gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top) 16 | { 17 | glOrtho(left, right, bottom, top, -1, 1); 18 | } 19 | 20 | 21 | static void Draw(int width, int height, uint32 step) 22 | { 23 | GLenum use_stipple_mode = GL_FALSE; 24 | GLenum use_smooth_mode = GL_TRUE; 25 | GLint linesize = 2; // Line width 26 | GLint pointsize = 4; // Point diameter 27 | 28 | float pntA[3] = { 29 | -160.0, 0.0, 0.0 30 | }; 31 | float pntB[3] = { 32 | -130.0, 0.0, 0.0 33 | }; 34 | 35 | glViewport(0, 0, width, height); 36 | glMatrixMode(GL_PROJECTION); 37 | glLoadIdentity(); 38 | gluOrtho2D(-175, 175, -175, 175); 39 | glMatrixMode(GL_MODELVIEW); 40 | 41 | 42 | glClearColor(0.5, 0.5, 0.5, 0.0); 43 | glLineStipple(1, 0xF0E0); 44 | glBlendFunc(GL_SRC_ALPHA, GL_ONE); 45 | 46 | glClear(GL_COLOR_BUFFER_BIT); 47 | glLineWidth(linesize); 48 | 49 | if (use_stipple_mode) { 50 | glEnable(GL_LINE_STIPPLE); 51 | } else { 52 | glDisable(GL_LINE_STIPPLE); 53 | } 54 | 55 | if (use_smooth_mode) { 56 | glEnable(GL_LINE_SMOOTH); 57 | glEnable(GL_BLEND); 58 | } else { 59 | glDisable(GL_LINE_SMOOTH); 60 | glDisable(GL_BLEND); 61 | } 62 | 63 | glPushMatrix(); 64 | 65 | glRotatef(0.1*step, 0, 0, 1); 66 | 67 | for (int i = 0; i < 360; i += 5) { 68 | glRotatef(5.0, 0,0,1); // Rotate right 5 degrees 69 | glColor3f(1.0, 1.0, 0.0); // Set color for line 70 | glBegin(GL_LINE_STRIP); // And create the line 71 | glVertex3fv(pntA); 72 | glVertex3fv(pntB); 73 | glEnd(); 74 | 75 | glPointSize(pointsize); // Set size for point 76 | glColor3f(0.0, 1.0, 0.0); // Set color for point 77 | glBegin(GL_POINTS); 78 | glVertex3fv(pntA); // Draw point at one end 79 | glVertex3fv(pntB); // Draw point at other end 80 | glEnd(); 81 | } 82 | 83 | glPopMatrix(); // Done with matrix 84 | } 85 | 86 | 87 | class GlAppImpl: public GlApp { 88 | private: 89 | BitmapHook *fBitmapHook{}; 90 | EGLDisplay eglDpy{}; 91 | EGLConfig eglCfg{}; 92 | EGLContext eglCtx{}; 93 | EGLSurface eglSurf{}; 94 | int pbufferWidth = 512; 95 | int pbufferHeight = 512; 96 | 97 | uint32 step = 0; 98 | 99 | public: 100 | GlAppImpl(BitmapHook *bitmapHook); 101 | virtual ~GlAppImpl(); 102 | 103 | status_t Init(); 104 | status_t Draw(); 105 | }; 106 | 107 | GlAppImpl::GlAppImpl(BitmapHook *bitmapHook): 108 | fBitmapHook(bitmapHook) 109 | {} 110 | 111 | GlAppImpl::~GlAppImpl() 112 | { 113 | eglTerminate(eglDpy); 114 | } 115 | 116 | status_t GlAppImpl::Init() 117 | { 118 | eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); 119 | 120 | EGLint major, minor; 121 | eglInitialize(eglDpy, &major, &minor); 122 | 123 | EGLint numConfigs; 124 | 125 | EGLint configAttribs[] = { 126 | EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 127 | EGL_BLUE_SIZE, 8, 128 | EGL_GREEN_SIZE, 8, 129 | EGL_RED_SIZE, 8, 130 | EGL_DEPTH_SIZE, 8, 131 | EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, 132 | EGL_NONE 133 | }; 134 | eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs); 135 | 136 | eglBindAPI(EGL_OPENGL_API); 137 | 138 | eglCtx = eglCreateContext(eglDpy, eglCfg, EGL_NO_CONTEXT, NULL); 139 | eglSurf = eglCreateWindowSurface(eglDpy, eglCfg, (EGLNativeWindowType)fBitmapHook, NULL); 140 | 141 | return B_OK; 142 | } 143 | 144 | status_t GlAppImpl::Draw() 145 | { 146 | eglMakeCurrent(eglDpy, eglSurf, eglSurf, eglCtx); 147 | uint32 newWidth, newHeight; 148 | fBitmapHook->GetSize(newWidth, newHeight); 149 | ::Draw(newWidth, newHeight, step++); 150 | eglSwapBuffers(eglDpy, eglSurf); 151 | return B_OK; 152 | } 153 | 154 | GlApp *CreateGlApp(BitmapHook *bitmapHook) 155 | { 156 | ObjectDeleter app(new GlAppImpl(bitmapHook)); 157 | if (!app.IsSet()) return NULL; 158 | if (app->Init() < B_OK) return NULL; 159 | return app.Detach(); 160 | } 161 | -------------------------------------------------------------------------------- /EGLTest2/GlApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class BitmapHook; 6 | 7 | class GlApp { 8 | public: 9 | virtual ~GlApp() {}; 10 | virtual status_t Draw() = 0; 11 | }; 12 | 13 | GlApp *CreateGlApp(BitmapHook *bitmapHook); 14 | -------------------------------------------------------------------------------- /EGLTest2/MinApp.cpp: -------------------------------------------------------------------------------- 1 | #include "MinApp.h" 2 | #include "GlApp.h" 3 | #include "BitmapHookView.h" 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | 18 | class TestView: public BView 19 | { 20 | private: 21 | enum { 22 | stepMsg = 1, 23 | }; 24 | 25 | BitmapHookView *fBmpHookView; 26 | ObjectDeleter fGlApp; 27 | 28 | public: 29 | TestView(BRect frame, const char *name): 30 | BView(frame, name, B_FOLLOW_NONE, B_FRAME_EVENTS) 31 | { 32 | fBmpHookView = new BitmapHookView(frame.OffsetToCopy(B_ORIGIN), "bitmapHookView", B_FOLLOW_ALL, 0); 33 | AddChild(fBmpHookView); 34 | } 35 | 36 | void AttachedToWindow() override 37 | { 38 | fGlApp.SetTo(CreateGlApp(fBmpHookView->Hook())); 39 | if (!fGlApp.IsSet()) { 40 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 41 | return; 42 | } 43 | BMessenger(this).SendMessage(stepMsg); 44 | } 45 | 46 | void FrameResized(float newWidth, float newHeight) override 47 | { 48 | //fGlApp->Draw(); 49 | } 50 | 51 | void MessageReceived(BMessage *msg) override 52 | { 53 | switch (msg->what) { 54 | case stepMsg: { 55 | fGlApp->Draw(); 56 | BMessenger(this).SendMessage(stepMsg); 57 | return; 58 | }; 59 | } 60 | BView::MessageReceived(msg); 61 | } 62 | 63 | }; 64 | 65 | 66 | class TestWindow: public BWindow 67 | { 68 | private: 69 | TestView *fView; 70 | 71 | public: 72 | TestWindow(BRect frame): BWindow(frame, "Minimal EGL App", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS) 73 | { 74 | fView = new TestView(Frame().OffsetToCopy(B_ORIGIN), "view"); 75 | fView->SetResizingMode(B_FOLLOW_ALL); 76 | AddChild(fView, NULL); 77 | } 78 | }; 79 | 80 | class TestApplication: public BApplication 81 | { 82 | private: 83 | TestWindow *fWnd; 84 | 85 | public: 86 | TestApplication(): BApplication("application/x-vnd.Test-App") 87 | { 88 | fWnd = new TestWindow(BRect(0, 0, 640 - 1, 480 - 1)); 89 | fWnd->SetFlags(fWnd->Flags() | B_QUIT_ON_WINDOW_CLOSE); 90 | fWnd->CenterOnScreen(); 91 | fWnd->Show(); 92 | } 93 | }; 94 | 95 | 96 | int main() 97 | { 98 | TestApplication app; 99 | app.Run(); 100 | return 0; 101 | } 102 | -------------------------------------------------------------------------------- /EGLTest2/MinApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BitmapHook.h" 4 | 5 | 6 | class VKLayerSurfaceBase { 7 | public: 8 | virtual ~VKLayerSurfaceBase() {}; 9 | virtual void SetBitmapHook(BitmapHook *hook) = 0; 10 | }; 11 | -------------------------------------------------------------------------------- /EGLTest2/meson.build: -------------------------------------------------------------------------------- 1 | project('EGLTest', 'cpp', 2 | version : '0.1', 3 | default_options : ['warning_level=3', 'cpp_std=c++14']) 4 | 5 | cpp = meson.get_compiler('cpp') 6 | 7 | libbe = cpp.find_library('be') 8 | libOpenGL = dependency('opengl') 9 | libEGL = dependency('egl') 10 | 11 | executable( 12 | 'EGLTest', 13 | 'GlApp.cpp', 14 | 'BitmapHookView.cpp', 15 | 'MinApp.cpp', 16 | include_directories: [ 17 | '/boot/system/develop/headers/private/shared', 18 | ], 19 | dependencies: [ 20 | libbe, 21 | libOpenGL, 22 | libEGL, 23 | ], 24 | install: true 25 | ) 26 | -------------------------------------------------------------------------------- /Editor/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = MinApp 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = App 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = MinApp.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := TRUE 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | 133 | run :: default 134 | $(TARGET) 135 | -------------------------------------------------------------------------------- /Editor/README.md: -------------------------------------------------------------------------------- 1 | Editor 2 | 3 | BView container with editing capabilities. Can accept replicants. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/Editor/screenshot.png) 6 | -------------------------------------------------------------------------------- /Editor/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Editor/screenshot.png -------------------------------------------------------------------------------- /Handles/README.md: -------------------------------------------------------------------------------- 1 | Handles 2 | 3 | List file descriptors and associated information of each team. 4 | 5 | File path is displayed only for directory descriptors because Haiku currently don't have API for retriving path of file descriptors. 6 | 7 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/Handles/screenshot.png) 8 | -------------------------------------------------------------------------------- /Handles/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Handles/screenshot.png -------------------------------------------------------------------------------- /I2cTabletDevice/README.md: -------------------------------------------------------------------------------- 1 | I2cTabletDevice 2 | 3 | Pen driver for Fujitsu arrows Tab WQ2/C1. 4 | -------------------------------------------------------------------------------- /I2cTabletDevice/TabletDevice.h: -------------------------------------------------------------------------------- 1 | #ifndef _KEYBOARDDEVICE_H_ 2 | #define _KEYBOARDDEVICE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | typedef struct i2c_hid_descriptor { 10 | uint16 wHIDDescLength; 11 | uint16 bcdVersion; 12 | uint16 wReportDescLength; 13 | uint16 wReportDescRegister; 14 | uint16 wInputRegister; 15 | uint16 wMaxInputLength; 16 | uint16 wOutputRegister; 17 | uint16 wMaxOutputLength; 18 | uint16 wCommandRegister; 19 | uint16 wDataRegister; 20 | uint16 wVendorID; 21 | uint16 wProductID; 22 | uint16 wVersionID; 23 | uint32 reserved; 24 | } _PACKED i2c_hid_descriptor; 25 | 26 | enum { 27 | tipSwitchFlag = 1 << 0, 28 | barrelSwitchFlag = 1 << 1, 29 | eraserFlag = 1 << 2, 30 | invertFlag = 1 << 3, 31 | secBarrelSwitchFlag = 1 << 4, 32 | inRangeFlag = 1 << 5, 33 | }; 34 | 35 | enum { 36 | xMax = 21658, 37 | yMax = 13536, 38 | pressureMax = 4095 39 | }; 40 | 41 | struct TabletPacket { 42 | uint16 size; 43 | uint8 reportId; 44 | uint8 flags; 45 | uint16 x; 46 | uint16 y; 47 | uint16 pressure; 48 | } _PACKED; 49 | 50 | struct TabletState { 51 | bigtime_t when; 52 | float x, y; 53 | float pressure; 54 | uint32 buttons; 55 | int32 clicks; 56 | }; 57 | 58 | class TabletDevice: public BInputServerDevice 59 | { 60 | public: 61 | TabletDevice(); 62 | ~TabletDevice(); 63 | 64 | status_t InitCheck(); 65 | 66 | status_t Start(const char* name, void* cookie); 67 | status_t Stop(const char* name, void* cookie); 68 | 69 | status_t Control(const char* name, void* cookie, uint32 command, BMessage* message); 70 | 71 | private: 72 | static int32 DeviceWatcher(void *arg); 73 | 74 | FileDescriptorCloser fDeviceFd; 75 | i2c_addr fDeviceAdr; 76 | i2c_hid_descriptor fDesc; 77 | TabletState fState; 78 | bigtime_t fLastClick; 79 | int fLastClickBtn; 80 | 81 | thread_id fWatcherThread; 82 | bool fRun; 83 | }; 84 | 85 | 86 | extern "C" _EXPORT BInputServerDevice* instantiate_input_device(); 87 | 88 | #endif // _KEYBOARDDEVICE_H_ 89 | -------------------------------------------------------------------------------- /I2cTabletDevice/_APP_: -------------------------------------------------------------------------------- 1 | /boot/system/servers/input_server -------------------------------------------------------------------------------- /I2cTabletDevice/devices: -------------------------------------------------------------------------------- 1 | /boot/home/config/non-packaged/add-ons/input_server/devices -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Contents of this repository are avalible under MIT License unless otherwize mentioned. 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2020 X512 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /MenuDynItems/MenuDynItems.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void BuildMenu(BMenu *dst, int level) 14 | { 15 | char buf[64]; 16 | int cnt = 4; 17 | BMenu *subMenu; 18 | if (level == 0) { 19 | dst->AddItem(new BMenuItem("Menu item", new BMessage('item'))); 20 | subMenu = new BMenu("Long menu"); 21 | dst->AddItem(subMenu); 22 | for (int i = 0; i < 200; ++i) { 23 | sprintf(buf, "Item %d", i); 24 | subMenu->AddItem(new BMenuItem(buf, new BMessage('item'))); 25 | } 26 | cnt = 16; 27 | } 28 | for (int i = 0; i < cnt; ++i) { 29 | if (level < 3) { 30 | sprintf(buf, "%d", i); 31 | subMenu = new BMenu(buf); 32 | BuildMenu(subMenu, level + 1); 33 | dst->AddItem(subMenu); 34 | } else { 35 | dst->AddItem(new BMenuItem("Item", new BMessage('item'))); 36 | } 37 | } 38 | } 39 | 40 | class TestMenuBar: public BMenuBar 41 | { 42 | public: 43 | TestMenuBar(): BMenuBar(BRect(0, 0, 32, 32), "menu", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_ITEMS_IN_ROW, true) 44 | { 45 | BuildMenu(this, 0); 46 | fDynItem = ItemAt(1)->Submenu()->ItemAt(1); 47 | } 48 | 49 | void UpdateDynItems(int32 modifiers) 50 | { 51 | if (((modifiers & B_SHIFT_KEY) != 0) != fModified) { 52 | BMenu *menu = fDynItem->Menu(); 53 | if (menu->Window() == NULL || menu->LockLooper()) { 54 | fModified = !fModified; 55 | if (fModified) { 56 | fOrigText = fDynItem->Label(); 57 | BString buf; 58 | buf += fDynItem->Label(); 59 | buf += " (Shift)"; 60 | fDynItem->SetLabel(buf); 61 | } else { 62 | fDynItem->SetLabel(fOrigText); 63 | } 64 | int32 index = menu->IndexOf(fDynItem); 65 | menu->RemoveItem(fDynItem); 66 | menu->AddItem(fDynItem, index); 67 | if (menu->Window() != NULL) 68 | menu->UnlockLooper(); 69 | } 70 | } 71 | } 72 | 73 | void MessageReceived(BMessage *msg) 74 | { 75 | switch (msg->what) { 76 | case B_MODIFIERS_CHANGED: { 77 | int32 modifiers = 0; 78 | msg->FindInt32("modifiers", &modifiers); 79 | UpdateDynItems(modifiers); 80 | break; 81 | } 82 | } 83 | BMenuBar::MessageReceived(msg); 84 | } 85 | 86 | private: 87 | BMenuItem *fDynItem; 88 | bool fModified; 89 | BString fOrigText; 90 | }; 91 | 92 | class TestWindow: public BWindow 93 | { 94 | private: 95 | TestMenuBar *fMenu; 96 | public: 97 | TestWindow(BRect frame): BWindow(frame, "TestApp", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 98 | { 99 | fMenu = new TestMenuBar(); 100 | this->AddChild(fMenu); 101 | } 102 | 103 | ~TestWindow() 104 | { 105 | } 106 | 107 | void MenusBeginning() 108 | { 109 | fMenu->SetEventMask(fMenu->EventMask() | B_KEYBOARD_EVENTS); 110 | fMenu->UpdateDynItems(modifiers()); 111 | } 112 | 113 | void MenusEnded() 114 | { 115 | fMenu->SetEventMask(fMenu->EventMask() & ~B_KEYBOARD_EVENTS); 116 | } 117 | 118 | }; 119 | 120 | class TestApplication: public BApplication 121 | { 122 | public: 123 | TestApplication(): BApplication("application/x-vnd.test.app") 124 | { 125 | } 126 | 127 | void ReadyToRun() { 128 | BWindow *wnd = new TestWindow(BRect(32, 32, 512, 256)); 129 | wnd->SetFlags(wnd->Flags() | B_QUIT_ON_WINDOW_CLOSE); 130 | wnd->Show(); 131 | } 132 | }; 133 | 134 | 135 | int main() 136 | { 137 | (new TestApplication())->Run(); 138 | return 0; 139 | } 140 | 141 | /* 142 | gcc -lbe -lstdc++ MenuDyn.cpp -o MenuDyn 143 | MenuDyn 144 | */ 145 | -------------------------------------------------------------------------------- /MinApp/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = MinApp 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = MinApp.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = #-Wl,-z,notext 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | 133 | run :: default 134 | $(TARGET) 135 | -------------------------------------------------------------------------------- /MinApp/MinApp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class TestView: public BView 10 | { 11 | public: 12 | TestView(BRect frame, const char *name): BView(frame, name, B_FOLLOW_NONE, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_SUBPIXEL_PRECISE) 13 | { 14 | SetViewColor(0xff - 0x44, 0xff - 0x44, 0xff - 0x44); 15 | } 16 | 17 | void Draw(BRect dirty) 18 | { 19 | BRect rect = Frame().OffsetToCopy(B_ORIGIN); 20 | rect.left += 1; rect.top += 1; 21 | SetHighColor(0x44, 0x44, 0x44); 22 | SetPenSize(2); 23 | StrokeRect(rect, B_SOLID_HIGH); 24 | SetPenSize(1); 25 | StrokeLine(rect.LeftTop(), rect.RightBottom()); 26 | StrokeLine(rect.RightTop(), rect.LeftBottom()); 27 | } 28 | 29 | }; 30 | 31 | class TestWindow: public BWindow 32 | { 33 | private: 34 | TestView *fView; 35 | public: 36 | TestWindow(BRect frame): BWindow(frame, "TestApp", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS) 37 | { 38 | fView = new TestView(frame.OffsetToCopy(B_ORIGIN), "view"); 39 | fView->SetResizingMode(B_FOLLOW_ALL); 40 | AddChild(fView, NULL); 41 | } 42 | 43 | void Quit() 44 | { 45 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 46 | BWindow::Quit(); 47 | } 48 | 49 | }; 50 | 51 | class TestApplication: public BApplication 52 | { 53 | private: 54 | TestWindow *fWnd; 55 | public: 56 | TestApplication(): BApplication("application/x-vnd.Test-App") 57 | { 58 | } 59 | 60 | void ReadyToRun() { 61 | fWnd = new TestWindow(BRect(0, 0, 256, 256).OffsetByCopy(64, 64)); 62 | fWnd->Show(); 63 | } 64 | }; 65 | 66 | 67 | int main() 68 | { 69 | TestApplication app; 70 | app.Run(); 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /MinApp/README.md: -------------------------------------------------------------------------------- 1 | MinApp 2 | 3 | Minimal Haiku GUI application sample code. 4 | 5 | Type `make run` in Terminal to compile and run. 6 | 7 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/MinApp/screenshot.png) 8 | -------------------------------------------------------------------------------- /MinApp/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/MinApp/screenshot.png -------------------------------------------------------------------------------- /MsgDump/Fields: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/MsgDump/Fields -------------------------------------------------------------------------------- /MsgDump/MsgDump.h: -------------------------------------------------------------------------------- 1 | #ifndef _MSGDUMP_H_ 2 | #define _MSGDUMP_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class TestWindow; 12 | class BTextControl; 13 | class BButton; 14 | class BColumnListView; 15 | class BRow; 16 | class BEntry; 17 | 18 | struct Operation 19 | { 20 | enum Kind { 21 | insertOp, 22 | removeOp, 23 | updateOp 24 | }; 25 | BString path; 26 | Kind kind; 27 | int8 *data; 28 | ssize_t size; 29 | BMessage msg; 30 | 31 | Operation() {} 32 | Operation(BString &path, Kind kind, const int8 *data, ssize_t size): path(path), kind(kind), size(size) { 33 | if (size <= 0) { 34 | this->data = NULL; 35 | } else { 36 | this->data = new int8[size]; 37 | memcpy(this->data, data, size); 38 | } 39 | } 40 | ~Operation() {if (data != NULL) delete[] data;} 41 | }; 42 | 43 | struct MessageLoc 44 | { 45 | BMessage &msg; 46 | BString name; 47 | int32 idx; 48 | int32 ofs; 49 | bool useOfs; 50 | }; 51 | 52 | class EditWindow: public BWindow 53 | { 54 | private: 55 | TestWindow *fBase; 56 | BTextControl *fNameView, *fTypeView, *fValueView; 57 | BButton *fOkView, *fCancelView; 58 | 59 | public: 60 | EditWindow(TestWindow *base); 61 | void SetTo(BRow *row); 62 | void Quit(); 63 | }; 64 | 65 | class TestWindow: public BWindow 66 | { 67 | private: 68 | BMenuBar *fMenuBar; 69 | BTextControl *fPathView; 70 | BColumnListView *fView; 71 | EditWindow *fEditWnd; 72 | BMessage fMessage; 73 | 74 | BObjectList fUndoStack, fRedoStack; 75 | 76 | friend class EditWindow; 77 | 78 | public: 79 | TestWindow(BRect frame); 80 | bool Load(BEntry &entry); 81 | void Quit(); 82 | void MessageReceived(BMessage* msg); 83 | }; 84 | 85 | class TestApplication: public BApplication 86 | { 87 | public: 88 | TestApplication(); 89 | virtual ~TestApplication(); 90 | 91 | void ArgvReceived(int32 argc, char** argv); 92 | void RefsReceived(BMessage *refsMsg); 93 | void MessageReceived(BMessage* msg); 94 | void ReadyToRun(); 95 | 96 | private: 97 | BFilePanel* fOpenPanel; 98 | }; 99 | 100 | #endif // _MSGDUMP_H_ 101 | -------------------------------------------------------------------------------- /MsgDump/MsgDump.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Test-MsgDump"; 2 | 3 | resource app_flags B_SINGLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 0, 8 | minor = 0, 9 | 10 | variety = B_APPV_DEVELOPMENT, 11 | internal = 0, 12 | 13 | short_info = "MsgDump", 14 | long_info = "Show contents of flattened BMessage" 15 | }; 16 | 17 | resource file_types message { 18 | "types" = "application/octet-stream" 19 | }; 20 | 21 | resource vector_icon array { 22 | $"6E63696606040179050102000602B48906376C703D2A3E3A580149DC9C45756F" 23 | $"00B17703FFC7AC5B02000605B9DCB83D4EE8BFD6FDBC3DCA4BD5FB4A53B700DA" 24 | $"D09F31FFFDF279DAD09FC5C7AC5BFFB1770302000604B66104385BC73D03703B" 25 | $"0A2346B1734ABA4F00DAD09F4FFFFDF29DDAD09FFFC7AC5B0501080006426046" 26 | $"6042604C5E4A604E5C4E584C5A505655505352574E5F4C5D506148423C5A3C42" 27 | $"3C0613BFF3FFF33C46273F254D29582A54285C2C56345A34563451334E405034" 28 | $"4E40494D444D444A51425E485E405E33553A592C51244E264F204C2746234629" 29 | $"462B472A472B472C422C442C42302D3E2D3E2E38312B2F30312B353228322833" 30 | $"24382235223B220610EFFFBEFF425E405E485E4D444A514D4449404E404E4050" 31 | $"34582A532A542846274D293F2538223B223522322833243228352BB9BFB76CB9" 32 | $"BFB76C2F30B821BEEF2E38B821BEEF3042B7C7C08EB7C7C08E2C442B472B47B6" 33 | $"CDC43D244EB5C64E264F33552C513A5900024F354F3554315A2B502B5A2B0004" 34 | $"405C405C405A465442544252354D3B502F4A28462A462846020628462A462446" 35 | $"244E204C264F33552C513A59425E405E3F5C465442544252354D3B502F4A0802" 36 | $"332F4B3808023235443D0A0A000100000A0101011001178402040A020101000A" 37 | $"0101031001178400040A01001001178400040A030102000A0101041001178422" 38 | $"040A040105000A05020607123FD5C7368D4FB6A8D13FFF1DBCCC394732100117" 39 | $"8200040A05020607100117820004" 40 | }; 41 | -------------------------------------------------------------------------------- /MsgDump/README.md: -------------------------------------------------------------------------------- 1 | MsgDump 2 | 3 | Opens flattened BMessage files. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/MsgDump/screenshot.png) 6 | -------------------------------------------------------------------------------- /MsgDump/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = MsgDump 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | SRCS = \ 27 | MsgDump.cpp \ 28 | 29 | 30 | # Specify the resource definition files to use. Full or relative paths can be 31 | # used. 32 | RDEFS = \ 33 | MsgDump.rdef \ 34 | 35 | 36 | # Specify the resource files to use. Full or relative paths can be used. 37 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 38 | RSRCS = \ 39 | 40 | 41 | # End Pe/Eddie support. 42 | # @<-src@ 43 | #%} 44 | 45 | # Specify libraries to link against. 46 | # There are two acceptable forms of library specifications: 47 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 48 | # you can simply specify XXX for the library. (e.g. the entry for 49 | # "libtracker.so" would be "tracker") 50 | # 51 | # - for GCC-independent linking of standard C++ libraries, you can use 52 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 53 | # 54 | # - if your library does not follow the standard library naming scheme, 55 | # you need to specify the path to the library and it's name. 56 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 57 | LIBS = $(STDCPPLIBS) be columnlistview tracker 58 | 59 | # Specify additional paths to directories following the standard libXXX.so 60 | # or libXXX.a naming scheme. You can specify full paths or paths relative 61 | # to the Makefile. The paths included are not parsed recursively, so 62 | # include all of the paths where libraries must be found. Directories where 63 | # source files were specified are automatically included. 64 | LIBPATHS = 65 | 66 | # Additional paths to look for system headers. These use the form 67 | # "#include
". Directories that contain the files in SRCS are 68 | # NOT auto-included here. 69 | SYSTEM_INCLUDE_PATHS = 70 | 71 | # Additional paths paths to look for local headers. These use the form 72 | # #include "header". Directories that contain the files in SRCS are 73 | # automatically included. 74 | LOCAL_INCLUDE_PATHS = /boot/system/develop/headers/private/interface 75 | 76 | # Specify the level of optimization that you want. Specify either NONE (O0), 77 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 78 | OPTIMIZE := 79 | 80 | # Specify the codes for languages you are going to support in this 81 | # application. The default "en" one must be provided too. "make catkeys" 82 | # will recreate only the "locales/en.catkeys" file. Use it as a template 83 | # for creating catkeys for other languages. All localization files must be 84 | # placed in the "locales" subdirectory. 85 | LOCALES = 86 | 87 | # Specify all the preprocessor symbols to be defined. The symbols will not 88 | # have their values set automatically; you must supply the value (if any) to 89 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 90 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 91 | # "-DDEBUG" on the compiler's command line. 92 | DEFINES = 93 | 94 | # Specify the warning level. Either NONE (suppress all warnings), 95 | # ALL (enable all warnings), or leave blank (enable default warnings). 96 | WARNINGS = ALL 97 | 98 | # With image symbols, stack crawls in the debugger are meaningful. 99 | # If set to "TRUE", symbols will be created. 100 | SYMBOLS := 101 | 102 | # Includes debug information, which allows the binary to be debugged easily. 103 | # If set to "TRUE", debug info will be created. 104 | DEBUGGER := 105 | 106 | # Specify any additional compiler flags to be used. 107 | COMPILER_FLAGS = 108 | 109 | # Specify any additional linker flags to be used. 110 | LINKER_FLAGS = 111 | 112 | # Specify the version of this binary. Example: 113 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 114 | # This may also be specified in a resource. 115 | APP_VERSION := 116 | 117 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 118 | # location in the /dev hierarchy. Example: 119 | # DRIVER_PATH = video/usb 120 | # will instruct the "driverinstall" rule to place a symlink to your driver's 121 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 122 | # appear at /dev/video/usb when loaded. The default is "misc". 123 | DRIVER_PATH = 124 | 125 | ## Include the Makefile-Engine 126 | DEVEL_DIRECTORY := \ 127 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 128 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 129 | -------------------------------------------------------------------------------- /MsgDump/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/MsgDump/screenshot.png -------------------------------------------------------------------------------- /OSMesaDriver/README.md: -------------------------------------------------------------------------------- 1 | OSMesaDriver 2 | 3 | Software rendering OpenGL driver for Haiku based on OSMesa interface. 4 | -------------------------------------------------------------------------------- /OSMesaDriver/SoftwareRenderer.h: -------------------------------------------------------------------------------- 1 | #ifndef SOFTWARERENDERER_H 2 | #define SOFTWARERENDERER_H 3 | 4 | 5 | #include 6 | #include "GLRenderer.h" 7 | #include 8 | 9 | class SoftwareRenderer: public BGLRenderer { 10 | public: 11 | SoftwareRenderer(BGLView *view, ulong bgl_options); 12 | virtual ~SoftwareRenderer(); 13 | void* GetGLProcAddress(const char* procName); 14 | 15 | void LockGL(); 16 | void UnlockGL(); 17 | 18 | void SwapBuffers(bool vsync = false); 19 | void Draw(BRect updateRect); 20 | status_t CopyPixelsOut(BPoint source, BBitmap *dest); 21 | status_t CopyPixelsIn(BBitmap *source, BPoint dest); 22 | void FrameResized(float width, float height); 23 | 24 | void EnableDirectMode(bool enabled); 25 | void DirectConnected(direct_buffer_info *info); 26 | 27 | private: 28 | bool _AllocBackBuf(); 29 | void _UpdateContext(); 30 | 31 | BLocker fLocker; 32 | OSMesaContext fCtx; 33 | BBitmap *fBackBuf; 34 | bool fDirectModeEnabled; 35 | direct_buffer_info* fInfo; 36 | int32 fWidth, fHeight; 37 | int32 fSwapBuffersLevel; 38 | }; 39 | 40 | #endif // SOFTPIPERENDERER_H 41 | -------------------------------------------------------------------------------- /OSMesaDriver/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = OSMesaDriver 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = SHARED 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = SoftwareRenderer.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be OSMesa 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = ../libGL 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | -------------------------------------------------------------------------------- /OSMesaDriver/opengl: -------------------------------------------------------------------------------- 1 | /boot/home/config/non-packaged/add-ons/opengl -------------------------------------------------------------------------------- /OpenGLTest/OpenGLTest.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Be-GLSample"; 2 | 3 | resource app_flags B_MULTIPLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 0, 8 | minor = 0, 9 | 10 | variety = B_APPV_DEVELOPMENT, 11 | internal = 0, 12 | 13 | short_info = "OpenGLTest", 14 | long_info = "OpenGLTest" 15 | }; 16 | -------------------------------------------------------------------------------- /OpenGLTest/README.md: -------------------------------------------------------------------------------- 1 | OpenGLTest 2 | 3 | Based on sample code in BeBook. New window can be opened by Alt+N. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/OpenGLTest/screenshot.png) 6 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLApp.cpp: -------------------------------------------------------------------------------- 1 | #include "SampleGLApp.h" 2 | #include "SampleGLWindow.h" 3 | #include 4 | #include 5 | 6 | SampleGLApp::SampleGLApp() 7 | : BApplication("application/x-vnd.Be-GLSample") 8 | { 9 | newPos = BPoint(32, 32); 10 | NewWindow(); 11 | } 12 | 13 | SampleGLWindow *SampleGLApp::NewWindow() 14 | { 15 | BRect windowRect; 16 | uint32 type; 17 | SampleGLWindow *wnd = NULL; 18 | if (Lock()) { 19 | // Set type to the appropriate value for the 20 | // sample program you're working with. 21 | 22 | type = BGL_RGB/*|BGL_DOUBLE*/; 23 | 24 | windowRect.Set(0, 0, 255, 255); 25 | wnd = new SampleGLWindow(windowRect, type); 26 | BScreen screen(wnd); 27 | BRect screenRect = screen.Frame(); 28 | windowRect.OffsetTo(newPos); 29 | newPos.x += 32; newPos.y += 32; 30 | if (windowRect.right > screenRect.right) { 31 | newPos.x += windowRect.Width() - screenRect.Width(); 32 | windowRect.OffsetBy(windowRect.Width() - screenRect.Width(), 0); 33 | } 34 | if (windowRect.bottom > screenRect.bottom) { 35 | newPos.y += windowRect.Height() - screenRect.Height(); 36 | windowRect.OffsetBy(0, windowRect.Height() - screenRect.Height()); 37 | } 38 | wnd->MoveTo(windowRect.LeftTop()); 39 | Unlock(); 40 | } 41 | if (wnd != NULL) wnd->Show(); 42 | return wnd; 43 | } 44 | 45 | 46 | int main() 47 | { 48 | SampleGLApp app; 49 | app.Run(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLApp.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLAPP_CPP_ 2 | #define _SAMPLEGLAPP_CPP_ 3 | 4 | #include 5 | 6 | class SampleGLWindow; 7 | 8 | class SampleGLApp : public BApplication { 9 | public: 10 | SampleGLApp(); 11 | SampleGLWindow *NewWindow(); 12 | private: 13 | BPoint newPos; 14 | }; 15 | 16 | #endif // _SAMPLEGLAPP_CPP_ 17 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLView.cpp: -------------------------------------------------------------------------------- 1 | #include "SampleGLView.h" 2 | #include 3 | #include 4 | 5 | GLenum use_stipple_mode; // GL_TRUE to use dashed lines 6 | GLenum use_smooth_mode; // GL_TRUE to use anti-aliased lines 7 | GLint linesize; // Line width 8 | GLint pointsize; // Point diameter 9 | 10 | float pntA[3] = { 11 | -160.0, 0.0, 0.0 12 | }; 13 | float pntB[3] = { 14 | -130.0, 0.0, 0.0 15 | }; 16 | 17 | SampleGLView::SampleGLView(BRect frame, uint32 type) 18 | : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type) 19 | { 20 | printf("+SampleGLView\n"); 21 | width = frame.right-frame.left; 22 | height = frame.bottom-frame.top; 23 | } 24 | 25 | SampleGLView::~SampleGLView() 26 | { 27 | printf("-SampleGLView\n"); 28 | } 29 | 30 | void SampleGLView::AttachedToWindow(void) { 31 | MakeFocus(true); 32 | BGLView::AttachedToWindow(); 33 | LockGL(); 34 | gInit(); 35 | gReshape(width, height); 36 | UnlockGL(); 37 | Render(); 38 | } 39 | 40 | void SampleGLView::FrameResized(float newWidth, float newHeight) { 41 | BGLView::FrameResized(newWidth, newHeight); 42 | LockGL(); 43 | width = newWidth; 44 | height = newHeight; 45 | gReshape(width, height); 46 | UnlockGL(); 47 | Render(); 48 | } 49 | 50 | extern "C" void glWindowPos2f(GLfloat x, GLfloat y); 51 | 52 | static void CopyFlipY(BBitmap &dst, BBitmap &src) 53 | { 54 | int32 h = dst.Bounds().Height() + 1; 55 | int32 stride = dst.BytesPerRow(); 56 | uint8 *dstBits = (uint8*)dst.Bits(); 57 | uint8 *srcBits = (uint8*)src.Bits() + stride*(h - 1); 58 | for (int32 y = 0; y < h; y++) { 59 | memcpy(dstBits, srcBits, stride); 60 | dstBits += stride; 61 | srcBits -= stride; 62 | } 63 | } 64 | 65 | static void WriteBitmap(BGLView *view, const BBitmap &bmp, BPoint pos) 66 | { 67 | glDisable(GL_BLEND); 68 | glWindowPos2f(pos.x, (view->Bounds().Height() + 1.0) - pos.y); 69 | glPixelZoom(1.0, -1.0); 70 | glDrawPixels((int32)bmp.Bounds().Width() + 1, (int32)bmp.Bounds().Height() + 1, GL_RGBA, GL_UNSIGNED_BYTE, bmp.Bits()); 71 | } 72 | 73 | static void ReadBitmap(BGLView *view, BBitmap &bmp, BPoint pos) 74 | { 75 | BBitmap buf(bmp.Bounds(), 0, bmp.ColorSpace(), bmp.BytesPerRow()); 76 | CopyFlipY(buf, bmp); 77 | glReadPixels(pos.x, (int32)view->Bounds().Height() + 1 - pos.y - ((int32)bmp.Bounds().Height() + 1), (int32)bmp.Bounds().Width() + 1, (int32)bmp.Bounds().Height() + 1, GL_RGBA, GL_UNSIGNED_BYTE, buf.Bits()); 78 | CopyFlipY(bmp, buf); 79 | } 80 | 81 | void SampleGLView::KeyDown(const char* bytes, int32 numBytes) 82 | { 83 | if ((numBytes == 1) && (bytes[0] == 'q')) { 84 | printf("Draw bitmap\n"); 85 | int32 w = 64, h = 64; 86 | BRect rect(0, 0, w - 1, h - 1); 87 | BBitmap *bmp = new BBitmap(rect, B_RGB32); 88 | int8 *bits = (int8*)bmp->Bits(); 89 | int32 stride = bmp->BytesPerRow(); 90 | for (int32 y = 0; y < h; y++) 91 | for (int32 x = 0; x < w; x++) 92 | *(int32*)(bits + y*stride + x*4) = 0xff000000 + (x*0xff/w)%0x100 + ((y*0xff/h)%0x100)*0x100; 93 | LockGL(); 94 | gDraw(); 95 | BPoint pos; 96 | GetMouse(&pos, NULL); 97 | ReadBitmap(this, *bmp, pos); 98 | WriteBitmap(this, *bmp, B_ORIGIN); 99 | SwapBuffers(); 100 | UnlockGL(); 101 | delete bmp; 102 | } 103 | /* 104 | CopyPixelsOut(B_ORIGIN, bmp); 105 | CopyPixelsIn(bmp, B_ORIGIN); 106 | */ 107 | } 108 | 109 | void SampleGLView::ErrorCallback(GLenum whichError) { 110 | fprintf(stderr, "Unexpected error occured (%d):\n", whichError); 111 | fprintf(stderr, " %s\n", gluErrorString(whichError)); 112 | } 113 | 114 | void SampleGLView::gInit(void) { 115 | printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); 116 | printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); 117 | printf("GL_VERSION: %s\n", glGetString(GL_VERSION)); 118 | printf("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); 119 | use_stipple_mode = GL_FALSE; 120 | use_smooth_mode = GL_TRUE; 121 | linesize = 2; 122 | pointsize = 4; 123 | } 124 | 125 | void SampleGLView::gDraw(void) { 126 | GLint i; 127 | 128 | glClearColor(0.5, 0.5, 0.5, 0.0); 129 | glLineStipple(1, 0xF0E0); 130 | glBlendFunc(GL_SRC_ALPHA, GL_ONE); 131 | 132 | glClear(GL_COLOR_BUFFER_BIT); 133 | glLineWidth(linesize); 134 | 135 | if (use_stipple_mode) { 136 | glEnable(GL_LINE_STIPPLE); 137 | } else { 138 | glDisable(GL_LINE_STIPPLE); 139 | } 140 | 141 | if (use_smooth_mode) { 142 | glEnable(GL_LINE_SMOOTH); 143 | glEnable(GL_BLEND); 144 | } else { 145 | glDisable(GL_LINE_SMOOTH); 146 | glDisable(GL_BLEND); 147 | } 148 | 149 | glPushMatrix(); 150 | 151 | for (i = 0; i < 360/6; i += 5) { 152 | glRotatef(5.0, 0,0,1); // Rotate right 5 degrees 153 | glColor3f(1.0, 1.0, 0.0); // Set color for line 154 | glBegin(GL_LINE_STRIP); // And create the line 155 | glVertex3fv(pntA); 156 | glVertex3fv(pntB); 157 | glEnd(); 158 | 159 | glPointSize(pointsize); // Set size for point 160 | glColor3f(0.0, 1.0, 0.0); // Set color for point 161 | glBegin(GL_POINTS); 162 | glVertex3fv(pntA); // Draw point at one end 163 | glVertex3fv(pntB); // Draw point at other end 164 | glEnd(); 165 | } 166 | 167 | glPopMatrix(); // Done with matrix 168 | } 169 | 170 | void SampleGLView::gReshape(int width, int height) { 171 | glViewport(0, 0, width, height); 172 | glMatrixMode(GL_PROJECTION); 173 | glLoadIdentity(); 174 | gluOrtho2D(-175, 175, -175, 175); 175 | glMatrixMode(GL_MODELVIEW); 176 | } 177 | 178 | void SampleGLView::Render(void) { 179 | LockGL(); 180 | gDraw(); 181 | SwapBuffers(); 182 | UnlockGL(); 183 | } 184 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLVIEW_H_ 2 | #define _SAMPLEGLVIEW_H_ 3 | 4 | #include 5 | 6 | class SampleGLView : public BGLView { 7 | public: 8 | SampleGLView(BRect frame, uint32 type); 9 | virtual ~SampleGLView(); 10 | void AttachedToWindow(void); 11 | void FrameResized(float newWidth, float newHeight); 12 | void KeyDown(const char* bytes, int32 numBytes); 13 | void ErrorCallback(GLenum which); 14 | 15 | void Render(void); 16 | 17 | private: 18 | void gInit(void); 19 | void gDraw(void); 20 | void gReshape(int width, int height); 21 | 22 | float width; 23 | float height; 24 | }; 25 | 26 | #endif // _SAMPLEGLVIEW_H_ 27 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "SampleGLApp.h" 2 | #include "SampleGLWindow.h" 3 | #include "SampleGLView.h" 4 | 5 | SampleGLWindow::SampleGLWindow(BRect frame, uint32 type) 6 | : BWindow(frame, "OpenGL Test", B_TITLED_WINDOW, 0) 7 | { 8 | AddShortcut('n', B_COMMAND_KEY, new BMessage('neww')); 9 | AddChild(theView=new SampleGLView(Bounds(), type)); 10 | } 11 | 12 | bool SampleGLWindow::QuitRequested() 13 | { 14 | if (be_app->CountWindows() == 1) 15 | be_app->PostMessage(B_QUIT_REQUESTED); 16 | return true; 17 | } 18 | 19 | void SampleGLWindow::MessageReceived(BMessage *msg) 20 | { 21 | switch (msg->what) { 22 | case 'neww': { 23 | ((SampleGLApp*)be_app)->NewWindow(); 24 | break; 25 | } 26 | default: 27 | BWindow::MessageReceived(msg); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenGLTest/SampleGLWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLWINDOW_H_ 2 | #define _SAMPLEGLWINDOW_H_ 3 | 4 | #include 5 | 6 | class SampleGLView; 7 | 8 | class SampleGLWindow : public BWindow { 9 | public: 10 | SampleGLWindow(BRect frame, uint32 type); 11 | virtual bool QuitRequested(); 12 | void MessageReceived(BMessage *msg); 13 | 14 | private: 15 | SampleGLView* theView; 16 | }; 17 | 18 | #endif // _SAMPLEGLWINDOW_H_ 19 | -------------------------------------------------------------------------------- /OpenGLTest/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = OpenGLTest 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | SRCS = SampleGLApp.cpp SampleGLWindow.cpp SampleGLView.cpp 27 | 28 | # Specify the resource definition files to use. Full or relative paths can be 29 | # used. 30 | RDEFS = OpenGLTest.rdef 31 | 32 | # Specify the resource files to use. Full or relative paths can be used. 33 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 34 | RSRCS = 35 | 36 | # End Pe/Eddie support. 37 | # @<-src@ 38 | #%} 39 | 40 | # Specify libraries to link against. 41 | # There are two acceptable forms of library specifications: 42 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 43 | # you can simply specify XXX for the library. (e.g. the entry for 44 | # "libtracker.so" would be "tracker") 45 | # 46 | # - for GCC-independent linking of standard C++ libraries, you can use 47 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 48 | # 49 | # - if your library does not follow the standard library naming scheme, 50 | # you need to specify the path to the library and it's name. 51 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 52 | LIBS = $(STDCPPLIBS) be GL GLU 53 | 54 | # Specify additional paths to directories following the standard libXXX.so 55 | # or libXXX.a naming scheme. You can specify full paths or paths relative 56 | # to the Makefile. The paths included are not parsed recursively, so 57 | # include all of the paths where libraries must be found. Directories where 58 | # source files were specified are automatically included. 59 | LIBPATHS = 60 | 61 | # Additional paths to look for system headers. These use the form 62 | # "#include
". Directories that contain the files in SRCS are 63 | # NOT auto-included here. 64 | SYSTEM_INCLUDE_PATHS = 65 | 66 | # Additional paths paths to look for local headers. These use the form 67 | # #include "header". Directories that contain the files in SRCS are 68 | # automatically included. 69 | LOCAL_INCLUDE_PATHS = 70 | 71 | # Specify the level of optimization that you want. Specify either NONE (O0), 72 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 73 | OPTIMIZE := 74 | 75 | # Specify the codes for languages you are going to support in this 76 | # application. The default "en" one must be provided too. "make catkeys" 77 | # will recreate only the "locales/en.catkeys" file. Use it as a template 78 | # for creating catkeys for other languages. All localization files must be 79 | # placed in the "locales" subdirectory. 80 | LOCALES = 81 | 82 | # Specify all the preprocessor symbols to be defined. The symbols will not 83 | # have their values set automatically; you must supply the value (if any) to 84 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 85 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 86 | # "-DDEBUG" on the compiler's command line. 87 | DEFINES = 88 | 89 | # Specify the warning level. Either NONE (suppress all warnings), 90 | # ALL (enable all warnings), or leave blank (enable default warnings). 91 | WARNINGS = 92 | 93 | # With image symbols, stack crawls in the debugger are meaningful. 94 | # If set to "TRUE", symbols will be created. 95 | SYMBOLS := 96 | 97 | # Includes debug information, which allows the binary to be debugged easily. 98 | # If set to "TRUE", debug info will be created. 99 | DEBUGGER := 100 | 101 | # Specify any additional compiler flags to be used. 102 | COMPILER_FLAGS = 103 | 104 | # Specify any additional linker flags to be used. 105 | LINKER_FLAGS = 106 | 107 | # Specify the version of this binary. Example: 108 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 109 | # This may also be specified in a resource. 110 | APP_VERSION := 111 | 112 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 113 | # location in the /dev hierarchy. Example: 114 | # DRIVER_PATH = video/usb 115 | # will instruct the "driverinstall" rule to place a symlink to your driver's 116 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 117 | # appear at /dev/video/usb when loaded. The default is "misc". 118 | DRIVER_PATH = 119 | 120 | ## Include the Makefile-Engine 121 | DEVEL_DIRECTORY := \ 122 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 123 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 124 | 125 | run :: default 126 | $(TARGET) 127 | -------------------------------------------------------------------------------- /OpenGLTest/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/OpenGLTest/screenshot.png -------------------------------------------------------------------------------- /OpenGLTest2/OpenGLTest.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Be-GLSample"; 2 | 3 | resource app_flags B_MULTIPLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 0, 8 | minor = 0, 9 | 10 | variety = B_APPV_DEVELOPMENT, 11 | internal = 0, 12 | 13 | short_info = "OpenGLTest", 14 | long_info = "OpenGLTest" 15 | }; 16 | -------------------------------------------------------------------------------- /OpenGLTest2/README.md: -------------------------------------------------------------------------------- 1 | OpenGLTest2 2 | 3 | Based on GLGears. New window can be opened by Alt+N. Demonstrates OpenGL rendering in separate thread. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/OpenGLTest2/screenshot.png) 6 | -------------------------------------------------------------------------------- /OpenGLTest2/SampleGLApp.cpp: -------------------------------------------------------------------------------- 1 | #include "SampleGLApp.h" 2 | #include "SampleGLWindow.h" 3 | #include 4 | #include 5 | 6 | SampleGLApp::SampleGLApp() 7 | : BApplication("application/x-vnd.Be-GLSample") 8 | { 9 | newPos = BPoint(32, 32); 10 | NewWindow(); 11 | } 12 | 13 | SampleGLWindow *SampleGLApp::NewWindow() 14 | { 15 | BRect windowRect; 16 | SampleGLWindow *wnd = NULL; 17 | if (Lock()) { 18 | windowRect.Set(0, 0, 255, 255); 19 | wnd = new SampleGLWindow(windowRect); 20 | BScreen screen(wnd); 21 | BRect screenRect = screen.Frame(); 22 | windowRect.OffsetTo(newPos); 23 | newPos.x += 32; newPos.y += 32; 24 | if (windowRect.right > screenRect.right) { 25 | newPos.x += windowRect.Width() - screenRect.Width(); 26 | windowRect.OffsetBy(windowRect.Width() - screenRect.Width(), 0); 27 | } 28 | if (windowRect.bottom > screenRect.bottom) { 29 | newPos.y += windowRect.Height() - screenRect.Height(); 30 | windowRect.OffsetBy(0, windowRect.Height() - screenRect.Height()); 31 | } 32 | wnd->MoveTo(windowRect.LeftTop()); 33 | Unlock(); 34 | } 35 | if (wnd != NULL) wnd->Show(); 36 | return wnd; 37 | } 38 | 39 | 40 | int main() 41 | { 42 | SampleGLApp app; 43 | app.Run(); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /OpenGLTest2/SampleGLApp.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLAPP_CPP_ 2 | #define _SAMPLEGLAPP_CPP_ 3 | 4 | #include 5 | 6 | class SampleGLWindow; 7 | 8 | class SampleGLApp : public BApplication { 9 | public: 10 | SampleGLApp(); 11 | SampleGLWindow *NewWindow(); 12 | private: 13 | BPoint newPos; 14 | }; 15 | 16 | #endif // _SAMPLEGLAPP_CPP_ 17 | -------------------------------------------------------------------------------- /OpenGLTest2/SampleGLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLVIEW_H_ 2 | #define _SAMPLEGLVIEW_H_ 3 | 4 | #include 5 | 6 | class SampleGLView : public BGLView { 7 | public: 8 | SampleGLView(BRect frame); 9 | virtual ~SampleGLView(); 10 | void AttachedToWindow(void); 11 | void DetachedFromWindow(void); 12 | void FrameResized(float newWidth, float newHeight); 13 | void KeyDown(const char* bytes, int32 numBytes); 14 | void ErrorCallback(GLenum which); 15 | 16 | private: 17 | void gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth); 18 | void init(); 19 | void cleanup(); 20 | void draw(); 21 | void reshape(int width, int height); 22 | void idle(); 23 | 24 | static status_t RenderThread(void *arg); 25 | 26 | bool fRun; 27 | thread_id fThread; 28 | float width; 29 | float height; 30 | 31 | bigtime_t T0; 32 | GLint Frames; 33 | GLfloat viewDist; 34 | GLfloat view_rotx, view_roty, view_rotz; 35 | GLint gear1, gear2, gear3; 36 | bigtime_t displayTime; 37 | GLfloat angle; 38 | }; 39 | 40 | #endif // _SAMPLEGLVIEW_H_ 41 | -------------------------------------------------------------------------------- /OpenGLTest2/SampleGLWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "SampleGLApp.h" 2 | #include "SampleGLWindow.h" 3 | #include "SampleGLView.h" 4 | 5 | SampleGLWindow::SampleGLWindow(BRect frame) 6 | : BWindow(frame, "OpenGL Test 2", B_TITLED_WINDOW, 0) 7 | { 8 | AddShortcut('n', B_COMMAND_KEY, new BMessage('neww')); 9 | AddChild(theView=new SampleGLView(Bounds())); 10 | } 11 | 12 | bool SampleGLWindow::QuitRequested() 13 | { 14 | if (be_app->CountWindows() == 1) 15 | be_app->PostMessage(B_QUIT_REQUESTED); 16 | return true; 17 | } 18 | 19 | void SampleGLWindow::MessageReceived(BMessage *msg) 20 | { 21 | switch (msg->what) { 22 | case 'neww': { 23 | ((SampleGLApp*)be_app)->NewWindow(); 24 | break; 25 | } 26 | default: 27 | BWindow::MessageReceived(msg); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenGLTest2/SampleGLWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLEGLWINDOW_H_ 2 | #define _SAMPLEGLWINDOW_H_ 3 | 4 | #include 5 | 6 | class SampleGLView; 7 | 8 | class SampleGLWindow : public BWindow { 9 | public: 10 | SampleGLWindow(BRect frame); 11 | virtual bool QuitRequested(); 12 | void MessageReceived(BMessage *msg); 13 | 14 | private: 15 | SampleGLView* theView; 16 | }; 17 | 18 | #endif // _SAMPLEGLWINDOW_H_ 19 | -------------------------------------------------------------------------------- /OpenGLTest2/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = OpenGLTest 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | SRCS = SampleGLApp.cpp SampleGLWindow.cpp SampleGLView.cpp 27 | 28 | # Specify the resource definition files to use. Full or relative paths can be 29 | # used. 30 | RDEFS = OpenGLTest.rdef 31 | 32 | # Specify the resource files to use. Full or relative paths can be used. 33 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 34 | RSRCS = 35 | 36 | # End Pe/Eddie support. 37 | # @<-src@ 38 | #%} 39 | 40 | # Specify libraries to link against. 41 | # There are two acceptable forms of library specifications: 42 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 43 | # you can simply specify XXX for the library. (e.g. the entry for 44 | # "libtracker.so" would be "tracker") 45 | # 46 | # - for GCC-independent linking of standard C++ libraries, you can use 47 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 48 | # 49 | # - if your library does not follow the standard library naming scheme, 50 | # you need to specify the path to the library and it's name. 51 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 52 | LIBS = $(STDCPPLIBS) be GL GLU 53 | 54 | # Specify additional paths to directories following the standard libXXX.so 55 | # or libXXX.a naming scheme. You can specify full paths or paths relative 56 | # to the Makefile. The paths included are not parsed recursively, so 57 | # include all of the paths where libraries must be found. Directories where 58 | # source files were specified are automatically included. 59 | LIBPATHS = 60 | 61 | # Additional paths to look for system headers. These use the form 62 | # "#include
". Directories that contain the files in SRCS are 63 | # NOT auto-included here. 64 | SYSTEM_INCLUDE_PATHS = 65 | 66 | # Additional paths paths to look for local headers. These use the form 67 | # #include "header". Directories that contain the files in SRCS are 68 | # automatically included. 69 | LOCAL_INCLUDE_PATHS = 70 | 71 | # Specify the level of optimization that you want. Specify either NONE (O0), 72 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 73 | OPTIMIZE := 74 | 75 | # Specify the codes for languages you are going to support in this 76 | # application. The default "en" one must be provided too. "make catkeys" 77 | # will recreate only the "locales/en.catkeys" file. Use it as a template 78 | # for creating catkeys for other languages. All localization files must be 79 | # placed in the "locales" subdirectory. 80 | LOCALES = 81 | 82 | # Specify all the preprocessor symbols to be defined. The symbols will not 83 | # have their values set automatically; you must supply the value (if any) to 84 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 85 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 86 | # "-DDEBUG" on the compiler's command line. 87 | DEFINES = 88 | 89 | # Specify the warning level. Either NONE (suppress all warnings), 90 | # ALL (enable all warnings), or leave blank (enable default warnings). 91 | WARNINGS = 92 | 93 | # With image symbols, stack crawls in the debugger are meaningful. 94 | # If set to "TRUE", symbols will be created. 95 | SYMBOLS := 96 | 97 | # Includes debug information, which allows the binary to be debugged easily. 98 | # If set to "TRUE", debug info will be created. 99 | DEBUGGER := 100 | 101 | # Specify any additional compiler flags to be used. 102 | COMPILER_FLAGS = 103 | 104 | # Specify any additional linker flags to be used. 105 | LINKER_FLAGS = 106 | 107 | # Specify the version of this binary. Example: 108 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 109 | # This may also be specified in a resource. 110 | APP_VERSION := 111 | 112 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 113 | # location in the /dev hierarchy. Example: 114 | # DRIVER_PATH = video/usb 115 | # will instruct the "driverinstall" rule to place a symlink to your driver's 116 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 117 | # appear at /dev/video/usb when loaded. The default is "misc". 118 | DRIVER_PATH = 119 | 120 | ## Include the Makefile-Engine 121 | DEVEL_DIRECTORY := \ 122 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 123 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 124 | 125 | run :: default 126 | $(TARGET) 127 | -------------------------------------------------------------------------------- /OpenGLTest2/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/OpenGLTest2/screenshot.png -------------------------------------------------------------------------------- /PictureDump/README.md: -------------------------------------------------------------------------------- 1 | PictureDump 2 | 3 | Command line utility to inspect contents of picture files produced by BPicture::Flatten. 4 | -------------------------------------------------------------------------------- /PictureDumpJson/README.md: -------------------------------------------------------------------------------- 1 | PictureDumpJson 2 | 3 | Command line utility to converd flattened BPicture file to JSON format. 4 | -------------------------------------------------------------------------------- /PictureDumpJson/meson.build: -------------------------------------------------------------------------------- 1 | project('PictureDumpJson', 'cpp') 2 | 3 | cpp = meson.get_compiler('cpp') 4 | dep_libbe = cpp.find_library('be') 5 | dep_rapidjson = dependency('RapidJSON') 6 | 7 | executable('PictureDumpJson', 8 | 'PictureDump.cpp', 9 | dependencies: [ 10 | dep_libbe, 11 | dep_rapidjson, 12 | ], 13 | gnu_symbol_visibility: 'hidden', 14 | install: true 15 | ) 16 | -------------------------------------------------------------------------------- /PictureView/PictureView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | enum { 14 | appWindowClosedMsg = 1, 15 | }; 16 | 17 | class StateGroup 18 | { 19 | private: 20 | BView *fView; 21 | public: 22 | StateGroup(BView *view): fView(view) {if (fView != NULL) fView->PushState();} 23 | ~StateGroup() {if (fView != NULL) fView->PopState();} 24 | }; 25 | 26 | 27 | class TestView: public BView 28 | { 29 | private: 30 | ObjectDeleter fPict; 31 | BPoint fOffset; 32 | float fScale; 33 | float fRotation; 34 | bool fTrack; 35 | BPoint fOldPos; 36 | 37 | public: 38 | TestView(BRect frame, const char *name): 39 | BView(frame, name, B_FOLLOW_NONE, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_SUBPIXEL_PRECISE), 40 | fOffset(0, 0), 41 | fScale(1), 42 | fRotation(0), 43 | fTrack(false) 44 | { 45 | } 46 | 47 | void SetPicture(BPicture *pict) 48 | { 49 | fPict.SetTo(pict); 50 | Invalidate(); 51 | } 52 | 53 | void Draw(BRect dirty) 54 | { 55 | if (fPict.Get() != NULL) { 56 | ScaleBy(fScale, fScale); 57 | RotateBy(fRotation); 58 | TranslateBy(fOffset.x, fOffset.y); 59 | DrawPicture(fPict.Get()); 60 | } 61 | } 62 | 63 | void MouseDown(BPoint where) 64 | { 65 | if (!fTrack) { 66 | SetMouseEventMask(B_POINTER_EVENTS, 0); 67 | fTrack = true; 68 | fOldPos = where; 69 | } 70 | } 71 | 72 | void Translate(BPoint offset) 73 | { 74 | fOffset += BPoint(offset.x/fScale, offset.y/fScale); 75 | Invalidate(); 76 | } 77 | 78 | void MouseUp(BPoint where) 79 | { 80 | fTrack = false; 81 | } 82 | 83 | void MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) 84 | { 85 | if (fTrack) { 86 | Translate(where - fOldPos); 87 | } 88 | fOldPos = where; 89 | } 90 | 91 | void MessageReceived(BMessage *msg) 92 | { 93 | switch (msg->what) { 94 | case B_MOUSE_WHEEL_CHANGED: { 95 | float deltaY = 0; 96 | if (msg->FindFloat("be:wheel_delta_y", &deltaY) != B_OK || deltaY == 0) 97 | return; 98 | 99 | Translate(-fOldPos); 100 | fScale *= powf(sqrt(2), -deltaY); 101 | Translate(fOldPos); 102 | Invalidate(); 103 | break; 104 | } 105 | default: 106 | BView::MessageReceived(msg); 107 | } 108 | } 109 | 110 | }; 111 | 112 | class TestWindow: public BWindow 113 | { 114 | private: 115 | TestView *fView; 116 | 117 | public: 118 | TestWindow(BRect frame): BWindow(frame, "TestApp", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 119 | { 120 | fView = new TestView(frame.OffsetToCopy(B_ORIGIN), "view"); 121 | fView->SetResizingMode(B_FOLLOW_ALL); 122 | AddChild(fView, NULL); 123 | fView->MakeFocus(true); 124 | } 125 | 126 | status_t Load(BEntry &entry) 127 | { 128 | status_t res; 129 | BFile file(&entry, B_READ_ONLY); 130 | res = file.InitCheck(); if (res < B_OK) return res; 131 | ObjectDeleter pict(new BPicture()); 132 | pict->Unflatten(&file); 133 | fView->SetPicture(pict.Detach()); 134 | SetTitle(entry.Name()); 135 | return B_OK; 136 | } 137 | 138 | void Quit() 139 | { 140 | be_app_messenger.SendMessage(appWindowClosedMsg); 141 | BWindow::Quit(); 142 | } 143 | 144 | }; 145 | 146 | 147 | class TestApplication: public BApplication 148 | { 149 | private: 150 | int32 fWndCnt; 151 | 152 | public: 153 | TestApplication(): BApplication("application/x-vnd.Test-PictureView"), 154 | fWndCnt(0) 155 | { 156 | } 157 | 158 | void ReadyToRun() { 159 | if (fWndCnt <= 0) 160 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 161 | } 162 | 163 | void RefsReceived(BMessage *refsMsg) 164 | { 165 | entry_ref ref; 166 | if (refsMsg->FindRef("refs", &ref) < B_OK) return; 167 | BEntry entry(&ref); 168 | 169 | BRect rect(0, 0, 640, 480); 170 | rect.OffsetBy(64, 64); 171 | TestWindow *wnd = new TestWindow(rect); 172 | if (wnd->Load(entry) < B_OK) return; 173 | fWndCnt++; 174 | wnd->Show(); 175 | } 176 | 177 | void MessageReceived(BMessage *msg) 178 | { 179 | switch (msg->what) { 180 | case appWindowClosedMsg: { 181 | fWndCnt--; 182 | if (fWndCnt <= 0) 183 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 184 | break; 185 | } 186 | default: 187 | BApplication::MessageReceived(msg); 188 | } 189 | } 190 | 191 | }; 192 | 193 | 194 | int main() 195 | { 196 | TestApplication app; 197 | app.Run(); 198 | return 0; 199 | } 200 | -------------------------------------------------------------------------------- /PictureView/PictureView.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Test-PictureView"; 2 | 3 | resource app_flags B_SINGLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 0, 8 | minor = 0, 9 | 10 | variety = B_APPV_DEVELOPMENT, 11 | internal = 0, 12 | 13 | short_info = "PictureView", 14 | long_info = "Show flattened BPicture files." 15 | }; 16 | 17 | resource file_types message { 18 | "types" = "image/vnd.haiku.picture" 19 | }; 20 | -------------------------------------------------------------------------------- /PictureView/Placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/PictureView/Placeholder -------------------------------------------------------------------------------- /PictureView/README.md: -------------------------------------------------------------------------------- 1 | PictureView 2 | 3 | Show flattened BPicture files. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/PictureView/screenshot.png) 6 | -------------------------------------------------------------------------------- /PictureView/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/PictureView/screenshot.png -------------------------------------------------------------------------------- /Promises/CredentialsApp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Promises.h" 13 | #include "CredentialsWindow.h" 14 | 15 | enum { 16 | loginBtnPressed = 1, 17 | cancelBtnPressed = 2, 18 | }; 19 | 20 | 21 | class TestWindow: public BWindow 22 | { 23 | private: 24 | BTextControl *fUserField; 25 | BTextControl *fPasswordField; 26 | BButton *fLoginBtn; 27 | BButton *fCancelBtn; 28 | CredentialsPromiseRef fPromise; 29 | 30 | public: 31 | TestWindow(BRect frame): 32 | BWindow(frame, "Login Request", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) 33 | { 34 | fUserField = new BTextControl("user", "User:", "", NULL); 35 | fPasswordField = new BTextControl("password", "Password:", "", NULL); 36 | fLoginBtn = new BButton("login", "Request", new BMessage(loginBtnPressed)); 37 | fCancelBtn = new BButton("cancel", "Cancel", new BMessage(cancelBtnPressed)); 38 | 39 | BLayoutBuilder::Group<>(this, B_VERTICAL, 0) 40 | .SetInsets(B_USE_DEFAULT_SPACING) 41 | .AddGlue() 42 | .AddGroup(B_HORIZONTAL) 43 | .Add(fUserField->CreateLabelLayoutItem()) 44 | .AddGlue() 45 | .End() 46 | .Add(fUserField->CreateTextViewLayoutItem()) 47 | .AddStrut(B_USE_DEFAULT_SPACING) 48 | .AddGroup(B_HORIZONTAL) 49 | .Add(fPasswordField->CreateLabelLayoutItem()) 50 | .AddGlue() 51 | .End() 52 | .Add(fPasswordField->CreateTextViewLayoutItem()) 53 | .AddStrut(B_USE_DEFAULT_SPACING) 54 | .AddGroup(B_HORIZONTAL) 55 | .AddGlue() 56 | .Add(fLoginBtn) 57 | .Add(fCancelBtn) 58 | .AddGlue() 59 | .End() 60 | .AddGlue() 61 | .End(); 62 | 63 | fUserField->SetEnabled(false); 64 | fPasswordField->SetEnabled(false); 65 | fLoginBtn->MakeFocus(true); 66 | fCancelBtn->SetEnabled(false); 67 | SetDefaultButton(fLoginBtn); 68 | } 69 | 70 | void MessageReceived(BMessage *msg) 71 | { 72 | switch (msg->what) { 73 | case loginBtnPressed: { 74 | CredentialsPromiseRef promise = GetCredentials(); 75 | fPromise = promise; 76 | fLoginBtn->SetEnabled(false); 77 | fCancelBtn->SetEnabled(true); 78 | 79 | promise->OnResolve([this](Promise &promise) { 80 | printf("GetCredentials done: \"%s\", \"%s\"\n", promise.ResolvedValue().login.String(), promise.ResolvedValue().password.String()); 81 | }); 82 | promise->OnResolve([this](Promise &promise) { 83 | BAutolock lock(this); 84 | fUserField->SetText(promise.ResolvedValue().login); 85 | fPasswordField->SetText(promise.ResolvedValue().password); 86 | fLoginBtn->SetEnabled(true); 87 | fCancelBtn->SetEnabled(false); 88 | fPromise.Unset(); 89 | }); 90 | 91 | promise->OnReject([this](Promise &promise) { 92 | printf("GetCredentials failed: %d\n", promise.RejectedValue()); 93 | }); 94 | promise->OnReject([this](Promise &promise) { 95 | (void)promise; 96 | BAutolock lock(this); 97 | fLoginBtn->SetEnabled(true); 98 | fCancelBtn->SetEnabled(false); 99 | fPromise.Unset(); 100 | }); 101 | break; 102 | } 103 | case cancelBtnPressed: { 104 | fPromise->Reject(B_ERROR); 105 | break; 106 | } 107 | default: 108 | BWindow::MessageReceived(msg); 109 | } 110 | } 111 | 112 | }; 113 | 114 | 115 | class TestApplication: public BApplication 116 | { 117 | private: 118 | TestWindow *fWnd; 119 | public: 120 | TestApplication(): BApplication("application/x-vnd.test.app") 121 | { 122 | TestWindow *fWnd = new TestWindow(BRect(0, 0, 255, 0)); 123 | fWnd->SetFlags(fWnd->Flags() | B_QUIT_ON_WINDOW_CLOSE); 124 | fWnd->CenterOnScreen(); 125 | fWnd->MoveBy(-192, -192); 126 | fWnd->Show(); 127 | } 128 | }; 129 | 130 | 131 | int main() 132 | { 133 | TestApplication app; 134 | app.Run(); 135 | return 0; 136 | } 137 | -------------------------------------------------------------------------------- /Promises/CredentialsWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "CredentialsWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | enum { 12 | loginBtnPressed = 1, 13 | }; 14 | 15 | 16 | class CredentialsWindow: public BWindow 17 | { 18 | private: 19 | CredentialsPromiseRef fPromise; 20 | bool fResolved; 21 | BTextControl *fUserField; 22 | BTextControl *fPasswordField; 23 | BButton *fLoginBtn; 24 | 25 | public: 26 | CredentialsWindow(CredentialsPromiseRef promise, BRect frame): 27 | BWindow(frame, "Login", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), 28 | fPromise(promise), 29 | fResolved(false) 30 | { 31 | fUserField = new BTextControl("user", "User:", "", NULL); 32 | fPasswordField = new BTextControl("password", "Password:", "", NULL); 33 | fPasswordField->TextView()->HideTyping(true); 34 | fLoginBtn = new BButton("login", "Login", new BMessage(loginBtnPressed)); 35 | 36 | BLayoutBuilder::Group<>(this, B_VERTICAL, 0) 37 | .SetInsets(B_USE_DEFAULT_SPACING) 38 | .AddGlue() 39 | .AddGroup(B_HORIZONTAL) 40 | .Add(fUserField->CreateLabelLayoutItem()) 41 | .AddGlue() 42 | .End() 43 | .Add(fUserField->CreateTextViewLayoutItem()) 44 | .AddStrut(B_USE_DEFAULT_SPACING) 45 | .AddGroup(B_HORIZONTAL) 46 | .Add(fPasswordField->CreateLabelLayoutItem()) 47 | .AddGlue() 48 | .End() 49 | .Add(fPasswordField->CreateTextViewLayoutItem()) 50 | .AddStrut(B_USE_DEFAULT_SPACING) 51 | .AddGroup(B_HORIZONTAL) 52 | .AddGlue() 53 | .Add(fLoginBtn) 54 | .AddGlue() 55 | .End() 56 | .AddGlue() 57 | .End(); 58 | 59 | fUserField->MakeFocus(true); 60 | SetDefaultButton(fLoginBtn); 61 | 62 | // close window if promise is set 63 | fPromise->OnSet([this](Promise &promise) { 64 | (void)promise; 65 | PostMessage(B_QUIT_REQUESTED); 66 | }); 67 | } 68 | 69 | void MessageReceived(BMessage *msg) 70 | { 71 | switch (msg->what) { 72 | case loginBtnPressed: { 73 | if (!fResolved) { 74 | fResolved = true; 75 | fPromise->Resolve(fUserField->Text(), fPasswordField->Text()); 76 | // PostMessage(B_QUIT_REQUESTED); 77 | } 78 | break; 79 | } 80 | default: 81 | BWindow::MessageReceived(msg); 82 | } 83 | } 84 | 85 | void Quit() 86 | { 87 | if (!fResolved) 88 | fPromise->Reject(B_ERROR); 89 | BWindow::Quit(); 90 | } 91 | 92 | }; 93 | 94 | 95 | CredentialsPromiseRef GetCredentials() 96 | { 97 | CredentialsPromiseRef promise(new Promise(), true); 98 | CredentialsWindow *fWnd = new CredentialsWindow(promise, BRect(0, 0, 255, 0)); 99 | fWnd->CenterOnScreen(); 100 | fWnd->Show(); 101 | return promise; 102 | } 103 | -------------------------------------------------------------------------------- /Promises/CredentialsWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Promises.h" 4 | #include 5 | 6 | struct Credentials { 7 | BString login; 8 | BString password; 9 | Credentials(const char *login, const char *password): login(login), password(password) {} 10 | }; 11 | 12 | typedef BReference > CredentialsPromiseRef; 13 | 14 | CredentialsPromiseRef GetCredentials(); 15 | -------------------------------------------------------------------------------- /Promises/Promises.cpp: -------------------------------------------------------------------------------- 1 | #include "Promises.h" 2 | #include 3 | 4 | // not used for now 5 | -------------------------------------------------------------------------------- /Promises/Promises.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | template 12 | class Promise: public BReferenceable { 13 | private: 14 | struct PromiseItem { 15 | PromiseItem *next; 16 | virtual void Do(Promise &promise) = 0; 17 | PromiseItem(): next(NULL) {} 18 | virtual ~PromiseItem() {} 19 | }; 20 | 21 | template 22 | struct PromiseItemImpl final: public PromiseItem { 23 | FnType fDoFn; 24 | void Do(Promise &promise) final {fDoFn(promise);} 25 | PromiseItemImpl(FnType doFn): fDoFn(doFn) {} 26 | }; 27 | 28 | BLocker fLocker; 29 | std::optional fResolvedVal; 30 | std::optional fRejectedVal; 31 | PromiseItem *fOnResolve; 32 | PromiseItem *fOnReject; 33 | 34 | public: 35 | Promise(): fOnResolve(NULL), fOnReject(NULL) 36 | {BAutolock lock(fLocker);} 37 | 38 | ~Promise() 39 | { 40 | printf("-Promise()\n"); 41 | BAutolock lock(fLocker); 42 | while (fOnResolve != NULL) { 43 | PromiseItem *next = fOnResolve->next; 44 | delete fOnResolve; 45 | fOnResolve = next; 46 | } 47 | while (fOnReject != NULL) { 48 | PromiseItem *next = fOnReject->next; 49 | delete fOnReject; 50 | fOnReject = next; 51 | } 52 | } 53 | 54 | bool IsResolved() {BAutolock lock(fLocker); return fResolvedVal.has_value();} 55 | bool IsRejected() {BAutolock lock(fLocker); return fRejectedVal.has_value();} 56 | bool IsSet() {BAutolock lock(fLocker); return IsResolved() || IsRejected();} 57 | ResolvedType &ResolvedValue() {BAutolock lock(fLocker); return *fResolvedVal;} 58 | RejectedType &RejectedValue() {BAutolock lock(fLocker); return *fRejectedVal;} 59 | 60 | template< class... Args > 61 | bool Resolve(Args&&... args) 62 | { 63 | BAutolock lock(fLocker); 64 | if (IsSet()) return false; 65 | fResolvedVal.emplace(std::forward(args)...); 66 | for (PromiseItem *item = fOnResolve; item != NULL; item = item->next) { 67 | item->Do(*this); 68 | } 69 | return true; 70 | } 71 | 72 | template< class... Args > 73 | bool Reject(Args&&... args) 74 | { 75 | BAutolock lock(fLocker); 76 | if (IsSet()) return false; 77 | fRejectedVal.emplace(std::forward(args)...); 78 | for (PromiseItem *item = fOnReject; item != NULL; item = item->next) { 79 | item->Do(*this); 80 | } 81 | return true; 82 | } 83 | 84 | template 85 | void OnResolve(DoFn callback) 86 | { 87 | BAutolock lock(fLocker); 88 | if (fResolvedVal.has_value()) { 89 | return callback(*this); 90 | } 91 | if (!fRejectedVal.has_value()) { 92 | PromiseItem *item = new PromiseItemImpl(callback); 93 | item->next = fOnResolve; fOnResolve = item; 94 | } 95 | } 96 | 97 | template 98 | void OnReject(DoFn callback) 99 | { 100 | BAutolock lock(fLocker); 101 | if (fRejectedVal.has_value()) { 102 | return callback(*this); 103 | } 104 | if (!fResolvedVal.has_value()) { 105 | PromiseItem *item = new PromiseItemImpl(callback); 106 | item->next = fOnReject; fOnReject = item; 107 | } 108 | } 109 | 110 | template 111 | void OnSet(DoFn callback) 112 | { 113 | BAutolock lock(fLocker); 114 | OnResolve(callback); 115 | OnReject(callback); 116 | } 117 | 118 | }; 119 | -------------------------------------------------------------------------------- /Promises/README.md: -------------------------------------------------------------------------------- 1 | Promises 2 | 3 | Simple promise implementation and demonstration of using promises to request user input with dialog window. 4 | 5 | Promises allow to run some task asynchronously and register callbacks that will be called when task is completed or failed. No threads are used by promises itself, it only register and call completion callbacks. 6 | 7 | Example use promise to ask user to enter login and password in a window. Then user enter form, promise will be resolved and all resolve callbacks will be called, receiving entered credentials. user also can cancel dialog that will cause reject callbacks to be called. Promise client can also reject promise it it don't need for data anymore, that will cause form dialog to be closed. 8 | 9 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/Promises/screenshot.png) 10 | -------------------------------------------------------------------------------- /Promises/Tests.cpp: -------------------------------------------------------------------------------- 1 | #include "Promises.h" 2 | #include 3 | 4 | 5 | Promise gPromise; 6 | 7 | 8 | int main() 9 | { 10 | gPromise.OnResolve([](Promise &promise) { 11 | printf("(1) gPromise resolved: %d\n", promise.ResolvedValue()); 12 | }); 13 | gPromise.OnResolve([](Promise &promise) { 14 | printf("(2) gPromise resolved: %d\n", promise.ResolvedValue()); 15 | }); 16 | gPromise.OnReject([](Promise &promise) { 17 | printf("gPromise rejected: %d\n", promise.RejectedValue()); 18 | }); 19 | gPromise.Resolve(123); 20 | //gPromise.Reject(-123); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Promises/meson.build: -------------------------------------------------------------------------------- 1 | project('Promises', 'cpp', 2 | default_options : ['warning_level=3', 'cpp_std=c++2a'] 3 | ) 4 | 5 | cpp = meson.get_compiler('cpp') 6 | 7 | executable('Promises', 8 | sources: [ 9 | 'Promises.cpp', 10 | 'Tests.cpp', 11 | ], 12 | dependencies: [ 13 | cpp.find_library('be') 14 | ], 15 | ) 16 | 17 | executable('Credentials', 18 | sources: [ 19 | 'CredentialsApp.cpp', 20 | 'CredentialsWindow.cpp', 21 | ], 22 | dependencies: [ 23 | cpp.find_library('be') 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /Promises/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Promises/screenshot.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Utilities and test programs for Haiku. 2 | 3 | Most programs can be compiled with `make` and executed with `make run`. GCC2 is not supported, use `setarch x86` before compiling programs on 32 bit x86 Haiku. 4 | 5 | Feel free to create issues if compile fails or some bug is found. 6 | -------------------------------------------------------------------------------- /ScreenKeyboard/KeyboardDevice.cpp: -------------------------------------------------------------------------------- 1 | #include "KeyboardDevice.h" 2 | #include "KeyboardWindow.h" 3 | #include 4 | 5 | KeyboardDevice *kbdDev; 6 | 7 | 8 | KeyboardDevice::KeyboardDevice(): handler(this, NULL, NULL, 0, 0) 9 | { 10 | key_map *keyMap; 11 | char *chars; 12 | bigtime_t delay; 13 | int32 rate; 14 | 15 | get_key_map(&keyMap, &chars); 16 | get_key_repeat_delay(&delay); 17 | get_key_repeat_rate (&rate); 18 | 19 | handler.SetKeyMap(keyMap, chars); 20 | handler.LocksChanged(keyMap->lock_settings); 21 | handler.SetRepeat(delay, rate); 22 | } 23 | 24 | KeyboardDevice::~KeyboardDevice() 25 | { 26 | } 27 | 28 | 29 | status_t KeyboardDevice::InitCheck() 30 | { 31 | kbdDev = this; 32 | 33 | static input_device_ref keyboard = {(char*)"Screen keyboard", B_KEYBOARD_DEVICE, (void*)this}; 34 | static input_device_ref *devices[2] = {&keyboard, NULL}; 35 | 36 | RegisterDevices(devices); 37 | return B_OK; 38 | } 39 | 40 | 41 | status_t KeyboardDevice::Start(const char* name, void* cookie) 42 | { 43 | wnd = new KeyboardWindow(&handler); 44 | wnd->Show(); 45 | return B_OK; 46 | } 47 | 48 | status_t KeyboardDevice::Stop(const char* name, void* cookie) 49 | { 50 | if (wnd != NULL && wnd->Lock()) { 51 | wnd->Quit(); 52 | wnd = NULL; 53 | } 54 | return B_OK; 55 | } 56 | 57 | 58 | status_t KeyboardDevice::Control(const char* name, void* cookie, uint32 command, BMessage* message) 59 | { 60 | switch (command) { 61 | case B_KEY_LOCKS_CHANGED: { 62 | key_map *keyMap; 63 | char *chars; 64 | get_key_map(&keyMap, &chars); 65 | handler.LocksChanged(keyMap->lock_settings); 66 | delete keyMap; 67 | delete chars; 68 | } 69 | case B_KEY_MAP_CHANGED: { 70 | key_map *keyMap; 71 | char *chars; 72 | get_key_map(&keyMap, &chars); 73 | handler.SetKeyMap(keyMap, chars); 74 | } 75 | case B_KEY_REPEAT_DELAY_CHANGED: 76 | case B_KEY_REPEAT_RATE_CHANGED: { 77 | bigtime_t delay; 78 | int32 rate; 79 | get_key_repeat_delay(&delay); 80 | get_key_repeat_rate (&rate); 81 | handler.SetRepeat(delay, rate); 82 | } 83 | } 84 | return B_OK; 85 | } 86 | 87 | 88 | extern "C" BInputServerDevice *instantiate_input_device() 89 | { 90 | return new(std::nothrow) KeyboardDevice(); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /ScreenKeyboard/KeyboardDevice.h: -------------------------------------------------------------------------------- 1 | #ifndef _KEYBOARDDEVICE_H_ 2 | #define _KEYBOARDDEVICE_H_ 3 | 4 | #include 5 | #include "KeyboardHandler.h" 6 | 7 | class KeyboardWindow; 8 | 9 | 10 | class KeyboardDevice: public BInputServerDevice 11 | { 12 | public: 13 | KeyboardDevice(); 14 | ~KeyboardDevice(); 15 | 16 | status_t InitCheck(); 17 | 18 | status_t Start(const char* name, void* cookie); 19 | status_t Stop(const char* name, void* cookie); 20 | 21 | status_t Control(const char* name, void* cookie, uint32 command, BMessage* message); 22 | 23 | private: 24 | KeyboardHandler handler; 25 | KeyboardWindow *wnd; 26 | }; 27 | 28 | 29 | extern KeyboardDevice *kbdDev; 30 | 31 | extern "C" _EXPORT BInputServerDevice* instantiate_input_device(); 32 | 33 | #endif // _KEYBOARDDEVICE_H_ 34 | -------------------------------------------------------------------------------- /ScreenKeyboard/KeyboardHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef _KEYBOARDHANDLER_H_ 2 | #define _KEYBOARDHANDLER_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class KeyboardNotifier 11 | { 12 | private: 13 | friend class KeyboardHandler; 14 | KeyboardNotifier *next; 15 | 16 | public: 17 | virtual void KeymapChanged() = 0; 18 | /* 19 | virtual void KeyStringChanged(uint32 scanCode) = 0; 20 | virtual void KeyStateChanged (uint32 scanCode, bool isDown) = 0; 21 | virtual void ModifierChanged (uint32 modifier, bool isOn) = 0; 22 | */ 23 | }; 24 | 25 | class KeyboardHandler 26 | { 27 | private: 28 | BInputServerDevice *dev; 29 | 30 | BPrivate::AutoDeleter keyMap; 31 | BPrivate::AutoDeleter chars; 32 | 33 | uint8 state[16]; 34 | uint32 modifiers; 35 | 36 | bigtime_t repeatDelay; 37 | int32 repeatRate; 38 | BMessage repeatMsg; 39 | thread_id repeatThread; 40 | sem_id repeatThreadSem; 41 | 42 | KeyboardNotifier *notifiers; 43 | 44 | void StartRepeating(BMessage *msg); 45 | void StopRepeating(); 46 | static status_t RepeatThread(void *arg); 47 | 48 | public: 49 | KeyboardHandler(BInputServerDevice *dev, key_map *keyMap, char *chars, bigtime_t repeatDelay, int32 repeatRate); 50 | ~KeyboardHandler(); 51 | 52 | void SetKeyMap(key_map *keyMap, char *chars); 53 | void SetRepeat(bigtime_t delay, int32 rate); 54 | 55 | void InstallNotifier (KeyboardNotifier *notifier); 56 | void UninstallNotifier(KeyboardNotifier *notifier); 57 | 58 | void State(uint *state); 59 | uint32 Modifiers(); 60 | void KeyString(uint32 code, char *str, size_t len); 61 | 62 | void KeyChanged(uint32 code, bool isDown); 63 | void CodelessKeyChanged(const char *str, bool isDown, bool doRepeat); 64 | void StateChanged(uint8 state[16]); 65 | void LocksChanged(uint32 locks); 66 | }; 67 | 68 | 69 | #endif // _KEYBOARDHANDLER_H_ 70 | -------------------------------------------------------------------------------- /ScreenKeyboard/KeyboardWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _KEYBOARDWINDOW_H_ 2 | #define _KEYBOARDWINDOW_H_ 3 | 4 | #include 5 | 6 | 7 | class KeyboardHandler; 8 | 9 | 10 | class KeyboardWindow: public BWindow 11 | { 12 | public: 13 | KeyboardWindow(KeyboardHandler *handler); 14 | }; 15 | 16 | #endif // _KEYBOARDWINDOW_H_ 17 | -------------------------------------------------------------------------------- /ScreenKeyboard/README.md: -------------------------------------------------------------------------------- 1 | ScreenKeyboard 2 | 3 | Intended to use on tablet PC. Depends on experimantal multitouch API. 4 | 5 | Keyboard is enabled/disabled by ToggleKeyboard script. Path to executable in script may be need to adjusted. 6 | 7 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/ScreenKeyboard/screenshot.png) 8 | -------------------------------------------------------------------------------- /ScreenKeyboard/ToggleKeyboard: -------------------------------------------------------------------------------- 1 | #!sh 2 | BIN_PATH=$(dirname $0)/objects.x86_64-cc8-release 3 | TARGET_PATH=/boot/home/config/non-packaged/add-ons/input_server/devices 4 | if test -f "$TARGET_PATH/screen_keyboard"; then 5 | mv "$TARGET_PATH/screen_keyboard" "$BIN_PATH/screen_keyboard" 6 | else 7 | mv "$BIN_PATH/screen_keyboard" "$TARGET_PATH/screen_keyboard" 8 | fi 9 | -------------------------------------------------------------------------------- /ScreenKeyboard/Translation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static const char *eisu[] = { 4 | "#", "E", "$", "%", "&", "\x27", "(", ")", "|", "Z", "y", "3", "e", "4", "5", "6", "t", "g", "h", ":", "b", "x", "d", "r", "p", "c", "q", "a", "z", "w", "s", "u", "i", "1", ",", "k", "f", "v", "2", "^", "-", "j", "n", "]", "/", "m", "7", "8", "9", "o", "l", ".", ";", "`", "0", ">", "<", "?", "{", "}", "\\", "[", "@" 5 | "" 6 | }; 7 | 8 | static const char *kana[] = { 9 | "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゃ", "ゅ", "ょ", "を", "っ", "ん", "あ", "い", "う", "え", "お", "か", "き", "く", "け", "こ", "さ", "し", "す", "せ", "そ", "た", "ち", "つ", "て", "と", "な", "に", "ぬ", "ね", "の", "は", "ひ", "ふ", "へ", "ほ", "ま", "み", "む", "め", "も", "や", "ゆ", "よ", "ら", "り", "る", "れ", "ろ", "わ", "。", "、", "・", "「", "」", "ー", "゜", "゛", 10 | "" 11 | }; 12 | 13 | const char *Translate(const char *ch) 14 | { 15 | unsigned i = 0; 16 | while (kana[i][0] != '\0' && strcmp(ch, kana[i]) != 0) ++i; 17 | if (kana[i][0] == '\0') return ch; 18 | else return eisu[i]; 19 | } 20 | -------------------------------------------------------------------------------- /ScreenKeyboard/_APP_: -------------------------------------------------------------------------------- 1 | /boot/system/servers/input_server -------------------------------------------------------------------------------- /ScreenKeyboard/devices: -------------------------------------------------------------------------------- 1 | /boot/home/config/non-packaged/add-ons/input_server/devices -------------------------------------------------------------------------------- /ScreenKeyboard/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/ScreenKeyboard/screenshot.png -------------------------------------------------------------------------------- /Services/Icons/Delete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/Icons/Delete -------------------------------------------------------------------------------- /Services/Icons/Pause: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/Icons/Pause -------------------------------------------------------------------------------- /Services/Icons/Restart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/Icons/Restart -------------------------------------------------------------------------------- /Services/Icons/Start: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/Icons/Start -------------------------------------------------------------------------------- /Services/Icons/Stop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/Icons/Stop -------------------------------------------------------------------------------- /Services/README.md: -------------------------------------------------------------------------------- 1 | Services 2 | 3 | Control Haiku Services powered by launch_daemon. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/Services/screenshot.png) 6 | -------------------------------------------------------------------------------- /Services/Resources.h: -------------------------------------------------------------------------------- 1 | enum { 2 | resStartIcon = 0x100, 3 | resStopIcon, 4 | resRestartIcon 5 | }; 6 | -------------------------------------------------------------------------------- /Services/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Services/screenshot.png -------------------------------------------------------------------------------- /StackTrace/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = StackTrace 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = App 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = StackTrace.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be debug 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | -------------------------------------------------------------------------------- /StackTrace/README.md: -------------------------------------------------------------------------------- 1 | StackTrace 2 | 3 | Command line utility that print stack trace of running thread. Utility continue thread and exit after printing stack trace. 4 | -------------------------------------------------------------------------------- /SystemManager/Docu: -------------------------------------------------------------------------------- 1 | Apps 2 | Teams 3 | Services 4 | Sockets 5 | 6 | Teams 7 | Threads 8 | Sems 9 | Areas 10 | Ports 11 | Files 12 | Info 13 | id 14 | name 15 | process group 16 | session 17 | uid 18 | gid 19 | euid 20 | egid 21 | cwd 22 | -------------------------------------------------------------------------------- /SystemManager/Errors.cpp: -------------------------------------------------------------------------------- 1 | #include "Errors.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | 9 | StatusError::StatusError(status_t res, const char *msg): 10 | res(res), msg(msg) 11 | {} 12 | 13 | void ShowError(const StatusError &err) 14 | { 15 | BString msg, buf; 16 | 17 | if (err.msg != NULL) { 18 | buf.SetToFormat("%s\n\n", err.msg); 19 | msg += buf; 20 | } 21 | buf.SetToFormat("Error code: 0x%08" B_PRIx32 " (%s).", err.res, strerror(err.res)); 22 | msg += buf; 23 | 24 | BAlert *alert = new BAlert("Error", msg, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); 25 | alert->Go(NULL); 26 | } 27 | -------------------------------------------------------------------------------- /SystemManager/Errors.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERRORS_H_ 2 | #define _ERRORS_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | 9 | class StatusError 10 | { 11 | public: 12 | status_t res; 13 | const char *msg; 14 | 15 | StatusError(status_t res, const char *msg); 16 | }; 17 | 18 | void ShowError(const StatusError &err); 19 | 20 | static inline status_t Check(status_t res, const char *msg = NULL, bool fatal = true) 21 | { 22 | if ((res < B_OK) && fatal) 23 | throw StatusError(res, msg); 24 | return res; 25 | } 26 | 27 | static inline status_t CheckErrno(status_t res, const char *msg = NULL, bool fatal = true) 28 | { 29 | if ((res < 0) && fatal) 30 | throw StatusError(errno, msg); 31 | return res; 32 | } 33 | 34 | #define CheckRet(err) {status_t _err = (err); if (_err < B_OK) return _err;} 35 | 36 | #define CheckRetVoid(err) {status_t _err = (err); if (_err < B_OK) return;} 37 | 38 | 39 | #endif // _ERRORS_H_ 40 | -------------------------------------------------------------------------------- /SystemManager/Old.cpp: -------------------------------------------------------------------------------- 1 | BLayoutItem *CreateTextControlLayoutItem(BTextControl *view) 2 | { 3 | BGroupLayout *layout; 4 | BLayoutBuilder::Group<>(B_VERTICAL, 0) 5 | .GetLayout(&layout) 6 | .AddGroup(B_HORIZONTAL, 0) 7 | .Add(view->CreateLabelLayoutItem()) 8 | .AddGlue() 9 | .End() 10 | .Add(view->CreateTextViewLayoutItem()) 11 | .End(); 12 | return layout; 13 | } 14 | 15 | BLayoutItem *CreateMenuFieldLayoutItem(BMenuField *view) 16 | { 17 | BGroupLayout *layout; 18 | BLayoutBuilder::Group<>(B_VERTICAL, 0) 19 | .GetLayout(&layout) 20 | .AddGroup(B_HORIZONTAL, 0) 21 | .Add(view->CreateLabelLayoutItem()) 22 | .AddGlue() 23 | .End() 24 | .AddStrut(16) 25 | .Add(view->CreateMenuBarLayoutItem()) 26 | .End(); 27 | return layout; 28 | } 29 | 30 | BBox *NewLabelBox(const char *name, const char *label, BView *content) 31 | { 32 | BBox *box = new BBox(name); 33 | if (label != NULL) 34 | box->SetLabel(label); 35 | if (content != NULL) 36 | box->AddChild(content); 37 | return box; 38 | } 39 | 40 | static BView *NewColorView(const char *name, rgb_color color) 41 | { 42 | BView *view = new BView(name, B_SUPPORTS_LAYOUT); 43 | view->SetViewColor(color); 44 | if (color == B_TRANSPARENT_COLOR) 45 | view->SetFlags(view->Flags() | B_TRANSPARENT_BACKGROUND); 46 | return view; 47 | } 48 | 49 | static BView *NewInfoView(TeamWindow *wnd) 50 | { 51 | BView *view = new BView("Info", B_TRANSPARENT_BACKGROUND); 52 | view->SetViewColor(B_TRANSPARENT_COLOR); 53 | 54 | BTextControl *fTeam, *fPort, *fToken; 55 | BTextControl *fLeftView, *fTopView, *fRightView, *fBottomView; 56 | BMenuField *fMenuField; 57 | 58 | fTeam = new BTextControl("team", "Team:", "0", NULL); fTeam->SetEnabled(false); 59 | fPort = new BTextControl("port", "Port:", "0", NULL); fPort->SetEnabled(false); 60 | fToken = new BTextControl("token", "Token:", "0", NULL); fToken->SetEnabled(false); 61 | 62 | fLeftView = new BTextControl("left", "User:", "0", NULL); 63 | fTopView = new BTextControl("top", "Group:", "0", NULL); 64 | fRightView = new BTextControl("right", "Right:", "255", NULL); 65 | fBottomView = new BTextControl("bottom", "Bottom:", "255", NULL); 66 | 67 | BMenu *menu = new BPopUpMenu("menu"); 68 | menu->AddItem(new BMenuItem("Item 1", NULL)); 69 | menu->AddItem(new BMenuItem("Item 2", NULL)); 70 | menu->AddItem(new BMenuItem("Item 3", NULL)); 71 | menu->AddItem(new BMenuItem("Item 4", NULL)); 72 | fMenuField = new BMenuField("menuField", "Menu field:", menu); 73 | 74 | BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_SMALL_SPACING) 75 | .SetInsets(B_USE_SMALL_SPACING) 76 | /* 77 | .Add( 78 | BLayoutBuilder::Group<>(NewLabelBox("frame", "Frame", NULL), B_HORIZONTAL, B_USE_SMALL_SPACING) 79 | .SetInsets(padding, 2*padding, padding, padding) 80 | .Add(CreateTextControlLayoutItem(fLeftView)) 81 | .Add(CreateTextControlLayoutItem(fTopView)) 82 | .Add(CreateTextControlLayoutItem(fRightView)) 83 | .Add(CreateTextControlLayoutItem(fBottomView)) 84 | .View() 85 | ) 86 | */ 87 | .Add( 88 | NewLabelBox("box1", NULL, 89 | BLayoutBuilder::Group<>(NewColorView("content", B_TRANSPARENT_COLOR), B_HORIZONTAL, B_USE_SMALL_SPACING) 90 | .SetInsets(B_USE_SMALL_SPACING) 91 | .Add(CreateTextControlLayoutItem(fTeam)) 92 | .Add(CreateTextControlLayoutItem(fPort)) 93 | .Add(CreateTextControlLayoutItem(fToken)) 94 | .View() 95 | ) 96 | ) 97 | 98 | .Add( 99 | NewLabelBox("frame", "Effective", 100 | BLayoutBuilder::Group<>(NewColorView("content", B_TRANSPARENT_COLOR), B_HORIZONTAL, B_USE_SMALL_SPACING) 101 | .SetInsets(B_USE_SMALL_SPACING, 0, B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) 102 | .Add(CreateTextControlLayoutItem(new BTextControl("euid", "User:", "0", NULL))) 103 | .Add(CreateTextControlLayoutItem(new BTextControl("egid", "Group:", "0", NULL))) 104 | .View() 105 | ) 106 | ) 107 | .Add( 108 | NewLabelBox("frame", "Actual", 109 | BLayoutBuilder::Group<>(NewColorView("content", B_TRANSPARENT_COLOR), B_HORIZONTAL, B_USE_SMALL_SPACING) 110 | .SetInsets(B_USE_SMALL_SPACING, 0, B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) 111 | .Add(CreateTextControlLayoutItem(new BTextControl("uid", "User:", "0", NULL))) 112 | .Add(CreateTextControlLayoutItem(new BTextControl("gid", "Group:", "0", NULL))) 113 | .View() 114 | ) 115 | ) 116 | .Add(CreateMenuFieldLayoutItem(fMenuField)) 117 | .AddGlue() 118 | .End(); 119 | 120 | return view; 121 | } 122 | -------------------------------------------------------------------------------- /SystemManager/README.md: -------------------------------------------------------------------------------- 1 | [WIP] SystemManager 2 | 3 | List running teams and explore various team objects (images, threads, etc.). Also provide stack trace of selected thread. 4 | 5 | Warning! This software is incomplete. 6 | 7 | ![Screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/SystemManager/Screenshot.png) 8 | 9 | ![ScreenshotTeam](https://raw.githubusercontent.com/X547/HaikuUtils/master/SystemManager/ScreenshotTeam.png) 10 | 11 | ![ScreenshotStack](https://raw.githubusercontent.com/X547/HaikuUtils/master/SystemManager/ScreenshotStack.png) 12 | -------------------------------------------------------------------------------- /SystemManager/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/SystemManager/Screenshot.png -------------------------------------------------------------------------------- /SystemManager/ScreenshotStack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/SystemManager/ScreenshotStack.png -------------------------------------------------------------------------------- /SystemManager/ScreenshotTeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/SystemManager/ScreenshotTeam.png -------------------------------------------------------------------------------- /SystemManager/StackWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _STACKWINDOW_H_ 2 | #define _STACKWINDOW_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class BColumnListView; 10 | 11 | class StackWindow: public BWindow 12 | { 13 | public: 14 | BColumnListView *fView; 15 | 16 | 17 | thread_id fId; 18 | team_id fTeam; 19 | port_id fDebuggerPort, fNubPort; 20 | debug_context fDebugContext; 21 | 22 | StackWindow(thread_id id); 23 | ~StackWindow(); 24 | 25 | void MessageReceived(BMessage *msg); 26 | }; 27 | 28 | void OpenStackWindow(thread_id id, BPoint center); 29 | 30 | #endif // _STACKWINDOW_H_ 31 | -------------------------------------------------------------------------------- /SystemManager/SystemManager.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Test-SystemManager"; 2 | 3 | resource app_flags B_SINGLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 0, 8 | minor = 0, 9 | 10 | variety = B_APPV_DEVELOPMENT, 11 | internal = 0, 12 | 13 | short_info = "SystemManager", 14 | long_info = "List running teams and its objects." 15 | }; 16 | 17 | resource vector_icon { 18 | $"6E6369660E03010000020002023980000000000000004000004BE00008908100" 19 | $"010000FFFF01000000020016023CC7EE389BC0BA16573E39B04977C842ADC700" 20 | $"FFFFD3020006023C529D3753A2B8966F3D9D084B6044496AAF00474747FFA5A0" 21 | $"A002001602BC4E76BC411B3C90DABCA00D47587D4ABA850090FFD40200160238" 22 | $"313C3B5CF0BFCD963C7AAC4C13943FCAF901ECFFC3054B04017E020006033E2F" 23 | $"99387F17BA42DB3FF5B94A0E32482C90001D1E2C3D454658FF01010102000602" 24 | $"3879063B8224BE2CC83B10DB4A1F6F49B894FF9A9A9A00242222020006033C69" 25 | $"A60000000000003E186148800049800058F3F3F300D4CECEFFD9D9D902000603" 26 | $"3C1F1A33E78CB7ACC03FFE4F48BB3EBD7B6C0078D905818CFF05FF7ADD050200" 27 | $"1602349C2E37B5FABA1F6036FC624A3E004B320001D3FF910200160235777837" 28 | $"0A67B7E8CE363A844A1D684B45D800F3FF2E0D0A04486050605C51544E04033E" 29 | $"5349594856475C49604B5C4E604B0A06262A264C485E5252523030240A04262A" 30 | $"4838523030240A044838485E525252300A04262A264C485E48380A04453A4553" 31 | $"2844282E0A04B6F9C0F42845282EB701B8EC0A044550455328452AC0F30A0445" 32 | $"3A45502A43B701B8EC0408AEBAB6BCBCC32FBD4F2E3930BDA8B9ACC0A5BA9EBC" 33 | $"03BB1EBFD937BF0DBD4FC072BCC3C019BDDBC0CB46460204BF23C726BF91C70D" 34 | $"BEB5C73FBE9FC87EBE7AC7D9BEC5C922BFAAC97BBF3CC994C018C962C02DC823" 35 | $"C053C8C8C008C77F0204BFCEC6FBC042C6E0BF5BC715BF48C85ABF1FC7B3BF71" 36 | $"C902C063C95ABFF0C974C0D7C93FC0EAC7FAC113C8A2C0C1C7530E0A07010000" 37 | $"0A0101011001178300040A0001021001178400040A020103000A080109000A0B" 38 | $"010A1001178120040A030104000A04020506000A090107000A0A0108000A0D01" 39 | $"0C0815FF0A0C010B0815FF0A0D010C0A3FEAF70000000000003FEAF7C573B4C2" 40 | $"770615FF0A0C010B0A3FEAF70000000000003FEAF7C573B4C2770615FF" 41 | }; 42 | -------------------------------------------------------------------------------- /SystemManager/TeamWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEAMWINDOW_H_ 2 | #define _TEAMWINDOW_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class BTabView; 9 | class BColumnListView; 10 | 11 | enum { 12 | teamWindowShowImageMsg = 1, 13 | teamWindowShowThreadMsg, 14 | teamWindowShowAreaMsg, 15 | teamWindowShowPortMsg, 16 | teamWindowShowSemMsg, 17 | teamWindowShowFileMsg, 18 | 19 | teamWindowPrivateMsgBase 20 | }; 21 | 22 | class TeamWindow: public BWindow 23 | { 24 | private: 25 | BMessageRunner fListUpdater; 26 | BTabView *fTabView; 27 | BMenuBar *fMenuBar; 28 | BMenuItem *fCurMenu; 29 | BMenuItem *fInfoMenu; 30 | BMenuItem *fImagesMenu; 31 | BMenuItem *fThreadsMenu; 32 | BMenuItem *fSemsMenu; 33 | BColumnListView *fInfoView; 34 | BColumnListView *fImagesView; 35 | BColumnListView *fThreadsView; 36 | BColumnListView *fAreasView; 37 | BColumnListView *fPortsView; 38 | BColumnListView *fSemsView; 39 | BColumnListView *fFilesView; 40 | 41 | public: 42 | team_id fId; 43 | 44 | TeamWindow(team_id id); 45 | ~TeamWindow(); 46 | 47 | void TabChanged(); 48 | void SetMenu(BMenuItem *menu); 49 | void MessageReceived(BMessage *msg); 50 | }; 51 | 52 | TeamWindow *OpenTeamWindow(team_id id, BPoint center); 53 | 54 | #endif // _TEAMWINDOW_H_ 55 | -------------------------------------------------------------------------------- /SystemManager/UIUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "UIUtils.h" 2 | 3 | #include 4 | 5 | 6 | IconStringField::IconStringField(BBitmap *icon, const char *string): 7 | BStringField(string), fIcon(icon) 8 | {} 9 | 10 | 11 | IconStringColumn::IconStringColumn( 12 | const char* title, float width, 13 | float minWidth, float maxWidth, uint32 truncate, 14 | alignment align 15 | ): BStringColumn(title, width, minWidth, maxWidth, truncate, align) 16 | {} 17 | 18 | void IconStringColumn::DrawField(BField* _field, BRect rect, BView* parent) 19 | { 20 | IconStringField *field = (IconStringField*)_field; 21 | 22 | parent->PushState(); 23 | parent->SetDrawingMode(B_OP_ALPHA); 24 | parent->DrawBitmap(field->Icon(), rect.LeftTop() + BPoint(4, 0)); 25 | parent->PopState(); 26 | rect.left += field->Icon()->Bounds().Width() + 1; 27 | 28 | BStringColumn::DrawField(field, rect, parent); 29 | } 30 | 31 | float IconStringColumn::GetPreferredWidth(BField* field, BView* parent) const 32 | { 33 | return BStringColumn::GetPreferredWidth(field, parent) + dynamic_cast(field)->Icon()->Bounds().Width() + 1; 34 | } 35 | 36 | bool IconStringColumn::AcceptsField(const BField* field) const 37 | { 38 | return dynamic_cast(field) != NULL; 39 | } 40 | 41 | 42 | HexIntegerColumn::HexIntegerColumn( 43 | const char* title, 44 | float width, float minWidth, float maxWidth, 45 | alignment align 46 | ): BTitledColumn(title, width, minWidth, maxWidth, align) 47 | {} 48 | 49 | void HexIntegerColumn::DrawField(BField *field, BRect rect, BView* parent) 50 | { 51 | float width = rect.Width() - (2 * 8); 52 | BString string; 53 | 54 | if (dynamic_cast(field) != NULL) 55 | string.SetToFormat("0x%" B_PRIx64, ((Int64Field*)field)->Value()); 56 | else 57 | string.SetToFormat("0x%x", (int)((BIntegerField*)field)->Value()); 58 | 59 | BFont oldFont; 60 | parent->GetFont(&oldFont); 61 | parent->SetFont(be_fixed_font); 62 | parent->TruncateString(&string, B_TRUNCATE_MIDDLE, width + 2); 63 | DrawString(string.String(), parent, rect); 64 | parent->SetFont(&oldFont); 65 | } 66 | 67 | int HexIntegerColumn::CompareFields(BField *field1, BField *field2) 68 | { 69 | if (dynamic_cast(field1) != NULL) { 70 | if (((Int64Field*)field1)->Value() == ((Int64Field*)field2)->Value()) 71 | return 0; 72 | else if (((Int64Field*)field1)->Value() > ((Int64Field*)field2)->Value()) 73 | return 1; 74 | else 75 | return -1; 76 | } else 77 | return (((BIntegerField*)field1)->Value() - ((BIntegerField*)field2)->Value()); 78 | } 79 | 80 | 81 | Int64Field::Int64Field(int64 value): fValue(value) 82 | { 83 | } 84 | 85 | 86 | void Int64Field::SetValue(int64 value) 87 | { 88 | fValue = value; 89 | } 90 | 91 | 92 | int64 Int64Field::Value() 93 | { 94 | return fValue; 95 | } 96 | -------------------------------------------------------------------------------- /SystemManager/UIUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef _UIUTILS_H_ 2 | #define _UIUTILS_H_ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class IconStringField: public BStringField 11 | { 12 | private: 13 | ObjectDeleter fIcon; 14 | 15 | public: 16 | IconStringField(BBitmap *icon = NULL, const char *string = ""); 17 | inline BBitmap *Icon() {return fIcon.Get();} 18 | 19 | inline void SetIcon(BBitmap *icon) {fIcon.SetTo(icon);} 20 | }; 21 | 22 | class IconStringColumn: public BStringColumn 23 | { 24 | public: 25 | IconStringColumn( 26 | const char* title, float width, 27 | float minWidth, float maxWidth, uint32 truncate, 28 | alignment align = B_ALIGN_LEFT 29 | ); 30 | 31 | void DrawField(BField* _field, BRect rect, BView* parent) final; 32 | float GetPreferredWidth(BField* field, BView* parent) const final; 33 | bool AcceptsField(const BField* field) const final; 34 | }; 35 | 36 | class HexIntegerColumn: public BTitledColumn 37 | { 38 | public: 39 | HexIntegerColumn( 40 | const char* title, 41 | float width, float minWidth, float maxWidth, 42 | alignment align 43 | ); 44 | 45 | void DrawField(BField *field, BRect rect, BView* parent); 46 | int CompareFields(BField *field1, BField *field2); 47 | }; 48 | 49 | class Int64Field: public BField 50 | { 51 | public: 52 | Int64Field(int64 value); 53 | void SetValue(int64 value); 54 | int64 Value(); 55 | 56 | private: 57 | int64 fValue; 58 | }; 59 | 60 | 61 | #endif // _UIUTILS_H_ 62 | -------------------------------------------------------------------------------- /SystemManager/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Utils.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | SignalRec signals[] = { 17 | {"SIGHUP", 1}, 18 | {"SIGINT", 2}, 19 | {"SIGQUIT", 3}, 20 | {"SIGILL", 4}, 21 | {"SIGCHLD", 5}, 22 | {"SIGABRT", 6}, 23 | {"SIGPIPE", 7}, 24 | {"SIGFPE", 8}, 25 | {"SIGKILL", 9}, 26 | {"SIGSTOP", 10}, 27 | {"SIGSEGV", 11}, 28 | {"SIGCONT", 12}, 29 | {"SIGTSTP", 13}, 30 | {"SIGALRM", 14}, 31 | {"SIGTERM", 15}, 32 | {"SIGTTIN", 16}, 33 | {"SIGTTOU", 17}, 34 | {"SIGUSR1", 18}, 35 | {"SIGUSR2", 19}, 36 | {"SIGWINCH", 20}, 37 | {"SIGKILLTHR", 21}, 38 | {"SIGTRAP", 22}, 39 | {"SIGPOLL", 23}, 40 | {"SIGPROF", 24}, 41 | {"SIGSYS", 25}, 42 | {"SIGURG", 26}, 43 | {"SIGVTALRM", 27}, 44 | {"SIGXCPU", 28}, 45 | {"SIGXFSZ", 29}, 46 | {"SIGBUS", 30}, 47 | {"SIGRESERVED1", 31}, 48 | {"SIGRESERVED2", 32}, 49 | }; 50 | 51 | 52 | void GetSizeString(BString &str, uint64 size) 53 | { 54 | const char* prefixes[] = {"", "K", "M", "G", "T"}; 55 | unsigned pow = 0; 56 | int fracSize = 0; 57 | while ((size >= 1024) && (pow < sizeof(prefixes)/sizeof(prefixes[0]) - 1)) { 58 | fracSize = size*100/1024%100; 59 | size /= 1024; 60 | pow++; 61 | } 62 | str.SetToFormat("%" B_PRIu64 ".%02d %sB", size, fracSize, prefixes[pow]); 63 | } 64 | 65 | void GetUsedMax(BString &str, uint64 used, uint64 max) 66 | { 67 | int32 ratio = 100; 68 | if (max > 0) { 69 | ratio = int32(double(used)/double(max)*100.0); 70 | } 71 | str.SetToFormat("%" B_PRIu64 "/%" B_PRIu64 " (%" B_PRId32 "%%)", used, max, ratio); 72 | } 73 | 74 | void GetUsedMaxSize(BString &str, uint64 used, uint64 max) 75 | { 76 | BString str2; 77 | int32 ratio = 100; 78 | if (max > 0) { 79 | ratio = int32(double(used)/double(max)*100.0); 80 | } 81 | GetSizeString(str, used); 82 | str += "/"; 83 | GetSizeString(str2, max); 84 | str += str2; 85 | str2.SetToFormat(" (%" B_PRId32 "%%)", ratio); 86 | str += str2; 87 | } 88 | 89 | 90 | void GetUserGroupString(BString &str, int32 uid, int32 gid, bool showId) 91 | { 92 | BString str2; 93 | passwd *userRec = getpwuid(uid); 94 | if (userRec == NULL) str.SetToFormat("%" B_PRId32, uid); 95 | else str = userRec->pw_name; 96 | str += ":"; 97 | group *grpRec = getgrgid(gid); 98 | if (grpRec == NULL) str2.SetToFormat("%" B_PRId32, gid); 99 | else str2 = grpRec->gr_name; 100 | str += str2; 101 | if (showId) { 102 | str2.SetToFormat(" (%" B_PRId32 ":%" B_PRId32 ")", uid, gid); 103 | str += str2; 104 | } 105 | } 106 | 107 | void GetTeamString(BString &str, team_id team) 108 | { 109 | const char *name = NULL; 110 | KMessage extInfo; 111 | if ( 112 | team >= B_OK && 113 | get_extended_team_info(team, B_TEAM_INFO_BASIC, extInfo) >= B_OK && 114 | extInfo.FindString("name", &name) >= B_OK 115 | ) 116 | str.SetToFormat("%" B_PRId32 " (%s)", team, name); 117 | else 118 | str.SetToFormat("%" B_PRId32, team); 119 | } 120 | 121 | void GetThreadString(BString &str, thread_id thread) 122 | { 123 | thread_info info; 124 | if ( 125 | thread != 0 && 126 | get_thread_info((thread >= 0)? thread: -thread, &info) >= B_OK 127 | ) 128 | str.SetToFormat("%" B_PRId32 " (%s)", thread, info.name); 129 | else 130 | str.SetToFormat("%" B_PRId32, thread); 131 | } 132 | 133 | void GetSemString(BString &str, sem_id sem) 134 | { 135 | sem_info info; 136 | if ( 137 | sem >= B_OK && 138 | get_sem_info(sem, &info) >= B_OK 139 | ) 140 | str.SetToFormat("%" B_PRId32 " (%s)", sem, info.name); 141 | else 142 | str.SetToFormat("%" B_PRId32, sem); 143 | } 144 | 145 | 146 | void ShowLocation(const char *path) 147 | { 148 | BEntry entry(path); 149 | if (!entry.Exists()) return; 150 | 151 | node_ref node; 152 | entry.GetNodeRef(&node); 153 | 154 | BEntry parent; 155 | entry.GetParent(&parent); 156 | entry_ref parentRef; 157 | parent.GetRef(&parentRef); 158 | 159 | BMessage message(B_REFS_RECEIVED); 160 | message.AddRef("refs", &parentRef); 161 | message.AddData("nodeRefToSelect", B_RAW_TYPE, &node, sizeof(node_ref)); 162 | 163 | BMessenger("application/x-vnd.Be-TRAK").SendMessage(&message); 164 | } 165 | 166 | 167 | const char *GetFileName(const char *path) 168 | { 169 | const char *name = path; 170 | for (const char *it = name; *it != '\0'; it++) { 171 | if (*it == '/') name = it + 1; 172 | } 173 | return name; 174 | } 175 | -------------------------------------------------------------------------------- /SystemManager/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTILS_H_ 2 | #define _UTILS_H_ 3 | 4 | #include 5 | 6 | class BString; 7 | 8 | 9 | struct SignalRec 10 | { 11 | const char *name; 12 | int val; 13 | }; 14 | 15 | extern SignalRec signals[32]; 16 | 17 | 18 | void GetSizeString(BString &str, uint64 size); 19 | void GetUsedMax(BString &str, uint64 used, uint64 max); 20 | void GetUsedMaxSize(BString &str, uint64 used, uint64 max); 21 | 22 | void GetUserGroupString(BString &str, int32 uid, int32 gid, bool showId = false); 23 | void GetTeamString(BString &str, team_id team); 24 | void GetThreadString(BString &str, thread_id thread); 25 | void GetSemString(BString &str, sem_id sem); 26 | 27 | void ShowLocation(const char *path); 28 | 29 | const char *GetFileName(const char *path); 30 | 31 | #endif // _UTILS_H_ 32 | -------------------------------------------------------------------------------- /TabbedWindows/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = MinApp 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = App 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = MinApp.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | 133 | run :: default 134 | $(TARGET) 135 | -------------------------------------------------------------------------------- /TabbedWindows/MinApp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | enum { 13 | newMsg = 1, 14 | }; 15 | 16 | class TestView: public BView 17 | { 18 | public: 19 | TestView(BRect frame, const char *name): BView(frame, name, B_FOLLOW_NONE, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_SUBPIXEL_PRECISE) 20 | { 21 | SetViewColor(0xff - 0x44, 0xff - 0x44, 0xff - 0x44); 22 | } 23 | 24 | void Draw(BRect dirty) 25 | { 26 | BRect rect = Frame().OffsetToCopy(B_ORIGIN); 27 | rect.left += 1; rect.top += 1; 28 | SetHighColor(0x44, 0x44, 0x44); 29 | SetPenSize(2); 30 | StrokeRect(rect, B_SOLID_HIGH); 31 | SetPenSize(1); 32 | StrokeLine(rect.LeftTop(), rect.RightBottom()); 33 | StrokeLine(rect.RightTop(), rect.LeftBottom()); 34 | } 35 | }; 36 | 37 | class TestWindow: public BWindow 38 | { 39 | private: 40 | TestView *fView; 41 | 42 | public: 43 | TestWindow(BRect frame): BWindow(frame, "TestApp", B_TITLED_WINDOW, B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) 44 | { 45 | fView = new TestView(frame.OffsetToCopy(B_ORIGIN), "view"); 46 | fView->SetResizingMode(B_FOLLOW_ALL); 47 | fView->SetExplicitMinSize(BSize(3, 3)); 48 | 49 | BMenuBar *menubar, *toolbar; 50 | BMenu *menu; 51 | BMenuItem *it; 52 | 53 | BMessage *newTabMsg = new BMessage(newMsg); 54 | newTabMsg->AddMessenger("window", BMessenger(this)); 55 | 56 | menubar = new BMenuBar("menu", B_ITEMS_IN_ROW, true); 57 | menu = new BMenu("File"); 58 | it = new BMenuItem("New window", new BMessage(newMsg), 'N'); it->SetTarget(be_app); menu->AddItem(it); 59 | it = new BMenuItem("New tab", newTabMsg, 'T'); it->SetTarget(be_app); menu->AddItem(it); 60 | it = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W'); menu->AddItem(it); 61 | it = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); it->SetTarget(be_app); menu->AddItem(it); 62 | menubar->AddItem(menu); 63 | 64 | BLayoutBuilder::Group<>(this, B_VERTICAL, 0) 65 | .Add(menubar) 66 | .Add(fView) 67 | .End(); 68 | } 69 | 70 | void Quit() 71 | { 72 | if (be_app->LockLooper()) { 73 | if (be_app->CountWindows() <= 1) 74 | be_app_messenger.SendMessage(B_QUIT_REQUESTED); 75 | be_app->UnlockLooper(); 76 | } 77 | BWindow::Quit(); 78 | } 79 | 80 | }; 81 | 82 | class TestApplication: public BApplication 83 | { 84 | public: 85 | TestApplication(): BApplication("application/x-vnd.test-app") 86 | {} 87 | 88 | void ReadyToRun() 89 | { 90 | PostMessage(newMsg); 91 | } 92 | 93 | void MessageReceived(BMessage *msg) 94 | { 95 | switch (msg->what) { 96 | case newMsg: { 97 | BWindow *fWnd = new TestWindow(BRect(0, 0, 320, 240).OffsetByCopy(64, 64)); 98 | BMessenger obj; 99 | if (msg->FindMessenger("window", &obj) >= B_OK) { 100 | BWindow *srcWnd = dynamic_cast(obj.Target(NULL)); 101 | if (srcWnd != NULL) { 102 | BWindowStack stack(srcWnd); 103 | stack.AddWindow(fWnd); 104 | } 105 | } 106 | fWnd->Show(); 107 | break; 108 | } 109 | default: 110 | BApplication::MessageReceived(msg); 111 | } 112 | } 113 | 114 | }; 115 | 116 | 117 | int main() 118 | { 119 | TestApplication app; 120 | app.Run(); 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /TabbedWindows/README.md: -------------------------------------------------------------------------------- 1 | TabbedWindows 2 | 3 | Demonstration of windows stacking API. 4 | 5 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/TabbedWindows/screenshot.png) 6 | -------------------------------------------------------------------------------- /TabbedWindows/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/TabbedWindows/screenshot.png -------------------------------------------------------------------------------- /TraverseApps/README.md: -------------------------------------------------------------------------------- 1 | TraverseApps 2 | 3 | Command line utility to list running applications and GUI objects inside them such as BWindow and BView. This utility use scripting to get information about contents of applications. Output is tab indented tree. 4 | -------------------------------------------------------------------------------- /TraverseApps/makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = TraverseApps 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | SRCS = TraverseApps.cpp 27 | 28 | # Specify the resource definition files to use. Full or relative paths can be 29 | # used. 30 | RDEFS = 31 | 32 | # Specify the resource files to use. Full or relative paths can be used. 33 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 34 | RSRCS = 35 | 36 | # End Pe/Eddie support. 37 | # @<-src@ 38 | #%} 39 | 40 | # Specify libraries to link against. 41 | # There are two acceptable forms of library specifications: 42 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 43 | # you can simply specify XXX for the library. (e.g. the entry for 44 | # "libtracker.so" would be "tracker") 45 | # 46 | # - for GCC-independent linking of standard C++ libraries, you can use 47 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 48 | # 49 | # - if your library does not follow the standard library naming scheme, 50 | # you need to specify the path to the library and it's name. 51 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 52 | LIBS = $(STDCPPLIBS) be 53 | 54 | # Specify additional paths to directories following the standard libXXX.so 55 | # or libXXX.a naming scheme. You can specify full paths or paths relative 56 | # to the Makefile. The paths included are not parsed recursively, so 57 | # include all of the paths where libraries must be found. Directories where 58 | # source files were specified are automatically included. 59 | LIBPATHS = 60 | 61 | # Additional paths to look for system headers. These use the form 62 | # "#include
". Directories that contain the files in SRCS are 63 | # NOT auto-included here. 64 | SYSTEM_INCLUDE_PATHS = 65 | 66 | # Additional paths paths to look for local headers. These use the form 67 | # #include "header". Directories that contain the files in SRCS are 68 | # automatically included. 69 | LOCAL_INCLUDE_PATHS = 70 | 71 | # Specify the level of optimization that you want. Specify either NONE (O0), 72 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 73 | OPTIMIZE := 74 | 75 | # Specify the codes for languages you are going to support in this 76 | # application. The default "en" one must be provided too. "make catkeys" 77 | # will recreate only the "locales/en.catkeys" file. Use it as a template 78 | # for creating catkeys for other languages. All localization files must be 79 | # placed in the "locales" subdirectory. 80 | LOCALES = 81 | 82 | # Specify all the preprocessor symbols to be defined. The symbols will not 83 | # have their values set automatically; you must supply the value (if any) to 84 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 85 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 86 | # "-DDEBUG" on the compiler's command line. 87 | DEFINES = 88 | 89 | # Specify the warning level. Either NONE (suppress all warnings), 90 | # ALL (enable all warnings), or leave blank (enable default warnings). 91 | WARNINGS = 92 | 93 | # With image symbols, stack crawls in the debugger are meaningful. 94 | # If set to "TRUE", symbols will be created. 95 | SYMBOLS := 96 | 97 | # Includes debug information, which allows the binary to be debugged easily. 98 | # If set to "TRUE", debug info will be created. 99 | DEBUGGER := 100 | 101 | # Specify any additional compiler flags to be used. 102 | COMPILER_FLAGS = 103 | 104 | # Specify any additional linker flags to be used. 105 | LINKER_FLAGS = 106 | 107 | # Specify the version of this binary. Example: 108 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 109 | # This may also be specified in a resource. 110 | APP_VERSION := 111 | 112 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 113 | # location in the /dev hierarchy. Example: 114 | # DRIVER_PATH = video/usb 115 | # will instruct the "driverinstall" rule to place a symlink to your driver's 116 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 117 | # appear at /dev/video/usb when loaded. The default is "misc". 118 | DRIVER_PATH = 119 | 120 | ## Include the Makefile-Engine 121 | DEVEL_DIRECTORY := \ 122 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 123 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 124 | 125 | run :: default 126 | $(TARGET) 127 | -------------------------------------------------------------------------------- /TraverseApps2/HighlightRect.cpp: -------------------------------------------------------------------------------- 1 | #include "HighlightRect.h" 2 | 3 | #include 4 | #include 5 | 6 | enum { 7 | borderSize = 2 8 | }; 9 | 10 | static BWindow *CreateHighlightWindow() 11 | { 12 | BWindow *wnd = new BWindow(BRect(0, 0, 0, 0), "highlightWindow", B_NO_BORDER_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FOCUS); 13 | BView *view = new BView(BRect(0, 0, 0, 0), "highlightView", B_FOLLOW_ALL, 0); 14 | view->SetViewColor(0xff, 0x00, 0x00); 15 | wnd->AddChild(view); 16 | return wnd; 17 | }; 18 | 19 | HighlightRect::HighlightRect() 20 | { 21 | for (int32 i = 0; i < 4; i++) 22 | fWnds[i] = NULL; 23 | } 24 | 25 | HighlightRect::~HighlightRect() 26 | { 27 | Hide(); 28 | } 29 | 30 | void HighlightRect::Show(BRect rect) 31 | { 32 | if (fWnds[0] == NULL) { 33 | for (int32 i = 0; i < 4; i++) 34 | fWnds[i] = CreateHighlightWindow(); 35 | } else { 36 | if (fRect == rect) 37 | return; 38 | for (int32 i = 0; i < 4; i++) 39 | fWnds[i]->Hide(); 40 | } 41 | fRect = rect; 42 | rect.InsetBy(-1, -1); 43 | fWnds[0]->MoveTo(rect.left - borderSize, rect.top); 44 | fWnds[0]->ResizeTo(borderSize, rect.Height()); 45 | fWnds[1]->MoveTo(rect.left - borderSize, rect.top - borderSize); 46 | fWnds[1]->ResizeTo(rect.Width() + 2*borderSize, borderSize); 47 | fWnds[2]->MoveTo(rect.right, rect.top); 48 | fWnds[2]->ResizeTo(borderSize, rect.Height()); 49 | fWnds[3]->MoveTo(rect.left - borderSize, rect.bottom); 50 | fWnds[3]->ResizeTo(rect.Width() + 2*borderSize, borderSize); 51 | for (int32 i = 0; i < 4; i++) 52 | fWnds[i]->Show(); 53 | } 54 | 55 | void HighlightRect::Hide() 56 | { 57 | for (int32 i = 0; i < 4; i++) { 58 | if (fWnds[i] != NULL) { 59 | fWnds[i]->LockLooper(); 60 | fWnds[i]->Quit(); 61 | fWnds[i] = NULL; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /TraverseApps2/HighlightRect.h: -------------------------------------------------------------------------------- 1 | #ifndef _HIGHLIGHTRECT_H_ 2 | #define _HIGHLIGHTRECT_H_ 3 | 4 | #include 5 | 6 | class BWindow; 7 | 8 | class HighlightRect 9 | { 10 | private: 11 | BRect fRect; 12 | BWindow *fWnds[4]; 13 | 14 | public: 15 | HighlightRect(); 16 | ~HighlightRect(); 17 | 18 | void Show(BRect rect); 19 | void Hide(); 20 | }; 21 | 22 | #endif // _HIGHLIGHTRECT_H_ 23 | -------------------------------------------------------------------------------- /TraverseApps2/Icons/Highlight: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/TraverseApps2/Icons/Highlight -------------------------------------------------------------------------------- /TraverseApps2/Icons/Target: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/TraverseApps2/Icons/Target -------------------------------------------------------------------------------- /TraverseApps2/README.md: -------------------------------------------------------------------------------- 1 | TraverseApps2 2 | 3 | Utility that display windows and views in a tree. It allows to pick view by pressing target icon at tool bar. view tree information is retrieved by scripting. Window visibility and z-order is not handled correctly for now. Tree is not updated automatically, using "Edit" -> "Update" is required to update. 4 | 5 | Currently only GCC4+ is supported. For 32 bit Haiku use `setarch x86`. 6 | 7 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/TraverseApps2/screenshot.png) 8 | -------------------------------------------------------------------------------- /TraverseApps2/Resources.h: -------------------------------------------------------------------------------- 1 | enum { 2 | resTargetIcon = 0x100, 3 | resHighlightIcon = 0x101, 4 | }; 5 | -------------------------------------------------------------------------------- /TraverseApps2/ScriptingUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptingUtils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void DumpMessenger(const BMessenger &handle) 8 | { 9 | printf("(team: %d, token: %d)", BMessenger::Private((BMessenger&)handle).Team(), BMessenger::Private((BMessenger&)handle).Token()); 10 | } 11 | 12 | status_t SendScriptingMessage(const BMessenger &obj, BMessage &spec, BMessage &reply) 13 | { 14 | status_t res = obj.SendMessage(&spec, &reply, 1000000, 1000000); 15 | if (res < B_OK) { 16 | printf("[!] can't send message to "); DumpMessenger(obj); printf(", error: %s\n", strerror(res)); 17 | return res; 18 | } 19 | return res; 20 | } 21 | 22 | status_t GetBool(bool &val, const BMessenger &obj, BMessage &spec) 23 | { 24 | status_t res; 25 | BMessage reply; 26 | if ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) return res; 27 | if ((res = reply.FindBool("result", &val)) != B_OK) return res; 28 | return res; 29 | } 30 | 31 | status_t GetInt32(int32 &val, const BMessenger &obj, BMessage &spec) 32 | { 33 | status_t res; 34 | BMessage reply; 35 | if ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) return res; 36 | if ((res = reply.FindInt32("result", &val)) != B_OK) return res; 37 | return res; 38 | } 39 | 40 | status_t GetString(BString &val, const BMessenger &obj, BMessage &spec) 41 | { 42 | status_t res; 43 | BMessage reply; 44 | if ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) return res; 45 | if ((res = reply.FindString("result", &val)) != B_OK) return res; 46 | return res; 47 | } 48 | 49 | status_t GetMessenger(BMessenger &val, const BMessenger &obj, BMessage &spec) 50 | { 51 | status_t res; 52 | BMessage reply; 53 | if ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) return res; 54 | if ((res = reply.FindMessenger("result", &val)) != B_OK) return res; 55 | return res; 56 | } 57 | 58 | status_t GetRect(BRect &val, const BMessenger &obj, BMessage &spec) 59 | { 60 | status_t res; 61 | BMessage reply; 62 | if ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) return res; 63 | if ((res = reply.FindRect("result", &val)) != B_OK) return res; 64 | return res; 65 | } 66 | 67 | void WriteError(BString &dst, status_t res) 68 | { 69 | dst += "<"; 70 | dst += strerror(res); 71 | dst += ">"; 72 | } 73 | 74 | void WriteStringProp(BString &dst, BMessenger &obj, const char *field) 75 | { 76 | BMessage spec; 77 | BString str; 78 | status_t res; 79 | spec.what = B_GET_PROPERTY; 80 | spec.AddSpecifier(field); 81 | if ((res = GetString(str, obj, spec)) != B_OK) { 82 | WriteError(dst, res); 83 | } else { 84 | dst += str; 85 | } 86 | } 87 | 88 | void WriteSuites(BString &dst, BMessenger &obj) 89 | { 90 | BMessage spec, reply; 91 | type_code type; 92 | int32 count; 93 | const char *str; 94 | status_t res; 95 | spec = BMessage(B_GET_SUPPORTED_SUITES); 96 | if ( 97 | ((res = SendScriptingMessage(obj, spec, reply)) != B_OK) 98 | ) { 99 | WriteError(dst, res); 100 | } else { 101 | reply.GetInfo("suites", &type, &count); 102 | for (int32 i = 0; i < count; i++) { 103 | if (i > 0) {dst += ", ";} 104 | reply.FindString("suites", i, &str); 105 | dst += str; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /TraverseApps2/ScriptingUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTINGUTILS_H_ 2 | #define _SCRIPTINGUTILS_H_ 3 | 4 | #include 5 | 6 | class BMessage; 7 | class BMessenger; 8 | class BRect; 9 | class BString; 10 | 11 | 12 | void DumpMessenger(const BMessenger &handle); 13 | status_t SendScriptingMessage(const BMessenger &obj, BMessage &spec, BMessage &reply); 14 | status_t GetBool(bool &val, const BMessenger &obj, BMessage &spec); 15 | status_t GetInt32(int32 &val, const BMessenger &obj, BMessage &spec); 16 | status_t GetString(BString &val, const BMessenger &obj, BMessage &spec); 17 | status_t GetMessenger(BMessenger &val, const BMessenger &obj, BMessage &spec); 18 | status_t GetRect(BRect &val, const BMessenger &obj, BMessage &spec); 19 | void WriteError(BString &dst, status_t res); 20 | void WriteStringProp(BString &dst, BMessenger &obj, const char *field); 21 | void WriteSuites(BString &dst, BMessenger &obj); 22 | 23 | 24 | #endif // _SCRIPTINGUTILS_H_ 25 | -------------------------------------------------------------------------------- /TraverseApps2/SuiteEditor.h: -------------------------------------------------------------------------------- 1 | #ifndef _SUITEEDITOR_H_ 2 | #define _SUITEEDITOR_H_ 3 | 4 | #include 5 | #include 6 | 7 | class BColumnListView; 8 | 9 | class SuiteEditor: public BWindow 10 | { 11 | private: 12 | BMessenger fHandle; 13 | status_t fStatus; 14 | 15 | BColumnListView *fView; 16 | 17 | public: 18 | SuiteEditor(BMessenger handle); 19 | status_t InitCheck(); 20 | }; 21 | 22 | #endif // _SUITEEDITOR_H_ 23 | -------------------------------------------------------------------------------- /TraverseApps2/TraverseApps.rdef: -------------------------------------------------------------------------------- 1 | #include "Resources.h" 2 | 3 | resource app_signature "application/x-vnd.Test-TraverseApps"; 4 | 5 | resource app_flags B_SINGLE_LAUNCH; 6 | 7 | resource app_version { 8 | major = 0, 9 | middle = 0, 10 | minor = 0, 11 | 12 | variety = B_APPV_DEVELOPMENT, 13 | internal = 0, 14 | 15 | short_info = "TraverseApps", 16 | long_info = "TraverseApps" 17 | }; 18 | 19 | resource vector_icon array { 20 | $"6E636966070500040064020016023BA4CA3BBF52BC04343BEBDB4B681C48B96C" 21 | $"00EDFFA505FF0200160232FD6F3A991DBE4480369C0E4B47C24869BD0091FFB5" 22 | $"020016023ACCF03D352ABFAA7A3D335C4C3DCF47577900FFFFE9020006023473" 23 | $"FD3A4FC4BB97F135D03F4A68F346473800FFEA00FFFFB830070604EA3E423645" 24 | $"5854604F6052604C0A06364256505631462D462736230A043628364256505631" 25 | $"0A06524A3A403841544D543352350A06382B38413A403A2E523554330A043A2E" 26 | $"3A40544B54360A043623362946B87A46270E0A010100000A0001011001178400" 27 | $"040A020102000A030103000A040104000A050105000A060106000A010100200E" 28 | $"2C0A000101300E2C01178400040A020102200E2C0A030103200E2C0A04010420" 29 | $"0E2C0A050105200E2C0A060106200E2C" 30 | }; 31 | 32 | resource(resTargetIcon) #'VICN' array { 33 | $"6E6369660205FF05000602044030C34530BC3A30304030BC3A30C3454050BC3A" 34 | $"50C34550504050C34550BC3A0802402840380802484058400802404840580802" 35 | $"2840384002044030C34530BC3A30304030BC3A30C3454050BC3A50C345505040" 36 | $"50C34550BC3A030A00050001020304301E1E01178C22040A0105000102030430" 37 | $"1E1E01178422040A010105023A00000000000000003A0000494000494000" 38 | }; 39 | 40 | resource(resHighlightIcon) #'VICN' array { 41 | $"6E6369660103FF0000010A043030305050505030010A000100100117880004" 42 | }; 43 | -------------------------------------------------------------------------------- /TraverseApps2/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/TraverseApps2/screenshot.png -------------------------------------------------------------------------------- /Users/GroupForm.h: -------------------------------------------------------------------------------- 1 | #ifndef _GROUPFORM_H_ 2 | #define _GROUPFORM_H_ 3 | 4 | #include 5 | 6 | class BWindow; 7 | 8 | 9 | void ShowGroupForm(int32 gid, BWindow *base); 10 | 11 | #endif // _GROUPFORM_H_ 12 | -------------------------------------------------------------------------------- /Users/Icons/Add.hvif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Users/Icons/Add.hvif -------------------------------------------------------------------------------- /Users/Icons/Edit.hvif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Users/Icons/Edit.hvif -------------------------------------------------------------------------------- /Users/Icons/Remove.hvif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Users/Icons/Remove.hvif -------------------------------------------------------------------------------- /Users/Icons/Settings.hvif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Users/Icons/Settings.hvif -------------------------------------------------------------------------------- /Users/PasswordForm.cpp: -------------------------------------------------------------------------------- 1 | #include "UserForm.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include "UserDB.h" 22 | 23 | enum { 24 | okMsg = 1, 25 | groupMsg, 26 | }; 27 | 28 | 29 | static BLayoutItem *CreateTextControlLayoutItem(BTextControl *view) 30 | { 31 | BGroupLayout *layout; 32 | BLayoutBuilder::Group<>(B_VERTICAL, 0) 33 | .GetLayout(&layout) 34 | .AddGroup(B_HORIZONTAL, 0) 35 | .Add(view->CreateLabelLayoutItem()) 36 | .AddGlue() 37 | .End() 38 | .Add(view->CreateTextViewLayoutItem()) 39 | .End(); 40 | return layout; 41 | } 42 | 43 | 44 | class PasswordForm: public BWindow 45 | { 46 | private: 47 | int32 fUid; 48 | 49 | BTextControl *fPasswordView; 50 | BTextControl *fPasswordRepeatView; 51 | 52 | BButton *fOkView; 53 | BButton *fCancelView; 54 | 55 | public: 56 | PasswordForm(int32 uid): 57 | BWindow( 58 | BRect(0, 0, 255, 0), "Set password", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 59 | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_CLOSE_ON_ESCAPE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS 60 | ), 61 | fUid(uid) 62 | { 63 | 64 | BLayoutBuilder::Group<>(this, B_VERTICAL, 0) 65 | .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) 66 | .SetInsets(B_USE_SMALL_SPACING) 67 | .Add(CreateTextControlLayoutItem(fPasswordView = new BTextControl("password", "Password:", "", NULL))) 68 | .Add(CreateTextControlLayoutItem(fPasswordRepeatView = new BTextControl("passwordRepeat", "Repeat password:", "", NULL))) 69 | .End() 70 | .Add(new BSeparatorView(B_HORIZONTAL)) 71 | .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) 72 | .SetInsets(B_USE_SMALL_SPACING) 73 | .AddGlue() 74 | .Add(fOkView = new BButton("ok", "OK", new BMessage(okMsg))) 75 | .Add(fCancelView = new BButton("cancel", "Cancel", new BMessage(B_CANCEL))) 76 | .End() 77 | .End(); 78 | 79 | fPasswordView->TextView()->HideTyping(true); 80 | fPasswordRepeatView->TextView()->HideTyping(true); 81 | 82 | SetDefaultButton(fOkView); 83 | fPasswordView->MakeFocus(); 84 | } 85 | 86 | void MessageReceived(BMessage *msg) 87 | { 88 | switch (msg->what) { 89 | case okMsg: { 90 | if (strcmp(fPasswordView->Text(), fPasswordRepeatView->Text()) != 0) { 91 | BAlert *alert = new BAlert("Users", "Passwords don't match.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); 92 | alert->Go(NULL); 93 | return; 94 | } 95 | 96 | const char *encryptedPassword; 97 | 98 | if (strcmp(fPasswordRepeatView->Text(), "") == 0) 99 | encryptedPassword = fPasswordRepeatView->Text(); 100 | else 101 | encryptedPassword = crypt(fPasswordView->Text(), NULL); 102 | 103 | KMessage message; 104 | if (message.AddInt32("uid", fUid) != B_OK 105 | || message.AddInt32("last changed", time(NULL)) != B_OK 106 | || message.AddString("password", "x") != B_OK 107 | || message.AddString("shadow password", encryptedPassword) != B_OK 108 | ) return; 109 | 110 | UpdateUser(message); 111 | 112 | PostMessage(B_QUIT_REQUESTED); 113 | return; 114 | } 115 | case B_CANCEL: 116 | PostMessage(B_QUIT_REQUESTED); 117 | return; 118 | } 119 | 120 | BWindow::MessageReceived(msg); 121 | } 122 | }; 123 | 124 | 125 | void ShowPasswordForm(int32 uid, BWindow *base) 126 | { 127 | PasswordForm *wnd = new PasswordForm(uid); 128 | wnd->AddToSubset(base); 129 | wnd->CenterIn(base->Frame()); 130 | wnd->Show(); 131 | } 132 | -------------------------------------------------------------------------------- /Users/PasswordForm.h: -------------------------------------------------------------------------------- 1 | #ifndef _PASSWORDFORM_H_ 2 | #define _PASSWORDFORM_H_ 3 | 4 | #include 5 | 6 | class BWindow; 7 | 8 | 9 | void ShowPasswordForm(int32 uid, BWindow *base); 10 | 11 | #endif // _PASSWORDFORM_H_ 12 | -------------------------------------------------------------------------------- /Users/README.md: -------------------------------------------------------------------------------- 1 | Users 2 | 3 | Utility to manage user accounts and user groups. 4 | 5 | Note that currently Haiku do not fully supports multi-user, multiple users are primary useful for remote access by SSH, file sharing and POSIX software. 6 | 7 | ![screenshot](https://raw.githubusercontent.com/X547/HaikuUtils/master/Users/screenshot.png) 8 | -------------------------------------------------------------------------------- /Users/Resources.h: -------------------------------------------------------------------------------- 1 | enum { 2 | resAddIcon = 0x100, 3 | resRemoveIcon, 4 | resEditIcon, 5 | resSettingsIcon 6 | }; 7 | -------------------------------------------------------------------------------- /Users/UIUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "UIUtils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | IconMenuItem::IconMenuItem(BBitmap *bitmap, BMessage* message, char shortcut, uint32 modifiers): 10 | BMenuItem("", message, shortcut, modifiers), 11 | fBitmap(bitmap) 12 | { 13 | } 14 | 15 | IconMenuItem::IconMenuItem(BBitmap *bitmap, BMenu* menu, BMessage* message): 16 | BMenuItem(menu, message), 17 | fBitmap(bitmap) 18 | { 19 | } 20 | 21 | void IconMenuItem::GetContentSize(float* width, float* height) 22 | { 23 | *width = 0; 24 | *height = 0; 25 | if (fBitmap.Get() != NULL) { 26 | *width += fBitmap->Bounds().Width() + 1; 27 | *height += fBitmap->Bounds().Height() + 1; 28 | } 29 | if (Submenu() != NULL) { 30 | *width += 2 + 7; 31 | } 32 | }; 33 | 34 | void IconMenuItem::DrawContent() 35 | { 36 | if (fBitmap.Get() == NULL) 37 | return; 38 | 39 | BRect frame = Frame(); 40 | if (Submenu() != NULL) { 41 | frame.right -= 2 + 7; 42 | } 43 | BPoint center = BPoint((frame.left + frame.right)/2, (frame.top + frame.bottom)/2); 44 | Menu()->PushState(); 45 | Menu()->SetDrawingMode(B_OP_ALPHA); 46 | Menu()->DrawBitmap(fBitmap.Get(), center - BPoint(fBitmap->Bounds().Width()/2, fBitmap->Bounds().Height()/2)); 47 | if (Submenu() != NULL) { 48 | BPoint origin = center + BPoint(fBitmap->Bounds().Width()/2 + 2 + 3, 0); 49 | Menu()->FillTriangle( 50 | origin + BPoint(-3, -1.5), 51 | origin + BPoint(3, -1.5), 52 | origin + BPoint(0, 1.5) 53 | ); 54 | } 55 | Menu()->PopState(); 56 | } 57 | 58 | 59 | BBitmap *LoadIcon(int32 id, int32 width, int32 height) 60 | { 61 | size_t dataSize; 62 | const void* data = BApplication::AppResources()->FindResource(B_VECTOR_ICON_TYPE, id, &dataSize); 63 | 64 | if (data == NULL) return NULL; 65 | 66 | ObjectDeleter bitmap(new BBitmap(BRect(0, 0, width - 1, height - 1), B_RGBA32)); 67 | 68 | if (bitmap.Get() == NULL) return NULL; 69 | 70 | if (BIconUtils::GetVectorIcon((const uint8*)data, dataSize, bitmap.Get()) != B_OK) 71 | return NULL; 72 | 73 | return bitmap.Detach(); 74 | } 75 | -------------------------------------------------------------------------------- /Users/UIUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef _UIUTILS_H_ 2 | #define _UIUTILS_H_ 3 | 4 | 5 | #include 6 | #include 7 | 8 | class BBitmap; 9 | 10 | 11 | class IconMenuItem: public BMenuItem 12 | { 13 | public: 14 | IconMenuItem(BBitmap *bitmap, BMessage* message, char shortcut = 0, uint32 modifiers = 0); 15 | IconMenuItem(BBitmap *bitmap, BMenu* menu, BMessage* message); 16 | void GetContentSize(float* width, float* height); 17 | void DrawContent(); 18 | 19 | private: 20 | ObjectDeleter fBitmap; 21 | }; 22 | 23 | 24 | BBitmap *LoadIcon(int32 id, int32 width, int32 height); 25 | 26 | 27 | #endif // _UIUTILS_H_ 28 | -------------------------------------------------------------------------------- /Users/UserDB.cpp: -------------------------------------------------------------------------------- 1 | #include "UserDB.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | #define CheckRet(err) {status_t _err = (err); if (_err < B_OK) {/* debugger(strerror(_err)); */ return _err;}} 12 | 13 | 14 | status_t GetUsers(KMessage &reply, int32 &count, passwd**& entries) 15 | { 16 | int32 numBytes; 17 | 18 | KMessage message(BPrivate::B_REG_GET_PASSWD_DB); 19 | CheckRet(BPrivate::send_authentication_request_to_registrar(message, reply)); 20 | CheckRet(reply.What()); 21 | CheckRet(reply.FindInt32("count", &count)); 22 | CheckRet(reply.FindData("entries", B_RAW_TYPE, (const void**)&entries, &numBytes)); 23 | 24 | addr_t baseAddress = (addr_t)entries; 25 | for (int32 i = 0; i < count; i++) { 26 | passwd* entry = BPrivate::relocate_pointer(baseAddress, entries[i]); 27 | BPrivate::relocate_pointer(baseAddress, entry->pw_name); 28 | BPrivate::relocate_pointer(baseAddress, entry->pw_passwd); 29 | BPrivate::relocate_pointer(baseAddress, entry->pw_dir); 30 | BPrivate::relocate_pointer(baseAddress, entry->pw_shell); 31 | BPrivate::relocate_pointer(baseAddress, entry->pw_gecos); 32 | } 33 | 34 | return B_OK; 35 | } 36 | 37 | status_t GetGroups(KMessage &reply, int32 &count, group**& entries) 38 | { 39 | int32 numBytes; 40 | 41 | KMessage message(BPrivate::B_REG_GET_GROUP_DB); 42 | CheckRet(BPrivate::send_authentication_request_to_registrar(message, reply)); 43 | CheckRet(reply.What()); 44 | CheckRet(reply.FindInt32("count", &count)); 45 | CheckRet(reply.FindData("entries", B_RAW_TYPE, (const void**)&entries, &numBytes)); 46 | 47 | addr_t baseAddress = (addr_t)entries; 48 | for (int32 i = 0; i < count; i++) { 49 | group* entry = BPrivate::relocate_pointer(baseAddress, entries[i]); 50 | BPrivate::relocate_pointer(baseAddress, entry->gr_name); 51 | BPrivate::relocate_pointer(baseAddress, entry->gr_passwd); 52 | BPrivate::relocate_pointer(baseAddress, entry->gr_mem); 53 | int32 k = 0; 54 | for (; entry->gr_mem[k] != (void*)-1; k++) 55 | BPrivate::relocate_pointer(baseAddress, entry->gr_mem[k]); 56 | entry->gr_mem[k] = NULL; 57 | } 58 | 59 | return B_OK; 60 | } 61 | 62 | status_t DeleteUser(uid_t id, const char *name) 63 | { 64 | KMessage message(BPrivate::B_REG_DELETE_USER), reply; 65 | if ((int32)id >= 0) 66 | CheckRet(message.AddInt32("uid", id)); 67 | if (name != NULL) 68 | CheckRet(message.AddString("name", name)); 69 | CheckRet(send_authentication_request_to_registrar(message, reply)); 70 | return reply.What(); 71 | } 72 | 73 | status_t DeleteGroup(gid_t id, const char *name) 74 | { 75 | KMessage message(BPrivate::B_REG_DELETE_GROUP), reply; 76 | if ((int32)id >= 0) 77 | CheckRet(message.AddInt32("gid", id)); 78 | if (name != NULL) 79 | CheckRet(message.AddString("name", name)); 80 | CheckRet(send_authentication_request_to_registrar(message, reply)); 81 | return reply.What(); 82 | } 83 | 84 | status_t UpdateUser(KMessage &message) 85 | { 86 | KMessage reply; 87 | message.SetWhat(BPrivate::B_REG_UPDATE_USER); 88 | CheckRet(send_authentication_request_to_registrar(message, reply)); 89 | return reply.What(); 90 | } 91 | 92 | status_t UpdateGroup(KMessage &message) 93 | { 94 | KMessage reply; 95 | message.SetWhat(BPrivate::B_REG_UPDATE_GROUP); 96 | CheckRet(send_authentication_request_to_registrar(message, reply)); 97 | return reply.What(); 98 | } 99 | 100 | status_t GetUser(KMessage &reply, uid_t id, const char *name, bool shadow) 101 | { 102 | KMessage message(BPrivate::B_REG_GET_USER); 103 | if ((int32)id >= 0) 104 | CheckRet(message.AddInt32("uid", id)); 105 | if (name != NULL) 106 | CheckRet(message.AddString("name", name)); 107 | if (shadow) 108 | CheckRet(message.AddBool("shadow", shadow)); 109 | CheckRet(send_authentication_request_to_registrar(message, reply)); 110 | return reply.What(); 111 | } 112 | 113 | status_t GetGroup(KMessage &reply, gid_t id, const char *name) 114 | { 115 | KMessage message(BPrivate::B_REG_GET_GROUP); 116 | if ((int32)id >= 0) 117 | CheckRet(message.AddInt32("gid", id)); 118 | if (name != NULL) 119 | CheckRet(message.AddString("name", name)); 120 | CheckRet(send_authentication_request_to_registrar(message, reply)); 121 | return reply.What(); 122 | } 123 | -------------------------------------------------------------------------------- /Users/UserDB.h: -------------------------------------------------------------------------------- 1 | #ifndef _USERDB_H_ 2 | #define _USERDB_H_ 3 | 4 | #include 5 | 6 | namespace BPrivate { 7 | class KMessage; 8 | } 9 | struct passwd; 10 | struct group; 11 | 12 | using BPrivate::KMessage; 13 | 14 | status_t GetUsers(KMessage &reply, int32 &count, passwd**& entries); 15 | status_t GetGroups(KMessage &reply, int32 &count, group**& entries); 16 | status_t DeleteUser(uid_t id, const char *name); 17 | status_t DeleteGroup(gid_t id, const char *name); 18 | status_t UpdateUser(KMessage &message); 19 | status_t UpdateGroup(KMessage &message); 20 | status_t GetUser(KMessage &reply, uid_t id, const char *name, bool shadow = false); 21 | status_t GetGroup(KMessage &reply, gid_t id, const char *name); 22 | 23 | #endif // _USERDB_H_ 24 | -------------------------------------------------------------------------------- /Users/UserForm.h: -------------------------------------------------------------------------------- 1 | #ifndef _USERFORM_H_ 2 | #define _USERFORM_H_ 3 | 4 | #include 5 | 6 | class BWindow; 7 | 8 | 9 | void ShowUserForm(int32 uid, BWindow *base); 10 | 11 | #endif // _USERFORM_H_ 12 | -------------------------------------------------------------------------------- /Users/Users.rdef: -------------------------------------------------------------------------------- 1 | #include "Resources.h" 2 | 3 | resource app_signature "application/x-vnd.Test-Users"; 4 | 5 | resource app_flags B_SINGLE_LAUNCH; 6 | 7 | resource app_version { 8 | major = 0, 9 | middle = 0, 10 | minor = 0, 11 | 12 | variety = B_APPV_DEVELOPMENT, 13 | internal = 0, 14 | 15 | short_info = "Users", 16 | long_info = "Manage user profiles." 17 | }; 18 | 19 | resource vector_icon { 20 | $"6E636966080500020006023CADF43D104EBF02CA3EA2224AF02046648D00FFDB" 21 | $"97FFFCAF29020006023A6496BA3F153EBCDD3EEA9146596A43B15700FFF7EAFE" 22 | $"FDD17B020006023AB3673751B2BC59783FD2D74AE3F146F85900C85805FFF063" 23 | $"06020106033BC71C0000000000003BB6DB48D40045300000F2F2F2AB7D7A7AFF" 24 | $"BCA18404016C03A3290402000602388A280000000000004000004A2000000000" 25 | $"00C85804FFDC952F090A0D2C322C4330473058345A365A37CAB53C5E4456444B" 26 | $"48474835352C0A0B2C322C4330473058345A365A37CAB53C5E3C4D404D403B0A" 27 | $"062C32403B48353A34BFBFB9C5352C0A08404D3C4D3C5E4456444B4847483540" 28 | $"3B02043A223E223622322A3226322E3A3236323E32422A422E42260607FE1B3C" 29 | $"60466041604B60C804CB5AC635CB4ACC26CB81CB41C8AACDCBC976C9BAC82FC6" 30 | $"92C76B54C837C51CC6674650570A043C4D3C53444B404D0A033A34483540310A" 31 | $"04345A365A364C344B0A0A050105000A0001001001178400040A010101000A02" 32 | $"0102000A030103000A060106000A070107000A0001041001178400040A040104" 33 | $"000A0301080815FF" 34 | }; 35 | 36 | 37 | resource(resAddIcon) #'VICN' array { 38 | $"6E636966030500020006020000003D0000C000000000004C0000497FFF0080FF" 39 | $"80FF00B200040168010A0C343424342444344434544454444454445434443444" 40 | $"243424030A02010030242401178800040A0001001001178800040A01010000" 41 | }; 42 | 43 | resource(resRemoveIcon) #'VICN' array { 44 | $"6E636966030500020006020000003A0000C000000000004C0000497FFF00FFAB" 45 | $"ABFFD90000040168010A042434244454445434030A0201003024240117880004" 46 | $"0A0001001001178800040A01010000" 47 | }; 48 | 49 | resource(resEditIcon) #'VICN' array { 50 | $"6E636966050401650200160239E2053C829BBFBB123CE2AE4B960047DFAB0046" 51 | $"FF01020006023A104F3A104FBED4133ED4134B4800459F6100FFC7C7FFE98A8A" 52 | $"02030602BFF3233A8721BA8721BFF3234400004B8000A7FFEDE3FFE9BA9D0200" 53 | $"06063A104F3A104FBED4133ED4134B4800459F6100FFEA0539FFFFFF67FFD203" 54 | $"A6FFA200D4E78506FFFF9C01060605FA02245828444824482450245834582C58" 55 | $"3438540607AF2A2844284430443854384C385429572B54275528512553020448" 56 | $"24482450245834582C5834503C503C5036402C462C402C02043E2E3E2E462E4E" 57 | $"3E4E364E3E3A523A523A4C2A4230422A4208022F45452F0802374D4D37060A00" 58 | $"010030242401158800040A0101001001158800040A020102000A030101000A04" 59 | $"0103000A01020405100117820004" 60 | }; 61 | 62 | resource(resSettingsIcon) #'VICN' array { 63 | $"6E63696603020006030000003D4000C000000000004C000049C00000FFFFFF7C" 64 | $"D3CDB6FFEBE9DD0500040065020214C94EBEEFC94EBEEFC94EC006C8C8C22BC9" 65 | $"20C11EC8C8C22BC4E9C2C7C4E9C2C7C458C3A8C2C7C4E8C39BC45DC2C7C4E8C2" 66 | $"28C8CBC228C8CBC11FC923BEECC94DC006C94DBEECC94DBD24C5CDBD24C5CDBC" 67 | $"22C58ABA75C46EBB3AC50FBA75C46EB691C50CB691C50CB5ECC42AB517C221B5" 68 | $"6EC32DB517C221B7DEBF59B7DEBF59B7CFBE4FB858BC62B7FCBD4EB858BC62B6" 69 | $"8EB8DEB68EB8DEB731B7FCB8DFB68FB7FAB735B8DFB68FBC5FB858BC5FB858BD" 70 | $"58B7F6BF58B7E0BE5BB7D0BF58B7E0C221B517C221B517C32CB56DC50CB695C4" 71 | $"27B5EFC50CB695C46EBA75C46EBA75C517BB44C5CBBD24C58ABC30C5CBBD2402" 72 | $"043E34C12734BCC034343E34BCC034C1273E48BCC048C12748483E48C12748BC" 73 | $"C0030A0202010030242401178800040A010200011001178800040A0002000100" 74 | }; 75 | -------------------------------------------------------------------------------- /Users/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X547/HaikuUtils/fa7befc1c6c7b03427b4a8d27e6a40a1b38d9c64/Users/screenshot.png -------------------------------------------------------------------------------- /VideoEncoder/Makefile: -------------------------------------------------------------------------------- 1 | ## Haiku Generic Makefile v2.6 ## 2 | 3 | ## Fill in this file to specify the project being created, and the referenced 4 | ## Makefile-Engine will do all of the hard work for you. This handles any 5 | ## architecture of Haiku. 6 | ## 7 | ## For more information, see: 8 | ## file:///system/develop/documentation/makefile-engine.html 9 | 10 | # The name of the binary. 11 | NAME = VideoEncoder 12 | 13 | # The type of binary, must be one of: 14 | # APP: Application 15 | # SHARED: Shared library or add-on 16 | # STATIC: Static library archive 17 | # DRIVER: Kernel driver 18 | TYPE = APP 19 | 20 | # If you plan to use localization, specify the application's MIME signature. 21 | APP_MIME_SIG = 22 | 23 | # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are 24 | # so that Pe and Eddie can fill them in for you. 25 | #%{ 26 | # @src->@ 27 | 28 | # Specify the source files to use. Full paths or paths relative to the 29 | # Makefile can be included. All files, regardless of directory, will have 30 | # their object files created in the common object directory. Note that this 31 | # means this Makefile will not work correctly if two source files with the 32 | # same name (source.c or source.cpp) are included from different directories. 33 | # Also note that spaces in folder names do not work well with this Makefile. 34 | SRCS = VideoEncoder.cpp 35 | 36 | # Specify the resource definition files to use. Full or relative paths can be 37 | # used. 38 | RDEFS = 39 | 40 | # Specify the resource files to use. Full or relative paths can be used. 41 | # Both RDEFS and RSRCS can be utilized in the same Makefile. 42 | RSRCS = 43 | 44 | # End Pe/Eddie support. 45 | # @<-src@ 46 | #%} 47 | 48 | # Specify libraries to link against. 49 | # There are two acceptable forms of library specifications: 50 | # - if your library follows the naming pattern of libXXX.so or libXXX.a, 51 | # you can simply specify XXX for the library. (e.g. the entry for 52 | # "libtracker.so" would be "tracker") 53 | # 54 | # - for GCC-independent linking of standard C++ libraries, you can use 55 | # $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. 56 | # 57 | # - if your library does not follow the standard library naming scheme, 58 | # you need to specify the path to the library and it's name. 59 | # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") 60 | LIBS = $(STDCPPLIBS) be media 61 | 62 | # Specify additional paths to directories following the standard libXXX.so 63 | # or libXXX.a naming scheme. You can specify full paths or paths relative 64 | # to the Makefile. The paths included are not parsed recursively, so 65 | # include all of the paths where libraries must be found. Directories where 66 | # source files were specified are automatically included. 67 | LIBPATHS = 68 | 69 | # Additional paths to look for system headers. These use the form 70 | # "#include
". Directories that contain the files in SRCS are 71 | # NOT auto-included here. 72 | SYSTEM_INCLUDE_PATHS = 73 | 74 | # Additional paths paths to look for local headers. These use the form 75 | # #include "header". Directories that contain the files in SRCS are 76 | # automatically included. 77 | LOCAL_INCLUDE_PATHS = 78 | 79 | # Specify the level of optimization that you want. Specify either NONE (O0), 80 | # SOME (O1), FULL (O3), or leave blank (for the default optimization level). 81 | OPTIMIZE := 82 | 83 | # Specify the codes for languages you are going to support in this 84 | # application. The default "en" one must be provided too. "make catkeys" 85 | # will recreate only the "locales/en.catkeys" file. Use it as a template 86 | # for creating catkeys for other languages. All localization files must be 87 | # placed in the "locales" subdirectory. 88 | LOCALES = 89 | 90 | # Specify all the preprocessor symbols to be defined. The symbols will not 91 | # have their values set automatically; you must supply the value (if any) to 92 | # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler 93 | # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass 94 | # "-DDEBUG" on the compiler's command line. 95 | DEFINES = 96 | 97 | # Specify the warning level. Either NONE (suppress all warnings), 98 | # ALL (enable all warnings), or leave blank (enable default warnings). 99 | WARNINGS = 100 | 101 | # With image symbols, stack crawls in the debugger are meaningful. 102 | # If set to "TRUE", symbols will be created. 103 | SYMBOLS := 104 | 105 | # Includes debug information, which allows the binary to be debugged easily. 106 | # If set to "TRUE", debug info will be created. 107 | DEBUGGER := 108 | 109 | # Specify any additional compiler flags to be used. 110 | COMPILER_FLAGS = 111 | 112 | # Specify any additional linker flags to be used. 113 | LINKER_FLAGS = 114 | 115 | # Specify the version of this binary. Example: 116 | # -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" 117 | # This may also be specified in a resource. 118 | APP_VERSION := 119 | 120 | # (Only used when "TYPE" is "DRIVER"). Specify the desired driver install 121 | # location in the /dev hierarchy. Example: 122 | # DRIVER_PATH = video/usb 123 | # will instruct the "driverinstall" rule to place a symlink to your driver's 124 | # binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will 125 | # appear at /dev/video/usb when loaded. The default is "misc". 126 | DRIVER_PATH = 127 | 128 | ## Include the Makefile-Engine 129 | DEVEL_DIRECTORY := \ 130 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY) 131 | include $(DEVEL_DIRECTORY)/etc/makefile-engine 132 | -------------------------------------------------------------------------------- /VideoEncoder/README.md: -------------------------------------------------------------------------------- 1 | VideoEncoder 2 | 3 | Video encode test by using Media Kit. Not working yet. 4 | -------------------------------------------------------------------------------- /VideoEncoder/VideoEncoder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum { 11 | width = 800, 12 | height = 600, 13 | }; 14 | 15 | int main() 16 | { 17 | BApplication app("application/x-vnd.test-app"); 18 | BFile file("output.mp4", B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); 19 | media_format mFormat; 20 | media_file_format mff; 21 | media_codec_info codec, firstCodec; 22 | media_format outFormat; 23 | 24 | ArrayDeleter data(new uint32[width*height*4]); 25 | for (int i = 0; i < width*height; i++) 26 | data.Get()[i] = 0xff0099ff; 27 | 28 | memset(&mFormat, 0, sizeof(media_format)); 29 | mFormat.type = B_MEDIA_RAW_VIDEO; 30 | mFormat.u.raw_video.display.line_width = width; 31 | mFormat.u.raw_video.display.line_count = height; 32 | mFormat.u.raw_video.last_active = mFormat.u.raw_video.display.line_count - 1; 33 | mFormat.u.raw_video.display.format = B_YUV422; 34 | mFormat.u.raw_video.display.bytes_per_row = width*4; 35 | mFormat.u.raw_video.interlace = 1; 36 | mFormat.u.raw_video.field_rate = 30; 37 | mFormat.u.raw_video.pixel_width_aspect = 1; 38 | mFormat.u.raw_video.pixel_height_aspect = 1; 39 | 40 | int32 cookie = 0; 41 | while (get_next_file_format(&cookie, &mff) == B_OK) { 42 | if (mff.capabilities & media_file_format::B_KNOWS_ENCODED_VIDEO) { 43 | if (BString(mff.file_extension) == "mp4") { 44 | printf("container: %s, %s\n", mff.pretty_name, mff.file_extension); 45 | break; 46 | } 47 | } 48 | } 49 | 50 | cookie = 0; 51 | while (get_next_encoder(&cookie, &mff, &mFormat, &outFormat, &codec) == B_OK) { 52 | //if (BString(codec.short_name) == "mpeg4") { 53 | printf("encoder: %s, %s\n", codec.pretty_name, codec.short_name); 54 | // break; 55 | //} 56 | } 57 | 58 | ObjectDeleter mediaFile(new BMediaFile(&file, &mff)); 59 | BMediaTrack* track = mediaFile->CreateTrack(&mFormat, &codec); 60 | mediaFile->CommitHeader(); 61 | 62 | for (int32 i = 0; i < 256; i++) { 63 | track->WriteFrames(data.Get(), 1, B_MEDIA_KEY_FRAME); 64 | } 65 | 66 | track->Flush(); 67 | mediaFile->CloseFile(); 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /VideoEncoder/output.mp4: -------------------------------------------------------------------------------- 1 | ftypisomisomiso2mp41freemdat -------------------------------------------------------------------------------- /libGL/GLRenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2008, Philippe Houdoin. All rights reserved. 3 | * Distributed under the terms of the MIT License. 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | #include "GLRenderer.h" 11 | 12 | void *_glapi_Dispatch; 13 | void *_glapi_Context; 14 | 15 | BGLRenderer::BGLRenderer(BGLView* view, ulong glOptions) 16 | : 17 | fRefCount(1), 18 | fView(view), 19 | fOptions(glOptions) 20 | { 21 | } 22 | 23 | 24 | BGLRenderer::~BGLRenderer() 25 | { 26 | } 27 | 28 | 29 | void 30 | BGLRenderer::Acquire() 31 | { 32 | atomic_add(&fRefCount, 1); 33 | } 34 | 35 | 36 | void 37 | BGLRenderer::Release() 38 | { 39 | if (atomic_add(&fRefCount, -1) <= 1) 40 | delete this; 41 | } 42 | 43 | 44 | void* 45 | BGLRenderer::GetGLProcAddress(const char* procName) 46 | { 47 | return NULL; 48 | } 49 | 50 | 51 | void 52 | BGLRenderer::LockGL() 53 | { 54 | } 55 | 56 | 57 | void 58 | BGLRenderer::UnlockGL() 59 | { 60 | } 61 | 62 | 63 | void 64 | BGLRenderer::SwapBuffers(bool VSync) 65 | { 66 | } 67 | 68 | 69 | void 70 | BGLRenderer::Draw(BRect updateRect) 71 | { 72 | } 73 | 74 | 75 | status_t 76 | BGLRenderer::CopyPixelsOut(BPoint source, BBitmap* dest) 77 | { 78 | return B_ERROR; 79 | } 80 | 81 | 82 | status_t 83 | BGLRenderer::CopyPixelsIn(BBitmap* source, BPoint dest) 84 | { 85 | return B_ERROR; 86 | } 87 | 88 | 89 | void 90 | BGLRenderer::FrameResized(float width, float height) 91 | { 92 | } 93 | 94 | 95 | void 96 | BGLRenderer::DirectConnected(direct_buffer_info* info) 97 | { 98 | } 99 | 100 | 101 | void 102 | BGLRenderer::EnableDirectMode(bool enabled) 103 | { 104 | } 105 | 106 | 107 | status_t BGLRenderer::_Reserved_Renderer_0(int32 n, void* p) { return B_ERROR; } 108 | status_t BGLRenderer::_Reserved_Renderer_1(int32 n, void* p) { return B_ERROR; } 109 | status_t BGLRenderer::_Reserved_Renderer_2(int32 n, void* p) { return B_ERROR; } 110 | status_t BGLRenderer::_Reserved_Renderer_3(int32 n, void* p) { return B_ERROR; } 111 | status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void* p) { return B_ERROR; } 112 | -------------------------------------------------------------------------------- /libGL/GLRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006, Philippe Houdoin. All rights reserved. 3 | * Distributed under the terms of the MIT License. 4 | 5 | * This header defines BGLRenderer, the base class making up 6 | * the Haiku GL renderer add-ons (essentially selfcontained C++ 7 | * shared libraries that do the actual rendering such as 8 | * libswpipe.so and libswrast.so) 9 | */ 10 | #ifndef GLRENDERER_H 11 | #define GLRENDERER_H 12 | 13 | 14 | #include 15 | #include 16 | 17 | 18 | class GLRendererRoster; 19 | 20 | typedef unsigned long renderer_id; 21 | 22 | class BGLRenderer 23 | { 24 | // Private unimplemented copy constructors 25 | BGLRenderer(const BGLRenderer &); 26 | BGLRenderer & operator=(const BGLRenderer &); 27 | 28 | public: 29 | BGLRenderer(BGLView *view, ulong bgl_options); 30 | virtual ~BGLRenderer(); 31 | 32 | void Acquire(); 33 | void Release(); 34 | 35 | virtual void *GetGLProcAddress(const char* procName); 36 | 37 | virtual void LockGL(); 38 | virtual void UnlockGL(); 39 | 40 | virtual void SwapBuffers(bool VSync = false); 41 | virtual void Draw(BRect updateRect); 42 | virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest); 43 | virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest); 44 | 45 | virtual void FrameResized(float width, float height); 46 | 47 | virtual void DirectConnected(direct_buffer_info *info); 48 | virtual void EnableDirectMode(bool enabled); 49 | 50 | inline int32 ReferenceCount() const { return fRefCount; }; 51 | inline ulong Options() const { return fOptions; }; 52 | inline BGLView* GLView() { return fView; }; 53 | 54 | private: 55 | friend class GLRendererRoster; 56 | 57 | virtual status_t _Reserved_Renderer_0(int32, void *); 58 | virtual status_t _Reserved_Renderer_1(int32, void *); 59 | virtual status_t _Reserved_Renderer_2(int32, void *); 60 | virtual status_t _Reserved_Renderer_3(int32, void *); 61 | virtual status_t _Reserved_Renderer_4(int32, void *); 62 | 63 | int32 fRefCount; // How much we're still useful 64 | BGLView* fView; // Never forget who is the boss! 65 | ulong fOptions; // Keep that tune in memory 66 | }; 67 | 68 | extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer2(BGLView *view, ulong options); 69 | 70 | 71 | #endif // GLRENDERER_H 72 | -------------------------------------------------------------------------------- /libGL/GLRendererRoster.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2012, Haiku, Inc. All Rights Reserved. 3 | * Distributed under the terms of the MIT License. 4 | * 5 | * Authors: 6 | * Philippe Houdoin 7 | */ 8 | #ifndef _GLRENDERER_ROSTER_H 9 | #define _GLRENDERER_ROSTER_H 10 | 11 | 12 | #include 13 | 14 | #include 15 | 16 | typedef BGLRenderer* (*InstantiateRenderer) (BGLView* view, ulong options); 17 | 18 | struct renderer_item { 19 | InstantiateRenderer entry; 20 | entry_ref ref; 21 | ino_t node; 22 | image_id image; 23 | }; 24 | 25 | typedef std::vector RendererMap; 26 | 27 | 28 | class GLRendererRoster { 29 | public: 30 | static GLRendererRoster *Roster(); 31 | 32 | BGLRenderer* GetRenderer(BGLView *view, ulong options); 33 | 34 | private: 35 | GLRendererRoster(); 36 | virtual ~GLRendererRoster(); 37 | 38 | void AddDefaultPaths(); 39 | status_t AddPath(const char* path); 40 | status_t AddRenderer(InstantiateRenderer entry, image_id image, const entry_ref* ref, ino_t node); 41 | status_t CreateRenderer(const entry_ref& ref); 42 | 43 | static GLRendererRoster *fInstance; 44 | bool fSafeMode; 45 | const char* fABISubDirectory; 46 | RendererMap fRenderers; 47 | 48 | }; 49 | 50 | 51 | #endif /* _GLRENDERER_ROSTER_H */ 52 | -------------------------------------------------------------------------------- /libGL2/GLRenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2008, Philippe Houdoin. All rights reserved. 3 | * Distributed under the terms of the MIT License. 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | #include "GLRenderer.h" 11 | 12 | void *_glapi_Dispatch; 13 | void *_glapi_Context; 14 | 15 | BGLRenderer::BGLRenderer(BGLView* view, ulong glOptions) 16 | : 17 | fRefCount(1), 18 | fView(view), 19 | fOptions(glOptions) 20 | { 21 | } 22 | 23 | 24 | BGLRenderer::~BGLRenderer() 25 | { 26 | } 27 | 28 | 29 | void 30 | BGLRenderer::Acquire() 31 | { 32 | atomic_add(&fRefCount, 1); 33 | } 34 | 35 | 36 | void 37 | BGLRenderer::Release() 38 | { 39 | if (atomic_add(&fRefCount, -1) <= 1) 40 | delete this; 41 | } 42 | 43 | 44 | void* 45 | BGLRenderer::GetGLProcAddress(const char* procName) 46 | { 47 | return NULL; 48 | } 49 | 50 | 51 | void 52 | BGLRenderer::LockGL() 53 | { 54 | } 55 | 56 | 57 | void 58 | BGLRenderer::UnlockGL() 59 | { 60 | } 61 | 62 | 63 | void 64 | BGLRenderer::SwapBuffers(bool VSync) 65 | { 66 | } 67 | 68 | 69 | void 70 | BGLRenderer::Draw(BRect updateRect) 71 | { 72 | } 73 | 74 | 75 | status_t 76 | BGLRenderer::CopyPixelsOut(BPoint source, BBitmap* dest) 77 | { 78 | return B_ERROR; 79 | } 80 | 81 | 82 | status_t 83 | BGLRenderer::CopyPixelsIn(BBitmap* source, BPoint dest) 84 | { 85 | return B_ERROR; 86 | } 87 | 88 | 89 | void 90 | BGLRenderer::FrameResized(float width, float height) 91 | { 92 | } 93 | 94 | 95 | void 96 | BGLRenderer::DirectConnected(direct_buffer_info* info) 97 | { 98 | } 99 | 100 | 101 | void 102 | BGLRenderer::EnableDirectMode(bool enabled) 103 | { 104 | } 105 | 106 | 107 | status_t BGLRenderer::_Reserved_Renderer_0(int32 n, void* p) { return B_ERROR; } 108 | status_t BGLRenderer::_Reserved_Renderer_1(int32 n, void* p) { return B_ERROR; } 109 | status_t BGLRenderer::_Reserved_Renderer_2(int32 n, void* p) { return B_ERROR; } 110 | status_t BGLRenderer::_Reserved_Renderer_3(int32 n, void* p) { return B_ERROR; } 111 | status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void* p) { return B_ERROR; } 112 | -------------------------------------------------------------------------------- /libGL2/GLRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006, Philippe Houdoin. All rights reserved. 3 | * Distributed under the terms of the MIT License. 4 | 5 | * This header defines BGLRenderer, the base class making up 6 | * the Haiku GL renderer add-ons (essentially selfcontained C++ 7 | * shared libraries that do the actual rendering such as 8 | * libswpipe.so and libswrast.so) 9 | */ 10 | #ifndef GLRENDERER_H 11 | #define GLRENDERER_H 12 | 13 | 14 | #include 15 | #include 16 | 17 | 18 | class GLRendererRoster; 19 | 20 | typedef unsigned long renderer_id; 21 | 22 | class BGLRenderer 23 | { 24 | // Private unimplemented copy constructors 25 | BGLRenderer(const BGLRenderer &); 26 | BGLRenderer & operator=(const BGLRenderer &); 27 | 28 | public: 29 | BGLRenderer(BGLView *view, ulong bgl_options); 30 | virtual ~BGLRenderer(); 31 | 32 | void Acquire(); 33 | void Release(); 34 | 35 | virtual void *GetGLProcAddress(const char* procName); 36 | 37 | virtual void LockGL(); 38 | virtual void UnlockGL(); 39 | 40 | virtual void SwapBuffers(bool VSync = false); 41 | virtual void Draw(BRect updateRect); 42 | virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest); 43 | virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest); 44 | 45 | virtual void FrameResized(float width, float height); 46 | 47 | virtual void DirectConnected(direct_buffer_info *info); 48 | virtual void EnableDirectMode(bool enabled); 49 | 50 | inline int32 ReferenceCount() const { return fRefCount; }; 51 | inline ulong Options() const { return fOptions; }; 52 | inline BGLView* GLView() { return fView; }; 53 | 54 | private: 55 | friend class GLRendererRoster; 56 | 57 | virtual status_t _Reserved_Renderer_0(int32, void *); 58 | virtual status_t _Reserved_Renderer_1(int32, void *); 59 | virtual status_t _Reserved_Renderer_2(int32, void *); 60 | virtual status_t _Reserved_Renderer_3(int32, void *); 61 | virtual status_t _Reserved_Renderer_4(int32, void *); 62 | 63 | int32 fRefCount; // How much we're still useful 64 | BGLView* fView; // Never forget who is the boss! 65 | ulong fOptions; // Keep that tune in memory 66 | }; 67 | 68 | extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer2(BGLView *view, ulong options); 69 | 70 | 71 | #endif // GLRENDERER_H 72 | -------------------------------------------------------------------------------- /libGL2/README.md: -------------------------------------------------------------------------------- 1 | libGL2 2 | 3 | Haiku OpenGL kit implementation based on OSMesa interface. 4 | --------------------------------------------------------------------------------