Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/cpicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@

#include "cpicker.h"

#include <glib/gi18n.h> /* For _() macro */

/* Forward declaration - defined in main.c when building yad */
gboolean yad_check_x11 (void);

/* Weak symbol: if yad_check_x11 doesn't exist (tools build), return TRUE for X11 */
#ifdef __GNUC__
gboolean __attribute__((weak)) yad_check_x11 (void) { return TRUE; }
#endif

#define BIG_STEP 20

typedef struct {
Expand Down Expand Up @@ -215,6 +225,15 @@ yad_get_screen_color (GtkWidget *widget)
GdkGrabStatus grab_status;
GdkWindow *window;

/* Color picking doesn't work on Wayland - screen capture and device grab are restricted */
if (!yad_check_x11 ())
{
g_printerr (_("WARNING: Color picker is not supported on Wayland.\n"
"Screen capture and pointer grab require X11 or a portal.\n"
"Use GDK_BACKEND=x11 to enable color picking.\n"));
return;
}

gd = g_new0 (GrabData, 1);
gd->color_widget = widget;
gd->time = gtk_get_current_event_time ();
Expand Down
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ static gboolean is_x11 = FALSE;

YadNTabs *tabs;

gboolean
yad_check_x11 (void)
{
return is_x11;
}

#ifndef G_OS_WIN32
static void
sa_usr1 (gint sig)
Expand Down
6 changes: 5 additions & 1 deletion src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ yad_print_run (void)
if (options.data.center)
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
else if (options.data.mouse)
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
{
/* Mouse positioning doesn't work on Wayland */
if (yad_check_x11 ())
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
}

/* create yad's top box */
if (options.data.dialog_text || options.data.dialog_image)
Expand Down
2 changes: 2 additions & 0 deletions src/yad.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ gboolean yad_send_notify (gboolean);
void notebook_close_childs (void);
void paned_close_childs (void);

gboolean yad_check_x11 (void);

void read_settings (void);
void write_settings (void);

Expand Down