mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Fix some possible null pointer dereference. (clang-check)
This commit is contained in:
parent
313dffa28d
commit
0e176199fc
4 changed files with 34 additions and 5 deletions
|
@ -108,6 +108,20 @@ int widget_get_height ( widget *widget );
|
||||||
*/
|
*/
|
||||||
int widget_get_width ( widget *widget );
|
int widget_get_width ( widget *widget );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param widget The widget handle
|
||||||
|
*
|
||||||
|
* @returns the y postion of the widget relative to its parent.
|
||||||
|
*/
|
||||||
|
int widget_get_y_pos ( widget *widget );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param widget The widget handle
|
||||||
|
*
|
||||||
|
* @returns the x postion of the widget relative to its parent.
|
||||||
|
*/
|
||||||
|
int widget_get_x_pos ( widget *widget );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget handle
|
* @param widget The widget handle
|
||||||
*
|
*
|
||||||
|
|
|
@ -208,6 +208,7 @@ static void box_free ( widget *wid )
|
||||||
|
|
||||||
void box_add ( box *box, widget *child, gboolean expand, gboolean end )
|
void box_add ( box *box, widget *child, gboolean expand, gboolean end )
|
||||||
{
|
{
|
||||||
|
if ( box == NULL ) return;
|
||||||
child->expand = expand;
|
child->expand = expand;
|
||||||
child->end = end;
|
child->end = end;
|
||||||
child->parent = WIDGET ( box );
|
child->parent = WIDGET ( box );
|
||||||
|
|
|
@ -151,7 +151,7 @@ static void listview_draw ( widget *wid, cairo_t *draw )
|
||||||
unsigned int width = lv->widget.w - lv->padding * ( lv->cur_columns - 1 );
|
unsigned int width = lv->widget.w - lv->padding * ( lv->cur_columns - 1 );
|
||||||
if ( widget_enabled ( WIDGET ( lv->scrollbar ) ) ) {
|
if ( widget_enabled ( WIDGET ( lv->scrollbar ) ) ) {
|
||||||
width -= lv->padding;
|
width -= lv->padding;
|
||||||
width -= lv->scrollbar->widget.w;
|
width -= widget_get_width ( WIDGET ( lv->scrollbar ) );
|
||||||
}
|
}
|
||||||
unsigned int element_width = ( width ) / lv->cur_columns;
|
unsigned int element_width = ( width ) / lv->cur_columns;
|
||||||
for ( unsigned int i = 0; i < max; i++ ) {
|
for ( unsigned int i = 0; i < max; i++ ) {
|
||||||
|
@ -237,8 +237,8 @@ static void listview_resize ( widget *wid, short w, short h )
|
||||||
lv->max_rows = ( lv->padding + lv->widget.h ) / ( lv->element_height + lv->padding );
|
lv->max_rows = ( lv->padding + lv->widget.h ) / ( lv->element_height + lv->padding );
|
||||||
lv->max_elements = lv->max_rows * lv->menu_columns;
|
lv->max_elements = lv->max_rows * lv->menu_columns;
|
||||||
|
|
||||||
widget_move ( WIDGET ( lv->scrollbar ), lv->widget.w - lv->scrollbar->widget.w, 0 );
|
widget_move ( WIDGET ( lv->scrollbar ), lv->widget.w - widget_get_width ( WIDGET (lv->scrollbar ) ), 0 );
|
||||||
widget_resize ( WIDGET ( lv->scrollbar ), lv->scrollbar->widget.w, h );
|
widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), h );
|
||||||
|
|
||||||
listview_recompute_elements ( lv );
|
listview_recompute_elements ( lv );
|
||||||
widget_queue_redraw ( wid );
|
widget_queue_redraw ( wid );
|
||||||
|
@ -260,8 +260,8 @@ static gboolean listview_clicked ( widget *wid, xcb_button_press_event_t *xce, G
|
||||||
if ( widget_enabled ( WIDGET ( lv->scrollbar ) ) && widget_intersect ( WIDGET ( lv->scrollbar ), xce->event_x, xce->event_y ) ) {
|
if ( widget_enabled ( WIDGET ( lv->scrollbar ) ) && widget_intersect ( WIDGET ( lv->scrollbar ), xce->event_x, xce->event_y ) ) {
|
||||||
// Forward to handler of scrollbar.
|
// Forward to handler of scrollbar.
|
||||||
xcb_button_press_event_t xce2 = *xce;
|
xcb_button_press_event_t xce2 = *xce;
|
||||||
xce->event_x -= lv->scrollbar->widget.x;
|
xce->event_x -= widget_get_x_pos ( WIDGET ( lv->scrollbar ) );
|
||||||
xce->event_y -= lv->scrollbar->widget.y;
|
xce->event_y -= widget_get_y_pos ( WIDGET ( lv->scrollbar ) );
|
||||||
return widget_clicked ( WIDGET ( lv->scrollbar ), &xce2 );
|
return widget_clicked ( WIDGET ( lv->scrollbar ), &xce2 );
|
||||||
}
|
}
|
||||||
// Handle the boxes.
|
// Handle the boxes.
|
||||||
|
|
|
@ -93,6 +93,20 @@ int widget_get_width ( widget *widget )
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int widget_get_x_pos ( widget *widget )
|
||||||
|
{
|
||||||
|
if ( widget ) {
|
||||||
|
return widget->x;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int widget_get_y_pos ( widget *widget )
|
||||||
|
{
|
||||||
|
if ( widget ) {
|
||||||
|
return widget->y;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void widget_update ( widget *widget )
|
void widget_update ( widget *widget )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue