1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Add -Wshadow to build system. (#2042)

* Add -Wshadow to build system.

Issue: #2036

* Take out unintended change

* [Icon] Add more descriptive variable name.
This commit is contained in:
Dave Davenport 2024-10-20 12:54:13 +02:00 committed by GitHub
parent df7d8b65f0
commit 9d785b5ce1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 528 additions and 548 deletions

View file

@ -59,9 +59,9 @@ icon *icon_create(widget *parent, const char *name);
void icon_set_size(widget *icon, const int size); 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. * @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 #endif // ROFI_ICON_H

View file

@ -85,7 +85,7 @@ typedef enum {
} WidgetTriggerActionResult; } WidgetTriggerActionResult;
/** /**
* @param widget The container widget itself * @param wid The container widget itself
* @param type The widget type searched for * @param type The widget type searched for
* @param x The X coordination of the mouse event relative to #widget * @param x The X coordination of the mouse event relative to #widget
* @param y The Y coordination of the mouse event relative to #widget * @param y The Y coordination of the mouse event relative to #widget
@ -95,11 +95,11 @@ typedef enum {
* *
* @returns A child widget if found, NULL otherwise * @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); 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 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 x The X coordination of the mouse event relative to #widget
* @param y The Y coordination of the mouse event relative to #widget * @param y The Y coordination of the mouse event relative to #widget
@ -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 * @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, guint action,
gint x, gint y, gint x, gint y,
void *user_data); void *user_data);
@ -119,7 +119,7 @@ typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
#define WIDGET(a) ((widget *)(a)) #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 x The X position relative to parent window
* @param y the Y position relative to parent window * @param y the Y position relative to parent window
* *
@ -127,65 +127,63 @@ typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
* *
* @return TRUE 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 x The new X position relative to parent window
* @param y The new Y position relative to parent window * @param y The new Y position relative to parent window
* *
* Moves the widget. * 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. * @param type The widget type.
* *
* Set 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. * Check if widget is enabled.
* @returns TRUE when 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 * @param enabled The new state
* *
* Disable the widget. * 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. * Disable the widget.
*/ */
static inline void widget_disable(widget *widget) { static inline void widget_disable(widget *wid) {
widget_set_enabled(widget, FALSE); widget_set_enabled(wid, FALSE);
} }
/** /**
* @param widget Handle to widget * @param wid Handle to widget
* *
* Enable the widget. * Enable the widget.
*/ */
static inline void widget_enable(widget *widget) { static inline void widget_enable(widget *wid) { widget_set_enabled(wid, TRUE); }
widget_set_enabled(widget, TRUE);
}
/** /**
* @param widget widget Handle to the widget * @param wid widget Handle to the widget
* @param d The cairo object used to draw itself. * @param d The cairo object used to draw itself.
* *
* Render the textbox. * 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 * @param wid Handle to the widget
@ -195,58 +193,58 @@ void widget_draw(widget *widget, cairo_t *d);
void widget_free(widget *wid); void widget_free(widget *wid);
/** /**
* @param widget The widget toresize * @param wid The widget toresize
* @param w The new width * @param w The new width
* @param h The new height * @param h The new height
* *
* Resizes the widget. * 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. * @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. * @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. * @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. * @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 x A pointer to the absolute X coordinates
* @param y A pointer to the absolute Y 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. * Update the widget, and its parent recursively.
* This should be called when size of widget changes. * This should be called when size of widget changes.
*/ */
void widget_update(widget *widget); void widget_update(widget *wid);
/** /**
* @param wid The widget handle * @param wid The widget handle
* *

View file

@ -362,13 +362,13 @@ 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 | 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 ) ) { for ( GList *liter = g_list_first ( $3); liter; liter = g_list_next ( liter ) ) {
ThemeWidget *widget = $1; ThemeWidget *wid = $1;
for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) { for ( GList *iter = g_list_first ( (GList*)liter->data ); wid && iter ; iter = g_list_next ( iter ) ) {
widget = rofi_theme_find_or_create_name ( widget, iter->data ); wid = rofi_theme_find_or_create_name ( wid, iter->data );
} }
g_list_free_full ( (GList*)liter->data, g_free ); g_list_free_full ( (GList*)liter->data, g_free );
widget->set = TRUE; wid->set = TRUE;
rofi_theme_widget_add_properties ( widget, $5); rofi_theme_widget_add_properties ( wid, $5);
} }
if ( $5 ) { if ( $5 ) {
g_hash_table_destroy ( $5 ); g_hash_table_destroy ( $5 );
@ -376,78 +376,78 @@ t_entry_list T_CONFIGURATION T_BOPEN t_config_property_list_optional T_BCLOSE {
g_list_free ( $3 ); g_list_free ( $3 );
} }
| t_entry_list T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE { | t_entry_list T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE {
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, "*" ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, "*" );
rofi_theme_widget_add_properties (widget, $4); rofi_theme_widget_add_properties (wid, $4);
if ( $4 ) { if ( $4 ) {
g_hash_table_destroy ( $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 { | 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); gchar *name = g_strdup_printf("@media ( %s: %f )",$4, $6);
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE; wid->set = TRUE;
widget->media = g_slice_new0(ThemeMedia); wid->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 ); wid->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->value = $6; wid->media->value = $6;
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) { for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
ThemeWidget *d = $9->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 ( $4 );
g_free ( name ); 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 { | 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); gchar *name = g_strdup_printf("@media ( %s: %d px )",$4, $6);
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE; wid->set = TRUE;
widget->media = g_slice_new0(ThemeMedia); wid->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 ); wid->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->value = (double)$6; wid->media->value = (double)$6;
for ( unsigned int i = 0; i < $10->num_widgets; i++ ) { for ( unsigned int i = 0; i < $10->num_widgets; i++ ) {
ThemeWidget *d = $10->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 ( $4 );
g_free ( name ); 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 { | 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"); gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $6?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE; wid->set = TRUE;
widget->media = g_slice_new0(ThemeMedia); wid->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 ); wid->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $6; wid->media->boolv = $6;
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) { for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
ThemeWidget *d = $9->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 ( $4 );
g_free ( name ); 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 { | 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"); gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $8?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE; wid->set = TRUE;
widget->media = g_slice_new0(ThemeMedia); wid->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 ); wid->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $8; wid->media->boolv = $8;
for ( unsigned int i = 0; i < $14->num_widgets; i++ ) { for ( unsigned int i = 0; i < $14->num_widgets; i++ ) {
ThemeWidget *d = $14->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 ( $4 );
g_free ( name ); 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 { | 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"); gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $9?"true":"false");
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name ); ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
widget->set = TRUE; wid->set = TRUE;
widget->media = g_slice_new0(ThemeMedia); wid->media = g_slice_new0(ThemeMedia);
widget->media->type = rofi_theme_parse_media_type ( $4 ); wid->media->type = rofi_theme_parse_media_type ( $4 );
widget->media->boolv = $9; wid->media->boolv = $9;
for ( unsigned int i = 0; i < $13->num_widgets; i++ ) { for ( unsigned int i = 0; i < $13->num_widgets; i++ ) {
ThemeWidget *d = $13->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 ( $4 );
g_free ( name ); g_free ( name );
@ -487,10 +487,10 @@ t_config_property
{ {
for ( GList *iter = g_list_first( $1) ; iter; iter = g_list_next(iter)){ for ( GList *iter = g_list_first( $1) ; iter; iter = g_list_next(iter)){
ThemeWidget *widget = rofi_configuration; ThemeWidget *wid = rofi_configuration;
widget = rofi_theme_find_or_create_name ( widget, iter->data ); wid = rofi_theme_find_or_create_name ( wid, iter->data );
widget->set = TRUE; wid->set = TRUE;
rofi_theme_widget_add_properties ( widget, $3); rofi_theme_widget_add_properties ( wid, $3);
} }
if ( $3 ) { if ( $3 ) {
g_hash_table_destroy ( $3 ); g_hash_table_destroy ( $3 );

View file

@ -25,7 +25,8 @@ flags = [
'-Wunreachable-code', '-Wunreachable-code',
'-Werror=missing-prototypes', '-Werror=missing-prototypes',
'-Wno-overlength-strings', '-Wno-overlength-strings',
'-Wno-inline' # A bit too noisy with Bison… '-Wno-inline', # A bit too noisy with Bison…
'-Wshadow'
] ]
foreach f : flags foreach f : flags
if c_compiler.has_argument(f) if c_compiler.has_argument(f)

View file

@ -574,14 +574,13 @@ static int dmenu_mode_init(Mode *sw) {
Property *p = rofi_theme_property_create(P_INTEGER); Property *p = rofi_theme_property_create(P_INTEGER);
p->name = g_strdup("lines"); p->name = g_strdup("lines");
p->value.i = lines; p->value.i = lines;
ThemeWidget *widget = ThemeWidget *wid = rofi_theme_find_or_create_name(rofi_theme, "listview");
rofi_theme_find_or_create_name(rofi_theme, "listview");
GHashTable *table = GHashTable *table =
g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
(GDestroyNotify)rofi_theme_property_free); (GDestroyNotify)rofi_theme_property_free);
g_hash_table_replace(table, p->name, p); 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); g_hash_table_destroy(table);
} }

View file

@ -328,7 +328,8 @@ static void print_main_application_options(int is_term) {
"Behave as a normal window. (experimental)", NULL, is_term); "Behave as a normal window. (experimental)", NULL, is_term);
print_help_msg("-transient-window", "", print_help_msg("-transient-window", "",
"Behave as a modal dialog that is transient to the currently " "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]", print_help_msg("-show", "[mode]",
"Show the mode 'mode' and exit. The mode has to be enabled.", "Show the mode 'mode' and exit. The mode has to be enabled.",
NULL, is_term); NULL, is_term);

File diff suppressed because it is too large Load diff

View file

@ -572,9 +572,9 @@ static void rofi_view_set_user_timeout(G_GNUC_UNUSED gpointer data) {
CacheState.user_timeout = CacheState.user_timeout =
g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL); g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL);
} else { } else {
Property *p = rofi_theme_find_property(wid, P_DOUBLE, "delay", TRUE); Property *prop = rofi_theme_find_property(wid, P_DOUBLE, "delay", TRUE);
if (p != NULL && p->type == P_DOUBLE && p->value.f > 0.01) { if (prop != NULL && prop->type == P_DOUBLE && prop->value.f > 0.01) {
double delay = p->value.f; double delay = prop->value.f;
CacheState.user_timeout = CacheState.user_timeout =
g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL); g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL);
} }
@ -1305,9 +1305,9 @@ static void selection_changed_callback(G_GNUC_UNUSED listview *lv,
int icon_height = int icon_height =
widget_get_desired_height(WIDGET(state->icon_current_entry), widget_get_desired_height(WIDGET(state->icon_current_entry),
WIDGET(state->icon_current_entry)->w); WIDGET(state->icon_current_entry)->w);
cairo_surface_t *icon = cairo_surface_t *surf_icon =
mode_get_icon(state->sw, state->line_map[index], icon_height); mode_get_icon(state->sw, state->line_map[index], icon_height);
icon_set_surface(state->icon_current_entry, icon); icon_set_surface(state->icon_current_entry, surf_icon);
} else { } else {
icon_set_surface(state->icon_current_entry, NULL); icon_set_surface(state->icon_current_entry, NULL);
} }
@ -1325,9 +1325,9 @@ static void update_callback(textbox *t, icon *ico, unsigned int index,
if (ico) { if (ico) {
int icon_height = widget_get_desired_height(WIDGET(ico), WIDGET(ico)->w); int icon_height = widget_get_desired_height(WIDGET(ico), WIDGET(ico)->w);
cairo_surface_t *icon = cairo_surface_t *surf_icon =
mode_get_icon(state->sw, state->line_map[index], icon_height); mode_get_icon(state->sw, state->line_map[index], icon_height);
icon_set_surface(ico, icon); icon_set_surface(ico, surf_icon);
} }
if (t) { if (t) {
// TODO needed for markup. // TODO needed for markup.
@ -2578,14 +2578,14 @@ int rofi_view_error_dialog(const char *msg, int markup) {
state->finalize = process_result; state->finalize = process_result;
state->main_window = box_create(NULL, "window", ROFI_ORIENTATION_VERTICAL); state->main_window = box_create(NULL, "window", ROFI_ORIENTATION_VERTICAL);
box *box = box_create(WIDGET(state->main_window), "error-message", box *new_box = box_create(WIDGET(state->main_window), "error-message",
ROFI_ORIENTATION_VERTICAL); ROFI_ORIENTATION_VERTICAL);
box_add(state->main_window, WIDGET(box), TRUE); box_add(state->main_window, WIDGET(new_box), TRUE);
state->text = state->text =
textbox_create(WIDGET(box), WIDGET_TYPE_TEXTBOX_TEXT, "textbox", textbox_create(WIDGET(new_box), WIDGET_TYPE_TEXTBOX_TEXT, "textbox",
(TB_AUTOHEIGHT | TB_WRAP) + ((markup) ? TB_MARKUP : 0), (TB_AUTOHEIGHT | TB_WRAP) + ((markup) ? TB_MARKUP : 0),
NORMAL, (msg != NULL) ? msg : "", 0, 0); NORMAL, (msg != NULL) ? msg : "", 0, 0);
box_add(box, WIDGET(state->text), TRUE); box_add(new_box, WIDGET(state->text), TRUE);
// Make sure we enable fixed num lines when in normal window mode. // Make sure we enable fixed num lines when in normal window mode.
if ((CacheState.flags & MENU_NORMAL_WINDOW) == MENU_NORMAL_WINDOW) { if ((CacheState.flags & MENU_NORMAL_WINDOW) == MENU_NORMAL_WINDOW) {

View file

@ -284,34 +284,34 @@ static void box_free(widget *wid) {
g_free(b); g_free(b);
} }
void box_add(box *box, widget *child, gboolean expand) { void box_add(box *wid, widget *child, gboolean expand) {
if (box == NULL) { if (wid == NULL) {
return; return;
} }
// Make sure box is width/heigh enough. // Make sure box is width/heigh enough.
if (box->type == ROFI_ORIENTATION_VERTICAL) { if (wid->type == ROFI_ORIENTATION_VERTICAL) {
int width = box->widget.w; int width = wid->widget.w;
width = width =
MAX(width, child->w + widget_padding_get_padding_width(WIDGET(box))); MAX(width, child->w + widget_padding_get_padding_width(WIDGET(wid)));
box->widget.w = width; wid->widget.w = width;
} else { } else {
int height = box->widget.h; int height = wid->widget.h;
height = height =
MAX(height, child->h + widget_padding_get_padding_height(WIDGET(box))); MAX(height, child->h + widget_padding_get_padding_height(WIDGET(wid)));
box->widget.h = height; wid->widget.h = height;
} }
child->expand = rofi_theme_get_boolean(child, "expand", expand); child->expand = rofi_theme_get_boolean(child, "expand", expand);
g_assert(child->parent == WIDGET(box)); g_assert(child->parent == WIDGET(wid));
box->children = g_list_append(box->children, (void *)child); wid->children = g_list_append(wid->children, (void *)child);
widget_update(WIDGET(box)); widget_update(WIDGET(wid));
} }
static void box_resize(widget *widget, short w, short h) { static void box_resize(widget *wid, short w, short h) {
box *b = (box *)widget; box *b = (box *)wid;
if (b->widget.w != w || b->widget.h != h) { if (b->widget.w != w || b->widget.h != h) {
b->widget.w = w; b->widget.w = w;
b->widget.h = h; b->widget.h = h;
widget_update(widget); widget_update(wid);
} }
} }

View file

@ -42,13 +42,13 @@ struct _container {
static void container_update(widget *wid); static void container_update(widget *wid);
static int container_get_desired_height(widget *widget, const int width) { static int container_get_desired_height(widget *wid, const int width) {
container *b = (container *)widget; container *b = (container *)wid;
int height = 0; int height = 0;
if (b->child) { if (b->child) {
height += widget_get_desired_height(b->child, width); height += widget_get_desired_height(b->child, width);
} }
height += widget_padding_get_padding_height(widget); height += widget_padding_get_padding_height(wid);
return height; return height;
} }
@ -65,21 +65,21 @@ static void container_free(widget *wid) {
g_free(b); g_free(b);
} }
void container_add(container *container, widget *child) { void container_add(container *cont, widget *child) {
if (container == NULL) { if (cont == NULL) {
return; return;
} }
container->child = child; cont->child = child;
g_assert(child->parent == WIDGET(container)); g_assert(child->parent == WIDGET(cont));
widget_update(WIDGET(container)); widget_update(WIDGET(cont));
} }
static void container_resize(widget *widget, short w, short h) { static void container_resize(widget *wid, short w, short h) {
container *b = (container *)widget; container *b = (container *)wid;
if (b->widget.w != w || b->widget.h != h) { if (b->widget.w != w || b->widget.h != h) {
b->widget.w = w; b->widget.w = w;
b->widget.h = h; b->widget.h = h;
widget_update(widget); widget_update(wid);
} }
} }

View file

@ -53,9 +53,8 @@ struct _icon {
cairo_surface_t *icon; cairo_surface_t *icon;
}; };
static int icon_get_desired_height(widget *widget, static int icon_get_desired_height(widget *wid, G_GNUC_UNUSED const int width) {
G_GNUC_UNUSED const int width) { icon *b = (icon *)wid;
icon *b = (icon *)widget;
int height = b->size; int height = b->size;
if (b->squared == FALSE) { if (b->squared == FALSE) {
if (b->icon) { if (b->icon) {
@ -66,12 +65,11 @@ static int icon_get_desired_height(widget *widget,
height = iconh * scale; height = iconh * scale;
} }
} }
height += widget_padding_get_padding_height(widget); height += widget_padding_get_padding_height(wid);
return height; return height;
} }
static int icon_get_desired_width(widget *widget, static int icon_get_desired_width(widget *wid, G_GNUC_UNUSED const int height) {
G_GNUC_UNUSED const int height) { icon *b = (icon *)wid;
icon *b = (icon *)widget;
int width = b->size; int width = b->size;
if (b->squared == FALSE) { if (b->squared == FALSE) {
if (b->icon) { if (b->icon) {
@ -82,7 +80,7 @@ static int icon_get_desired_width(widget *widget,
width = iconw * scale; width = iconw * scale;
} }
} }
width += widget_padding_get_padding_width(widget); width += widget_padding_get_padding_width(wid);
return width; return width;
} }
@ -129,26 +127,26 @@ static void icon_free(widget *wid) {
g_free(b); g_free(b);
} }
static void icon_resize(widget *widget, short w, short h) { static void icon_resize(widget *wid, short w, short h) {
icon *b = (icon *)widget; icon *b = (icon *)wid;
if (b->widget.w != w || b->widget.h != h) { if (b->widget.w != w || b->widget.h != h) {
b->widget.w = w; b->widget.w = w;
b->widget.h = h; b->widget.h = h;
widget_update(widget); widget_update(wid);
} }
} }
void icon_set_surface(icon *icon, cairo_surface_t *surf) { void icon_set_surface(icon *icon_widget, cairo_surface_t *surf) {
icon->icon_fetch_id = 0; icon_widget->icon_fetch_id = 0;
if (icon->icon) { if (icon_widget->icon) {
cairo_surface_destroy(icon->icon); cairo_surface_destroy(icon_widget->icon);
icon->icon = NULL; icon_widget->icon = NULL;
} }
if (surf) { if (surf) {
cairo_surface_reference(surf); cairo_surface_reference(surf);
icon->icon = surf; icon_widget->icon = surf;
} }
widget_queue_redraw(WIDGET(icon)); widget_queue_redraw(WIDGET(icon_widget));
} }
icon *icon_create(widget *parent, const char *name) { icon *icon_create(widget *parent, const char *name) {

View file

@ -55,126 +55,125 @@ void widget_init(widget *wid, widget *parent, WidgetType type,
wid->enabled = rofi_theme_get_boolean(wid, "enabled", TRUE); wid->enabled = rofi_theme_get_boolean(wid, "enabled", TRUE);
} }
void widget_set_state(widget *widget, const char *state) { void widget_set_state(widget *wid, const char *state) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
if (g_strcmp0(widget->state, state)) { if (g_strcmp0(wid->state, state)) {
widget->state = state; wid->state = state;
// Update border. // Update border.
widget->border = wid->border = rofi_theme_get_padding(wid, "border", wid->def_border);
rofi_theme_get_padding(widget, "border", widget->def_border); wid->border_radius =
widget->border_radius = rofi_theme_get_padding(widget, "border-radius", rofi_theme_get_padding(wid, "border-radius", wid->def_border_radius);
widget->def_border_radius); if (wid->set_state != NULL) {
if (widget->set_state != NULL) { wid->set_state(wid, state);
widget->set_state(widget, state);
} }
widget_queue_redraw(widget); widget_queue_redraw(wid);
} }
} }
int widget_intersect(const widget *widget, int x, int y) { int widget_intersect(const widget *wid, int x, int y) {
if (widget == NULL) { if (wid == NULL) {
return FALSE; return FALSE;
} }
if (x >= (widget->x) && x < (widget->x + widget->w) && y >= (widget->y) && if (x >= (wid->x) && x < (wid->x + wid->w) && y >= (wid->y) &&
y < (widget->y + widget->h)) { y < (wid->y + wid->h)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
void widget_resize(widget *widget, short w, short h) { void widget_resize(widget *wid, short w, short h) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
if (widget->resize != NULL) { if (wid->resize != NULL) {
if (widget->w != w || widget->h != h) { if (wid->w != w || wid->h != h) {
widget->resize(widget, w, h); wid->resize(wid, w, h);
} }
} else { } else {
widget->w = w; wid->w = w;
widget->h = h; wid->h = h;
} }
// On a resize we always want to update. // On a resize we always want to update.
widget_queue_redraw(widget); widget_queue_redraw(wid);
} }
void widget_move(widget *widget, short x, short y) { void widget_move(widget *wid, short x, short y) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
widget->x = x; wid->x = x;
widget->y = y; wid->y = y;
} }
void widget_set_type(widget *widget, WidgetType type) { void widget_set_type(widget *wid, WidgetType type) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
widget->type = type; wid->type = type;
} }
gboolean widget_enabled(widget *widget) { gboolean widget_enabled(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return FALSE; return FALSE;
} }
return widget->enabled; return wid->enabled;
} }
void widget_set_enabled(widget *widget, gboolean enabled) { void widget_set_enabled(widget *wid, gboolean enabled) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
if (widget->enabled != enabled) { if (wid->enabled != enabled) {
widget->enabled = enabled; wid->enabled = enabled;
widget_update(widget); widget_update(wid);
widget_update(widget->parent); widget_update(wid->parent);
widget_queue_redraw(widget); widget_queue_redraw(wid);
} }
} }
void widget_draw(widget *widget, cairo_t *d) { void widget_draw(widget *wid, cairo_t *d) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
// Check if enabled and if draw is implemented. // Check if enabled and if draw is implemented.
if (widget->enabled && widget->draw) { if (wid->enabled && wid->draw) {
// Don't draw if there is no space. // Don't draw if there is no space.
if (widget->h < 1 || widget->w < 1) { if (wid->h < 1 || wid->w < 1) {
widget->need_redraw = FALSE; wid->need_redraw = FALSE;
return; return;
} }
// Store current state. // Store current state.
cairo_save(d); cairo_save(d);
const int margin_left = const int margin_left =
distance_get_pixel(widget->margin.left, ROFI_ORIENTATION_HORIZONTAL); distance_get_pixel(wid->margin.left, ROFI_ORIENTATION_HORIZONTAL);
const int margin_top = const int margin_top =
distance_get_pixel(widget->margin.top, ROFI_ORIENTATION_VERTICAL); distance_get_pixel(wid->margin.top, ROFI_ORIENTATION_VERTICAL);
const int margin_right = const int margin_right =
distance_get_pixel(widget->margin.right, ROFI_ORIENTATION_HORIZONTAL); distance_get_pixel(wid->margin.right, ROFI_ORIENTATION_HORIZONTAL);
const int margin_bottom = const int margin_bottom =
distance_get_pixel(widget->margin.bottom, ROFI_ORIENTATION_VERTICAL); distance_get_pixel(wid->margin.bottom, ROFI_ORIENTATION_VERTICAL);
const int left = const int left =
distance_get_pixel(widget->border.left, ROFI_ORIENTATION_HORIZONTAL); distance_get_pixel(wid->border.left, ROFI_ORIENTATION_HORIZONTAL);
const int right = const int right =
distance_get_pixel(widget->border.right, ROFI_ORIENTATION_HORIZONTAL); distance_get_pixel(wid->border.right, ROFI_ORIENTATION_HORIZONTAL);
const int top = const int top =
distance_get_pixel(widget->border.top, ROFI_ORIENTATION_VERTICAL); distance_get_pixel(wid->border.top, ROFI_ORIENTATION_VERTICAL);
const int bottom = const int bottom =
distance_get_pixel(widget->border.bottom, ROFI_ORIENTATION_VERTICAL); distance_get_pixel(wid->border.bottom, ROFI_ORIENTATION_VERTICAL);
int radius_bl = distance_get_pixel(widget->border_radius.left, int radius_bl = distance_get_pixel(wid->border_radius.left,
ROFI_ORIENTATION_HORIZONTAL); ROFI_ORIENTATION_HORIZONTAL);
int radius_tr = distance_get_pixel(widget->border_radius.right, int radius_tr = distance_get_pixel(wid->border_radius.right,
ROFI_ORIENTATION_HORIZONTAL); ROFI_ORIENTATION_HORIZONTAL);
int radius_tl = distance_get_pixel(widget->border_radius.top, int radius_tl =
ROFI_ORIENTATION_VERTICAL); distance_get_pixel(wid->border_radius.top, ROFI_ORIENTATION_VERTICAL);
int radius_br = distance_get_pixel(widget->border_radius.bottom, int radius_br = distance_get_pixel(wid->border_radius.bottom,
ROFI_ORIENTATION_VERTICAL); ROFI_ORIENTATION_VERTICAL);
double vspace = double vspace =
widget->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0; wid->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0;
double hspace = double hspace =
widget->w - margin_left - margin_right - left / 2.0 - right / 2.0; wid->w - margin_left - margin_right - left / 2.0 - right / 2.0;
if ((radius_bl + radius_tl) > (vspace)) { if ((radius_bl + radius_tl) > (vspace)) {
int j = ((vspace) / 2.0); int j = ((vspace) / 2.0);
radius_bl = MIN(radius_bl, j); radius_bl = MIN(radius_bl, j);
@ -198,14 +197,14 @@ void widget_draw(widget *widget, cairo_t *d) {
// Background painting. // Background painting.
// Set new x/y position. // Set new x/y position.
cairo_translate(d, widget->x, widget->y); cairo_translate(d, wid->x, wid->y);
cairo_set_line_width(d, 0); cairo_set_line_width(d, 0);
// Outer outline outlines // Outer outline outlines
double x1, y1, x2, y2; double x1, y1, x2, y2;
x1 = margin_left + left / 2.0, y1 = margin_top + top / 2.0, x1 = margin_left + left / 2.0, y1 = margin_top + top / 2.0,
x2 = widget->w - margin_right - right / 2.0, x2 = wid->w - margin_right - right / 2.0,
y2 = widget->h - margin_bottom - bottom / 2.0; y2 = wid->h - margin_bottom - bottom / 2.0;
if (radius_tl > 0) { if (radius_tl > 0) {
cairo_move_to(d, x1, y1 + radius_tl); cairo_move_to(d, x1, y1 + radius_tl);
@ -238,15 +237,15 @@ void widget_draw(widget *widget, cairo_t *d) {
cairo_close_path(d); cairo_close_path(d);
cairo_set_source_rgba(d, 1.0, 1.0, 1.0, 1.0); cairo_set_source_rgba(d, 1.0, 1.0, 1.0, 1.0);
rofi_theme_get_color(widget, "background-color", d); rofi_theme_get_color(wid, "background-color", d);
cairo_fill_preserve(d); cairo_fill_preserve(d);
if (rofi_theme_get_image(widget, "background-image", d)) { if (rofi_theme_get_image(wid, "background-image", d)) {
cairo_fill_preserve(d); cairo_fill_preserve(d);
} }
cairo_clip(d); cairo_clip(d);
widget->draw(widget, d); wid->draw(wid, d);
widget->need_redraw = FALSE; wid->need_redraw = FALSE;
cairo_restore(d); cairo_restore(d);
@ -255,9 +254,9 @@ void widget_draw(widget *widget, cairo_t *d) {
// thus no need for these. // thus no need for these.
cairo_push_group(d); cairo_push_group(d);
cairo_set_operator(d, CAIRO_OPERATOR_ADD); cairo_set_operator(d, CAIRO_OPERATOR_ADD);
cairo_translate(d, widget->x, widget->y); cairo_translate(d, wid->x, wid->y);
cairo_new_path(d); cairo_new_path(d);
rofi_theme_get_color(widget, "border-color", d); rofi_theme_get_color(wid, "border-color", d);
// Calculate the different offsets for the corners. // Calculate the different offsets for the corners.
double minof_tr = MIN(right / 2.0, top / 2.0); double minof_tr = MIN(right / 2.0, top / 2.0);
@ -309,30 +308,30 @@ void widget_draw(widget *widget, cairo_t *d) {
if (left > 0) { if (left > 0) {
cairo_set_line_width(d, left); cairo_set_line_width(d, left);
distance_get_linestyle(widget->border.left, d); distance_get_linestyle(wid->border.left, d);
cairo_move_to(d, x1, margin_top + offset_ttl); cairo_move_to(d, x1, margin_top + offset_ttl);
cairo_line_to(d, x1, widget->h - margin_bottom - offset_bbl); cairo_line_to(d, x1, wid->h - margin_bottom - offset_bbl);
cairo_stroke(d); cairo_stroke(d);
} }
if (right > 0) { if (right > 0) {
cairo_set_line_width(d, right); cairo_set_line_width(d, right);
distance_get_linestyle(widget->border.right, d); distance_get_linestyle(wid->border.right, d);
cairo_move_to(d, x2, margin_top + offset_ttr); cairo_move_to(d, x2, margin_top + offset_ttr);
cairo_line_to(d, x2, widget->h - margin_bottom - offset_bbr); cairo_line_to(d, x2, wid->h - margin_bottom - offset_bbr);
cairo_stroke(d); cairo_stroke(d);
} }
if (top > 0) { if (top > 0) {
cairo_set_line_width(d, top); cairo_set_line_width(d, top);
distance_get_linestyle(widget->border.top, d); distance_get_linestyle(wid->border.top, d);
cairo_move_to(d, margin_left + offset_ltl, y1); cairo_move_to(d, margin_left + offset_ltl, y1);
cairo_line_to(d, widget->w - margin_right - offset_rtr, y1); cairo_line_to(d, wid->w - margin_right - offset_rtr, y1);
cairo_stroke(d); cairo_stroke(d);
} }
if (bottom > 0) { if (bottom > 0) {
cairo_set_line_width(d, bottom); cairo_set_line_width(d, bottom);
distance_get_linestyle(widget->border.bottom, d); distance_get_linestyle(wid->border.bottom, d);
cairo_move_to(d, margin_left + offset_lbl, y2); cairo_move_to(d, margin_left + offset_lbl, y2);
cairo_line_to(d, widget->w - margin_right - offset_rbr, y2); cairo_line_to(d, wid->w - margin_right - offset_rbr, y2);
cairo_stroke(d); cairo_stroke(d);
} }
if (radius_tl > 0) { if (radius_tl > 0) {
@ -353,61 +352,59 @@ void widget_draw(widget *widget, cairo_t *d) {
} }
if (radius_tr > 0) { if (radius_tr > 0) {
double radius_outer = radius_tr + minof_tr; double radius_outer = radius_tr + minof_tr;
cairo_arc(d, widget->w - margin_right - radius_outer, cairo_arc(d, wid->w - margin_right - radius_outer,
margin_top + radius_outer, radius_outer, -G_PI_2, 0); margin_top + radius_outer, radius_outer, -G_PI_2, 0);
cairo_line_to(d, widget->w - margin_right, margin_top + offset_ttr); cairo_line_to(d, wid->w - margin_right, margin_top + offset_ttr);
cairo_line_to(d, widget->w - margin_right - right, cairo_line_to(d, wid->w - margin_right - right,
margin_top + offset_ttr); margin_top + offset_ttr);
if (radius_inner_tr > 0) { if (radius_inner_tr > 0) {
cairo_arc_negative( cairo_arc_negative(d, wid->w - margin_right - right - radius_inner_tr,
d, widget->w - margin_right - right - radius_inner_tr, margin_top + top + radius_inner_tr,
margin_top + top + radius_inner_tr, radius_inner_tr, 0, -G_PI_2); radius_inner_tr, 0, -G_PI_2);
cairo_line_to(d, widget->w - margin_right - offset_rtr, cairo_line_to(d, wid->w - margin_right - offset_rtr,
margin_top + top); margin_top + top);
} }
cairo_line_to(d, widget->w - margin_right - offset_rtr, margin_top); cairo_line_to(d, wid->w - margin_right - offset_rtr, margin_top);
cairo_close_path(d); cairo_close_path(d);
cairo_fill(d); cairo_fill(d);
} }
if (radius_br > 0) { if (radius_br > 0) {
double radius_outer = radius_br + minof_br; double radius_outer = radius_br + minof_br;
cairo_arc(d, widget->w - margin_right - radius_outer, cairo_arc(d, wid->w - margin_right - radius_outer,
widget->h - margin_bottom - radius_outer, radius_outer, 0.0, wid->h - margin_bottom - radius_outer, radius_outer, 0.0,
G_PI_2); G_PI_2);
cairo_line_to(d, widget->w - margin_right - offset_rbr, cairo_line_to(d, wid->w - margin_right - offset_rbr,
widget->h - margin_bottom); wid->h - margin_bottom);
cairo_line_to(d, widget->w - margin_right - offset_rbr, cairo_line_to(d, wid->w - margin_right - offset_rbr,
widget->h - margin_bottom - bottom); wid->h - margin_bottom - bottom);
if (radius_inner_br > 0) { if (radius_inner_br > 0) {
cairo_arc_negative( cairo_arc_negative(d, wid->w - margin_right - right - radius_inner_br,
d, widget->w - margin_right - right - radius_inner_br, wid->h - margin_bottom - bottom - radius_inner_br,
widget->h - margin_bottom - bottom - radius_inner_br, radius_inner_br, G_PI_2, 0.0);
radius_inner_br, G_PI_2, 0.0); cairo_line_to(d, wid->w - margin_right - right,
cairo_line_to(d, widget->w - margin_right - right, wid->h - margin_bottom - offset_bbr);
widget->h - margin_bottom - offset_bbr);
} }
cairo_line_to(d, widget->w - margin_right, cairo_line_to(d, wid->w - margin_right,
widget->h - margin_bottom - offset_bbr); wid->h - margin_bottom - offset_bbr);
cairo_close_path(d); cairo_close_path(d);
cairo_fill(d); cairo_fill(d);
} }
if (radius_bl > 0) { if (radius_bl > 0) {
double radius_outer = radius_bl + minof_bl; double radius_outer = radius_bl + minof_bl;
cairo_arc(d, margin_left + radius_outer, cairo_arc(d, margin_left + radius_outer,
widget->h - margin_bottom - radius_outer, radius_outer, wid->h - margin_bottom - radius_outer, radius_outer, G_PI_2,
G_PI_2, G_PI); G_PI);
cairo_line_to(d, margin_left, widget->h - margin_bottom - offset_bbl); cairo_line_to(d, margin_left, wid->h - margin_bottom - offset_bbl);
cairo_line_to(d, margin_left + left, cairo_line_to(d, margin_left + left,
widget->h - margin_bottom - offset_bbl); wid->h - margin_bottom - offset_bbl);
if (radius_inner_bl > 0) { if (radius_inner_bl > 0) {
cairo_arc_negative(d, margin_left + left + radius_inner_bl, cairo_arc_negative(d, margin_left + left + radius_inner_bl,
widget->h - margin_bottom - bottom - wid->h - margin_bottom - bottom - radius_inner_bl,
radius_inner_bl,
radius_inner_bl, G_PI, G_PI_2); radius_inner_bl, G_PI, G_PI_2);
cairo_line_to(d, margin_left + offset_lbl, cairo_line_to(d, margin_left + offset_lbl,
widget->h - margin_bottom - bottom); wid->h - margin_bottom - bottom);
} }
cairo_line_to(d, margin_left + offset_lbl, widget->h - margin_bottom); cairo_line_to(d, margin_left + offset_lbl, wid->h - margin_bottom);
cairo_close_path(d); cairo_close_path(d);
cairo_fill(d); cairo_fill(d);
@ -430,53 +427,53 @@ void widget_free(widget *wid) {
} }
} }
int widget_get_height(widget *widget) { int widget_get_height(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return 0; return 0;
} }
if (widget->get_height == NULL) { if (wid->get_height == NULL) {
return widget->h; return wid->h;
} }
return widget->get_height(widget); return wid->get_height(wid);
} }
int widget_get_width(widget *widget) { int widget_get_width(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return 0; return 0;
} }
if (widget->get_width == NULL) { if (wid->get_width == NULL) {
return widget->w; return wid->w;
} }
return widget->get_width(widget); return wid->get_width(wid);
} }
int widget_get_x_pos(widget *widget) { int widget_get_x_pos(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return 0; return 0;
} }
return widget->x; return wid->x;
} }
int widget_get_y_pos(widget *widget) { int widget_get_y_pos(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return 0; return 0;
} }
return widget->y; return wid->y;
} }
void widget_xy_to_relative(widget *widget, gint *x, gint *y) { void widget_xy_to_relative(widget *wid, gint *x, gint *y) {
*x -= widget->x; *x -= wid->x;
*y -= widget->y; *y -= wid->y;
if (widget->parent == NULL) { if (wid->parent == NULL) {
return; return;
} }
widget_xy_to_relative(widget->parent, x, y); widget_xy_to_relative(wid->parent, x, y);
} }
void widget_update(widget *widget) { void widget_update(widget *wid) {
if (widget == NULL) { if (wid == NULL) {
return; return;
} }
// When (desired )size of widget changes. // When (desired )size of wid changes.
if (widget->update != NULL) { if (wid->update != NULL) {
widget->update(widget); wid->update(wid);
} }
} }

View file

@ -31,8 +31,8 @@
#include "config.h" #include "config.h"
#ifdef XCB_IMDKIT #ifdef XCB_IMDKIT
#include <xcb/xcb_keysyms.h>
#include <xcb-imdkit/encoding.h> #include <xcb-imdkit/encoding.h>
#include <xcb/xcb_keysyms.h>
#endif #endif
#include <cairo-xcb.h> #include <cairo-xcb.h>
#include <cairo.h> #include <cairo.h>
@ -128,13 +128,13 @@ const struct {
} cursor_names[] = { } cursor_names[] = {
{"default", "left_ptr"}, {"pointer", "hand"}, {"text", "xterm"}}; {"default", "left_ptr"}, {"pointer", "hand"}, {"text", "xterm"}};
static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t visual) { static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t vis) {
xcb_depth_iterator_t d; xcb_depth_iterator_t d;
d = xcb_screen_allowed_depths_iterator(s); d = xcb_screen_allowed_depths_iterator(s);
for (; d.rem; xcb_depth_next(&d)) { for (; d.rem; xcb_depth_next(&d)) {
xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data); xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data);
for (; v.rem; xcb_visualtype_next(&v)) { for (; v.rem; xcb_visualtype_next(&v)) {
if (v.data->visual_id == visual) { if (v.data->visual_id == vis) {
return v.data; return v.data;
} }
} }