Merge branch 'master' into clipboard

This commit is contained in:
IoI_xD 2026-04-15 23:42:47 -05:00
commit 5136207bf1
47 changed files with 841 additions and 345 deletions

View file

@ -56,6 +56,43 @@ struct _MwLLCommonPixmap {
void* user;
};
#ifdef USE_DBUS
typedef struct _MwLLDBusFuncTable {
void* lib;
void (*dbus_error_init)(DBusError* error);
DBusConnection* (*dbus_bus_get)(DBusBusType type, DBusError* error);
dbus_bool_t (*dbus_error_is_set)(const DBusError* error);
void (*dbus_error_free)(DBusError* error);
DBusMessage* (*dbus_message_new_method_call)(const char* bus_name, const char* path, const char* iface, const char* method);
void (*dbus_message_iter_init_append)(DBusMessage* message, DBusMessageIter* iter);
dbus_bool_t (*dbus_message_iter_append_basic)(DBusMessageIter* iter, int type, const void* value);
DBusMessage* (*dbus_connection_send_with_reply_and_block)(DBusConnection* connection, DBusMessage* message, int timeout_milliseconds, DBusError* error);
void (*dbus_message_unref)(DBusMessage* message);
dbus_bool_t (*dbus_message_iter_init)(DBusMessage* message, DBusMessageIter* iter);
int (*dbus_message_iter_get_arg_type)(DBusMessageIter* iter);
void (*dbus_message_iter_recurse)(DBusMessageIter* iter, DBusMessageIter* sub);
void (*dbus_connection_unref)(DBusConnection* connection);
void (*dbus_message_iter_get_basic)(DBusMessageIter* iter, void* value);
} MwLLDBusFuncTable;
typedef struct _MwLLDBusContext {
DBusConnection* dbus_conn;
DBusError dbus_err;
DBusMessage* dbus_msg;
DBusMessage* dbus_reply;
DBusMessageIter dbus_args, dbus_variant, dbus_inner_variant;
} MwLLDBusContext;
/* setup the dbus func table. Returns false and prints a warning if dbus couldn't be found. */
MWDECL MwBool MwLLDBusFuncSetup(MwLLDBusFuncTable* tbl);
MWDECL MwBool MwLLDBusNewContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
MWDECL MwBool MwLLDBusPortalGet(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal, const char* namespace, const char* key, void* out);
MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
#endif
#ifdef _MILSKO
#ifdef USE_X11
#include <Mw/LowLevel/X11.h>
@ -69,6 +106,9 @@ struct _MwLLCommonPixmap {
#ifdef USE_COCOA
#include <Mw/LowLevel/Cocoa.h>
#endif
#ifdef CLASSIC_MAC_OS
#include <Mw/LowLevel/ClassicMacOS.h>
#endif
union _MwLL {
struct _MwLLCommon common;
@ -84,6 +124,9 @@ union _MwLL {
#ifdef USE_COCOA
struct _MwLLCocoa cocoa;
#endif
#ifdef CLASSIC_MAC_OS
struct _MwLLClassicMacOS cmacos;
#endif
};
union _MwLLColor {
@ -240,6 +283,8 @@ MWDECL void (*MwLLGetClipboard)(MwLL handle, int clipboard_type);
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
MWDECL void (*MwLLSetDarkTheme)(MwLL handle, int toggle);
/* font renderer */
MWDECL void MwFLSetup(void);

View file

@ -0,0 +1,31 @@
/*!
* @file Mw/LowLevel/ClassicMacOS.h
* @brief ClassicMacOS Backend
* @warning This is used internally
*/
#ifndef __MW_LOWLEVEL_ClassicMacOS_H__
#define __MW_LOWLEVEL_ClassicMacOS_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
struct _MwLLClassicMacOS {
struct _MwLLCommon common;
WindowRef window;
EventRecord event;
Rect winRect;
};
struct _MwLLClassicMacOSColor {
struct _MwLLCommonColor common;
};
struct _MwLLClassicMacOSPixmap {
struct _MwLLCommonPixmap common;
};
MWDECL int MwLLClassicMacOSCallInit(void);
#endif

View file

@ -36,7 +36,10 @@ typedef struct wayland_call_table {
void* lib;
void* xkb_lib;
void* cairo_lib;
void* dbus_lib;
#ifdef USE_DBUS
MwLLDBusFuncTable dbus;
MwBool has_dbus;
#endif
int (*wl_display_dispatch_pending)(struct wl_display* display);
void (*wl_display_disconnect)(struct wl_display* display);
@ -125,21 +128,6 @@ typedef struct wayland_call_table {
void (*cairo_set_antialias)(cairo_t*, cairo_antialias_t);
void (*cairo_set_operator)(cairo_t* cr, cairo_operator_t op);
void (*dbus_error_init)(DBusError* error);
DBusConnection* (*dbus_bus_get)(DBusBusType type, DBusError* error);
dbus_bool_t (*dbus_error_is_set)(const DBusError* error);
void (*dbus_error_free)(DBusError* error);
DBusMessage* (*dbus_message_new_method_call)(const char* bus_name, const char* path, const char* iface, const char* method);
void (*dbus_message_iter_init_append)(DBusMessage* message, DBusMessageIter* iter);
dbus_bool_t (*dbus_message_iter_append_basic)(DBusMessageIter* iter, int type, const void* value);
DBusMessage* (*dbus_connection_send_with_reply_and_block)(DBusConnection* connection, DBusMessage* message, int timeout_milliseconds, DBusError* error);
void (*dbus_message_unref)(DBusMessage* message);
dbus_bool_t (*dbus_message_iter_init)(DBusMessage* message, DBusMessageIter* iter);
int (*dbus_message_iter_get_arg_type)(DBusMessageIter* iter);
void (*dbus_message_iter_recurse)(DBusMessageIter* iter, DBusMessageIter* sub);
void (*dbus_connection_unref)(DBusConnection* connection);
void (*dbus_message_iter_get_basic)(DBusMessageIter* iter, void* value);
} wayland_call_table_t;
extern wayland_call_table_t wl_call_tbl;
@ -240,34 +228,9 @@ MwInline int wayland_load_funcs() {
CAIRO_FUNC(cairo_pattern_set_filter);
#undef CAIRO_FUNC
wl_call_tbl.dbus_lib = MwDynamicOpen("libdbus-1.so");
if(!wl_call_tbl.dbus_lib) {
fprintf(stderr, "[WARNING] Will not be able to detect dark theme: dbus library (libdbus-1.so) not found.\n");
return 0;
}
#define DBUS_FUNC(x) \
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.dbus_lib, #x); \
if(!wl_call_tbl.x) { \
fprintf(stderr, "[WARNING] Will not be able to detect dark theme: dbus function %s not found.\n", #x); \
dlclose(wl_call_tbl.dbus_lib); \
return 0; \
}
DBUS_FUNC(dbus_error_init);
DBUS_FUNC(dbus_bus_get);
DBUS_FUNC(dbus_error_is_set);
DBUS_FUNC(dbus_error_free);
DBUS_FUNC(dbus_message_new_method_call);
DBUS_FUNC(dbus_message_iter_init_append);
DBUS_FUNC(dbus_message_iter_append_basic);
DBUS_FUNC(dbus_connection_send_with_reply_and_block);
DBUS_FUNC(dbus_message_unref);
DBUS_FUNC(dbus_message_iter_init);
DBUS_FUNC(dbus_message_iter_get_arg_type);
DBUS_FUNC(dbus_message_iter_recurse);
DBUS_FUNC(dbus_connection_unref);
DBUS_FUNC(dbus_message_iter_get_basic);
#ifdef USE_DBUS
wl_call_tbl.has_dbus = MwLLDBusFuncSetup(&wl_call_tbl.dbus);
#endif
return 0;
}
@ -480,13 +443,11 @@ struct _MwLLWayland {
struct zwp_locked_pointer_v1* locked_pointer;
MwBool pointer_constrained;
MwBool dark_theme_detection;
time_t dbus_timer;
DBusConnection* dbus_conn;
DBusError dbus_err;
DBusMessage* dbus_msg;
DBusMessage* dbus_reply;
DBusMessageIter dbus_args, dbus_variant, dbus_inner_variant;
#ifdef USE_DBUS
MwLLDBusContext dbus;
#endif
MwBool dark_theme_detection;
/* clipboard related stuff.
* Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/

View file

@ -57,6 +57,12 @@ struct _MwLLX11 {
unsigned long blue_mask;
unsigned long blue_max;
unsigned long blue_shift;
#ifdef USE_DBUS
MwLLDBusContext dbus;
#endif
MwBool dark_theme_detection;
};
struct _MwLLX11Color {

View file

@ -37,22 +37,37 @@
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
#endif
#endif
#elif defined(CLASSIC_MAC_OS)
#include <unistd.h>
#include <MacTypes.h>
#include <CFBundle.h>
#include <CodeFragments.h>
#include <Timer.h>
#include <MacWindows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#else
#include <unistd.h>
#include <pwd.h>
#include <dlfcn.h>
#include <signal.h>
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#endif
#ifdef __unix__
#include <dirent.h>
#include <dlfcn.h>
#endif
#ifdef __APPLE__
#include <mach/clock.h>
#include <mach/mach.h>
#endif
#ifdef USE_DBUS
#include <dbus/dbus.h>
#endif
#ifndef M_PI
#define M_PI 3.14159265
#endif