rofi  1.5.4
view.c
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
29 #define G_LOG_DOMAIN "View"
30 
31 #include <config.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <unistd.h>
36 #include <stdint.h>
37 #include <signal.h>
38 #include <errno.h>
39 #include <time.h>
40 #include <locale.h>
41 #include <xkbcommon/xkbcommon-x11.h>
42 #include <xcb/xkb.h>
43 #include <xcb/xcb_ewmh.h>
44 #include <xcb/xcb_icccm.h>
45 
46 #include <cairo.h>
47 #include <cairo-xcb.h>
48 
50 #define SN_API_NOT_YET_FROZEN
51 #include <libsn/sn.h>
52 #include "rofi.h"
53 
54 #include "timings.h"
55 #include "settings.h"
56 
57 #include "mode.h"
58 #include "display.h"
59 #include "xcb-internal.h"
60 #include "helper.h"
61 #include "helper-theme.h"
62 #include "xrmoptions.h"
63 #include "dialogs/dialogs.h"
64 
65 #include "view.h"
66 #include "view-internal.h"
67 
68 #include "theme.h"
69 
70 #include "xcb.h"
71 
78 void rofi_view_update ( RofiViewState *state, gboolean qr );
79 
80 static int rofi_view_calculate_height ( RofiViewState *state );
81 
83 GThreadPool *tpool = NULL;
84 
87 
91 struct
92 {
94  xcb_window_t main_window;
96  cairo_surface_t *fake_bg;
98  xcb_gcontext_t gc;
100  xcb_pixmap_t edit_pixmap;
102  cairo_surface_t *edit_surf;
104  cairo_t *edit_draw;
110  GQueue views;
116  unsigned long long count;
120  gboolean fullscreen;
121 } CacheState = {
122  .main_window = XCB_WINDOW_NONE,
123  .fake_bg = NULL,
124  .edit_surf = NULL,
125  .edit_draw = NULL,
126  .fake_bgrel = FALSE,
127  .flags = MENU_NORMAL,
128  .views = G_QUEUE_INIT,
129  .idle_timeout = 0,
130  .count = 0L,
131  .repaint_source = 0,
132  .fullscreen = FALSE,
133 };
134 
135 void rofi_view_get_current_monitor ( int *width, int *height )
136 {
137  if ( width ) {
138  *width = CacheState.mon.w;
139  }
140  if ( height ) {
141  *height = CacheState.mon.h;
142  }
143 }
144 static char * get_matching_state ( void )
145 {
146  if ( config.case_sensitive ) {
147  if ( config.sort ) {
148  return "±";
149  }
150  else {
151  return "-";
152  }
153  }
154  else{
155  if ( config.sort ) {
156  return "+";
157  }
158  }
159  return " ";
160 }
161 
165 static int lev_sort ( const void *p1, const void *p2, void *arg )
166 {
167  const int *a = p1;
168  const int *b = p2;
169  int *distances = arg;
170 
171  return distances[*a] - distances[*b];
172 }
173 
178 {
179  const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
180  if ( CacheState.edit_surf == NULL ) {
181  // Nothing to store.
182  g_warning ( "There is no rofi surface to store" );
183  return;
184  }
185  const char *xdg_pict_dir = g_get_user_special_dir ( G_USER_DIRECTORY_PICTURES );
186  if ( outp == NULL && xdg_pict_dir == NULL ) {
187  g_warning ( "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot." );
188  return;
189  }
190  // Get current time.
191  GDateTime *now = g_date_time_new_now_local ();
192  // Format filename.
193  char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
194  char *filename = g_strdup_printf ( "%s-%05d.png", timestmp, 0 );
195  // Build full path
196  char *fpath = NULL;
197  if ( outp == NULL ) {
198  int index = 0;
199  fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
200  while ( g_file_test ( fpath, G_FILE_TEST_EXISTS ) && index < 99 ) {
201  g_free ( fpath );
202  g_free ( filename );
203  // Try the next index.
204  index++;
205  // Format filename.
206  filename = g_strdup_printf ( "%s-%05d.png", timestmp, index );
207  // Build full path
208  fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
209  }
210  }
211  else {
212  fpath = g_strdup ( outp );
213  }
214  fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath );
215  cairo_status_t status = cairo_surface_write_to_png ( CacheState.edit_surf, fpath );
216  if ( status != CAIRO_STATUS_SUCCESS ) {
217  g_warning ( "Failed to produce screenshot '%s', got error: '%s'", fpath,
218  cairo_status_to_string ( status ) );
219  }
220  g_free ( fpath );
221  g_free ( filename );
222  g_free ( timestmp );
223  g_date_time_unref ( now );
224 }
225 
226 static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
227 {
228  if ( current_active_menu ) {
229  // Repaint the view (if needed).
230  // After a resize the edit_pixmap surface might not contain anything anymore.
231  // If we already re-painted, this does nothing.
233  g_debug ( "expose event" );
234  TICK_N ( "Expose" );
235  xcb_copy_area ( xcb->connection, CacheState.edit_pixmap, CacheState.main_window, CacheState.gc,
237  xcb_flush ( xcb->connection );
238  TICK_N ( "flush" );
239  CacheState.repaint_source = 0;
240  }
241  return G_SOURCE_REMOVE;
242 }
243 
245 {
246  if ( state->prompt ) {
247  const char *str = mode_get_display_name ( state->sw );
248  textbox_text ( state->prompt, str );
249  }
250 }
251 
264 static const int loc_transtable[9] = {
265  WL_CENTER,
266  WL_NORTH | WL_WEST,
267  WL_NORTH,
268  WL_NORTH | WL_EAST,
269  WL_EAST,
270  WL_SOUTH | WL_EAST,
271  WL_SOUTH,
272  WL_SOUTH | WL_WEST,
273  WL_WEST
274 };
276 {
277  int location = rofi_theme_get_position ( WIDGET ( state->main_window ), "location", loc_transtable[config.location] );
278  int anchor = location;
279  if ( !listview_get_fixed_num_lines ( state->list_view ) ) {
280  anchor = location;
281  if ( location == WL_CENTER ) {
282  anchor = WL_NORTH;
283  }
284  else if ( location == WL_EAST ) {
285  anchor = WL_NORTH_EAST;
286  }
287  else if ( location == WL_WEST ) {
288  anchor = WL_NORTH_WEST;
289  }
290  }
291  anchor = rofi_theme_get_position ( WIDGET ( state->main_window ), "anchor", anchor );
292 
293  if ( CacheState.fullscreen ) {
294  state->x = CacheState.mon.x;
295  state->y = CacheState.mon.y;
296  return;
297  }
298  state->y = CacheState.mon.y + ( CacheState.mon.h ) / 2;
299  state->x = CacheState.mon.x + ( CacheState.mon.w ) / 2;
300  // Determine window location
301  switch ( location )
302  {
303  case WL_NORTH_WEST:
304  state->x = CacheState.mon.x;
305  /* FALLTHRU */
306  case WL_NORTH:
307  state->y = CacheState.mon.y;
308  break;
309  case WL_NORTH_EAST:
310  state->y = CacheState.mon.y;
311  /* FALLTHRU */
312  case WL_EAST:
313  state->x = CacheState.mon.x + CacheState.mon.w;
314  break;
315  case WL_SOUTH_EAST:
316  state->x = CacheState.mon.x + CacheState.mon.w;
317  /* FALLTHRU */
318  case WL_SOUTH:
319  state->y = CacheState.mon.y + CacheState.mon.h;
320  break;
321  case WL_SOUTH_WEST:
322  state->y = CacheState.mon.y + CacheState.mon.h;
323  /* FALLTHRU */
324  case WL_WEST:
325  state->x = CacheState.mon.x;
326  break;
327  case WL_CENTER:
328  ;
329  /* FALLTHRU */
330  default:
331  break;
332  }
333  switch ( anchor )
334  {
335  case WL_SOUTH_WEST:
336  state->y -= state->height;
337  break;
338  case WL_SOUTH:
339  state->x -= state->width / 2;
340  state->y -= state->height;
341  break;
342  case WL_SOUTH_EAST:
343  state->x -= state->width;
344  state->y -= state->height;
345  break;
346  case WL_NORTH_EAST:
347  state->x -= state->width;
348  break;
349  case WL_NORTH_WEST:
350  break;
351  case WL_NORTH:
352  state->x -= state->width / 2;
353  break;
354  case WL_EAST:
355  state->x -= state->width;
356  state->y -= state->height / 2;
357  break;
358  case WL_WEST:
359  state->y -= state->height / 2;
360  break;
361  case WL_CENTER:
362  state->y -= state->height / 2;
363  state->x -= state->width / 2;
364  break;
365  default:
366  break;
367  }
368  // Apply offset.
369  RofiDistance x = rofi_theme_get_distance ( WIDGET ( state->main_window ), "x-offset", config.x_offset );
370  RofiDistance y = rofi_theme_get_distance ( WIDGET ( state->main_window ), "y-offset", config.y_offset );
373 }
374 
376 {
377  uint16_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
378  uint32_t vals[] = { state->x, state->y, state->width, state->height };
379 
380  // Display it.
381  xcb_configure_window ( xcb->connection, CacheState.main_window, mask, vals );
382  cairo_destroy ( CacheState.edit_draw );
383  cairo_surface_destroy ( CacheState.edit_surf );
384 
385  xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap );
386  CacheState.edit_pixmap = xcb_generate_id ( xcb->connection );
387  xcb_create_pixmap ( xcb->connection, depth->depth,
388  CacheState.edit_pixmap, CacheState.main_window, state->width, state->height );
389 
390  CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height );
391  CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
392 
393  g_debug ( "Re-size window based internal request: %dx%d.", state->width, state->height );
394  // Should wrap main window in a widget.
395  widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
396 }
397 
399 {
400  if ( state->mesg_box == NULL ) {
401  return;
402  }
403  char *msg = mode_get_message ( state->sw );
404  if ( msg ) {
405  textbox_text ( state->mesg_tb, msg );
406  widget_enable ( WIDGET ( state->mesg_box ) );
407  g_free ( msg );
408  }
409  else {
410  widget_disable ( WIDGET ( state->mesg_box ) );
411  }
412 }
413 
414 static gboolean rofi_view_reload_idle ( G_GNUC_UNUSED gpointer data )
415 {
416  if ( current_active_menu ) {
417  current_active_menu->reload = TRUE;
420  }
421  CacheState.idle_timeout = 0;
422  return G_SOURCE_REMOVE;
423 }
424 
425 void rofi_view_reload ( void )
426 {
427  // @TODO add check if current view is equal to the callee
428  if ( CacheState.idle_timeout == 0 ) {
429  CacheState.idle_timeout = g_timeout_add ( 1000 / 10, rofi_view_reload_idle, NULL );
430  }
431 }
433 {
434  if ( current_active_menu && CacheState.repaint_source == 0 ) {
435  CacheState.count++;
436  g_debug ( "redraw %llu", CacheState.count );
437  CacheState.repaint_source = g_idle_add_full ( G_PRIORITY_HIGH_IDLE, rofi_view_repaint, NULL, NULL );
438  }
439 }
440 
442 {
443  state->quit = FALSE;
444  state->retv = MENU_CANCEL;
445 }
446 
448 {
449  return current_active_menu;
450 }
451 
453 {
454  if ( current_active_menu != NULL && state != NULL ) {
455  g_queue_push_head ( &( CacheState.views ), current_active_menu );
456  // TODO check.
457  current_active_menu = state;
458  g_debug ( "stack view." );
461  return;
462  }
463  else if ( state == NULL && !g_queue_is_empty ( &( CacheState.views ) ) ) {
464  g_debug ( "pop view." );
465  current_active_menu = g_queue_pop_head ( &( CacheState.views ) );
468  return;
469  }
470  g_assert ( ( current_active_menu == NULL && state != NULL ) || ( current_active_menu != NULL && state == NULL ) );
471  current_active_menu = state;
473 }
474 
475 void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line )
476 {
477  state->selected_line = selected_line;
478  // Find the line.
479  unsigned int selected = 0;
480  for ( unsigned int i = 0; ( ( state->selected_line ) ) < UINT32_MAX && !selected && i < state->filtered_lines; i++ ) {
481  if ( state->line_map[i] == ( state->selected_line ) ) {
482  selected = i;
483  break;
484  }
485  }
486  listview_set_selected ( state->list_view, selected );
487  xcb_clear_area ( xcb->connection, CacheState.main_window, 1, 0, 0, 1, 1 );
488  xcb_flush ( xcb->connection );
489 }
490 
492 {
493  if ( state->tokens ) {
494  helper_tokenize_free ( state->tokens );
495  state->tokens = NULL;
496  }
497  // Do this here?
498  // Wait for final release?
499  widget_free ( WIDGET ( state->main_window ) );
500 
501  g_free ( state->line_map );
502  g_free ( state->distance );
503  // Free the switcher boxes.
504  // When state is free'ed we should no longer need these.
505  g_free ( state->modi );
506  state->num_modi = 0;
507  g_free ( state );
508 }
509 
511 {
512  return state->retv;
513 }
514 
515 unsigned int rofi_view_get_selected_line ( const RofiViewState *state )
516 {
517  return state->selected_line;
518 }
519 
520 unsigned int rofi_view_get_next_position ( const RofiViewState *state )
521 {
522  unsigned int next_pos = state->selected_line;
523  unsigned int selected = listview_get_selected ( state->list_view );
524  if ( ( selected + 1 ) < state->num_lines ) {
525  ( next_pos ) = state->line_map[selected + 1];
526  }
527  return next_pos;
528 }
529 
530 unsigned int rofi_view_get_completed ( const RofiViewState *state )
531 {
532  return state->quit;
533 }
534 
535 const char * rofi_view_get_user_input ( const RofiViewState *state )
536 {
537  if ( state->text ) {
538  return state->text->text;
539  }
540  return NULL;
541 }
542 
549 {
550  return g_malloc0 ( sizeof ( RofiViewState ) );
551 }
552 
556 typedef struct _thread_state_view
557 {
560 
562  GCond *cond;
564  GMutex *mutex;
566  unsigned int *acount;
567 
571  unsigned int start;
573  unsigned int stop;
575  unsigned int count;
576 
578  const char *pattern;
580  glong plen;
588 static void rofi_view_call_thread ( gpointer data, gpointer user_data )
589 {
590  thread_state *t = (thread_state *) data;
591  t->callback ( t, user_data );
592 }
593 
594 static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data )
595 {
597  for ( unsigned int i = t->start; i < t->stop; i++ ) {
598  int match = mode_token_match ( t->state->sw, t->state->tokens, i );
599  // If each token was matched, add it to list.
600  if ( match ) {
601  t->state->line_map[t->start + t->count] = i;
602  if ( config.sort ) {
603  // This is inefficient, need to fix it.
604  char * str = mode_get_completion ( t->state->sw, i );
605  glong slen = g_utf8_strlen ( str, -1 );
606  switch ( config.sorting_method_enum )
607  {
608  case SORT_FZF:
609  t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( t->pattern, t->plen, str, slen );
610  break;
611  case SORT_NORMAL:
612  default:
613  t->state->distance[i] = levenshtein ( t->pattern, t->plen, str, slen );
614  break;
615  }
616  g_free ( str );
617  }
618  t->count++;
619  }
620  }
621  if ( t->acount != NULL ) {
622  g_mutex_lock ( t->mutex );
623  ( *( t->acount ) )--;
624  g_cond_signal ( t->cond );
625  g_mutex_unlock ( t->mutex );
626  }
627 }
628 static void rofi_view_setup_fake_transparency ( const char* const fake_background )
629 {
630  if ( CacheState.fake_bg == NULL ) {
631  cairo_surface_t *s = NULL;
636  TICK_N ( "Fake start" );
637  if ( g_strcmp0 ( fake_background, "real" ) == 0 ) {
638  return;
639  }
640  else if ( g_strcmp0 ( fake_background, "screenshot" ) == 0 ) {
642  }
643  else if ( g_strcmp0 ( fake_background, "background" ) == 0 ) {
645  }
646  else {
647  char *fpath = rofi_expand_path ( fake_background );
648  g_debug ( "Opening %s to use as background.", fpath );
649  s = cairo_image_surface_create_from_png ( fpath );
650  CacheState.fake_bgrel = TRUE;
651  g_free ( fpath );
652  }
653  TICK_N ( "Get surface." );
654  if ( s != NULL ) {
655  if ( cairo_surface_status ( s ) != CAIRO_STATUS_SUCCESS ) {
656  g_debug ( "Failed to open surface fake background: %s",
657  cairo_status_to_string ( cairo_surface_status ( s ) ) );
658  cairo_surface_destroy ( s );
659  s = NULL;
660  }
661  else {
662  CacheState.fake_bg = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, CacheState.mon.w, CacheState.mon.h );
663  cairo_t *dr = cairo_create ( CacheState.fake_bg );
664  if ( CacheState.fake_bgrel ) {
665  cairo_set_source_surface ( dr, s, 0, 0 );
666  }
667  else {
668  cairo_set_source_surface ( dr, s, -CacheState.mon.x, -CacheState.mon.y );
669  }
670  cairo_paint ( dr );
671  cairo_destroy ( dr );
672  cairo_surface_destroy ( s );
673  }
674  }
675  TICK_N ( "Fake transparency" );
676  }
677 }
678 void __create_window ( MenuFlags menu_flags )
679 {
680  uint32_t selmask = XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
681  uint32_t selval[] = {
682  XCB_BACK_PIXMAP_NONE, 0,
683  XCB_GRAVITY_STATIC,
684  XCB_BACKING_STORE_NOT_USEFUL,
685  XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
686  XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_KEYMAP_STATE |
687  XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,
688  map
689  };
690 
691  xcb_window_t box_window = xcb_generate_id ( xcb->connection );
692  xcb_void_cookie_t cc = xcb_create_window_checked ( xcb->connection, depth->depth, box_window, xcb_stuff_get_root_window ( ),
693  0, 0, 200, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
694  visual->visual_id, selmask, selval );
695  xcb_generic_error_t *error;
696  error = xcb_request_check ( xcb->connection, cc );
697  if ( error ) {
698  g_error ( "xcb_create_window() failed error=0x%x\n", error->error_code );
699  exit ( EXIT_FAILURE );
700  }
701  TICK_N ( "xcb create window" );
702  CacheState.gc = xcb_generate_id ( xcb->connection );
703  xcb_create_gc ( xcb->connection, CacheState.gc, box_window, 0, 0 );
704 
705  TICK_N ( "xcb create gc" );
706  // Create a drawable.
707  CacheState.edit_pixmap = xcb_generate_id ( xcb->connection );
708  xcb_create_pixmap ( xcb->connection, depth->depth,
709  CacheState.edit_pixmap, CacheState.main_window, 200, 100 );
710 
711  CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, 200, 100 );
712  CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
713 
714  TICK_N ( "create cairo surface" );
715  // Set up pango context.
716  cairo_font_options_t *fo = cairo_font_options_create ();
717  // Take font description from xlib surface
718  cairo_surface_get_font_options ( CacheState.edit_surf, fo );
719  // TODO should we update the drawable each time?
720  PangoContext *p = pango_cairo_create_context ( CacheState.edit_draw );
721  // Set the font options from the xlib surface
722  pango_cairo_context_set_font_options ( p, fo );
723  TICK_N ( "pango cairo font setup" );
724 
725  CacheState.main_window = box_window;
726  CacheState.flags = menu_flags;
727  monitor_active ( &( CacheState.mon ) );
728  // Setup dpi
729  if ( config.dpi > 1 ) {
730  PangoFontMap *font_map = pango_cairo_font_map_get_default ();
731  pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
732  }
733  else if ( config.dpi == 0 || config.dpi == 1 ) {
734  // Auto-detect mode.
735  double dpi = 96;
736  if ( CacheState.mon.mh > 0 && config.dpi == 1 ) {
737  dpi = ( CacheState.mon.h * 25.4 ) / (double) ( CacheState.mon.mh );
738  }
739  else {
740  dpi = ( xcb->screen->height_in_pixels * 25.4 ) / (double) ( xcb->screen->height_in_millimeters );
741  }
742 
743  g_debug ( "Auto-detected DPI: %.2lf", dpi );
744  PangoFontMap *font_map = pango_cairo_font_map_get_default ();
745  pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, dpi );
746  config.dpi = dpi;
747  }
748  // Setup font.
749  // Dummy widget.
750  box *win = box_create ( NULL, "window", ROFI_ORIENTATION_HORIZONTAL );
751  const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font );
752  if ( font ) {
753  PangoFontDescription *pfd = pango_font_description_from_string ( font );
754  if ( helper_validate_font ( pfd, font ) ) {
755  pango_context_set_font_description ( p, pfd );
756  }
757  pango_font_description_free ( pfd );
758  }
759  PangoLanguage *l = pango_language_get_default ();
760  pango_context_set_language ( p, l );
761  TICK_N ( "configure font" );
762 
763  // Tell textbox to use this context.
764  textbox_set_pango_context ( font, p );
765  // cleanup
766  g_object_unref ( p );
767  cairo_font_options_destroy ( fo );
768 
769  TICK_N ( "textbox setup" );
770  // // make it an unmanaged window
771  if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) ) {
772  window_set_atom_prop ( box_window, xcb->ewmh._NET_WM_STATE, &( xcb->ewmh._NET_WM_STATE_ABOVE ), 1 );
773  uint32_t values[] = { 1 };
774  xcb_change_window_attributes ( xcb->connection, box_window, XCB_CW_OVERRIDE_REDIRECT, values );
775  }
776  else{
777  window_set_atom_prop ( box_window, xcb->ewmh._NET_WM_WINDOW_TYPE, &( xcb->ewmh._NET_WM_WINDOW_TYPE_NORMAL ), 1 );
778  x11_disable_decoration ( box_window );
779  }
780 
781  TICK_N ( "setup window attributes" );
782  CacheState.fullscreen = rofi_theme_get_boolean ( WIDGET ( win ), "fullscreen", config.fullscreen );
783  if ( CacheState.fullscreen ) {
784  xcb_atom_t atoms[] = {
785  xcb->ewmh._NET_WM_STATE_FULLSCREEN,
786  xcb->ewmh._NET_WM_STATE_ABOVE
787  };
788  window_set_atom_prop ( box_window, xcb->ewmh._NET_WM_STATE, atoms, sizeof ( atoms ) / sizeof ( xcb_atom_t ) );
789  }
790 
791  TICK_N ( "setup window fullscreen" );
792  // Set the WM_NAME
793  xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, box_window, xcb->ewmh._NET_WM_NAME, xcb->ewmh.UTF8_STRING, 8, 4, "rofi" );
794  xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, box_window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 4, "rofi" );
795 
796  const char wm_class_name[] = "rofi\0Rofi";
797  xcb_icccm_set_wm_class ( xcb->connection, box_window, sizeof ( wm_class_name ), wm_class_name );
798 
799  TICK_N ( "setup window name and class" );
800  const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL );
801  if ( transparency ) {
802  rofi_view_setup_fake_transparency ( transparency );
803  }
806  }
807  if ( xcb->sncontext != NULL ) {
808  sn_launchee_context_setup_window ( xcb->sncontext, CacheState.main_window );
809  }
810  TICK_N ( "setup startup notification" );
811  widget_free ( WIDGET ( win ) );
812  TICK_N ( "done" );
813 
814  // Set the PID.
815  pid_t pid = getpid ();
816  xcb_ewmh_set_wm_pid ( &( xcb->ewmh ), CacheState.main_window, pid );
817 
818  // Get hostname
819  const char *hostname = g_get_host_name ();
820  char *ahost = g_hostname_to_ascii ( hostname );
821  if ( ahost != NULL ) {
822  xcb_icccm_set_wm_client_machine ( xcb->connection,
823  CacheState.main_window,
824  XCB_ATOM_STRING, 8,
825  strlen ( ahost ), ahost );
826  g_free ( ahost );
827  }
828 }
829 
836 {
837  if ( CacheState.fullscreen ) {
838  state->width = CacheState.mon.w;
839  return;
840  }
841  if ( config.menu_width < 0 ) {
842  double fw = textbox_get_estimated_char_width ( );
843  state->width = -( fw * config.menu_width );
844  state->width += widget_padding_get_padding_width ( WIDGET ( state->main_window ) );
845  }
846  else{
847  // Calculate as float to stop silly, big rounding down errors.
848  state->width = config.menu_width < 101 ? ( CacheState.mon.w / 100.0f ) * ( float ) config.menu_width : config.menu_width;
849  }
850  // Use theme configured width, if set.
851  RofiDistance width = rofi_theme_get_distance ( WIDGET ( state->main_window ), "width", state->width );
853 }
854 
864 static void rofi_view_nav_row_tab ( RofiViewState *state )
865 {
866  if ( state->filtered_lines == 1 ) {
867  state->retv = MENU_OK;
868  ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )];
869  state->quit = 1;
870  return;
871  }
872 
873  // Double tab!
874  if ( state->filtered_lines == 0 && ROW_TAB == state->prev_action ) {
875  state->retv = MENU_NEXT;
876  ( state->selected_line ) = 0;
877  state->quit = TRUE;
878  }
879  else {
880  listview_nav_down ( state->list_view );
881  }
882  state->prev_action = ROW_TAB;
883 }
889 inline static void rofi_view_nav_row_select ( RofiViewState *state )
890 {
891  if ( state->list_view == NULL ) {
892  return;
893  }
894  unsigned int selected = listview_get_selected ( state->list_view );
895  // If a valid item is selected, return that..
896  if ( selected < state->filtered_lines ) {
897  char *str = mode_get_completion ( state->sw, state->line_map[selected] );
898  textbox_text ( state->text, str );
899  g_free ( str );
900  textbox_keybinding ( state->text, MOVE_END );
901  state->refilter = TRUE;
902  }
903 }
904 
910 inline static void rofi_view_nav_first ( RofiViewState * state )
911 {
912 // state->selected = 0;
913  listview_set_selected ( state->list_view, 0 );
914 }
915 
921 inline static void rofi_view_nav_last ( RofiViewState * state )
922 {
923  // If no lines, do nothing.
924  if ( state->filtered_lines == 0 ) {
925  return;
926  }
927  //state->selected = state->filtered_lines - 1;
928  listview_set_selected ( state->list_view, -1 );
929 }
930 
931 static void update_callback ( textbox *t, unsigned int index, void *udata, TextBoxFontType type, gboolean full )
932 {
933  RofiViewState *state = (RofiViewState *) udata;
934  if ( full ) {
935  GList *add_list = NULL;
936  int fstate = 0;
937  char *text = mode_get_display_value ( state->sw, state->line_map[index], &fstate, &add_list, TRUE );
938  type |= fstate;
939  textbox_font ( t, type );
940  // Move into list view.
941  textbox_text ( t, text );
942  PangoAttrList *list = textbox_get_pango_attributes ( t );
943  if ( list != NULL ) {
944  pango_attr_list_ref ( list );
945  }
946  else{
947  list = pango_attr_list_new ();
948  }
949  int icon_height = textbox_get_font_height ( t );
950 
951  cairo_surface_t *icon = mode_get_icon ( state->sw, state->line_map[index], icon_height );
952  textbox_icon ( t, icon );
953 
954  if ( state->tokens && config.show_match ) {
955  RofiHighlightColorStyle th = { ROFI_HL_BOLD | ROFI_HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
956  th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th );
958  }
959  for ( GList *iter = g_list_first ( add_list ); iter != NULL; iter = g_list_next ( iter ) ) {
960  pango_attr_list_insert ( list, (PangoAttribute *) ( iter->data ) );
961  }
962  textbox_set_pango_attributes ( t, list );
963  pango_attr_list_unref ( list );
964  g_list_free ( add_list );
965  g_free ( text );
966  }
967  else {
968  int fstate = 0;
969  mode_get_display_value ( state->sw, state->line_map[index], &fstate, NULL, FALSE );
970  type |= fstate;
971  textbox_font ( t, type );
972  }
973 }
974 
975 void rofi_view_update ( RofiViewState *state, gboolean qr )
976 {
977  if ( !widget_need_redraw ( WIDGET ( state->main_window ) ) ) {
978  return;
979  }
980  g_debug ( "Redraw view" );
981  TICK ();
982  cairo_t *d = CacheState.edit_draw;
983  cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
984  if ( CacheState.fake_bg != NULL ) {
985  if ( CacheState.fake_bgrel ) {
986  cairo_set_source_surface ( d, CacheState.fake_bg, 0.0, 0.0 );
987  }
988  else {
989  cairo_set_source_surface ( d, CacheState.fake_bg,
990  -(double) ( state->x - CacheState.mon.x ),
991  -(double) ( state->y - CacheState.mon.y ) );
992  }
993  cairo_paint ( d );
994  cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
995  }
996  else {
997  // Paint the background transparent.
998  cairo_set_source_rgba ( d, 0, 0, 0, 0.0 );
999  cairo_paint ( d );
1000  }
1001  TICK_N ( "Background" );
1002 
1003  // Always paint as overlay over the background.
1004  cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
1005  widget_draw ( WIDGET ( state->main_window ), d );
1006 
1007  TICK_N ( "widgets" );
1008  cairo_surface_flush ( CacheState.edit_surf );
1009  if ( qr ) {
1011  }
1012 }
1013 
1014 static void _rofi_view_reload_row ( RofiViewState *state )
1015 {
1016  g_free ( state->line_map );
1017  g_free ( state->distance );
1018  state->num_lines = mode_get_num_entries ( state->sw );
1019  state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
1020  state->distance = g_malloc0_n ( state->num_lines, sizeof ( int ) );
1021  listview_set_max_lines ( state->list_view, state->num_lines );
1022  rofi_view_reload_message_bar ( state );
1023 }
1024 
1025 static void rofi_view_refilter ( RofiViewState *state )
1026 {
1027  TICK_N ( "Filter start" );
1028  if ( state->reload ) {
1029  _rofi_view_reload_row ( state );
1030  state->reload = FALSE;
1031  }
1032  if ( state->tokens ) {
1033  helper_tokenize_free ( state->tokens );
1034  state->tokens = NULL;
1035  }
1036  if ( state->text && strlen ( state->text->text ) > 0 ) {
1037  unsigned int j = 0;
1038  gchar *pattern = mode_preprocess_input ( state->sw, state->text->text );
1039  glong plen = pattern ? g_utf8_strlen ( pattern, -1 ) : 0;
1040  state->tokens = helper_tokenize ( pattern, config.case_sensitive );
1047  unsigned int nt = MAX ( 1, state->num_lines / 500 );
1048  thread_state_view states[nt];
1049  GCond cond;
1050  GMutex mutex;
1051  g_mutex_init ( &mutex );
1052  g_cond_init ( &cond );
1053  unsigned int count = nt;
1054  unsigned int steps = ( state->num_lines + nt ) / nt;
1055  for ( unsigned int i = 0; i < nt; i++ ) {
1056  states[i].state = state;
1057  states[i].start = i * steps;
1058  states[i].stop = MIN ( state->num_lines, ( i + 1 ) * steps );
1059  states[i].count = 0;
1060  states[i].cond = &cond;
1061  states[i].mutex = &mutex;
1062  states[i].acount = &count;
1063  states[i].plen = plen;
1064  states[i].pattern = pattern;
1065  states[i].st.callback = filter_elements;
1066  if ( i > 0 ) {
1067  g_thread_pool_push ( tpool, &states[i], NULL );
1068  }
1069  }
1070  // Run one in this thread.
1071  rofi_view_call_thread ( &states[0], NULL );
1072  // No need to do this with only one thread.
1073  if ( nt > 1 ) {
1074  g_mutex_lock ( &mutex );
1075  while ( count > 0 ) {
1076  g_cond_wait ( &cond, &mutex );
1077  }
1078  g_mutex_unlock ( &mutex );
1079  }
1080  g_cond_clear ( &cond );
1081  g_mutex_clear ( &mutex );
1082  for ( unsigned int i = 0; i < nt; i++ ) {
1083  if ( j != states[i].start ) {
1084  memmove ( &( state->line_map[j] ), &( state->line_map[states[i].start] ), sizeof ( unsigned int ) * ( states[i].count ) );
1085  }
1086  j += states[i].count;
1087  }
1088  if ( config.sort ) {
1089  g_qsort_with_data ( state->line_map, j, sizeof ( int ), lev_sort, state->distance );
1090  }
1091 
1092  // Cleanup + bookkeeping.
1093  state->filtered_lines = j;
1094  g_free ( pattern );
1095  }
1096  else{
1097  for ( unsigned int i = 0; i < state->num_lines; i++ ) {
1098  state->line_map[i] = i;
1099  }
1100  state->filtered_lines = state->num_lines;
1101  }
1103 
1104  if ( config.auto_select == TRUE && state->filtered_lines == 1 && state->num_lines > 1 ) {
1105  ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )];
1106  state->retv = MENU_OK;
1107  state->quit = TRUE;
1108  }
1109  // Size the window.
1110  int height = rofi_view_calculate_height ( state );
1111  if ( height != state->height ) {
1112  state->height = height;
1114  rofi_view_window_update_size ( state );
1115  g_debug ( "Resize based on re-filter" );
1116  }
1117  state->refilter = FALSE;
1118  TICK_N ( "Filter done" );
1119 }
1125 void process_result ( RofiViewState *state );
1127 {
1128  if ( state && state->finalize != NULL ) {
1129  state->finalize ( state );
1130  }
1131 }
1132 
1134 {
1135  RofiViewState *state = rofi_view_get_active ();
1136  switch ( action )
1137  {
1138  // Handling of paste
1139  case PASTE_PRIMARY:
1140  xcb_convert_selection ( xcb->connection, CacheState.main_window, XCB_ATOM_PRIMARY,
1141  xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
1142  xcb_flush ( xcb->connection );
1143  break;
1144  case PASTE_SECONDARY:
1145  xcb_convert_selection ( xcb->connection, CacheState.main_window, netatoms[CLIPBOARD],
1146  xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
1147  xcb_flush ( xcb->connection );
1148  break;
1149  case SCREENSHOT:
1151  break;
1152  case CHANGE_ELLIPSIZE:
1153  if ( state->list_view ) {
1155  }
1156  break;
1157  case TOGGLE_SORT:
1158  if ( state->case_indicator != NULL ) {
1159  config.sort = !config.sort;
1160  state->refilter = TRUE;
1162  }
1163  break;
1164  case MODE_PREVIOUS:
1165  state->retv = MENU_PREVIOUS;
1166  ( state->selected_line ) = 0;
1167  state->quit = TRUE;
1168  break;
1169  // Menu navigation.
1170  case MODE_NEXT:
1171  state->retv = MENU_NEXT;
1172  ( state->selected_line ) = 0;
1173  state->quit = TRUE;
1174  break;
1175  // Toggle case sensitivity.
1177  if ( state->case_indicator != NULL ) {
1179  ( state->selected_line ) = 0;
1180  state->refilter = TRUE;
1182  }
1183  break;
1184  // Special delete entry command.
1185  case DELETE_ENTRY:
1186  {
1187  unsigned int selected = listview_get_selected ( state->list_view );
1188  if ( selected < state->filtered_lines ) {
1189  ( state->selected_line ) = state->line_map[selected];
1190  state->retv = MENU_ENTRY_DELETE;
1191  state->quit = TRUE;
1192  }
1193  break;
1194  }
1195  case SELECT_ELEMENT_1:
1196  case SELECT_ELEMENT_2:
1197  case SELECT_ELEMENT_3:
1198  case SELECT_ELEMENT_4:
1199  case SELECT_ELEMENT_5:
1200  case SELECT_ELEMENT_6:
1201  case SELECT_ELEMENT_7:
1202  case SELECT_ELEMENT_8:
1203  case SELECT_ELEMENT_9:
1204  case SELECT_ELEMENT_10:
1205  {
1206  unsigned int index = action - SELECT_ELEMENT_1;
1207  if ( index < state->filtered_lines ) {
1208  state->selected_line = state->line_map[index];
1209  state->retv = MENU_OK;
1210  state->quit = TRUE;
1211  }
1212  break;
1213  }
1214  case CUSTOM_1:
1215  case CUSTOM_2:
1216  case CUSTOM_3:
1217  case CUSTOM_4:
1218  case CUSTOM_5:
1219  case CUSTOM_6:
1220  case CUSTOM_7:
1221  case CUSTOM_8:
1222  case CUSTOM_9:
1223  case CUSTOM_10:
1224  case CUSTOM_11:
1225  case CUSTOM_12:
1226  case CUSTOM_13:
1227  case CUSTOM_14:
1228  case CUSTOM_15:
1229  case CUSTOM_16:
1230  case CUSTOM_17:
1231  case CUSTOM_18:
1232  case CUSTOM_19:
1233  {
1234  state->selected_line = UINT32_MAX;
1235  unsigned int selected = listview_get_selected ( state->list_view );
1236  if ( selected < state->filtered_lines ) {
1237  ( state->selected_line ) = state->line_map[selected];
1238  }
1239  state->retv = MENU_QUICK_SWITCH | ( ( action - CUSTOM_1 ) & MENU_LOWER_MASK );
1240  state->quit = TRUE;
1241  break;
1242  }
1243  // If you add a binding here, make sure to add it to rofi_view_keyboard_navigation too
1244  case CANCEL:
1245  state->retv = MENU_CANCEL;
1246  state->quit = TRUE;
1247  break;
1248  case ROW_UP:
1249  listview_nav_up ( state->list_view );
1250  break;
1251  case ROW_TAB:
1252  rofi_view_nav_row_tab ( state );
1253  break;
1254  case ROW_DOWN:
1255  listview_nav_down ( state->list_view );
1256  break;
1257  case ROW_LEFT:
1258  listview_nav_left ( state->list_view );
1259  break;
1260  case ROW_RIGHT:
1261  listview_nav_right ( state->list_view );
1262  break;
1263  case PAGE_PREV:
1264  listview_nav_page_prev ( state->list_view );
1265  break;
1266  case PAGE_NEXT:
1267  listview_nav_page_next ( state->list_view );
1268  break;
1269  case ROW_FIRST:
1270  rofi_view_nav_first ( state );
1271  break;
1272  case ROW_LAST:
1273  rofi_view_nav_last ( state );
1274  break;
1275  case ROW_SELECT:
1276  rofi_view_nav_row_select ( state );
1277  break;
1278  // If you add a binding here, make sure to add it to textbox_keybinding too
1279  case MOVE_CHAR_BACK:
1280  {
1281  if ( textbox_keybinding ( state->text, action ) == 0 ) {
1282  listview_nav_left ( state->list_view );
1283  }
1284  break;
1285  }
1286  case MOVE_CHAR_FORWARD:
1287  {
1288  if ( textbox_keybinding ( state->text, action ) == 0 ) {
1289  listview_nav_right ( state->list_view );
1290  }
1291  break;
1292  }
1293  case CLEAR_LINE:
1294  case MOVE_FRONT:
1295  case MOVE_END:
1296  case REMOVE_TO_EOL:
1297  case REMOVE_TO_SOL:
1298  case REMOVE_WORD_BACK:
1299  case REMOVE_WORD_FORWARD:
1300  case REMOVE_CHAR_FORWARD:
1301  case MOVE_WORD_BACK:
1302  case MOVE_WORD_FORWARD:
1303  case REMOVE_CHAR_BACK:
1304  {
1305  int rc = textbox_keybinding ( state->text, action );
1306  if ( rc == 1 ) {
1307  // Entry changed.
1308  state->refilter = TRUE;
1309  }
1310  else if ( rc == 2 ) {
1311  // Movement.
1312  }
1313  break;
1314  }
1315  case ACCEPT_ALT:
1316  {
1317  unsigned int selected = listview_get_selected ( state->list_view );
1318  state->selected_line = UINT32_MAX;
1319  if ( selected < state->filtered_lines ) {
1320  ( state->selected_line ) = state->line_map[selected];
1321  state->retv = MENU_OK;
1322  }
1323  else {
1324  // Nothing entered and nothing selected.
1325  state->retv = MENU_CUSTOM_INPUT;
1326  }
1327  state->retv |= MENU_CUSTOM_ACTION;
1328  state->quit = TRUE;
1329  break;
1330  }
1331  case ACCEPT_CUSTOM:
1332  {
1333  state->selected_line = UINT32_MAX;
1334  state->retv = MENU_CUSTOM_INPUT;
1335  state->quit = TRUE;
1336  break;
1337  }
1338  case ACCEPT_ENTRY:
1339  {
1340  // If a valid item is selected, return that..
1341  unsigned int selected = listview_get_selected ( state->list_view );
1342  state->selected_line = UINT32_MAX;
1343  if ( selected < state->filtered_lines ) {
1344  ( state->selected_line ) = state->line_map[selected];
1345  state->retv = MENU_OK;
1346  }
1347  else {
1348  // Nothing entered and nothing selected.
1349  state->retv = MENU_CUSTOM_INPUT;
1350  }
1351 
1352  state->quit = TRUE;
1353  break;
1354  }
1355  }
1356 }
1357 
1358 gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
1359 {
1360  switch ( scope )
1361  {
1362  case SCOPE_GLOBAL:
1364  return TRUE;
1365  case SCOPE_MOUSE_LISTVIEW:
1367  case SCOPE_MOUSE_EDITBOX:
1368  case SCOPE_MOUSE_SCROLLBAR:
1370  {
1371  gint x = state->mouse.x, y = state->mouse.y;
1372  widget *target = widget_find_mouse_target ( WIDGET ( state->main_window ), scope, x, y );
1373  if ( target == NULL ) {
1374  return FALSE;
1375  }
1376  widget_xy_to_relative ( target, &x, &y );
1377  switch ( widget_trigger_action ( target, action, x, y ) )
1378  {
1380  return FALSE;
1382  target = NULL;
1383  /* FALLTHRU */
1385  state->mouse.motion_target = target;
1386  /* FALLTHRU */
1388  return TRUE;
1389  }
1390  break;
1391  }
1392  }
1393  return FALSE;
1394 }
1395 
1396 void rofi_view_handle_text ( RofiViewState *state, char *text )
1397 {
1398  if ( textbox_append_text ( state->text, text, strlen ( text ) ) ) {
1399  state->refilter = TRUE;
1400  }
1401 }
1402 
1403 void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
1404 {
1405  state->mouse.x = x;
1406  state->mouse.y = y;
1407  if ( state->mouse.motion_target != NULL ) {
1408  widget_xy_to_relative ( state->mouse.motion_target, &x, &y );
1409  widget_motion_notify ( state->mouse.motion_target, x, y );
1410  }
1411 }
1412 
1414 {
1415  if ( rofi_view_get_completed ( state ) ) {
1416  // This menu is done.
1417  rofi_view_finalize ( state );
1418  // If there a state. (for example error) reload it.
1419  state = rofi_view_get_active ();
1420 
1421  // cleanup, if no more state to display.
1422  if ( state == NULL ) {
1423  // Quit main-loop.
1425  return;
1426  }
1427  }
1428 
1429  // Update if requested.
1430  if ( state->refilter ) {
1431  rofi_view_refilter ( state );
1432  }
1433  rofi_view_update ( state, TRUE );
1434 }
1435 
1440 void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce )
1441 {
1442  if ( xce->window == CacheState.main_window ) {
1443  if ( state->x != xce->x || state->y != xce->y ) {
1444  state->x = xce->x;
1445  state->y = xce->y;
1446  widget_queue_redraw ( WIDGET ( state->main_window ) );
1447  }
1448  if ( state->width != xce->width || state->height != xce->height ) {
1449  state->width = xce->width;
1450  state->height = xce->height;
1451 
1452  cairo_destroy ( CacheState.edit_draw );
1453  cairo_surface_destroy ( CacheState.edit_surf );
1454 
1455  xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap );
1456  CacheState.edit_pixmap = xcb_generate_id ( xcb->connection );
1457  xcb_create_pixmap ( xcb->connection, depth->depth, CacheState.edit_pixmap, CacheState.main_window,
1458  state->width, state->height );
1459 
1460  CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height );
1461  CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
1462  g_debug ( "Re-size window based external request: %d %d", state->width, state->height );
1463  widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
1464  }
1465  }
1466 }
1467 
1471 void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target )
1472 {
1473  if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) {
1474  if ( target != CacheState.main_window ) {
1475  state->quit = TRUE;
1476  state->retv = MENU_CANCEL;
1477  }
1478  }
1479 }
1480 
1482 {
1483  if ( CacheState.repaint_source == 0 ) {
1484  CacheState.repaint_source = g_idle_add_full ( G_PRIORITY_HIGH_IDLE, rofi_view_repaint, NULL, NULL );
1485  }
1486 }
1487 
1489 {
1490  if ( CacheState.fullscreen == TRUE ) {
1491  return CacheState.mon.h;
1492  }
1493 
1494  RofiDistance h = rofi_theme_get_distance ( WIDGET ( state->main_window ), "height", 0 );
1495  unsigned int height = distance_get_pixel ( h, ROFI_ORIENTATION_VERTICAL );
1496  // If height is set, return it.
1497  if ( height > 0 ) {
1498  return height;
1499  }
1500  // Autosize based on widgets.
1501  widget *main_window = WIDGET ( state->main_window );
1503 }
1504 
1505 static WidgetTriggerActionResult textbox_sidebar_modi_trigger_action ( widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data )
1506 {
1507  RofiViewState *state = ( RofiViewState *) user_data;
1508  unsigned int i;
1509  for ( i = 0; i < state->num_modi; i++ ) {
1510  if ( WIDGET ( state->modi[i] ) == wid ) {
1511  break;
1512  }
1513  }
1514  if ( i == state->num_modi ) {
1516  }
1517 
1518  switch ( action )
1519  {
1520  case MOUSE_CLICK_DOWN:
1521  state->retv = MENU_QUICK_SWITCH | ( i & MENU_LOWER_MASK );
1522  state->quit = TRUE;
1523  state->skip_absorb = TRUE;
1525  case MOUSE_CLICK_UP:
1526  case MOUSE_DCLICK_DOWN:
1527  case MOUSE_DCLICK_UP:
1528  break;
1529  }
1531 }
1532 
1533 // @TODO don't like this construction.
1534 static void rofi_view_listview_mouse_activated_cb ( listview *lv, gboolean custom, void *udata )
1535 {
1536  RofiViewState *state = (RofiViewState *) udata;
1537  state->retv = MENU_OK;
1538  if ( custom ) {
1539  state->retv |= MENU_CUSTOM_ACTION;
1540  }
1541  ( state->selected_line ) = state->line_map[listview_get_selected ( lv )];
1542  // Quit
1543  state->quit = TRUE;
1544  state->skip_absorb = TRUE;
1545 }
1546 
1547 static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, const char *name )
1548 {
1549  char *defaults = NULL;
1550  widget *wid = NULL;
1551 
1555  if ( strcmp ( name, "mainbox" ) == 0 ) {
1556  wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
1557  box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
1558  if ( config.sidebar_mode ) {
1559  defaults = "inputbar,message,listview,mode-switcher";
1560  } else {
1561  defaults = "inputbar,message,listview";
1562  }
1563  }
1567  else if ( strcmp ( name, "inputbar" ) == 0 ) {
1568  wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL );
1569  defaults = "prompt,entry,overlay,case-indicator";
1570  box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE );
1571  }
1575  else if ( strcmp ( name, "prompt" ) == 0 ) {
1576  if ( state->prompt != NULL ) {
1577  g_error ( "Prompt widget can only be added once to the layout." );
1578  return;
1579  }
1580  // Prompt box.
1581  state->prompt = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "", 0, 0 );
1582  rofi_view_update_prompt ( state );
1583  box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
1584  defaults = NULL;
1585  }
1589  else if ( strcmp ( name, "case-indicator" ) == 0 ) {
1590  if ( state->case_indicator != NULL ) {
1591  g_error ( "Case indicator widget can only be added once to the layout." );
1592  return;
1593  }
1594  state->case_indicator = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*", 0, 0 );
1595  // Add small separator between case indicator and text box.
1596  box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE );
1598  }
1602  else if ( strcmp ( name, "entry" ) == 0 ) {
1603  if ( state->text != NULL ) {
1604  g_error ( "Entry textbox widget can only be added once to the layout." );
1605  return;
1606  }
1607  // Entry box
1608  TextboxFlags tfl = TB_EDITABLE;
1609  tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
1610  state->text = textbox_create ( parent_widget, WIDGET_TYPE_EDITBOX, name, tfl | TB_AUTOHEIGHT, NORMAL, NULL, 0, 0 );
1611  box_add ( (box *) parent_widget, WIDGET ( state->text ), TRUE );
1612  }
1616  else if ( strcmp ( name, "message" ) == 0 ) {
1617  if ( state->mesg_box != NULL ) {
1618  g_error ( "Message widget can only be added once to the layout." );
1619  return;
1620  }
1621  state->mesg_box = container_create ( parent_widget, name );
1622  state->mesg_tb = textbox_create ( WIDGET ( state->mesg_box ), WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL, 0, 0 );
1623  container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) );
1624  rofi_view_reload_message_bar ( state );
1625  box_add ( (box *) parent_widget, WIDGET ( state->mesg_box ), FALSE );
1626  }
1630  else if ( strcmp ( name, "listview" ) == 0 ) {
1631  if ( state->list_view != NULL ) {
1632  g_error ( "Listview widget can only be added once to the layout." );
1633  return;
1634  }
1635  state->list_view = listview_create ( parent_widget, name, update_callback, state, config.element_height, 0 );
1636  box_add ( (box *) parent_widget, WIDGET ( state->list_view ), TRUE );
1637  // Set configuration
1641 
1642  int lines = rofi_theme_get_integer ( WIDGET ( state->list_view ), "lines", config.menu_lines );
1643  listview_set_num_lines ( state->list_view, lines );
1644  listview_set_max_lines ( state->list_view, state->num_lines );
1645  }
1649  else if ( strcmp ( name, "mode-switcher" ) == 0 ) {
1650  if ( state->sidebar_bar != NULL ) {
1651  g_error ( "Mode-switcher can only be added once to the layout." );
1652  return;
1653  }
1654  state->sidebar_bar = box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL );
1655  box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
1656  state->num_modi = rofi_get_num_enabled_modi ();
1657  state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
1658  for ( unsigned int j = 0; j < state->num_modi; j++ ) {
1659  const Mode * mode = rofi_get_mode ( j );
1660  state->modi[j] = textbox_create ( WIDGET ( state->sidebar_bar ), WIDGET_TYPE_MODE_SWITCHER, "button", TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
1661  mode_get_display_name ( mode ), 0.5, 0.5 );
1662  box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
1664  }
1665  }
1666  else if ( g_ascii_strcasecmp ( name, "overlay" ) == 0 ) {
1667  state->overlay = textbox_create ( WIDGET ( parent_widget ), WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
1668  box_add ( (box *) parent_widget, WIDGET ( state->overlay), FALSE );
1669  widget_disable ( WIDGET ( state->overlay ) );
1670  }
1671  else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) {
1672  textbox *t = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0 );
1673  box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
1674  }
1675  else if ( g_ascii_strncasecmp ( name, "icon", 4 ) == 0 ) {
1676  icon *t = icon_create ( parent_widget, name );
1677  box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
1678  }
1679  else {
1680  wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
1681  box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
1682  //g_error("The widget %s does not exists. Invalid layout.", name);
1683  }
1684  if ( wid ) {
1685  GList *list = rofi_theme_get_list ( wid, "children", defaults );
1686  for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
1687  rofi_view_add_widget ( state, wid, (const char *) iter->data );
1688  }
1689  g_list_free_full ( list, g_free );
1690  }
1691 }
1692 
1694  const char *input,
1695  MenuFlags menu_flags,
1696  void ( *finalize )( RofiViewState * ) )
1697 {
1698  TICK ();
1700  state->menu_flags = menu_flags;
1701  state->sw = sw;
1702  state->selected_line = UINT32_MAX;
1703  state->retv = MENU_CANCEL;
1704  state->distance = NULL;
1705  state->quit = FALSE;
1706  state->skip_absorb = FALSE;
1707  //We want to filter on the first run.
1708  state->refilter = TRUE;
1709  state->finalize = finalize;
1710  state->mouse_seen = FALSE;
1711 
1712  // Request the lines to show.
1713  state->num_lines = mode_get_num_entries ( sw );
1714 
1715  TICK_N ( "Startup notification" );
1716 
1717  // Get active monitor size.
1718  TICK_N ( "Get active monitor" );
1719 
1720  state->main_window = box_create ( NULL, "window", ROFI_ORIENTATION_VERTICAL );
1721  // Get children.
1722  GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" );
1723  for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
1724  rofi_view_add_widget ( state, WIDGET ( state->main_window ), (const char *) iter->data );
1725  }
1726  g_list_free_full ( list, g_free );
1727 
1728  if ( state->text && input ) {
1729  textbox_text ( state->text, input );
1730  textbox_cursor_end ( state->text );
1731  }
1732 
1733 
1734  // filtered list
1735  state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
1736  state->distance = (int *) g_malloc0_n ( state->num_lines, sizeof ( int ) );
1737 
1739  // Need to resize otherwise calculated desired height is wrong.
1740  widget_resize ( WIDGET ( state->main_window ), state->width, 100 );
1741  // Only needed when window is fixed size.
1742  if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == MENU_NORMAL_WINDOW ) {
1744  }
1745 
1746  state->height = rofi_view_calculate_height ( state );
1747  // Move the window to the correct x,y position.
1749  rofi_view_window_update_size ( state );
1750 
1751  state->quit = FALSE;
1752  rofi_view_refilter ( state );
1753  rofi_view_update ( state, TRUE );
1754  xcb_map_window ( xcb->connection, CacheState.main_window );
1755  widget_queue_redraw ( WIDGET ( state->main_window ) );
1756  xcb_flush ( xcb->connection );
1757  if ( xcb->sncontext != NULL ) {
1758  sn_launchee_context_complete ( xcb->sncontext );
1759  }
1760  return state;
1761 }
1762 
1763 int rofi_view_error_dialog ( const char *msg, int markup )
1764 {
1766  state->retv = MENU_CANCEL;
1767  state->menu_flags = MENU_ERROR_DIALOG;
1768  state->finalize = process_result;
1769 
1770  state->main_window = box_create ( NULL, "window", ROFI_ORIENTATION_VERTICAL );
1771  box *box = box_create ( WIDGET ( state->main_window ), "error-message", ROFI_ORIENTATION_VERTICAL );
1772  box_add ( state->main_window, WIDGET ( box ), TRUE );
1773  state->text = textbox_create ( WIDGET ( box ), WIDGET_TYPE_TEXTBOX_TEXT, "textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
1774  NORMAL, ( msg != NULL ) ? msg : "", 0, 0 );
1775  box_add ( box, WIDGET ( state->text ), TRUE );
1776 
1777  // Make sure we enable fixed num lines when in normal window mode.
1778  if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == MENU_NORMAL_WINDOW ) {
1780  }
1782  // Need to resize otherwise calculated desired height is wrong.
1783  widget_resize ( WIDGET ( state->main_window ), state->width, 100 );
1784  // resize window vertically to suit
1785  state->height = widget_get_desired_height ( WIDGET ( state->main_window ) );
1786 
1787  // Calculte window position.
1789 
1790  // Move the window to the correct x,y position.
1791  rofi_view_window_update_size ( state );
1792 
1793  // Display it.
1794  xcb_map_window ( xcb->connection, CacheState.main_window );
1795  widget_queue_redraw ( WIDGET ( state->main_window ) );
1796 
1797  if ( xcb->sncontext != NULL ) {
1798  sn_launchee_context_complete ( xcb->sncontext );
1799  }
1800 
1801  // Set it as current window.
1802  rofi_view_set_active ( state );
1803  return TRUE;
1804 }
1805 
1806 void rofi_view_hide ( void )
1807 {
1808  if ( CacheState.main_window != XCB_WINDOW_NONE ) {
1809  xcb_unmap_window ( xcb->connection, CacheState.main_window );
1811  }
1812 }
1813 
1815 {
1816  g_debug ( "Cleanup." );
1817  if ( CacheState.idle_timeout > 0 ) {
1818  g_source_remove ( CacheState.idle_timeout );
1819  CacheState.idle_timeout = 0;
1820  }
1821  if ( CacheState.repaint_source > 0 ) {
1822  g_source_remove ( CacheState.repaint_source );
1823  CacheState.repaint_source = 0;
1824  }
1825  if ( CacheState.fake_bg ) {
1826  cairo_surface_destroy ( CacheState.fake_bg );
1827  CacheState.fake_bg = NULL;
1828  }
1829  if ( CacheState.edit_draw ) {
1830  cairo_destroy ( CacheState.edit_draw );
1831  CacheState.edit_draw = NULL;
1832  }
1833  if ( CacheState.edit_surf ) {
1834  cairo_surface_destroy ( CacheState.edit_surf );
1835  CacheState.edit_surf = NULL;
1836  }
1837  if ( CacheState.main_window != XCB_WINDOW_NONE ) {
1838  g_debug ( "Unmapping and free'ing window" );
1839  xcb_unmap_window ( xcb->connection, CacheState.main_window );
1840  xcb_free_gc ( xcb->connection, CacheState.gc );
1841  xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap );
1842  xcb_destroy_window ( xcb->connection, CacheState.main_window );
1843  CacheState.main_window = XCB_WINDOW_NONE;
1844  }
1845  if ( map != XCB_COLORMAP_NONE ) {
1846  xcb_free_colormap ( xcb->connection, map );
1847  map = XCB_COLORMAP_NONE;
1848  }
1849  xcb_flush ( xcb->connection );
1850  g_assert ( g_queue_is_empty ( &( CacheState.views ) ) );
1851 }
1853 {
1854  TICK_N ( "Setup Threadpool, start" );
1855  if ( config.threads == 0 ) {
1856  config.threads = 1;
1857  long procs = sysconf ( _SC_NPROCESSORS_CONF );
1858  if ( procs > 0 ) {
1859  config.threads = MIN ( procs, 128l );
1860  }
1861  }
1862  // Create thread pool
1863  GError *error = NULL;
1864  tpool = g_thread_pool_new ( rofi_view_call_thread, NULL, config.threads, FALSE, &error );
1865  if ( error == NULL ) {
1866  // Idle threads should stick around for a max of 60 seconds.
1867  g_thread_pool_set_max_idle_time ( 60000 );
1868  // We are allowed to have
1869  g_thread_pool_set_max_threads ( tpool, config.threads, &error );
1870  }
1871  // If error occurred during setup of pool, tell user and exit.
1872  if ( error != NULL ) {
1873  g_warning ( "Failed to setup thread pool: '%s'", error->message );
1874  g_error_free ( error );
1875  exit ( EXIT_FAILURE );
1876  }
1877  TICK_N ( "Setup Threadpool, done" );
1878 }
1880 {
1881  if ( tpool ) {
1882  g_thread_pool_free ( tpool, TRUE, TRUE );
1883  tpool = NULL;
1884  }
1885 }
1887 {
1888  return state->sw;
1889 }
1890 
1891 void rofi_view_set_overlay ( RofiViewState *state, const char *text )
1892 {
1893  if ( state->overlay == NULL || state->list_view == NULL ) {
1894  return;
1895  }
1896  if ( text == NULL ) {
1897  widget_disable ( WIDGET ( state->overlay ) );
1898  return;
1899  }
1900  widget_enable ( WIDGET ( state->overlay ) );
1901  textbox_text ( state->overlay, text );
1902  // We want to queue a repaint.
1904 }
1905 
1907 {
1908  if ( state->text ) {
1909  textbox_text ( state->text, "" );
1910  rofi_view_set_selected_line ( state, 0 );
1911  }
1912 }
1913 
1915 {
1916  state->sw = mode;
1917  // Update prompt;
1918  if ( state->prompt ) {
1919  rofi_view_update_prompt ( state );
1920  }
1921  if ( state->sidebar_bar ) {
1922  for ( unsigned int j = 0; j < state->num_modi; j++ ) {
1923  const Mode * mode = rofi_get_mode ( j );
1924  textbox_font ( state->modi[j], ( mode == state->sw ) ? HIGHLIGHT : NORMAL );
1925  }
1926  }
1927  rofi_view_restart ( state );
1928  state->reload = TRUE;
1929  state->refilter = TRUE;
1930  rofi_view_refilter ( state );
1931  rofi_view_update ( state, TRUE );
1932 }
1933 
1934 xcb_window_t rofi_view_get_window ( void )
1935 {
1936  return CacheState.main_window;
1937 }
rofi_theme_get_position
int rofi_theme_get_position(const widget *widget, const char *property, int def)
Definition: theme.c:546
views
GQueue views
Definition: view.c:110
SCOPE_GLOBAL
@ SCOPE_GLOBAL
Definition: keyb.h:44
RofiViewState::sw
Mode * sw
Definition: view-internal.h:50
SELECT_ELEMENT_5
@ SELECT_ELEMENT_5
Definition: keyb.h:135
widget_xy_to_relative
void widget_xy_to_relative(widget *widget, gint *x, gint *y)
Definition: widget.c:413
PASTE_SECONDARY
@ PASTE_SECONDARY
Definition: keyb.h:63
current_active_menu
RofiViewState * current_active_menu
Definition: view.c:86
WIDGET
#define WIDGET(a)
Definition: widget.h:115
helper_tokenize_free
void helper_tokenize_free(rofi_int_matcher **tokens)
Definition: helper.c:127
REMOVE_WORD_BACK
@ REMOVE_WORD_BACK
Definition: keyb.h:79
BindingsScope
BindingsScope
Definition: keyb.h:43
SELECT_ELEMENT_9
@ SELECT_ELEMENT_9
Definition: keyb.h:139
listview_toggle_ellipsizing
void listview_toggle_ellipsizing(listview *lv)
Definition: listview.c:837
rofi_view_frame_callback
void rofi_view_frame_callback(void)
Definition: view.c:1481
CANCEL
@ CANCEL
Definition: keyb.h:108
rofi_view_add_widget
static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget, const char *name)
Definition: view.c:1547
textbox_font
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition: textbox.c:231
MenuFlags
MenuFlags
Definition: view.h:44
rofi_view_repaint
static gboolean rofi_view_repaint(G_GNUC_UNUSED void *data)
Definition: view.c:226
MOVE_CHAR_BACK
@ MOVE_CHAR_BACK
Definition: keyb.h:75
MENU_QUICK_SWITCH
@ MENU_QUICK_SWITCH
Definition: mode.h:79
xcb
xcb_stuff * xcb
Definition: xcb.c:87
ACCEPT_ENTRY
@ ACCEPT_ENTRY
Definition: keyb.h:91
xrmoptions.h
rofi_view_call_thread
static void rofi_view_call_thread(gpointer data, gpointer user_data)
Definition: view.c:588
CUSTOM_17
@ CUSTOM_17
Definition: keyb.h:125
REMOVE_WORD_FORWARD
@ REMOVE_WORD_FORWARD
Definition: keyb.h:81
depth
xcb_depth_t * depth
Definition: xcb.c:92
widget_set_trigger_action_handler
void widget_set_trigger_action_handler(widget *wid, widget_trigger_action_cb cb, void *cb_data)
Definition: widget.c:479
edit_surf
cairo_surface_t * edit_surf
Definition: view.c:102
RofiViewState::height
int height
Definition: view-internal.h:116
dialogs.h
CUSTOM_6
@ CUSTOM_6
Definition: keyb.h:114
rofi_view_workers_initialize
void rofi_view_workers_initialize(void)
Definition: view.c:1852
_thread_state
Definition: rofi-types.h:245
ROW_LAST
@ ROW_LAST
Definition: keyb.h:106
rofi_capture_screenshot
void rofi_capture_screenshot(void)
Definition: view.c:177
ROW_LEFT
@ ROW_LEFT
Definition: keyb.h:98
listview_nav_up
void listview_nav_up(listview *lv)
Definition: listview.c:598
mode_get_completion
char * mode_get_completion(const Mode *mode, unsigned int selected_line)
Definition: mode.c:84
SELECT_ELEMENT_7
@ SELECT_ELEMENT_7
Definition: keyb.h:137
fake_bgrel
int fake_bgrel
Definition: view.c:106
listview_nav_page_prev
void listview_nav_page_prev(listview *lv)
Definition: listview.c:713
_xcb_stuff::screen
xcb_screen_t * screen
Definition: xcb-internal.h:49
settings.h
rofi_view_nav_first
static void rofi_view_nav_first(RofiViewState *state)
Definition: view.c:910
WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END
Definition: widget.h:86
textbox_icon
void textbox_icon(textbox *tb, cairo_surface_t *icon)
Definition: textbox.c:337
listview_set_num_elements
void listview_set_num_elements(listview *lv, unsigned int rows)
Definition: listview.c:392
MENU_INDICATOR
@ MENU_INDICATOR
Definition: view.h:54
CUSTOM_9
@ CUSTOM_9
Definition: keyb.h:117
PAGE_NEXT
@ PAGE_NEXT
Definition: keyb.h:104
listview_create
listview * listview_create(widget *parent, const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse)
Definition: listview.c:524
rofi_view_nav_row_select
static void rofi_view_nav_row_select(RofiViewState *state)
Definition: view.c:889
mode_token_match
int mode_token_match(const Mode *mode, rofi_int_matcher **tokens, unsigned int selected_line)
Definition: mode.c:105
helper_tokenize
rofi_int_matcher ** helper_tokenize(const char *input, int case_sensitive)
Definition: helper.c:228
RofiViewState::num_modi
unsigned int num_modi
Definition: view-internal.h:101
MOUSE_CLICK_UP
@ MOUSE_CLICK_UP
Definition: keyb.h:170
ROFI_ORIENTATION_VERTICAL
@ ROFI_ORIENTATION_VERTICAL
Definition: rofi-types.h:107
rofi_view_clear_input
void rofi_view_clear_input(RofiViewState *state)
Definition: view.c:1906
KeyBindingAction
KeyBindingAction
Definition: keyb.h:59
Settings::element_height
int element_height
Definition: settings.h:130
REMOVE_TO_EOL
@ REMOVE_TO_EOL
Definition: keyb.h:87
SELECT_ELEMENT_10
@ SELECT_ELEMENT_10
Definition: keyb.h:140
MENU_OK
@ MENU_OK
Definition: mode.h:69
textbox_text
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:305
rofi_view_get_next_position
unsigned int rofi_view_get_next_position(const RofiViewState *state)
Definition: view.c:520
rofi_view_get_active
RofiViewState * rofi_view_get_active(void)
Definition: view.c:447
x11_disable_decoration
void x11_disable_decoration(xcb_window_t window)
Definition: xcb.c:1362
listview_set_scroll_type
void listview_set_scroll_type(listview *lv, ScrollType type)
Definition: listview.c:782
Settings::menu_width
int menu_width
Definition: settings.h:63
container_create
container * container_create(widget *parent, const char *name)
Definition: container.c:104
textbox_cursor_end
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:600
MODE_PREVIOUS
@ MODE_PREVIOUS
Definition: keyb.h:95
rofi_view_trigger_global_action
static void rofi_view_trigger_global_action(KeyBindingAction action)
Definition: view.c:1133
NORMAL
@ NORMAL
Definition: textbox.h:97
_thread_state_view::st
thread_state st
Definition: view.c:559
rofi_scorer_fuzzy_evaluate
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, glong slen)
Definition: helper.c:880
distance_get_pixel
int distance_get_pixel(RofiDistance d, RofiOrientation ori)
Definition: theme.c:765
_thread_state_view::start
unsigned int start
Definition: view.c:571
box_create
box * box_create(widget *parent, const char *name, RofiOrientation type)
Definition: box.c:336
mon
workarea mon
Definition: view.c:112
SCOPE_MOUSE_SCROLLBAR
@ SCOPE_MOUSE_SCROLLBAR
Definition: keyb.h:50
CUSTOM_10
@ CUSTOM_10
Definition: keyb.h:118
rofi_theme_get_distance
RofiDistance rofi_theme_get_distance(const widget *widget, const char *property, int def)
Definition: theme.c:579
TB_PASSWORD
@ TB_PASSWORD
Definition: textbox.h:87
MOUSE_DCLICK_UP
@ MOUSE_DCLICK_UP
Definition: keyb.h:172
rofi_theme_get_boolean
int rofi_theme_get_boolean(const widget *widget, const char *property, int def)
Definition: theme.c:601
mode_get_icon
cairo_surface_t * mode_get_icon(const Mode *mode, unsigned int selected_line, int height)
Definition: mode.c:72
RofiViewState::distance
int * distance
Definition: view-internal.h:73
textbox_append_text
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:801
RofiViewState::skip_absorb
int skip_absorb
Definition: view-internal.h:90
mode.h
SELECT_ELEMENT_1
@ SELECT_ELEMENT_1
Definition: keyb.h:131
rofi_view_error_dialog
int rofi_view_error_dialog(const char *msg, int markup)
Definition: view.c:1763
rofi_view_maybe_update
void rofi_view_maybe_update(RofiViewState *state)
Definition: view.c:1413
HIGHLIGHT
@ HIGHLIGHT
Definition: textbox.h:110
rofi_get_mode
const Mode * rofi_get_mode(unsigned int index)
Definition: rofi.c:134
TB_AUTOHEIGHT
@ TB_AUTOHEIGHT
Definition: textbox.h:82
WL_EAST
@ WL_EAST
Definition: rofi-types.h:164
rofi_view_handle_text
void rofi_view_handle_text(RofiViewState *state, char *text)
Definition: view.c:1396
MENU_PREVIOUS
@ MENU_PREVIOUS
Definition: mode.h:81
TB_AUTOWIDTH
@ TB_AUTOWIDTH
Definition: textbox.h:83
MOUSE_CLICK_DOWN
@ MOUSE_CLICK_DOWN
Definition: keyb.h:169
_icon
Definition: icon.c:41
CUSTOM_11
@ CUSTOM_11
Definition: keyb.h:119
_xcb_stuff::sncontext
SnLauncheeContext * sncontext
Definition: xcb-internal.h:52
rofi_theme_get_integer
int rofi_theme_get_integer(const widget *widget, const char *property, int def)
Definition: theme.c:563
get_matching_state
static char * get_matching_state(void)
Definition: view.c:144
rofi_view_queue_redraw
void rofi_view_queue_redraw(void)
Definition: view.c:432
rofi_view_get_selected_line
unsigned int rofi_view_get_selected_line(const RofiViewState *state)
Definition: view.c:515
widget_find_mouse_target
widget * widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y)
Definition: widget.c:453
textbox_get_font_height
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:883
RofiViewState::retv
MenuReturn retv
Definition: view-internal.h:94
box_add
void box_add(box *box, widget *child, gboolean expand)
Definition: box.c:284
ROW_RIGHT
@ ROW_RIGHT
Definition: keyb.h:99
MOVE_WORD_FORWARD
@ MOVE_WORD_FORWARD
Definition: keyb.h:73
rofi_view_get_mode
Mode * rofi_view_get_mode(RofiViewState *state)
Definition: view.c:1886
CLEAR_LINE
@ CLEAR_LINE
Definition: keyb.h:65
_thread_state_view
Definition: view.c:557
CUSTOM_13
@ CUSTOM_13
Definition: keyb.h:121
rofi_view_get_current_monitor
void rofi_view_get_current_monitor(int *width, int *height)
Definition: view.c:135
MENU_NORMAL
@ MENU_NORMAL
Definition: view.h:46
listview_set_mouse_activated_cb
void listview_set_mouse_activated_cb(listview *lv, listview_mouse_activated_cb cb, void *udata)
Definition: listview.c:789
WL_NORTH_EAST
@ WL_NORTH_EAST
Definition: rofi-types.h:172
__create_window
void __create_window(MenuFlags menu_flags)
Definition: view.c:678
Settings::sorting_method_enum
SortingMethod sorting_method_enum
Definition: settings.h:116
helper_validate_font
gboolean helper_validate_font(PangoFontDescription *pfd, const char *font)
Definition: helper.c:528
fake_bg
cairo_surface_t * fake_bg
Definition: view.c:96
RofiViewState::quit
int quit
Definition: view-internal.h:88
rofi_view_free
void rofi_view_free(RofiViewState *state)
Definition: view.c:491
CUSTOM_5
@ CUSTOM_5
Definition: keyb.h:113
SELECT_ELEMENT_6
@ SELECT_ELEMENT_6
Definition: keyb.h:136
MenuReturn
MenuReturn
Definition: mode.h:67
Settings::location
WindowLocation location
Definition: settings.h:100
RofiViewState::tokens
rofi_int_matcher ** tokens
Definition: view-internal.h:134
textbox_get_estimated_char_width
double textbox_get_estimated_char_width(void)
Definition: textbox.c:910
rofi_view_reload_message_bar
static void rofi_view_reload_message_bar(RofiViewState *state)
Definition: view.c:398
SORT_FZF
@ SORT_FZF
Definition: settings.h:49
_workarea
Definition: xcb.h:100
_thread_state_view::mutex
GMutex * mutex
Definition: view.c:564
tpool
GThreadPool * tpool
Definition: view.c:83
WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN
Definition: widget.h:84
RofiViewState::motion_target
widget * motion_target
Definition: view-internal.h:130
WL_SOUTH_WEST
@ WL_SOUTH_WEST
Definition: rofi-types.h:176
rofi_view_calculate_window_position
static void rofi_view_calculate_window_position(RofiViewState *state)
Definition: view.c:275
timings.h
Settings::fake_transparency
unsigned int fake_transparency
Definition: settings.h:160
MouseBindingMouseDefaultAction
MouseBindingMouseDefaultAction
Definition: keyb.h:168
rofi_view_get_return_value
MenuReturn rofi_view_get_return_value(const RofiViewState *state)
Definition: view.c:510
Settings::show_match
gboolean show_match
Definition: settings.h:173
REMOVE_TO_SOL
@ REMOVE_TO_SOL
Definition: keyb.h:89
textbox_keybinding
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:737
Settings::sidebar_mode
unsigned int sidebar_mode
Definition: settings.h:132
theme.h
helper_token_match_get_pango_attr
PangoAttrList * helper_token_match_get_pango_attr(RofiHighlightColorStyle th, rofi_int_matcher **tokens, const char *input, PangoAttrList *retv)
Definition: helper.c:382
_thread_state_view::pattern
const char * pattern
Definition: view.c:578
rofi_quit_main_loop
void rofi_quit_main_loop(void)
Definition: rofi.c:635
ROW_DOWN
@ ROW_DOWN
Definition: keyb.h:101
ROW_TAB
@ ROW_TAB
Definition: keyb.h:102
flags
MenuFlags flags
Definition: view.c:108
rofi_view_set_active
void rofi_view_set_active(RofiViewState *state)
Definition: view.c:452
loc_transtable
static const int loc_transtable[9]
Definition: view.c:264
CHANGE_ELLIPSIZE
@ CHANGE_ELLIPSIZE
Definition: keyb.h:129
listview_nav_right
void listview_nav_right(listview *lv)
Definition: listview.c:637
_thread_state_view::plen
glong plen
Definition: view.c:580
widget_free
void widget_free(widget *wid)
Definition: widget.c:365
_xcb_stuff::ewmh
xcb_ewmh_connection_t ewmh
Definition: xcb-internal.h:48
SELECT_ELEMENT_4
@ SELECT_ELEMENT_4
Definition: keyb.h:134
listview_set_num_lines
void listview_set_num_lines(listview *lv, unsigned int num_lines)
Definition: listview.c:802
CacheState
struct @0 CacheState
RofiDistance
Definition: rofi-types.h:93
RofiViewState::main_window
box * main_window
Definition: view-internal.h:55
rofi_theme_get_list
GList * rofi_theme_get_list(const widget *widget, const char *property, const char *defaults)
Definition: theme.c:722
SCOPE_MOUSE_LISTVIEW_ELEMENT
@ SCOPE_MOUSE_LISTVIEW_ELEMENT
Definition: keyb.h:46
ROFI_HL_UNDERLINE
@ ROFI_HL_UNDERLINE
Definition: rofi-types.h:54
rofi_view_handle_mouse_motion
void rofi_view_handle_mouse_motion(RofiViewState *state, gint x, gint y)
Definition: view.c:1403
mode_get_num_entries
unsigned int mode_get_num_entries(const Mode *mode)
Definition: mode.c:56
CUSTOM_12
@ CUSTOM_12
Definition: keyb.h:120
CUSTOM_1
@ CUSTOM_1
Definition: keyb.h:109
textbox_get_visible_text
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:282
MOVE_END
@ MOVE_END
Definition: keyb.h:69
SCOPE_MOUSE_MODE_SWITCHER
@ SCOPE_MOUSE_MODE_SWITCHER
Definition: keyb.h:51
DELETE_ENTRY
@ DELETE_ENTRY
Definition: keyb.h:97
monitor_active
int monitor_active(workarea *mon)
Definition: xcb.c:681
CUSTOM_7
@ CUSTOM_7
Definition: keyb.h:115
WL_CENTER
@ WL_CENTER
Definition: rofi-types.h:160
Settings::menu_font
char * menu_font
Definition: settings.h:69
listview_get_selected
unsigned int listview_get_selected(listview *lv)
Definition: listview.c:403
widget_queue_redraw
void widget_queue_redraw(widget *wid)
Definition: widget.c:432
RofiViewState::mesg_tb
textbox * mesg_tb
Definition: view-internal.h:70
RofiViewState::list_view
listview * list_view
Definition: view-internal.h:64
MENU_ENTRY_DELETE
@ MENU_ENTRY_DELETE
Definition: mode.h:77
RofiViewState::prev_action
KeyBindingAction prev_action
Definition: view-internal.h:83
textbox::text
char * text
Definition: textbox.h:55
MOUSE_DCLICK_DOWN
@ MOUSE_DCLICK_DOWN
Definition: keyb.h:171
rofi_view_temp_configure_notify
void rofi_view_temp_configure_notify(RofiViewState *state, xcb_configure_notify_event_t *xce)
Definition: view.c:1440
TICK_N
#define TICK_N(a)
Definition: timings.h:68
icon_create
icon * icon_create(widget *parent, const char *name)
Definition: icon.c:139
CUSTOM_15
@ CUSTOM_15
Definition: keyb.h:123
RofiViewState::num_lines
unsigned int num_lines
Definition: view-internal.h:77
mode_preprocess_input
char * mode_preprocess_input(Mode *mode, const char *input)
Definition: mode.c:157
SCREENSHOT
@ SCREENSHOT
Definition: keyb.h:128
view-internal.h
rofi_view_calculate_height
static int rofi_view_calculate_height(RofiViewState *state)
Definition: view.c:1488
thread_state_view
struct _thread_state_view thread_state_view
visual
xcb_visualtype_t * visual
Definition: xcb.c:93
rofi_view_finalize
void rofi_view_finalize(RofiViewState *state)
Definition: view.c:1126
window_set_atom_prop
void window_set_atom_prop(xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count)
Definition: xcb.c:178
CUSTOM_3
@ CUSTOM_3
Definition: keyb.h:111
WL_WEST
@ WL_WEST
Definition: rofi-types.h:168
RofiViewState::refilter
int refilter
Definition: view-internal.h:53
RofiViewState::y
int y
Definition: view-internal.h:120
WL_SOUTH_EAST
@ WL_SOUTH_EAST
Definition: rofi-types.h:174
x11_helper_get_bg_surface
cairo_surface_t * x11_helper_get_bg_surface(void)
Definition: xcb.c:141
rofi_expand_path
char * rofi_expand_path(const char *input)
Definition: helper.c:658
rofi_theme_get_string
const char * rofi_theme_get_string(const widget *widget, const char *property, const char *def)
Definition: theme.c:634
widget_motion_notify
gboolean widget_motion_notify(widget *wid, gint x, gint y)
Definition: widget.c:488
CUSTOM_19
@ CUSTOM_19
Definition: keyb.h:127
rofi_view_restart
void rofi_view_restart(RofiViewState *state)
Definition: view.c:441
rofi_view_update_prompt
static void rofi_view_update_prompt(RofiViewState *state)
Definition: view.c:244
URGENT
@ URGENT
Definition: textbox.h:99
rofi_view_get_window
xcb_window_t rofi_view_get_window(void)
Definition: view.c:1934
TB_MARKUP
@ TB_MARKUP
Definition: textbox.h:85
PASTE_PRIMARY
@ PASTE_PRIMARY
Definition: keyb.h:61
widget_disable
void widget_disable(widget *widget)
Definition: widget.c:133
SCOPE_MOUSE_EDITBOX
@ SCOPE_MOUSE_EDITBOX
Definition: keyb.h:49
rofi_mode
Definition: mode-private.h:152
rofi.h
RofiViewState::selected_line
unsigned int selected_line
Definition: view-internal.h:92
__rofi_view_state_create
static RofiViewState * __rofi_view_state_create(void)
Definition: view.c:548
SELECT_ELEMENT_3
@ SELECT_ELEMENT_3
Definition: keyb.h:133
WL_SOUTH
@ WL_SOUTH
Definition: rofi-types.h:166
CUSTOM_14
@ CUSTOM_14
Definition: keyb.h:122
TextboxFlags
TextboxFlags
Definition: textbox.h:81
rofi_view_temp_click_to_exit
void rofi_view_temp_click_to_exit(RofiViewState *state, xcb_window_t target)
Definition: view.c:1471
idle_timeout
guint idle_timeout
Definition: view.c:114
_listview
Definition: listview.c:62
RofiViewState::modi
textbox ** modi
Definition: view-internal.h:103
RofiViewState::menu_flags
MenuFlags menu_flags
Definition: view-internal.h:105
x11_helper_get_screenshot_surface
cairo_surface_t * x11_helper_get_screenshot_surface(void)
Definition: xcb.c:106
MENU_PASSWORD
@ MENU_PASSWORD
Definition: view.h:48
RofiViewState::mouse
struct RofiViewState::@4 mouse
textbox_sidebar_modi_trigger_action
static WidgetTriggerActionResult textbox_sidebar_modi_trigger_action(widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data)
Definition: view.c:1505
ROW_SELECT
@ ROW_SELECT
Definition: keyb.h:107
levenshtein
unsigned int levenshtein(const char *needle, const glong needlelen, const char *haystack, const glong haystacklen)
Definition: helper.c:691
xcb.h
_box
Definition: box.c:42
RofiViewState::width
int width
Definition: view-internal.h:114
listview_set_multi_select
void listview_set_multi_select(listview *lv, gboolean enable)
Definition: listview.c:796
MOVE_FRONT
@ MOVE_FRONT
Definition: keyb.h:67
rofi_get_num_enabled_modi
unsigned int rofi_get_num_enabled_modi(void)
Definition: rofi.c:129
listview_nav_page_next
void listview_nav_page_next(listview *lv)
Definition: listview.c:725
TOGGLE_CASE_SENSITIVITY
@ TOGGLE_CASE_SENSITIVITY
Definition: keyb.h:96
textbox_get_pango_attributes
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:289
_thread_state_view::state
RofiViewState * state
Definition: view.c:569
rofi_view_calculate_window_width
static void rofi_view_calculate_window_width(RofiViewState *state)
Definition: view.c:835
WL_NORTH
@ WL_NORTH
Definition: rofi-types.h:162
_thread_state_view::cond
GCond * cond
Definition: view.c:562
container_add
void container_add(container *container, widget *child)
Definition: container.c:72
MENU_CUSTOM_ACTION
@ MENU_CUSTOM_ACTION
Definition: mode.h:83
edit_pixmap
xcb_pixmap_t edit_pixmap
Definition: view.c:100
RofiViewState::prompt
textbox * prompt
Definition: view-internal.h:57
mode_get_display_name
const char * mode_get_display_name(const Mode *mode)
Definition: mode.c:143
_xcb_stuff::connection
xcb_connection_t * connection
Definition: xcb-internal.h:47
Settings::dpi
int dpi
Definition: settings.h:162
TOGGLE_SORT
@ TOGGLE_SORT
Definition: keyb.h:130
WIDGET_TYPE_EDITBOX
@ WIDGET_TYPE_EDITBOX
Definition: widget.h:65
display.h
WIDGET_TYPE_MODE_SWITCHER
@ WIDGET_TYPE_MODE_SWITCHER
Definition: widget.h:69
MODE_NEXT
@ MODE_NEXT
Definition: keyb.h:94
_thread_state_view::count
unsigned int count
Definition: view.c:575
listview_set_fixed_num_lines
void listview_set_fixed_num_lines(listview *lv)
Definition: listview.c:830
MENU_CUSTOM_INPUT
@ MENU_CUSTOM_INPUT
Definition: mode.h:75
_rofi_view_reload_row
static void _rofi_view_reload_row(RofiViewState *state)
Definition: view.c:1014
MENU_NORMAL_WINDOW
@ MENU_NORMAL_WINDOW
Definition: view.h:50
rofi_view_refilter
static void rofi_view_refilter(RofiViewState *state)
Definition: view.c:1025
RofiViewState::reload
int reload
Definition: view-internal.h:109
lev_sort
static int lev_sort(const void *p1, const void *p2, void *arg)
Definition: view.c:165
CUSTOM_2
@ CUSTOM_2
Definition: keyb.h:110
netatoms
xcb_atom_t netatoms[NUM_NETATOMS]
Definition: xcb.c:99
TB_WRAP
@ TB_WRAP
Definition: textbox.h:86
main_window
xcb_window_t main_window
Definition: view.c:94
rofi_view_update
void rofi_view_update(RofiViewState *state, gboolean qr)
Definition: view.c:975
filter_elements
static void filter_elements(thread_state *ts, G_GNUC_UNUSED gpointer user_data)
Definition: view.c:594
gc
xcb_gcontext_t gc
Definition: view.c:98
rofi_view_nav_row_tab
static void rofi_view_nav_row_tab(RofiViewState *state)
Definition: view.c:864
widget_trigger_action
WidgetTriggerActionResult widget_trigger_action(widget *wid, guint action, gint x, gint y)
Definition: widget.c:471
ACCEPT_CUSTOM
@ ACCEPT_CUSTOM
Definition: keyb.h:93
widget_enable
void widget_enable(widget *widget)
Definition: widget.c:124
Settings::auto_select
unsigned int auto_select
Definition: settings.h:136
MENU_NEXT
@ MENU_NEXT
Definition: mode.h:73
count
unsigned long long count
Definition: view.c:116
RofiViewState::finalize
void(* finalize)(struct RofiViewState *state)
Definition: view-internal.h:111
display_early_cleanup
void display_early_cleanup(void)
Definition: xcb.c:1327
Settings::x_offset
int x_offset
Definition: settings.h:106
TextBoxFontType
TextBoxFontType
Definition: textbox.h:95
listview_set_max_lines
void listview_set_max_lines(listview *lv, unsigned int max_lines)
Definition: listview.c:816
textbox_set_pango_attributes
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition: textbox.c:296
CUSTOM_8
@ CUSTOM_8
Definition: keyb.h:116
widget_draw
void widget_draw(widget *widget, cairo_t *d)
Definition: widget.c:142
SELECT_ELEMENT_2
@ SELECT_ELEMENT_2
Definition: keyb.h:132
RofiViewState::text
textbox * text
Definition: view-internal.h:59
rofi_view_hide
void rofi_view_hide(void)
Definition: view.c:1806
RofiViewState::line_map
unsigned int * line_map
Definition: view-internal.h:75
view.h
rofi_theme_get_highlight
RofiHighlightColorStyle rofi_theme_get_highlight(widget *widget, const char *property, RofiHighlightColorStyle th)
Definition: theme.c:748
listview_get_fixed_num_lines
gboolean listview_get_fixed_num_lines(listview *lv)
Definition: listview.c:823
map
xcb_colormap_t map
Definition: xcb.c:94
Settings::fullscreen
unsigned int fullscreen
Definition: settings.h:158
listview_nav_left
void listview_nav_left(listview *lv)
Definition: listview.c:623
SORT_NORMAL
@ SORT_NORMAL
Definition: settings.h:48
textbox
Definition: textbox.h:51
MENU_ERROR_DIALOG
@ MENU_ERROR_DIALOG
Definition: view.h:52
WL_NORTH_WEST
@ WL_NORTH_WEST
Definition: rofi-types.h:170
MENU_CANCEL
@ MENU_CANCEL
Definition: mode.h:71
RofiViewState::sidebar_bar
box * sidebar_bar
Definition: view-internal.h:99
Settings::fake_background
char * fake_background
Definition: settings.h:168
xcb_stuff_get_root_window
xcb_window_t xcb_stuff_get_root_window(void)
Definition: xcb.c:1322
update_callback
static void update_callback(textbox *t, unsigned int index, void *udata, TextBoxFontType type, gboolean full)
Definition: view.c:931
helper-theme.h
mode_get_display_value
char * mode_get_display_value(const Mode *mode, unsigned int selected_line, int *state, GList **attribute_list, int get_entry)
Definition: mode.c:63
TICK
#define TICK()
Definition: timings.h:63
RofiViewState::x
int x
Definition: view-internal.h:118
textbox_set_pango_context
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:840
rofi_view_create
RofiViewState * rofi_view_create(Mode *sw, const char *input, MenuFlags menu_flags, void(*finalize)(RofiViewState *))
Definition: view.c:1693
PAGE_PREV
@ PAGE_PREV
Definition: keyb.h:103
Settings::menu_lines
unsigned int menu_lines
Definition: settings.h:65
Settings::case_sensitive
unsigned int case_sensitive
Definition: settings.h:126
Settings::y_offset
int y_offset
Definition: settings.h:104
rofi_view_nav_last
static void rofi_view_nav_last(RofiViewState *state)
Definition: view.c:921
RofiViewState::mesg_box
container * mesg_box
Definition: view-internal.h:68
CUSTOM_18
@ CUSTOM_18
Definition: keyb.h:126
rofi_view_get_user_input
const char * rofi_view_get_user_input(const RofiViewState *state)
Definition: view.c:535
color_reset
#define color_reset
Definition: rofi.h:90
rofi_view_workers_finalize
void rofi_view_workers_finalize(void)
Definition: view.c:1879
SCOPE_MOUSE_LISTVIEW
@ SCOPE_MOUSE_LISTVIEW
Definition: keyb.h:45
widget_get_desired_height
int widget_get_desired_height(widget *wid)
Definition: widget.c:567
mode_get_message
char * mode_get_message(const Mode *mode)
Definition: mode.c:164
rofi_view_cleanup
void rofi_view_cleanup()
Definition: view.c:1814
SELECT_ELEMENT_8
@ SELECT_ELEMENT_8
Definition: keyb.h:138
RofiViewState::overlay
textbox * overlay
Definition: view-internal.h:66
MOVE_WORD_BACK
@ MOVE_WORD_BACK
Definition: keyb.h:71
CUSTOM_16
@ CUSTOM_16
Definition: keyb.h:124
_thread_state_view::stop
unsigned int stop
Definition: view.c:573
MENU_LOWER_MASK
@ MENU_LOWER_MASK
Definition: mode.h:85
_thread_state_view::acount
unsigned int * acount
Definition: view.c:566
rofi_view_listview_mouse_activated_cb
static void rofi_view_listview_mouse_activated_cb(listview *lv, gboolean custom, void *udata)
Definition: view.c:1534
helper.h
xcb-internal.h
rofi_view_get_completed
unsigned int rofi_view_get_completed(const RofiViewState *state)
Definition: view.c:530
rofi_view_trigger_action
gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope, guint action)
Definition: view.c:1358
_thread_state::callback
void(* callback)(struct _thread_state *t, gpointer data)
Definition: rofi-types.h:246
ROFI_HL_BOLD
@ ROFI_HL_BOLD
Definition: rofi-types.h:52
MOVE_CHAR_FORWARD
@ MOVE_CHAR_FORWARD
Definition: keyb.h:77
REMOVE_CHAR_FORWARD
@ REMOVE_CHAR_FORWARD
Definition: keyb.h:83
process_result
void process_result(RofiViewState *state)
Definition: rofi.c:199
widget_resize
void widget_resize(widget *widget, short w, short h)
Definition: widget.c:84
RofiViewState::case_indicator
textbox * case_indicator
Definition: view-internal.h:61
RofiViewState
Definition: view-internal.h:48
widget_need_redraw
gboolean widget_need_redraw(widget *wid)
Definition: widget.c:445
WIDGET_TRIGGER_ACTION_RESULT_HANDLED
@ WIDGET_TRIGGER_ACTION_RESULT_HANDLED
Definition: widget.h:82
config
Settings config
Settings::scroll_method
unsigned int scroll_method
Definition: settings.h:165
WIDGET_TRIGGER_ACTION_RESULT_IGNORED
@ WIDGET_TRIGGER_ACTION_RESULT_IGNORED
Definition: widget.h:80
RofiViewState::filtered_lines
unsigned int filtered_lines
Definition: view-internal.h:80
RofiHighlightColorStyle
Definition: rofi-types.h:141
ROFI_ORIENTATION_HORIZONTAL
@ ROFI_ORIENTATION_HORIZONTAL
Definition: rofi-types.h:108
listview_set_selected
void listview_set_selected(listview *lv, unsigned int selected)
Definition: listview.c:411
color_green
#define color_green
Definition: rofi.h:96
repaint_source
guint repaint_source
Definition: view.c:118
TB_EDITABLE
@ TB_EDITABLE
Definition: textbox.h:84
Settings::sort
unsigned int sort
Definition: settings.h:114
ROW_UP
@ ROW_UP
Definition: keyb.h:100
fullscreen
gboolean fullscreen
Definition: view.c:120
listview_nav_down
void listview_nav_down(listview *lv)
Definition: listview.c:610
rofi_view_reload_idle
static gboolean rofi_view_reload_idle(G_GNUC_UNUSED gpointer data)
Definition: view.c:414
widget_padding_get_padding_width
int widget_padding_get_padding_width(const widget *wid)
Definition: widget.c:559
rofi_view_setup_fake_transparency
static void rofi_view_setup_fake_transparency(const char *const fake_background)
Definition: view.c:628
rofi_view_set_selected_line
void rofi_view_set_selected_line(RofiViewState *state, unsigned int selected_line)
Definition: view.c:475
_widget
Definition: widget-internal.h:36
WidgetTriggerActionResult
WidgetTriggerActionResult
Definition: widget.h:78
Settings::threads
unsigned int threads
Definition: settings.h:164
ACCEPT_ALT
@ ACCEPT_ALT
Definition: keyb.h:92
ROW_FIRST
@ ROW_FIRST
Definition: keyb.h:105
rofi_view_set_overlay
void rofi_view_set_overlay(RofiViewState *state, const char *text)
Definition: view.c:1891
REMOVE_CHAR_BACK
@ REMOVE_CHAR_BACK
Definition: keyb.h:85
RofiViewState::mouse_seen
int mouse_seen
Definition: view-internal.h:107
WIDGET_TYPE_TEXTBOX_TEXT
@ WIDGET_TYPE_TEXTBOX_TEXT
Definition: widget.h:71
rofi_view_window_update_size
static void rofi_view_window_update_size(RofiViewState *state)
Definition: view.c:375
rofi_view_reload
void rofi_view_reload(void)
Definition: view.c:425
CUSTOM_4
@ CUSTOM_4
Definition: keyb.h:112
rofi_view_switch_mode
void rofi_view_switch_mode(RofiViewState *state, Mode *mode)
Definition: view.c:1914
textbox_create
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition: textbox.c:166
edit_draw
cairo_t * edit_draw
Definition: view.c:104