diff --git a/src/applets/leds.c b/src/applets/leds.c index 615e6d9..b879c3c 100644 --- a/src/applets/leds.c +++ b/src/applets/leds.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2016-2023 Pierre Pronchery */ +/* Copyright (c) 2016-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include #include #include -#ifdef GDK_WINDOWING_X11 +#if defined(GDK_WINDOWING_X11) # include # include # include @@ -38,6 +38,7 @@ typedef struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) GtkWidget * widget; GtkWidget * leds[XkbNumIndicators]; gulong source; @@ -45,6 +46,7 @@ typedef struct _PanelApplet GdkDisplay * display; XkbDescPtr xkb; +#endif } LEDs; @@ -54,9 +56,11 @@ static LEDs * _leds_init(PanelAppletHelper * helper, GtkWidget ** widget); static void _leds_destroy(LEDs * leds); /* callbacks */ +#if defined(GDK_WINDOWING_X11) static void _leds_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data); static gboolean _leds_on_timeout(gpointer data); +#endif /* public */ @@ -79,6 +83,7 @@ PanelAppletDefinition applet = /* leds_init */ static LEDs * _leds_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) LEDs * leds; size_t i; @@ -104,12 +109,20 @@ static LEDs * _leds_init(PanelAppletHelper * helper, GtkWidget ** widget) gtk_widget_show(leds->widget); *widget = leds->widget; return leds; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } /* leds_destroy */ static void _leds_destroy(LEDs * leds) { +#if defined(GDK_WINDOWING_X11) /* XXX free xkb? */ if(leds->timeout != 0) g_source_remove(leds->timeout); @@ -117,9 +130,13 @@ static void _leds_destroy(LEDs * leds) g_signal_handler_disconnect(leds->widget, leds->source); gtk_widget_destroy(leds->widget); object_delete(leds); +#else + (void) leds; +#endif } +#if defined(GDK_WINDOWING_X11) /* callbacks */ /* leds_on_screen_changed */ static void _leds_on_screen_changed(GtkWidget * widget, GdkScreen * previous, @@ -245,3 +262,4 @@ static gboolean _leds_on_timeout(gpointer data) } return TRUE; } +#endif diff --git a/src/applets/mixer.c b/src/applets/mixer.c index 4bcc05f..0b625a3 100644 --- a/src/applets/mixer.c +++ b/src/applets/mixer.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2012-2023 Pierre Pronchery */ +/* Copyright (c) 2012-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,14 +29,16 @@ #include #include #include -#ifdef GDK_WINDOWING_X11 -# include -#endif -#if GTK_CHECK_VERSION(3, 0, 0) -# include +#if defined(GDK_WINDOWING_X11) +# if GTK_CHECK_VERSION(3, 0, 0) +# include +# else +# include +# endif #endif #include #include "Panel/applet.h" + #define _(string) gettext(string) #define N_(string) string @@ -47,6 +49,7 @@ typedef struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) GtkWidget * widget; guint source; @@ -65,6 +68,7 @@ typedef struct _PanelApplet GtkWidget * pr_width; GtkWidget * pr_height; GtkWidget * pr_ratio; +#endif } Mixer; @@ -76,6 +80,7 @@ static void _mixer_destroy(Mixer * mixer); static GtkWidget * _mixer_settings(Mixer * mixer, gboolean apply, gboolean reset); +#if defined(GDK_WINDOWING_X11) /* useful */ static int _mixer_spawn(Mixer * mixer, unsigned long * xid); @@ -83,6 +88,7 @@ static int _mixer_spawn(Mixer * mixer, unsigned long * xid); static void _mixer_on_child(GPid pid, gint status, gpointer data); static gboolean _mixer_on_removed(void); static void _mixer_on_toggled(GtkWidget * widget, gpointer data); +#endif /* constants */ @@ -107,13 +113,16 @@ PanelAppletDefinition applet = /* private */ /* functions */ /* mixer_init */ +#if defined(GDK_WINDOWING_X11) static void _init_size(Mixer * mixer, PanelAppletHelper * helper); /* callbacks */ static gboolean _init_idle(gpointer data); +#endif static Mixer * _mixer_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) Mixer * mixer; GtkWidget * image; @@ -131,9 +140,9 @@ static Mixer * _mixer_init(PanelAppletHelper * helper, mixer->pr_box = NULL; _init_size(mixer, helper); mixer->widget = gtk_toggle_button_new(); -#if GTK_CHECK_VERSION(2, 12, 0) +# if GTK_CHECK_VERSION(2, 12, 0) gtk_widget_set_tooltip_text(mixer->widget, _("Show mixer")); -#endif +# endif gtk_button_set_relief(GTK_BUTTON(mixer->widget), GTK_RELIEF_NONE); g_signal_connect(mixer->widget, "toggled", G_CALLBACK( _mixer_on_toggled), mixer); @@ -144,8 +153,16 @@ static Mixer * _mixer_init(PanelAppletHelper * helper, mixer->source = g_idle_add(_init_idle, mixer); *widget = mixer->widget; return mixer; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } +#if defined(GDK_WINDOWING_X11) static void _init_size(Mixer * mixer, PanelAppletHelper * helper) { char const * p; @@ -169,10 +186,10 @@ static void _init_size(Mixer * mixer, PanelAppletHelper * helper) mixer->width = mixer->height * 3; else if(mixer->height == -1) mixer->height = mixer->width / 3; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s() width=%d height=%d\n", __func__, mixer->width, mixer->height); -#endif +# endif } /* callbacks */ @@ -185,9 +202,9 @@ static gboolean _init_idle(gpointer data) return FALSE; mixer->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_accept_focus(GTK_WINDOW(mixer->window), FALSE); -#if GTK_CHECK_VERSION(2, 6, 0) +# if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_focus_on_map(GTK_WINDOW(mixer->window), FALSE); -#endif +# endif /* XXX let this be configurable (resize applications automatically) */ gtk_window_set_type_hint(GTK_WINDOW(mixer->window), GDK_WINDOW_TYPE_HINT_DOCK); @@ -200,20 +217,26 @@ static gboolean _init_idle(gpointer data) gtk_widget_show(mixer->socket); return FALSE; } +#endif /* mixer_destroy */ static void _mixer_destroy(Mixer * mixer) { +#if defined(GDK_WINDOWING_X11) if(mixer->source > 0) g_source_remove(mixer->source); if(mixer->pid > 0) g_spawn_close_pid(mixer->pid); gtk_widget_destroy(mixer->widget); free(mixer); +#else + (void) mixer; +#endif } +#if defined(GDK_WINDOWING_X11) /* mixer_settings */ static void _settings_apply(Mixer * mixer, PanelAppletHelper * helper); static void _settings_reset(Mixer * mixer, PanelAppletHelper * helper); @@ -221,16 +244,18 @@ static GtkWidget * _settings_widget(Mixer * mixer); /* callbacks */ static void _settings_on_width_value_changed(gpointer data); static void _settings_on_height_value_changed(gpointer data); +#endif static GtkWidget * _mixer_settings(Mixer * mixer, gboolean apply, gboolean reset) { +#if defined(GDK_WINDOWING_X11) PanelAppletHelper * helper = mixer->helper; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(%p, %s, %s)\n", __func__, (void *)mixer, apply ? "TRUE" : "FALSE", reset ? "TRUE" : "FALSE"); -#endif +# endif if(mixer->pr_box == NULL) { mixer->pr_box = _settings_widget(mixer); @@ -241,8 +266,16 @@ static GtkWidget * _mixer_settings(Mixer * mixer, gboolean apply, if(apply == TRUE) _settings_apply(mixer, helper); return mixer->pr_box; +#else + (void) mixer; + (void) apply; + (void) reset; + + return NULL; +#endif } +#if defined(GDK_WINDOWING_X11) static void _settings_apply(Mixer * mixer, PanelAppletHelper * helper) { char const * p; @@ -287,13 +320,13 @@ static GtkWidget * _settings_widget(Mixer * mixer) GtkWidget * widget; group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); -#else +# else vbox = gtk_vbox_new(FALSE, 4); hbox = gtk_hbox_new(FALSE, 4); -#endif +# endif widget = gtk_label_new(_("Command:")); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); mixer->pr_command = gtk_entry_new(); @@ -301,18 +334,18 @@ static GtkWidget * _settings_widget(Mixer * mixer) gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* frame */ frame = gtk_frame_new(_("Size:")); -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); -#else +# else vbox2 = gtk_vbox_new(FALSE, 4); -#endif +# endif gtk_container_set_border_width(GTK_CONTAINER(vbox2), 4); /* width */ -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); -#else +# else hbox = gtk_hbox_new(FALSE, 4); -#endif +# endif widget = gtk_label_new(_("Width:")); gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); @@ -323,11 +356,11 @@ static GtkWidget * _settings_widget(Mixer * mixer) gtk_box_pack_start(GTK_BOX(hbox), mixer->pr_width, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, TRUE, 0); /* height */ -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); -#else +# else hbox = gtk_hbox_new(FALSE, 4); -#endif +# endif widget = gtk_label_new(_("Height:")); gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); @@ -424,9 +457,9 @@ static void _mixer_on_child(GPid pid, gint status, gpointer data) const int timeout = 1000; Mixer * mixer = data; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(%u) %u\n", __func__, pid, mixer->pid); -#endif +# endif if(mixer->source != 0 || mixer->pid != pid) return; if(WIFEXITED(status) || WIFSIGNALED(status)) @@ -485,3 +518,4 @@ static void _mixer_on_toggled(GtkWidget * widget, gpointer data) else gtk_widget_hide(mixer->window); } +#endif diff --git a/src/applets/pager.c b/src/applets/pager.c index a035fe3..c5b2b88 100644 --- a/src/applets/pager.c +++ b/src/applets/pager.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2010-2023 Pierre Pronchery */ +/* Copyright (c) 2010-2024 Pierre Pronchery */ /* This file is part of DeforaOS Pager Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +52,7 @@ typedef struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) GtkWidget * box; gulong source; @@ -62,10 +63,12 @@ typedef struct _PanelApplet GdkDisplay * display; GdkScreen * screen; GdkWindow * root; +#endif } Pager; /* constants */ +#if defined(GDK_WINDOWING_X11) static const char * _pager_atom[PAGER_ATOM_COUNT] = { "_NET_CURRENT_DESKTOP", @@ -73,12 +76,14 @@ static const char * _pager_atom[PAGER_ATOM_COUNT] = "_NET_NUMBER_OF_DESKTOPS", "UTF8_STRING" }; +#endif /* prototypes */ static Pager * _pager_init(PanelAppletHelper * helper, GtkWidget ** widget); static void _pager_destroy(Pager * pager); +#if defined(GDK_WINDOWING_X11) /* accessors */ static int _pager_get_current_desktop(Pager * pager); static char ** _pager_get_desktop_names(Pager * pager); @@ -96,6 +101,7 @@ static GdkFilterReturn _pager_on_filter(GdkXEvent * xevent, GdkEvent * event, gpointer data); static void _pager_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data); +#endif /* public */ @@ -118,6 +124,7 @@ PanelAppletDefinition applet = /* pager_init */ static Pager * _pager_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) Pager * pager; GtkOrientation orientation; @@ -128,13 +135,13 @@ static Pager * _pager_init(PanelAppletHelper * helper, GtkWidget ** widget) } pager->helper = helper; orientation = panel_window_get_orientation(helper->window); -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) pager->box = gtk_box_new(orientation, 0); gtk_box_set_homogeneous(GTK_BOX(pager->box), TRUE); -#else +# else pager->box = (orientation == GTK_ORIENTATION_VERTICAL) ? gtk_vbox_new(TRUE, 0) : gtk_hbox_new(TRUE, 0); -#endif +# endif pager->source = g_signal_connect(pager->box, "screen-changed", G_CALLBACK(_pager_on_screen_changed), pager); pager->widgets = NULL; @@ -144,12 +151,20 @@ static Pager * _pager_init(PanelAppletHelper * helper, GtkWidget ** widget) pager->root = NULL; *widget = pager->box; return pager; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } /* pager_destroy */ static void _pager_destroy(Pager * pager) { +#if defined(GDK_WINDOWING_X11) if(pager->source != 0) g_signal_handler_disconnect(pager->box, pager->source); pager->source = 0; @@ -157,9 +172,13 @@ static void _pager_destroy(Pager * pager) gdk_window_remove_filter(pager->root, _pager_on_filter, pager); gtk_widget_destroy(pager->box); free(pager); +#else + (void) pager; +#endif } +#if defined(GDK_WINDOWING_X11) /* accessors */ /* pager_get_current_desktop */ static int _pager_get_current_desktop(Pager * pager) @@ -226,10 +245,10 @@ static int _pager_get_window_property(Pager * pager, Window window, int format; unsigned long bytes; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(pager, window, %s, %lu)\n", __func__, _pager_atom[property], atom); -#endif +# endif gdk_error_trap_push(); res = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(pager->display), window, pager->atoms[property], 0, G_MAXLONG, False, atom, @@ -264,9 +283,9 @@ static void _pager_do(Pager * pager) XA_CARDINAL, &cnt, (void*)&p) != 0) return; l = *p; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s() l=%ld\n", __func__, l); -#endif +# endif XFree(p); for(i = l; i < pager->widgets_cnt; i++) if(pager->widgets[i] != NULL) @@ -319,22 +338,22 @@ static void _pager_refresh(Pager * pager) if(cur < 0 || i != (unsigned int)cur) { gtk_widget_set_sensitive(pager->widgets[i], TRUE); -#if GTK_CHECK_VERSION(2, 12, 0) +# if GTK_CHECK_VERSION(2, 12, 0) snprintf(buf, sizeof(buf), _("Switch to %s"), gtk_button_get_label( GTK_BUTTON(pager->widgets[i]))); gtk_widget_set_tooltip_text(pager->widgets[i], buf); -#endif +# endif } else { gtk_widget_set_sensitive(pager->widgets[i], FALSE); -#if GTK_CHECK_VERSION(2, 12, 0) +# if GTK_CHECK_VERSION(2, 12, 0) snprintf(buf, sizeof(buf), _("On %s"), gtk_button_get_label( GTK_BUTTON(pager->widgets[i]))); gtk_widget_set_tooltip_text(pager->widgets[i], buf); -#endif +# endif } } @@ -424,3 +443,4 @@ static void _pager_on_screen_changed(GtkWidget * widget, GdkScreen * previous, pager->display, _pager_atom[i]); _pager_do(pager); } +#endif diff --git a/src/applets/systray.c b/src/applets/systray.c index f15c2c3..2ed3714 100644 --- a/src/applets/systray.c +++ b/src/applets/systray.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2010-2023 Pierre Pronchery */ +/* Copyright (c) 2010-2024 Pierre Pronchery */ /* This file is part of DeforaOS Pager Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,15 +20,17 @@ #include #include #include -#if GTK_CHECK_VERSION(3, 0, 0) -# include -#endif -#ifdef GDK_WINDOWING_X11 -# include -# include +#if defined(GDK_WINDOWING_X11) +# if GTK_CHECK_VERSION(3, 0, 0) +# include +# else +# include +# include +# endif #endif #include #include "Panel/applet.h" + #define N_(string) string @@ -38,9 +40,11 @@ typedef struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) GtkWidget * hbox; GtkWidget * owner; gulong source; +#endif } Systray; @@ -54,12 +58,14 @@ typedef struct _PanelApplet static Systray * _systray_init(PanelAppletHelper * helper, GtkWidget ** widget); static void _systray_destroy(Systray * systray); +#if defined(GDK_WINDOWING_X11) /* callbacks */ static GdkFilterReturn _systray_on_filter(GdkXEvent * xevent, GdkEvent * event, gpointer data); static void _systray_on_owner_destroy(gpointer data); static void _systray_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data); +#endif /* public */ @@ -82,6 +88,7 @@ PanelAppletDefinition applet = /* systray_init */ static Systray * _systray_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) Systray * systray; gint height = 24; @@ -91,11 +98,11 @@ static Systray * _systray_init(PanelAppletHelper * helper, GtkWidget ** widget) return NULL; } systray->helper = helper; -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) systray->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); -#else +# else systray->hbox = gtk_hbox_new(FALSE, 0); -#endif +# endif gtk_icon_size_lookup(panel_window_get_icon_size(helper->window), NULL, &height); gtk_widget_set_size_request(systray->hbox, -1, height); @@ -105,12 +112,20 @@ static Systray * _systray_init(PanelAppletHelper * helper, GtkWidget ** widget) gtk_widget_show(systray->hbox); *widget = systray->hbox; return systray; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } /* systray_destroy */ static void _systray_destroy(Systray * systray) { +#if defined(GDK_WINDOWING_X11) GdkWindow * window; if(systray->source != 0) @@ -124,9 +139,13 @@ static void _systray_destroy(Systray * systray) } gtk_widget_destroy(systray->hbox); free(systray); +#else + (void) systray; +#endif } +#if defined(GDK_WINDOWING_X11) /* callbacks */ /* systray_on_filter */ static GdkFilterReturn _filter_clientmessage(Systray * systray, @@ -139,9 +158,9 @@ static GdkFilterReturn _systray_on_filter(GdkXEvent * xevent, GdkEvent * event, XEvent * xev = xevent; (void) event; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); -#endif +# endif if(xev->type == ClientMessage) return _filter_clientmessage(systray, &xev->xclient); return GDK_FILTER_CONTINUE; @@ -162,10 +181,10 @@ static GdkFilterReturn _filter_clientmessage(Systray * systray, gtk_box_pack_start(GTK_BOX(systray->hbox), socket, FALSE, TRUE, 0); gtk_socket_add_id(GTK_SOCKET(socket), xev->data.l[2]); -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s() %ld\n", __func__, xev->data.l[2]); -#endif +# endif return GDK_FILTER_REMOVE; } return GDK_FILTER_CONTINUE; @@ -233,3 +252,4 @@ static void _systray_on_screen_changed(GtkWidget * widget, GdkScreen * previous, | GDK_STRUCTURE_MASK); gdk_window_add_filter(window, _systray_on_filter, systray); } +#endif diff --git a/src/applets/tasks.c b/src/applets/tasks.c index a8a3c68..adc3d6f 100644 --- a/src/applets/tasks.c +++ b/src/applets/tasks.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2011-2023 Pierre Pronchery */ +/* Copyright (c) 2011-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,14 +20,19 @@ #include #include #include -#include -#ifdef GDK_WINDOWING_X11 -# include +#include +#if defined(GDK_WINDOWING_X11) +# if GTK_CHECK_VERSION(3, 0, 0) +# include +# else +# include +# endif # include #endif #include #include #include "Panel/applet.h" + #define _(string) gettext(string) #define N_(string) string @@ -39,17 +44,20 @@ /* Tasks */ /* private */ /* types */ -#define atom(a) TASKS_ATOM_ ## a +#if defined(GDK_WINDOWING_X11) +# define atom(a) TASKS_ATOM_ ## a typedef enum _TasksAtom { -#include "tasks.atoms" +# include "tasks.atoms" } TasksAtom; -#define TASKS_ATOM_LAST TASKS_ATOM_UTF8_STRING -#define TASKS_ATOM_COUNT (TASKS_ATOM_LAST + 1) -#undef atom +# define TASKS_ATOM_LAST TASKS_ATOM_UTF8_STRING +# define TASKS_ATOM_COUNT (TASKS_ATOM_LAST + 1) +# undef atom +#endif typedef struct _PanelApplet Tasks; +#if defined(GDK_WINDOWING_X11) typedef struct _Task { Tasks * tasks; @@ -60,10 +68,12 @@ typedef struct _Task gboolean delete; gboolean reorder; } Task; +#endif struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) Task ** tasks; size_t tasks_cnt; gboolean label; @@ -81,23 +91,27 @@ struct _PanelApplet GdkDisplay * display; GdkScreen * screen; GdkWindow * root; +#endif }; +#if defined(GDK_WINDOWING_X11) /* constants */ -#define atom(a) "" # a +# define atom(a) "" # a static const char * _tasks_atom[TASKS_ATOM_COUNT] = { -#include "tasks.atoms" +# include "tasks.atoms" }; -#undef atom +# undef atom -#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */ -#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */ -#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */ +# define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */ +# define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */ +# define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */ +#endif /* prototypes */ +#if defined(GDK_WINDOWING_X11) /* task */ static Task * _task_new(Tasks * tasks, gboolean label, gboolean reorder, Window window, char const * name, GdkPixbuf * pixbuf); @@ -106,11 +120,13 @@ static void _task_set(Task * task, char const * name, GdkPixbuf * pixbuf); static void _task_toggle_state(Task * task, TasksAtom state); static void _task_toggle_state2(Task * task, TasksAtom state1, TasksAtom state2); +#endif /* tasks */ static Tasks * _tasks_init(PanelAppletHelper * helper, GtkWidget ** widget); static void _tasks_destroy(Tasks * tasks); +#if defined(GDK_WINDOWING_X11) /* accessors */ static int _tasks_get_current_desktop(Tasks * tasks); static int _tasks_get_text_property(Tasks * tasks, Window window, Atom property, @@ -143,6 +159,7 @@ static void _task_on_popup_shade(gpointer data); static void _task_on_popup_stick(gpointer data); static void _task_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data); +#endif /* public */ @@ -164,6 +181,7 @@ PanelAppletDefinition applet = }; +#if defined(GDK_WINDOWING_X11) /* private */ /* functions */ /* Task */ @@ -193,11 +211,11 @@ static Task * _task_new(Tasks * tasks, gboolean label, gboolean reorder, task->image = gtk_image_new(); task->delete = FALSE; task->reorder = reorder; -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); -#else +# else hbox = gtk_hbox_new(FALSE, 0); -#endif +# endif gtk_box_pack_start(GTK_BOX(hbox), task->image, FALSE, TRUE, 0); if(label) { @@ -282,12 +300,14 @@ static void _task_toggle_state2(Task * task, TasksAtom state1, &xev); gdk_error_trap_pop_ignored(); } +#endif /* Tasks */ /* tasks_init */ static Tasks * _tasks_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) Tasks * tasks; char const * p; GtkOrientation orientation; @@ -361,12 +381,20 @@ static Tasks * _tasks_init(PanelAppletHelper * helper, GtkWidget ** widget) gtk_widget_show_all(tasks->widget); *widget = tasks->widget; return tasks; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } /* tasks_destroy */ static void _tasks_destroy(Tasks * tasks) { +#if defined(GDK_WINDOWING_X11) size_t i; if(tasks->source != 0) @@ -381,9 +409,13 @@ static void _tasks_destroy(Tasks * tasks) tasks->tasks_cnt = 0; gtk_widget_destroy(tasks->widget); free(tasks); +#else + (void) tasks; +#endif } +#if defined(GDK_WINDOWING_X11) /* accessors */ /* tasks_get_current_desktop */ static int _tasks_get_current_desktop(Tasks * tasks) @@ -415,22 +447,22 @@ static int _tasks_get_text_property(Tasks * tasks, Window window, Atom property, char ** list; int i; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(tasks, window, %lu)\n", __func__, property); -#endif +# endif gdk_error_trap_push(); res = XGetTextProperty(GDK_DISPLAY_XDISPLAY(tasks->display), window, &text, property); if(gdk_error_trap_pop() != 0 || res == 0) return -1; atom = gdk_x11_xatom_to_atom(text.encoding); -#if GTK_CHECK_VERSION(2, 24, 0) +# if GTK_CHECK_VERSION(2, 24, 0) cnt = gdk_x11_display_text_property_to_text_list(tasks->display, atom, text.format, text.value, text.nitems, &list); -#else +# else cnt = gdk_text_property_to_utf8_list(atom, text.format, text.value, text.nitems, &list); -#endif +# endif if(cnt > 0) { *ret = list[0]; @@ -456,10 +488,10 @@ static int _tasks_get_window_property(Tasks * tasks, Window window, int format; unsigned long bytes; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(tasks, window, %s, %lu)\n", __func__, _tasks_atom[property], atom); -#endif +# endif gdk_error_trap_push(); res = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(tasks->display), window, tasks->atom[property], 0, G_MAXLONG, False, atom, @@ -495,9 +527,9 @@ static void _tasks_do(Tasks * tasks) unsigned long i; char * name; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); -#endif +# endif if(_tasks_get_window_property(tasks, GDK_WINDOW_XID(tasks->root), TASKS_ATOM__NET_CLIENT_LIST, XA_WINDOW, &cnt, (void *)&windows) != 0) @@ -628,14 +660,14 @@ static int _do_tasks_add(Tasks * tasks, int desktop, Window window, { size_t i; Task * p = NULL; -#ifndef EMBEDDED +# ifndef EMBEDDED unsigned long * l; unsigned long cnt; int cur = -1; -#endif +# endif Task ** q; -#ifndef EMBEDDED +# ifndef EMBEDDED if(_tasks_get_window_property(tasks, window, TASKS_ATOM__NET_WM_DESKTOP, XA_CARDINAL, &cnt, (void *)&l) == 0) { @@ -645,7 +677,7 @@ static int _do_tasks_add(Tasks * tasks, int desktop, Window window, } if(cur >= 0 && cur != desktop) return 0; -#endif +# endif for(i = 0; i < tasks->tasks_cnt; i++) if(tasks->tasks[i]->window == window) break; @@ -747,9 +779,9 @@ static void _clicked_activate(Task * task) { GdkDisplay * display; XEvent xev; -#ifdef DEBUG +# ifdef DEBUG int res; -#endif +# endif display = task->tasks->display; memset(&xev, 0, sizeof(xev)); @@ -762,19 +794,19 @@ static void _clicked_activate(Task * task) xev.xclient.data.l[1] = gdk_x11_display_get_user_time(display); xev.xclient.data.l[2] = 0; gdk_error_trap_push(); -#ifdef DEBUG +# ifdef DEBUG res = -#endif +# endif XSendEvent(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XID(task->tasks->root), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev); -#ifdef DEBUG +# ifdef DEBUG if(gdk_error_trap_pop() != 0 || res != Success) fprintf(stderr, "DEBUG: %s() error\n", __func__); -#else +# else gdk_error_trap_pop_ignored(); -#endif +# endif } @@ -799,10 +831,10 @@ static GdkFilterReturn _task_on_filter(GdkXEvent * xevent, GdkEvent * event, if(xev->type != PropertyNotify) return GDK_FILTER_CONTINUE; if(xev->xproperty.atom != tasks->atom[TASKS_ATOM__NET_CLIENT_LIST] -#ifndef EMBEDDED +# ifndef EMBEDDED && xev->xproperty.atom != tasks->atom[TASKS_ATOM__NET_CURRENT_DESKTOP] -#endif +# endif ) return GDK_FILTER_CONTINUE; _tasks_do(tasks); @@ -869,7 +901,7 @@ static gboolean _task_on_popup(gpointer data) if(menu == NULL) menu = gtk_menu_new(); if(items[j].stock != NULL) -#if GTK_CHECK_VERSION(3, 10, 0) +# if GTK_CHECK_VERSION(3, 10, 0) { menuitem = gtk_image_menu_item_new_with_label( items[j].label); @@ -879,10 +911,10 @@ static gboolean _task_on_popup(gpointer data) items[j].stock, GTK_ICON_SIZE_MENU)); } -#else +# else menuitem = gtk_image_menu_item_new_from_stock( items[j].stock, NULL); -#endif +# endif else menuitem = gtk_menu_item_new_with_label( _(items[j].label)); @@ -1073,9 +1105,9 @@ static void _task_on_screen_changed(GtkWidget * widget, GdkScreen * previous, size_t i; (void) previous; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); -#endif +# endif if(tasks->root != NULL) gdk_window_remove_filter(tasks->root, _task_on_filter, tasks); tasks->screen = gtk_widget_get_screen(widget); @@ -1090,3 +1122,4 @@ static void _task_on_screen_changed(GtkWidget * widget, GdkScreen * previous, tasks->display, _tasks_atom[i]); _tasks_do(tasks); } +#endif diff --git a/src/applets/title.c b/src/applets/title.c index 4f2a7c2..4d0f0df 100644 --- a/src/applets/title.c +++ b/src/applets/title.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2011-2023 Pierre Pronchery */ +/* Copyright (c) 2011-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,13 +20,14 @@ #include #include #include -#include -#ifdef GDK_WINDOWING_X11 +#include +#if defined(GDK_WINDOWING_X11) # include # include #endif #include #include "Panel/applet.h" + #define _(string) gettext(string) #define N_(string) string @@ -37,6 +38,7 @@ typedef struct _PanelApplet { PanelAppletHelper * helper; +#if defined(GDK_WINDOWING_X11) GtkWidget * widget; gulong source; @@ -48,6 +50,7 @@ typedef struct _PanelApplet Atom atom_name; Atom atom_utf8_string; Atom atom_visible_name; +#endif } Title; @@ -56,6 +59,7 @@ typedef struct _PanelApplet static Title * _title_init(PanelAppletHelper * helper, GtkWidget ** widget); static void _title_destroy(Title * title); +#if defined(GDK_WINDOWING_X11) /* accessors */ static int _title_get_text_property(Title * title, Window window, Atom property, char ** ret); @@ -68,6 +72,7 @@ static GdkFilterReturn _title_on_filter(GdkXEvent * xevent, GdkEvent * event, gpointer data); static void _title_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data); +#endif /* public */ @@ -90,6 +95,7 @@ PanelAppletDefinition applet = /* title_init */ static Title * _title_init(PanelAppletHelper * helper, GtkWidget ** widget) { +#if defined(GDK_WINDOWING_X11) Title * title; PangoFontDescription * bold; @@ -102,11 +108,11 @@ static Title * _title_init(PanelAppletHelper * helper, GtkWidget ** widget) bold = pango_font_description_new(); pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD); title->widget = gtk_label_new(""); -#if GTK_CHECK_VERSION(3, 0, 0) +# if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_override_font(title->widget, bold); -#else +# else gtk_widget_modify_font(title->widget, bold); -#endif +# endif pango_font_description_free(bold); title->source = g_signal_connect(title->widget, "screen-changed", G_CALLBACK(_title_on_screen_changed), title); @@ -119,12 +125,20 @@ static Title * _title_init(PanelAppletHelper * helper, GtkWidget ** widget) gtk_widget_show(title->widget); *widget = title->widget; return title; +#else + (void) helper; + (void) widget; + + error_set_code(-ENOSYS, "X11 support not detected"); + return NULL; +#endif } /* title_destroy */ static void _title_destroy(Title * title) { +#if defined(GDK_WINDOWING_X11) if(title->source != 0) g_signal_handler_disconnect(title->widget, title->source); title->source = 0; @@ -132,9 +146,13 @@ static void _title_destroy(Title * title) gdk_window_remove_filter(title->root, _title_on_filter, title); gtk_widget_destroy(title->widget); free(title); +#else + (void) title; +#endif } +#if defined(GDK_WINDOWING_X11) /* accessors */ /* title_get_window_property */ static int _title_get_window_property(Title * title, Window window, @@ -146,10 +164,10 @@ static int _title_get_window_property(Title * title, Window window, int format; unsigned long bytes; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(title, window, %lu, %lu)\n", __func__, property, atom); -#endif +# endif gdk_error_trap_push(); res = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(title->display), window, property, 0, G_MAXLONG, False, atom, &type, &format, @@ -178,22 +196,22 @@ static int _title_get_text_property(Title * title, Window window, Atom property, char ** list; int i; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s(title, window, %lu)\n", __func__, property); -#endif +# endif gdk_error_trap_push(); res = XGetTextProperty(GDK_DISPLAY_XDISPLAY(title->display), window, &text, property); if(gdk_error_trap_pop() != 0 || res == 0) return 1; atom = gdk_x11_xatom_to_atom(text.encoding); -#if GTK_CHECK_VERSION(2, 24, 0) +# if GTK_CHECK_VERSION(2, 24, 0) cnt = gdk_x11_display_text_property_to_text_list(title->display, atom, text.format, text.value, text.nitems, &list); -#else +# else cnt = gdk_text_property_to_utf8_list(atom, text.format, text.value, text.nitems, &list); -#endif +# endif if(cnt > 0) { *ret = list[0]; @@ -220,9 +238,9 @@ static void _title_do(Title * title) Window * window; char * name; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); -#endif +# endif if(_title_get_window_property(title, GDK_WINDOW_XID(title->root), title->atom_active, XA_WINDOW, &cnt, (void*)&window) != 0 || cnt != 1) @@ -303,9 +321,9 @@ static void _title_on_screen_changed(GtkWidget * widget, GdkScreen * previous, GdkEventMask events; (void) previous; -#ifdef DEBUG +# ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); -#endif +# endif if(title->root != NULL) gdk_window_remove_filter(title->root, _title_on_filter, title); title->screen = gtk_widget_get_screen(widget); @@ -325,3 +343,4 @@ static void _title_on_screen_changed(GtkWidget * widget, GdkScreen * previous, title->display, "_NET_WM_VISIBLE_NAME"); _title_do(title); } +#endif diff --git a/src/window.c b/src/window.c index 2e850b4..1041708 100644 --- a/src/window.c +++ b/src/window.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2011-2022 Pierre Pronchery */ +/* Copyright (c) 2011-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,9 @@ #include #include #if GTK_CHECK_VERSION(3, 0, 0) -# include +# if defined(GDK_WINDOWING_X11) +# include +# endif #endif #include "window.h" #include "../config.h" @@ -113,8 +115,14 @@ PanelWindow * panel_window_new(PanelAppletHelper * helper, } else { +#if defined(GDK_WINDOWING_X11) panel->window = gtk_plug_new(0); gtk_widget_show(panel->window); +#else + error_set_code(1, _("Unsupported panel position")); + object_delete(panel); + return NULL; +#endif } gtk_container_set_border_width(GTK_CONTAINER(panel->window), 2); panel->height = icon_height + (PANEL_BORDER_WIDTH * 4); @@ -266,8 +274,14 @@ int panel_window_get_width(PanelWindow * panel) /* panel_window_get_xid */ uint32_t panel_window_get_xid(PanelWindow * panel) { - return (panel->position == PANEL_WINDOW_POSITION_EMBEDDED) - ? gtk_plug_get_id(GTK_PLUG(panel->window)) : 0; +#if !defined(GDK_WINDOWING_X11) + (void) panel; + +#else + if(panel->position == PANEL_WINDOW_POSITION_EMBEDDED) + return gtk_plug_get_id(GTK_PLUG(panel->window)); +#endif + return 0; } diff --git a/tools/message.c b/tools/message.c index 06be426..80ac522 100644 --- a/tools/message.c +++ b/tools/message.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2012-2022 Pierre Pronchery */ +/* Copyright (c) 2012-2024 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,12 +22,16 @@ #include #include #include +#include #include -#if GTK_CHECK_VERSION(3, 0, 0) -# include +#if defined(GDK_WINDOWING_X11) +# if GTK_CHECK_VERSION(3, 0, 0) +# include +# endif #endif #include "../include/Panel.h" #include "../config.h" + #define _(string) gettext(string) /* constants */ @@ -50,8 +54,10 @@ static int _message(unsigned int timeout, char const * stock, char const * title, char const * message); +#if defined(GDK_WINDOWING_X11) /* callbacks */ static gboolean _message_on_timeout(gpointer data); +#endif static int _error(char const * message, int ret); static int _usage(void); @@ -62,6 +68,7 @@ static int _usage(void); static int _message(unsigned int timeout, char const * stock, char const * title, char const * message) { +#if defined(GDK_WINDOWING_X11) PangoFontDescription * bold; GtkWidget * plug; GtkWidget * hbox; @@ -136,9 +143,19 @@ static int _message(unsigned int timeout, char const * stock, pango_font_description_free(bold); gtk_main(); return 0; +#else + (void) timeout; + (void) stock; + (void) title; + (void) message; + + return error_set_print(PROGNAME_PANEL_MESSAGE, 2, "%s", + "X11 support not detected"); +#endif } +#if defined(GDK_WINDOWING_X11) /* callbacks */ /* message_on_timeout */ static gboolean _message_on_timeout(gpointer data) @@ -148,6 +165,7 @@ static gboolean _message_on_timeout(gpointer data) gtk_main_quit(); return FALSE; } +#endif /* error */