gdk,gtk: fix warnings and harden GFileInfo attribute handling

This commit is contained in:
Daemonratte 2026-04-23 21:14:31 +02:00
commit ec22e35012
6 changed files with 118 additions and 28 deletions

View file

@ -959,9 +959,6 @@ gdk_offscreen_window_move_resize (GdkWindow *window,
gint height)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
if (!with_move)
{
@ -994,18 +991,8 @@ gdk_offscreen_window_show (GdkWindow *window,
static void
gdk_offscreen_window_hide (GdkWindow *window)
{
GdkWindowObject *private;
GdkOffscreenWindow *offscreen;
GdkDisplay *display;
g_return_if_fail (window != NULL);
private = (GdkWindowObject*) window;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
/* May need to break grabs on children */
display = gdk_drawable_get_display (window);
/* TODO: This needs updating to the new grab world */
#if 0
if (display->pointer_grab.window != NULL)

View file

@ -156,7 +156,12 @@ send_event_handler (Display *dpy,
else if (dpy->last_request_read == state->get_input_focus_req)
{
xGetInputFocusReply replbuf;
xGetInputFocusReply *repl;
G_GNUC_UNUSED xGetInputFocusReply *repl;
/* If this still causes trouble on some toolchains, remove the
* 'repl' variable entirely and cast the _XGetAsyncReply() call
* to (void) instead.
*/
if (rep->generic.type != X_Error)
{
@ -167,6 +172,13 @@ send_event_handler (Display *dpy,
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
True);
/*
* Fallback variant if G_GNUC_UNUSED causes problems:
*
* (void) _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
* (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
* True);
*/
}
if (state->callback)
@ -275,9 +287,25 @@ _gdk_x11_send_client_message_async (GdkDisplay *display,
* XSync (dpy, 0)
*/
{
xReq *req;
G_GNUC_UNUSED xReq *req;
/* Keep the GetInputFocus roundtrip for the conservative variant.
* If this code ever causes trouble, try commenting out the
* GetEmptyReq() call first and keep only the request number
* assignment below.
*/
GetEmptyReq(GetInputFocus, req);
/*
* Fallback variant if the extra roundtrip causes problems:
*
* state->get_input_focus_req = dpy->request;
* return;
*
* or, more locally, comment out the GetEmptyReq() line above and
* leave only the assignment below.
*/
state->get_input_focus_req = dpy->request;
}
@ -309,7 +337,12 @@ set_input_focus_handler (Display *dpy,
if (dpy->last_request_read == state->get_input_focus_req)
{
xGetInputFocusReply replbuf;
xGetInputFocusReply *repl;
G_GNUC_UNUSED xGetInputFocusReply *repl;
/* If this still causes trouble on some toolchains, remove the
* 'repl' variable entirely and cast the _XGetAsyncReply() call
* to (void) instead.
*/
if (rep->generic.type != X_Error)
{
@ -320,6 +353,13 @@ set_input_focus_handler (Display *dpy,
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
True);
/*
* Fallback variant if G_GNUC_UNUSED causes problems:
*
* (void) _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
* (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
* True);
*/
}
DeqAsyncHandler(state->dpy, &state->async);
@ -368,9 +408,25 @@ _gdk_x11_set_input_focus_safe (GdkDisplay *display,
* XSync (dpy, 0)
*/
{
xReq *req;
G_GNUC_UNUSED xReq *req;
/* Keep the GetInputFocus roundtrip for the conservative variant.
* If this code ever causes trouble, try commenting out the
* GetEmptyReq() call first and keep only the request number
* assignment below.
*/
GetEmptyReq(GetInputFocus, req);
/*
* Fallback variant if the extra roundtrip causes problems:
*
* state->get_input_focus_req = dpy->request;
* return;
*
* or, more locally, comment out the GetEmptyReq() line above and
* leave only the assignment below.
*/
state->get_input_focus_req = dpy->request;
}
@ -778,7 +834,12 @@ roundtrip_handler (Display *dpy,
if (dpy->last_request_read == state->get_input_focus_req)
{
xGetInputFocusReply replbuf;
xGetInputFocusReply *repl;
G_GNUC_UNUSED xGetInputFocusReply *repl;
/* If this still causes trouble on some toolchains, remove the
* 'repl' variable entirely and cast the _XGetAsyncReply() call
* to (void) instead.
*/
if (rep->generic.type != X_Error)
{
@ -789,6 +850,13 @@ roundtrip_handler (Display *dpy,
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
True);
/*
* Fallback variant if G_GNUC_UNUSED causes problems:
*
* (void) _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
* (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
* True);
*/
}
@ -831,9 +899,25 @@ _gdk_x11_roundtrip_async (GdkDisplay *display,
* XSync (dpy, 0)
*/
{
xReq *req;
G_GNUC_UNUSED xReq *req;
/* Keep the GetInputFocus roundtrip for the conservative variant.
* If this code ever causes trouble, try commenting out the
* GetEmptyReq() call first and keep only the request number
* assignment below.
*/
GetEmptyReq(GetInputFocus, req);
/*
* Fallback variant if the extra roundtrip causes problems:
*
* state->get_input_focus_req = dpy->request;
* return;
*
* or, more locally, comment out the GetEmptyReq() line above and
* leave only the assignment below.
*/
state->get_input_focus_req = dpy->request;
}

View file

@ -168,7 +168,6 @@ _gdk_input_crossing_event (GdkWindow *window,
gboolean enter)
{
GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
GdkWindowObject *priv = (GdkWindowObject *)window;
GdkInputWindow *input_window;
gint root_x, root_y;
@ -268,7 +267,6 @@ _gdk_input_other_event (GdkEvent *event,
GdkEventType event_type;
int x, y;
GdkDisplay *display = GDK_WINDOW_DISPLAY (event_window);
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of

View file

@ -449,9 +449,20 @@ node_should_be_visible (GtkFileSystemModel *model, guint id, gboolean filtered_o
if (node->info == NULL)
return FALSE;
if (!model->show_hidden &&
(g_file_info_get_is_hidden (node->info) || g_file_info_get_is_backup (node->info)))
return FALSE;
if (!model->show_hidden)
{
gboolean is_hidden = FALSE;
gboolean is_backup = FALSE;
if (g_file_info_has_attribute (node->info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
is_hidden = g_file_info_get_is_hidden (node->info);
if (g_file_info_has_attribute (node->info, G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP))
is_backup = g_file_info_get_is_backup (node->info);
if (is_hidden || is_backup)
return FALSE;
}
if (_gtk_file_info_consider_as_directory (node->info))
{
@ -1952,6 +1963,7 @@ _gtk_file_system_model_update_file (GtkFileSystemModel *model,
node = get_node (model, id);
old_info = node->info;
node->info = g_object_ref (info);
if (old_info)

View file

@ -1641,6 +1641,8 @@ gtk_path_bar_get_info_callback (GCancellable *cancellable,
ButtonData *button_data;
const gchar *display_name;
gboolean is_hidden;
gboolean info_is_hidden = FALSE;
gboolean info_is_backup = FALSE;
if (cancellable != file_info->path_bar->get_info_cancellable)
{
@ -1659,7 +1661,14 @@ gtk_path_bar_get_info_callback (GCancellable *cancellable,
}
display_name = g_file_info_get_display_name (info);
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
info_is_hidden = g_file_info_get_is_hidden (info);
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP))
info_is_backup = g_file_info_get_is_backup (info);
is_hidden = info_is_hidden || info_is_backup;
gtk_widget_push_composite_child ();
button_data = make_directory_button (file_info->path_bar, display_name,

View file

@ -159,9 +159,9 @@ query_module (const char *dir, const char *name, GString *contents)
{
void (*list) (const GtkIMContextInfo ***contexts,
guint *n_contexts);
void (*init) (GTypeModule *type_module);
void (*exit) (void);
GtkIMContext *(*create) (const gchar *context_id);
G_GNUC_UNUSED void (*init) (GTypeModule *type_module);
G_GNUC_UNUSED void (*exit) (void);
G_GNUC_UNUSED GtkIMContext *(*create) (const gchar *context_id);
gpointer list_ptr;
gpointer init_ptr;