mirror of
https://github.com/lbonn/rofi
synced 2025-03-01 05:37:08 +00:00
Put most of view implementation in common
This commit is contained in:
parent
8e53896bbd
commit
17b4265a5f
11 changed files with 1423 additions and 2235 deletions
50
include/display-internal.h
Normal file
50
include/display-internal.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* rofi
|
||||
*
|
||||
* MIT/X11 License
|
||||
* Copyright © 2013-2020 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ROFI_DISPLAY_INTERNAL_H
|
||||
#define ROFI_DISPLAY_INTERNAL_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "helper.h"
|
||||
#include "nkutils-bindings.h"
|
||||
|
||||
struct _workarea;
|
||||
struct _view_proxy;
|
||||
|
||||
typedef struct _display_proxy {
|
||||
gboolean (*setup) ( GMainLoop *main_loop, NkBindings *bindings );
|
||||
gboolean (*late_setup) ( void );
|
||||
void (*early_cleanup) ( void );
|
||||
void (*cleanup) ( void );
|
||||
void (*dump_monitor_layout) ( void );
|
||||
void (*startup_notification) ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data );
|
||||
int (*monitor_active) ( struct _workarea *mon );
|
||||
|
||||
const struct _view_proxy* (*view) ( void );
|
||||
} display_proxy;
|
||||
|
||||
#endif
|
|
@ -56,27 +56,15 @@ typedef struct _workarea
|
|||
struct _workarea *next;
|
||||
} workarea;
|
||||
|
||||
struct _view_proxy;
|
||||
|
||||
typedef struct _display_proxy {
|
||||
gboolean (*setup) ( GMainLoop *main_loop, NkBindings *bindings );
|
||||
gboolean (*late_setup) ( void );
|
||||
void (*early_cleanup) ( void );
|
||||
void (*cleanup) ( void );
|
||||
void (*dump_monitor_layout) ( void );
|
||||
void (*startup_notification) ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data );
|
||||
int (*monitor_active) ( workarea *mon );
|
||||
|
||||
const struct _view_proxy* (*view) ( void );
|
||||
} display_proxy;
|
||||
struct _display_proxy;
|
||||
|
||||
/* Implementations */
|
||||
extern display_proxy * const xcb_proxy;
|
||||
extern struct _display_proxy * const xcb_proxy;
|
||||
#ifdef ENABLE_WAYLAND
|
||||
extern display_proxy * const wayland_proxy;
|
||||
extern struct _display_proxy * const wayland_proxy;
|
||||
#endif
|
||||
|
||||
void display_init( const display_proxy *disp_in );
|
||||
void display_init( const struct _display_proxy *disp_in );
|
||||
|
||||
/**
|
||||
* @param mon workarea to be filled in.
|
||||
|
|
|
@ -151,11 +151,54 @@ struct RofiViewState
|
|||
};
|
||||
/** @} */
|
||||
|
||||
void rofi_view_reload_message_bar ( struct RofiViewState *state );
|
||||
typedef struct _view_proxy {
|
||||
void (*update) ( RofiViewState *state, gboolean qr );
|
||||
void (*maybe_update) ( RofiViewState *state );
|
||||
void (*temp_configure_notify) ( RofiViewState *state, xcb_configure_notify_event_t *xce );
|
||||
void (*temp_click_to_exit) ( RofiViewState *state, xcb_window_t target );
|
||||
void (*frame_callback) ( void );
|
||||
|
||||
void (*queue_redraw) ( void );
|
||||
|
||||
void (*set_window_title) ( const char * title );
|
||||
void (*calculate_window_position) ( RofiViewState *state );
|
||||
void (*calculate_window_width) ( RofiViewState *state );
|
||||
int (*calculate_window_height) ( RofiViewState *state );
|
||||
void (*window_update_size) ( RofiViewState *state );
|
||||
|
||||
void (*cleanup) ( void );
|
||||
void (*hide) ( void );
|
||||
void (*reload) ( void );
|
||||
void (*__create_window) ( MenuFlags menu_flags );
|
||||
xcb_window_t (*get_window) ( void );
|
||||
|
||||
void (*get_current_monitor) ( int *width, int *height );
|
||||
void (*capture_screenshot) ( void );
|
||||
|
||||
void (*set_size) ( RofiViewState * state, gint width, gint height );
|
||||
void (*get_size) ( RofiViewState * state, gint *width, gint *height );
|
||||
} view_proxy;
|
||||
|
||||
/**
|
||||
* Structure holding cached state.
|
||||
*/
|
||||
struct _rofi_view_cache_state
|
||||
{
|
||||
/** main x11 windows */
|
||||
xcb_window_t main_window;
|
||||
/** Main flags */
|
||||
MenuFlags flags;
|
||||
/** List of stacked views */
|
||||
GQueue views;
|
||||
};
|
||||
extern struct _rofi_view_cache_state CacheState;
|
||||
|
||||
void rofi_view_update ( struct RofiViewState *state, gboolean qr );
|
||||
void rofi_view_calculate_window_position ( struct RofiViewState *state );
|
||||
void rofi_view_calculate_window_width ( struct RofiViewState *state );
|
||||
int rofi_view_calculate_window_height ( struct RofiViewState *state );
|
||||
void rofi_view_window_update_size ( struct RofiViewState * state );
|
||||
void rofi_view_call_thread ( gpointer data, gpointer user_data );
|
||||
void rofi_view_refilter ( struct RofiViewState *state );
|
||||
void rofi_view_set_window_title ( const char * title );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -315,50 +315,17 @@ void rofi_view_set_size ( RofiViewState * state, gint width, gint height );
|
|||
|
||||
void rofi_view_get_size ( RofiViewState * state, gint *width, gint *height );
|
||||
|
||||
typedef struct _view_proxy {
|
||||
RofiViewState* (*create) ( Mode *sw, const char *input, MenuFlags menu_flags, void ( *finalize )( RofiViewState * ) );
|
||||
void (*handle_text) ( RofiViewState *state, char *text );
|
||||
void (*maybe_update) ( RofiViewState *state );
|
||||
void (*temp_configure_notify) ( RofiViewState *state, xcb_configure_notify_event_t *xce );
|
||||
void (*temp_click_to_exit) ( RofiViewState *state, xcb_window_t target );
|
||||
void (*frame_callback) ( void );
|
||||
const char * (*get_user_input) ( const RofiViewState *state );
|
||||
void (*set_selected_line) ( RofiViewState *state, unsigned int selected_line );
|
||||
gboolean (*trigger_action) ( RofiViewState *state, BindingsScope scope, guint action );
|
||||
void (*free) ( RofiViewState *state );
|
||||
RofiViewState * (*get_active) ( void );
|
||||
void (*set_active) ( RofiViewState *state );
|
||||
int (*error_dialog) ( const char *msg, int markup );
|
||||
void (*queue_redraw) ( void );
|
||||
void (*calculate_window_position) ( RofiViewState *state );
|
||||
int (*calculate_window_height) ( RofiViewState *state );
|
||||
void (*window_update_size) ( RofiViewState *state );
|
||||
void rofi_view_set_window_tilte ( const char * title );
|
||||
|
||||
void (*cleanup) ( void );
|
||||
Mode * (*get_mode) ( RofiViewState *state );
|
||||
void (*hide) ( void );
|
||||
void (*reload) ( void );
|
||||
void (*switch_mode) ( RofiViewState *state, Mode *mode );
|
||||
void (*set_overlay) ( RofiViewState *state, const char *text );
|
||||
void (*clear_input) ( RofiViewState *state );
|
||||
void (*__create_window) ( MenuFlags menu_flags );
|
||||
xcb_window_t (*get_window) ( void );
|
||||
void (*workers_initialize) ( void );
|
||||
void (*workers_finalize) ( void );
|
||||
void (*get_current_monitor) ( int *width, int *height );
|
||||
void (*capture_screenshot) ( void );
|
||||
|
||||
void (*set_size) ( RofiViewState * state, gint width, gint height );
|
||||
void (*get_size) ( RofiViewState * state, gint *width, gint *height );
|
||||
} view_proxy;
|
||||
|
||||
struct _view_proxy;
|
||||
|
||||
/* Implementations */
|
||||
extern const view_proxy *xcb_view_proxy;
|
||||
extern const struct _view_proxy *xcb_view_proxy;
|
||||
#ifdef ENABLE_WAYLAND
|
||||
extern const view_proxy *wayland_view_proxy;
|
||||
extern const struct _view_proxy *wayland_view_proxy;
|
||||
#endif
|
||||
|
||||
void view_init( const view_proxy *view_in );
|
||||
void view_init( const struct _view_proxy *view_in );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include <glib.h>
|
||||
#include <xcb/xkb.h>
|
||||
#include "keyb.h"
|
||||
|
||||
#include "display.h"
|
||||
#include "display-internal.h"
|
||||
|
||||
#include "view.h"
|
||||
#include "view-internal.h"
|
||||
|
|
|
@ -858,7 +858,7 @@ int main ( int argc, char *argv[] )
|
|||
|
||||
TICK_N ( "Setup Locale" );
|
||||
|
||||
const display_proxy *proxy = xcb_proxy;
|
||||
const struct _display_proxy *proxy = xcb_proxy;
|
||||
config.backend = DISPLAY_XCB;
|
||||
#ifdef ENABLE_WAYLAND
|
||||
if ( find_arg ( "-x11" ) < 0 ) {
|
||||
|
|
1281
source/view.c
1281
source/view.c
File diff suppressed because it is too large
Load diff
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "wayland-internal.h"
|
||||
#include "display.h"
|
||||
#include "display-internal.h"
|
||||
|
||||
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -61,6 +61,7 @@
|
|||
#include "settings.h"
|
||||
#include "helper.h"
|
||||
#include "timings.h"
|
||||
#include "display-internal.h"
|
||||
|
||||
#include <rofi.h>
|
||||
|
||||
|
|
1243
source/xcb/view.c
1243
source/xcb/view.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue