2017-04-15 06:32:05 -04:00
|
|
|
/*
|
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
|
|
|
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-10-21 12:48:01 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h>
|
2017-06-02 10:09:20 -04:00
|
|
|
#include <theme.h>
|
2016-10-21 12:48:01 -04:00
|
|
|
#include <widgets/box.h>
|
|
|
|
#include <widgets/widget.h>
|
|
|
|
#include <widgets/widget-internal.h>
|
2017-05-04 08:54:38 -04:00
|
|
|
#include "rofi.h"
|
|
|
|
#include "xrmoptions.h"
|
|
|
|
#include "helper.h"
|
2021-06-15 06:45:02 -04:00
|
|
|
#include "rofi-icon-fetcher.h"
|
2016-10-21 12:48:01 -04:00
|
|
|
unsigned int test =0;
|
|
|
|
#define TASSERT( a ) { \
|
|
|
|
assert ( a ); \
|
2019-02-02 05:12:01 -05:00
|
|
|
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
|
2016-10-21 12:48:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define TASSERTE( a, b ) { \
|
|
|
|
if ( ( a ) == ( b ) ) { \
|
2019-02-02 05:12:01 -05:00
|
|
|
printf ( "Test %u passed (%s == %s) (%d == %d)\n", ++test, # a, # b, a, b ); \
|
2016-10-21 12:48:01 -04:00
|
|
|
}else { \
|
2019-02-02 05:12:01 -05:00
|
|
|
printf ( "Test %u failed (%s == %s) (%d != %d)\n", ++test, # a, # b, a, b ); \
|
2016-10-21 12:48:01 -04:00
|
|
|
abort ( ); \
|
|
|
|
} \
|
|
|
|
}
|
2017-01-09 17:15:45 -05:00
|
|
|
|
2017-05-30 07:31:35 -04:00
|
|
|
#define TASSERTW( a, b ) { \
|
|
|
|
if ( ( a ) == ( b ) ) { \
|
2019-02-02 05:12:01 -05:00
|
|
|
printf ( "Test %u passed (%s == %s) (%p == %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
|
2017-05-30 07:31:35 -04:00
|
|
|
}else { \
|
2019-02-02 05:12:01 -05:00
|
|
|
printf ( "Test %u failed (%s == %s) (%p != %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
|
2017-05-30 07:31:35 -04:00
|
|
|
abort ( ); \
|
|
|
|
} \
|
|
|
|
}
|
2021-06-15 06:31:32 -04:00
|
|
|
ThemeWidget *rofi_configuration = NULL;
|
|
|
|
|
|
|
|
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-06-15 18:11:57 -04:00
|
|
|
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-06-15 06:31:32 -04:00
|
|
|
|
|
|
|
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-05-30 07:31:35 -04:00
|
|
|
|
2019-09-27 04:43:29 -04:00
|
|
|
|
|
|
|
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-17 12:17:26 -04:00
|
|
|
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
2017-03-28 06:08:14 -04:00
|
|
|
{
|
2017-06-20 15:02:13 -04:00
|
|
|
return FALSE;
|
2017-03-28 06:08:14 -04:00
|
|
|
}
|
2017-05-03 11:57:08 -04:00
|
|
|
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
|
2017-03-11 11:06:06 -05:00
|
|
|
{
|
2017-05-03 11:57:08 -04:00
|
|
|
return NULL;
|
2017-03-11 11:06:06 -05:00
|
|
|
}
|
2017-04-17 12:07:50 -04:00
|
|
|
|
|
|
|
char * helper_get_theme_path ( const char *file )
|
|
|
|
{
|
|
|
|
return g_strdup ( file );
|
|
|
|
}
|
2017-05-03 11:57:08 -04:00
|
|
|
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
2017-01-09 17:15:45 -05:00
|
|
|
{
|
|
|
|
}
|
2017-01-01 10:32:01 -05:00
|
|
|
int textbox_get_estimated_char_height ( void );
|
|
|
|
int textbox_get_estimated_char_height ( void )
|
|
|
|
{
|
|
|
|
return 16;
|
|
|
|
}
|
2017-09-05 07:52:21 -04:00
|
|
|
double textbox_get_estimated_ch ( void );
|
|
|
|
double textbox_get_estimated_ch ( void )
|
|
|
|
{
|
|
|
|
return 8;
|
|
|
|
}
|
2017-05-03 11:57:08 -04:00
|
|
|
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
2017-01-03 13:35:23 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2017-01-01 10:32:01 -05:00
|
|
|
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|
|
|
{
|
|
|
|
{
|
2017-09-07 07:46:09 -04:00
|
|
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_HORIZONTAL );
|
2016-12-16 03:28:13 -05:00
|
|
|
//box_set_padding ( b, 5 );
|
2017-01-01 10:32:01 -05:00
|
|
|
widget_resize ( WIDGET (b), 100, 20);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget *wid1 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid1->parent = WIDGET(b);
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid1 ), TRUE );
|
2016-10-21 12:48:01 -04:00
|
|
|
// Widget not enabled. no width allocated.
|
2019-02-02 05:19:43 -05:00
|
|
|
TASSERTE ( wid1->h, 0 );
|
|
|
|
TASSERTE ( wid1->w, 0 );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid1 ) );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_update ( WIDGET ( b ) ) ;
|
2016-10-21 12:48:01 -04:00
|
|
|
// Widget enabled. so width allocated.
|
2019-02-02 05:12:01 -05:00
|
|
|
TASSERTE ( wid1->h, 20 );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid1->w, 100 );
|
|
|
|
widget *wid2 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid2->parent = WIDGET (b) ;
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid2 ) );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid2 ), TRUE );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid1->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->w, 49);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->w, 49);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget *wid3 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid3->parent = WIDGET (b);
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid3 ) );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid3 ), FALSE );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid1->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->w, 48);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->w, 48);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget_resize ( WIDGET (wid3) , 20, 10 );
|
|
|
|
// TODO should this happen automagically?
|
|
|
|
widget_update ( WIDGET ( b ) ) ;
|
|
|
|
TASSERTE ( wid1->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->w, 38);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->w, 38);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid3->h, 20);
|
|
|
|
TASSERTE ( wid3->w, 20);
|
|
|
|
|
|
|
|
widget_resize ( WIDGET (b ), 200, 20 );
|
|
|
|
TASSERTE ( wid1->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->w, 88);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->h, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->w, 88);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid3->h, 20);
|
|
|
|
TASSERTE ( wid3->w, 20);
|
2017-01-09 17:15:45 -05:00
|
|
|
// TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
|
2016-10-25 12:26:18 -04:00
|
|
|
|
2016-10-21 12:48:01 -04:00
|
|
|
widget *wid4 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid4->parent = WIDGET ( b );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid4 ) );
|
|
|
|
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid4 ), FALSE );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid4->x, 200-20);
|
2016-10-21 14:21:53 -04:00
|
|
|
widget *wid5 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid5->parent = WIDGET ( b );
|
2016-10-21 14:21:53 -04:00
|
|
|
widget_enable ( WIDGET ( wid5 ) );
|
|
|
|
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid5 ), TRUE );
|
2017-01-06 10:53:21 -05:00
|
|
|
TASSERTE ( wid5->x, 149);
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_free ( WIDGET ( b ) );
|
|
|
|
}
|
|
|
|
{
|
2017-09-07 07:46:09 -04:00
|
|
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
2017-01-01 10:32:01 -05:00
|
|
|
widget_resize ( WIDGET (b), 20, 100);
|
2016-12-16 03:28:13 -05:00
|
|
|
//box_set_padding ( b, 5 );
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget *wid1 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid1->parent = WIDGET ( b );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid1 ), TRUE );
|
2016-10-21 12:48:01 -04:00
|
|
|
// Widget not enabled. no width allocated.
|
|
|
|
TASSERTE ( wid1->h, 0);
|
|
|
|
TASSERTE ( wid1->w, 0 );
|
|
|
|
widget_enable ( WIDGET ( wid1 ) );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_update ( WIDGET ( b ) ) ;
|
2016-10-21 12:48:01 -04:00
|
|
|
// Widget enabled. so width allocated.
|
|
|
|
TASSERTE ( wid1->h, 100);
|
|
|
|
TASSERTE ( wid1->w, 20 );
|
|
|
|
widget *wid2 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid2->parent = WIDGET ( b );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid2 ) );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid2 ), TRUE );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid1->w, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->h, 49);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->w, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->h, 49);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget *wid3 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid3->parent = WIDGET ( b );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid3 ) );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid3 ), FALSE );
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid1->w, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid1->h, 48);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->w, 20);
|
2017-01-01 10:32:01 -05:00
|
|
|
TASSERTE ( wid2->h, 48);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget_resize ( WIDGET (wid3) , 10, 20 );
|
|
|
|
// TODO should this happen automagically?
|
|
|
|
widget_update ( WIDGET ( b ) ) ;
|
|
|
|
TASSERTE ( wid1->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid1->h, 38);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid2->h, 38);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid3->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid3->h, 20);
|
2016-10-21 12:48:01 -04:00
|
|
|
|
|
|
|
widget_resize ( WIDGET (b ), 20, 200 );
|
|
|
|
TASSERTE ( wid1->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid1->h, 88);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid2->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid2->h, 88);
|
2016-10-21 12:48:01 -04:00
|
|
|
TASSERTE ( wid3->w, 20);
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid3->h, 20);
|
2017-01-09 17:15:45 -05:00
|
|
|
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget *wid4 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid4->parent = WIDGET ( b );
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_enable ( WIDGET ( wid4 ) );
|
|
|
|
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid4 ), FALSE );
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid4->y, 180);
|
2016-10-21 14:21:53 -04:00
|
|
|
widget *wid5 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid5->parent = WIDGET ( b );
|
2016-10-21 14:21:53 -04:00
|
|
|
widget_enable ( WIDGET ( wid5 ) );
|
|
|
|
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid5 ), TRUE );
|
2017-06-02 10:09:20 -04:00
|
|
|
TASSERTE ( wid5->y, 149);
|
2016-10-21 12:48:01 -04:00
|
|
|
widget_free ( WIDGET ( b ) );
|
|
|
|
}
|
2016-10-25 12:26:18 -04:00
|
|
|
{
|
2017-09-07 07:46:09 -04:00
|
|
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
2017-05-30 07:31:35 -04:00
|
|
|
widget_resize ( WIDGET (b), 20, 90);
|
2016-12-16 03:28:13 -05:00
|
|
|
//box_set_padding ( b, 5 );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget *wid1 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid1->parent = WIDGET ( b );
|
2017-05-30 07:31:35 -04:00
|
|
|
wid1->type = 1;
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_enable(wid1);
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid1 ), TRUE );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget *wid2 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid2->parent = WIDGET ( b );
|
2017-05-30 07:31:35 -04:00
|
|
|
wid2->type = 1;
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_enable(wid2);
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid2 ), TRUE );
|
2017-05-30 07:31:35 -04:00
|
|
|
widget *wid3 = g_malloc0(sizeof(widget));
|
2017-09-07 14:03:21 -04:00
|
|
|
wid3->parent = WIDGET ( b );
|
2017-05-30 07:31:35 -04:00
|
|
|
wid3->type = 2;
|
|
|
|
widget_enable(wid3);
|
2017-06-02 10:53:39 -04:00
|
|
|
box_add ( b , WIDGET( wid3 ), TRUE );
|
2017-05-30 07:31:35 -04:00
|
|
|
|
|
|
|
gint x = 10;
|
|
|
|
gint y = 50;
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
|
|
|
|
|
|
|
y = 30;
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
|
|
|
y = 27;
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_disable ( wid2 );
|
2017-05-30 07:31:35 -04:00
|
|
|
y = 40;
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_disable ( wid1 );
|
|
|
|
widget_enable ( wid2 );
|
2017-05-30 07:31:35 -04:00
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), NULL );
|
|
|
|
y = 55;
|
|
|
|
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), WIDGET(wid3) );
|
2016-10-25 12:26:18 -04:00
|
|
|
widget_free ( WIDGET ( b ) );
|
|
|
|
}
|
2016-10-21 12:48:01 -04:00
|
|
|
}
|