Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Wshadow to build system. #2042

Merged
merged 3 commits into from
Oct 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions include/widgets/icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ icon *icon_create(widget *parent, const char *name);
void icon_set_size(widget *icon, const int size);

/**
* @param icon The icon widget handle.
* @param icon_widget The icon widget handle.
* @param surf The surface to display.
*/
void icon_set_surface(icon *icon, cairo_surface_t *surf);
void icon_set_surface(icon *icon_widget, cairo_surface_t *surf);
/**@}*/
#endif // ROFI_ICON_H
74 changes: 36 additions & 38 deletions include/widgets/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef enum {
} WidgetTriggerActionResult;

/**
* @param widget The container widget itself
* @param wid The container widget itself
* @param type The widget type searched for
* @param x The X coordination of the mouse event relative to #widget
* @param y The Y coordination of the mouse event relative to #widget
Expand All @@ -95,11 +95,11 @@ typedef enum {
*
* @returns A child widget if found, NULL otherwise
*/
typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
typedef widget *(*widget_find_mouse_target_cb)(widget *wid, WidgetType type,
gint x, gint y);

/**
* @param widget The target widget
* @param wid The target widget
* @param action The action value (which enum it is depends on the widget type)
* @param x The X coordination of the mouse event relative to #widget
* @param y The Y coordination of the mouse event relative to #widget
Expand All @@ -110,7 +110,7 @@ typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
*
* @returns Whether the action was handled or not, see enum values for details
*/
typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *wid,
guint action,
gint x, gint y,
void *user_data);
Expand All @@ -119,73 +119,71 @@ typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
#define WIDGET(a) ((widget *)(a))

/**
* @param widget The widget to check
* @param wid The widget to check
* @param x The X position relative to parent window
* @param y the Y position relative to parent window
*
* Check if x,y falls within the widget.
*
* @return TRUE if x,y falls within the widget
*/
int widget_intersect(const widget *widget, int x, int y);
int widget_intersect(const widget *wid, int x, int y);

/**
* @param widget The widget to move
* @param wid The widget to move
* @param x The new X position relative to parent window
* @param y The new Y position relative to parent window
*
* Moves the widget.
*/
void widget_move(widget *widget, short x, short y);
void widget_move(widget *wid, short x, short y);

/**
* @param widget Handle to widget
* @param wid Handle to widget
* @param type The widget type.
*
* Set the widget type.
*/
void widget_set_type(widget *widget, WidgetType type);
void widget_set_type(widget *wid, WidgetType type);

/**
* @param widget Handle to widget
* @param wid Handle to widget
*
* Check if widget is enabled.
* @returns TRUE when widget is enabled.
*/
gboolean widget_enabled(widget *widget);
gboolean widget_enabled(widget *wid);

/**
* @param widget Handle to widget
* @param wid Handle to widget
* @param enabled The new state
*
* Disable the widget.
*/
void widget_set_enabled(widget *widget, gboolean enabled);
void widget_set_enabled(widget *wid, gboolean enabled);

/**
* @param widget Handle to widget
* @param wid Handle to widget
*
* Disable the widget.
*/
static inline void widget_disable(widget *widget) {
widget_set_enabled(widget, FALSE);
static inline void widget_disable(widget *wid) {
widget_set_enabled(wid, FALSE);
}
/**
* @param widget Handle to widget
* @param wid Handle to widget
*
* Enable the widget.
*/
static inline void widget_enable(widget *widget) {
widget_set_enabled(widget, TRUE);
}
static inline void widget_enable(widget *wid) { widget_set_enabled(wid, TRUE); }

/**
* @param widget widget Handle to the widget
* @param wid widget Handle to the widget
* @param d The cairo object used to draw itself.
*
* Render the textbox.
*/
void widget_draw(widget *widget, cairo_t *d);
void widget_draw(widget *wid, cairo_t *d);

/**
* @param wid Handle to the widget
Expand All @@ -195,58 +193,58 @@ void widget_draw(widget *widget, cairo_t *d);
void widget_free(widget *wid);

/**
* @param widget The widget toresize
* @param wid The widget toresize
* @param w The new width
* @param h The new height
*
* Resizes the widget.
*/
void widget_resize(widget *widget, short w, short h);
void widget_resize(widget *wid, short w, short h);

/**
* @param widget The widget handle
* @param wid The widget handle
*
* @returns the height of the widget.
*/
int widget_get_height(widget *widget);
int widget_get_height(widget *wid);

/**
* @param widget The widget handle
* @param wid The widget handle
*
* @returns the width of the widget.
*/
int widget_get_width(widget *widget);
int widget_get_width(widget *wid);

/**
* @param widget The widget handle
* @param wid The widget handle
*
* @returns the y position of the widget relative to its parent.
*/
int widget_get_y_pos(widget *widget);
int widget_get_y_pos(widget *wid);

/**
* @param widget The widget handle
* @param wid The widget handle
*
* @returns the x position of the widget relative to its parent.
*/
int widget_get_x_pos(widget *widget);
int widget_get_x_pos(widget *wid);

/**
* @param widget The widget handle
* @param wid The widget handle
* @param x A pointer to the absolute X coordinates
* @param y A pointer to the absolute Y coordinates
*
* Will modify param x and param y to make them relative to param widget .
* Will modify param x and param y to make them relative to param wid .
*/
void widget_xy_to_relative(widget *widget, gint *x, gint *y);
void widget_xy_to_relative(widget *wid, gint *x, gint *y);

/**
* @param widget The widget handle
* @param wid The widget handle
*
* Update the widget, and its parent recursively.
* This should be called when size of widget changes.
*/
void widget_update(widget *widget);
void widget_update(widget *wid);
/**
* @param wid The widget handle
*
Expand Down
82 changes: 41 additions & 41 deletions lexer/theme-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -362,92 +362,92 @@ t_entry_list T_CONFIGURATION T_BOPEN t_config_property_list_optional T_BCLOSE {
| t_entry_list t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE
{
for ( GList *liter = g_list_first ( $3); liter; liter = g_list_next ( liter ) ) {
ThemeWidget *widget = $1;
for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) {
widget = rofi_theme_find_or_create_name ( widget, iter->data );
ThemeWidget *wid = $1;
for ( GList *iter = g_list_first ( (GList*)liter->data ); wid && iter ; iter = g_list_next ( iter ) ) {
wid = rofi_theme_find_or_create_name ( wid, iter->data );
}
g_list_free_full ( (GList*)liter->data, g_free );
widget->set = TRUE;
rofi_theme_widget_add_properties ( widget, $5);
wid->set = TRUE;
rofi_theme_widget_add_properties ( wid, $5);
}
if ( $5 ) {
g_hash_table_destroy ( $5 );
}
g_list_free ( $3 );
}
| t_entry_list T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE {
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, "*" );
rofi_theme_widget_add_properties (widget, $4);
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, "*" );
rofi_theme_widget_add_properties (wid, $4);
if ( $4 ) {
g_hash_table_destroy ( $4 );
}
}
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP t_property_number T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
gchar *name = g_strdup_printf("@media ( %s: %f )",$4, $6);
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE;
widget->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->value = $6;
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
wid->set = TRUE;
wid->media = g_slice_new0(ThemeMedia);
wid->media->type = rofi_theme_parse_media_type ( $4 );
wid->media->value = $6;
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
ThemeWidget *d = $9->widgets[i];
rofi_theme_parse_merge_widgets(widget, d);
rofi_theme_parse_merge_widgets(wid, d);
}
g_free ( $4 );
g_free ( name );
}
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
gchar *name = g_strdup_printf("@media ( %s: %d px )",$4, $6);
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE;
widget->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->value = (double)$6;
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
wid->set = TRUE;
wid->media = g_slice_new0(ThemeMedia);
wid->media->type = rofi_theme_parse_media_type ( $4 );
wid->media->value = (double)$6;
for ( unsigned int i = 0; i < $10->num_widgets; i++ ) {
ThemeWidget *d = $10->widgets[i];
rofi_theme_parse_merge_widgets(widget, d);
rofi_theme_parse_merge_widgets(wid, d);
}
g_free ( $4 );
g_free ( name );
}
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_BOOLEAN T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $6?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE;
widget->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $6;
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
wid->set = TRUE;
wid->media = g_slice_new0(ThemeMedia);
wid->media->type = rofi_theme_parse_media_type ( $4 );
wid->media->boolv = $6;
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
ThemeWidget *d = $9->widgets[i];
rofi_theme_parse_merge_widgets(widget, d);
rofi_theme_parse_merge_widgets(wid, d);
}
g_free ( $4 );
g_free ( name );
}
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_ENV_START T_PARENT_LEFT T_BOOLEAN T_COMMA T_BOOLEAN T_PARENT_RIGHT T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $8?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE;
widget->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $8;
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
wid->set = TRUE;
wid->media = g_slice_new0(ThemeMedia);
wid->media->type = rofi_theme_parse_media_type ( $4 );
wid->media->boolv = $8;
for ( unsigned int i = 0; i < $14->num_widgets; i++ ) {
ThemeWidget *d = $14->widgets[i];
rofi_theme_parse_merge_widgets(widget, d);
rofi_theme_parse_merge_widgets(wid, d);
}
g_free ( $4 );
g_free ( name );
}
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_ENV_START T_PARENT_LEFT T_COMMA T_BOOLEAN T_PARENT_RIGHT T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $9?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE;
widget->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $9;
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
wid->set = TRUE;
wid->media = g_slice_new0(ThemeMedia);
wid->media->type = rofi_theme_parse_media_type ( $4 );
wid->media->boolv = $9;
for ( unsigned int i = 0; i < $13->num_widgets; i++ ) {
ThemeWidget *d = $13->widgets[i];
rofi_theme_parse_merge_widgets(widget, d);
rofi_theme_parse_merge_widgets(wid, d);
}
g_free ( $4 );
g_free ( name );
Expand Down Expand Up @@ -487,10 +487,10 @@ t_config_property
{

for ( GList *iter = g_list_first( $1) ; iter; iter = g_list_next(iter)){
ThemeWidget *widget = rofi_configuration;
widget = rofi_theme_find_or_create_name ( widget, iter->data );
widget->set = TRUE;
rofi_theme_widget_add_properties ( widget, $3);
ThemeWidget *wid = rofi_configuration;
wid = rofi_theme_find_or_create_name ( wid, iter->data );
wid->set = TRUE;
rofi_theme_widget_add_properties ( wid, $3);
}
if ( $3 ) {
g_hash_table_destroy ( $3 );
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ flags = [
'-Wunreachable-code',
'-Werror=missing-prototypes',
'-Wno-overlength-strings',
'-Wno-inline' # A bit too noisy with Bison…
'-Wno-inline', # A bit too noisy with Bison…
'-Wshadow'
]
foreach f : flags
if c_compiler.has_argument(f)
Expand Down
5 changes: 2 additions & 3 deletions source/modes/dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,13 @@ static int dmenu_mode_init(Mode *sw) {
Property *p = rofi_theme_property_create(P_INTEGER);
p->name = g_strdup("lines");
p->value.i = lines;
ThemeWidget *widget =
rofi_theme_find_or_create_name(rofi_theme, "listview");
ThemeWidget *wid = rofi_theme_find_or_create_name(rofi_theme, "listview");
GHashTable *table =
g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
(GDestroyNotify)rofi_theme_property_free);

g_hash_table_replace(table, p->name, p);
rofi_theme_widget_add_properties(widget, table);
rofi_theme_widget_add_properties(wid, table);
g_hash_table_destroy(table);
}

Expand Down
3 changes: 2 additions & 1 deletion source/rofi.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ static void print_main_application_options(int is_term) {
"Behave as a normal window. (experimental)", NULL, is_term);
print_help_msg("-transient-window", "",
"Behave as a modal dialog that is transient to the currently "
"focused window. (experimental)", NULL, is_term);
"focused window. (experimental)",
NULL, is_term);
print_help_msg("-show", "[mode]",
"Show the mode 'mode' and exit. The mode has to be enabled.",
NULL, is_term);
Expand Down
Loading
Loading