Open
Description
I try translating WinDisplay.h to CocoaDisplay.h this help me learning c++ you think its good start with this code? it is correct
/*
*
*
* This file is part of lsp-ws-lib (macOS Cocoa implementation)
* Created on: 6 mar. 2025
*
* lsp-ws-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-ws-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-ws-lib. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PRIVATE_COCOA_COCOADISPLAY_H_
#define PRIVATE_COCOA_COCOADISPLAY_H_
#include <lsp-plug.in/ws/version.h>
#include <lsp-plug.in/common/types.h>
#ifdef PLATFORM_MACOS
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreText/CoreText.h>
#import <IOKit/hid/IOHIDLib.h>
namespace lsp
{
namespace ws
{
namespace cocoa
{
class CocoaWindow;
class LSP_HIDDEN_MODIFIER CocoaDisplay: public IDisplay
{
private:
friend class CocoaWindow;
protected:
NSApplication *pApplication;
NSMenu *pMainMenu;
NSMutableArray *pWindows;
NSScreen *pPrimaryScreen;
NSCursor *vCursors[__MP_COUNT];
NSMutableArray *pClipboardData;
NSMutableArray *pFontCache;
bool bExit;
NSTimer *pIdleTimer;
protected:
void do_destroy();
status_t do_main_iteration(timestamp_t ts);
public:
explicit CocoaDisplay();
virtual ~CocoaDisplay() override;
virtual status_t init(int argc, const char **argv) override;
virtual void destroy() override;
virtual status_t main() override;
virtual status_t main_iteration() override;
virtual void quit_main() override;
virtual status_t wait_events(wssize_t millis) override;
virtual IWindow *create_window() override;
virtual IWindow *create_window(size_t screen) override;
virtual IWindow *create_window(void *handle) override;
virtual IWindow *wrap_window(void *handle) override;
virtual size_t screens() override;
virtual size_t default_screen() override;
virtual status_t screen_size(size_t screen, ssize_t *w, ssize_t *h) override;
virtual status_t work_area_geometry(ws::rectangle_t *r) override;
virtual const NSScreen *enum_monitors(size_t *count) override;
virtual status_t set_clipboard(size_t id, NSData *data) override;
virtual status_t get_clipboard(size_t id, NSData **data) override;
virtual status_t get_pointer_location(size_t *screen, ssize_t *left, ssize_t *top) override;
// Font management
virtual status_t add_font(const char *name, NSData *data) override;
virtual status_t remove_font(const char *name) override;
virtual void remove_all_fonts() override;
virtual bool get_font_parameters(const char *name, CTFontRef *font) override;
// Drag & Drop support
virtual bool drag_pending() override;
virtual status_t reject_drag() override;
virtual status_t accept_drag(NSPasteboard *pasteboard) override;
// Event handling
virtual status_t process_mouse_event(NSEvent *event) override;
virtual status_t process_keyboard_event(NSEvent *event) override;
// Cursor management
virtual status_t set_cursor(NSCursor *cursor) override;
// Idle event handling
virtual void start_idle_timer() override;
virtual void stop_idle_timer() override;
// Monitor change detection
virtual void monitor_screen_changes() override;
// Task queue
virtual void task_queue_changed() override;
};
} /* namespace cocoa */
} /* namespace ws */
} /* namespace lsp */
#endif /* PLATFORM_MACOS */
#endif /* PRIVATE_COCOA_COCOADISPLAY_H_ */
and this decode.h for cocoa
/*
*
*
* This file is part of lsp-ws-lib (macOS Cocoa implementation)
* Created on: 6 mar. 2025
*
* lsp-ws-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-ws-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-ws-lib. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LSP_PLUG_IN_WS_COCOA_DECODE_H_
#define LSP_PLUG_IN_WS_COCOA_DECODE_H_
#include <lsp-plug.in/ws/version.h>
#include <lsp-plug.in/ws/types.h>
#ifdef PLATFORM_MACOS
#import <Cocoa/Cocoa.h>
#import <IOKit/hid/IOHIDLib.h>
namespace lsp
{
namespace ws
{
namespace cocoa
{
/**
* Decode the key state from the macOS event
* @param event the NSEvent representing a key press
* @return mask that indicates the pressure of some specific keys
*/
size_t decode_keystate(NSEvent *event);
/**
* Obtain the current state of keys for the keyboard
* @return mask that indicates the state of modifier keys
*/
size_t get_modifier_keystate();
/**
* Decode keyboard input from a CGEventRef
* @param event the CGEvent representing a key press
* @return virtual keycode
*/
CGKeyCode decode_keycode(CGEventRef event);
}
}
}
#endif /* PLATFORM_MACOS */
#endif /* LSP_PLUG_IN_WS_COCOA_DECODE_H_ */
Metadata
Metadata
Assignees
Labels
No labels