mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
Run indenter
This commit is contained in:
parent
6fb94876ca
commit
a4fd907fe8
11 changed files with 280 additions and 282 deletions
|
@ -137,7 +137,7 @@ void remove_pid_file ( int fd );
|
||||||
*
|
*
|
||||||
* This functions exits the program with 1 when it finds an invalid configuration.
|
* This functions exits the program with 1 when it finds an invalid configuration.
|
||||||
*/
|
*/
|
||||||
int config_sanity_check ( xcb_connection_t *xcb_connection);
|
int config_sanity_check ( xcb_connection_t *xcb_connection );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arg string to parse.
|
* @param arg string to parse.
|
||||||
|
|
|
@ -207,9 +207,8 @@ static void x11_cache_free ( void )
|
||||||
*/
|
*/
|
||||||
static xcb_get_window_attributes_reply_t * window_get_attributes ( xcb_connection_t *xcb_connection, xcb_window_t w )
|
static xcb_get_window_attributes_reply_t * window_get_attributes ( xcb_connection_t *xcb_connection, xcb_window_t w )
|
||||||
{
|
{
|
||||||
|
xcb_get_window_attributes_cookie_t c = xcb_get_window_attributes ( xcb_connection, w );
|
||||||
xcb_get_window_attributes_cookie_t c = xcb_get_window_attributes(xcb_connection, w);
|
xcb_get_window_attributes_reply_t *r = xcb_get_window_attributes_reply ( xcb_connection, c, NULL );
|
||||||
xcb_get_window_attributes_reply_t *r = xcb_get_window_attributes_reply ( xcb_connection, c, NULL);
|
|
||||||
if ( r ) {
|
if ( r ) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -261,38 +260,37 @@ static client* window_client ( xcb_connection_t *xcb_connection, xcb_window_t wi
|
||||||
// copy xattr so we don't have to care when stuff is freed
|
// copy xattr so we don't have to care when stuff is freed
|
||||||
memmove ( &c->xattr, attr, sizeof ( xcb_get_window_attributes_reply_t ) );
|
memmove ( &c->xattr, attr, sizeof ( xcb_get_window_attributes_reply_t ) );
|
||||||
|
|
||||||
|
xcb_get_property_cookie_t cky = xcb_ewmh_get_wm_state ( &xcb_ewmh, win );
|
||||||
xcb_get_property_cookie_t cky = xcb_ewmh_get_wm_state(&xcb_ewmh, win);
|
|
||||||
xcb_ewmh_get_atoms_reply_t states;
|
xcb_ewmh_get_atoms_reply_t states;
|
||||||
if(xcb_ewmh_get_wm_state_reply( &xcb_ewmh, cky, &states, NULL)){
|
if ( xcb_ewmh_get_wm_state_reply ( &xcb_ewmh, cky, &states, NULL ) ) {
|
||||||
c->states = MIN(CLIENTSTATE,states.atoms_len);
|
c->states = MIN ( CLIENTSTATE, states.atoms_len );
|
||||||
memcpy(c->state, states.atoms, MIN(CLIENTSTATE, states.atoms_len));
|
memcpy ( c->state, states.atoms, MIN ( CLIENTSTATE, states.atoms_len ) );
|
||||||
xcb_ewmh_get_atoms_reply_wipe(&states);
|
xcb_ewmh_get_atoms_reply_wipe ( &states );
|
||||||
}
|
}
|
||||||
cky = xcb_ewmh_get_wm_window_type(&xcb_ewmh, win);
|
cky = xcb_ewmh_get_wm_window_type ( &xcb_ewmh, win );
|
||||||
if(xcb_ewmh_get_wm_window_type_reply( &xcb_ewmh, cky, &states, NULL)){
|
if ( xcb_ewmh_get_wm_window_type_reply ( &xcb_ewmh, cky, &states, NULL ) ) {
|
||||||
c->window_types= MIN(CLIENTWINDOWTYPE,states.atoms_len);
|
c->window_types = MIN ( CLIENTWINDOWTYPE, states.atoms_len );
|
||||||
memcpy(c->window_type, states.atoms, MIN(CLIENTWINDOWTYPE, states.atoms_len));
|
memcpy ( c->window_type, states.atoms, MIN ( CLIENTWINDOWTYPE, states.atoms_len ) );
|
||||||
xcb_ewmh_get_atoms_reply_wipe(&states);
|
xcb_ewmh_get_atoms_reply_wipe ( &states );
|
||||||
}
|
}
|
||||||
|
|
||||||
c->title = window_get_text_prop ( xcb_connection, c->window, xcb_ewmh._NET_WM_NAME );
|
c->title = window_get_text_prop ( xcb_connection, c->window, xcb_ewmh._NET_WM_NAME );
|
||||||
if ( c->title == NULL ) {
|
if ( c->title == NULL ) {
|
||||||
c->title = window_get_text_prop ( xcb_connection, c->window, XCB_ATOM_WM_NAME);
|
c->title = window_get_text_prop ( xcb_connection, c->window, XCB_ATOM_WM_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
c->role = window_get_text_prop ( xcb_connection, c->window, netatoms[WM_WINDOW_ROLE] );
|
c->role = window_get_text_prop ( xcb_connection, c->window, netatoms[WM_WINDOW_ROLE] );
|
||||||
|
|
||||||
cky = xcb_icccm_get_wm_class ( xcb_connection, c->window );
|
cky = xcb_icccm_get_wm_class ( xcb_connection, c->window );
|
||||||
xcb_icccm_get_wm_class_reply_t wcr;
|
xcb_icccm_get_wm_class_reply_t wcr;
|
||||||
if ( xcb_icccm_get_wm_class_reply (xcb_connection, cky, &wcr, NULL)) {
|
if ( xcb_icccm_get_wm_class_reply ( xcb_connection, cky, &wcr, NULL ) ) {
|
||||||
c->class = g_strdup(wcr.class_name);
|
c->class = g_strdup ( wcr.class_name );
|
||||||
xcb_icccm_get_wm_class_reply_wipe (&wcr);
|
xcb_icccm_get_wm_class_reply_wipe ( &wcr );
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_get_property_cookie_t cc = xcb_icccm_get_wm_hints ( xcb_connection, c->window);
|
xcb_get_property_cookie_t cc = xcb_icccm_get_wm_hints ( xcb_connection, c->window );
|
||||||
xcb_icccm_wm_hints_t r;
|
xcb_icccm_wm_hints_t r;
|
||||||
if (xcb_icccm_get_wm_hints_reply ( xcb_connection, cc, &r, NULL)){
|
if ( xcb_icccm_get_wm_hints_reply ( xcb_connection, cc, &r, NULL ) ) {
|
||||||
c->hint_flags = r.flags;
|
c->hint_flags = r.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,31 +373,31 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
x11_cache_create ();
|
x11_cache_create ();
|
||||||
// Check for i3
|
// Check for i3
|
||||||
pd->config_i3_mode = i3_support_initialize ( xcb_connection );
|
pd->config_i3_mode = i3_support_initialize ( xcb_connection );
|
||||||
xcb_get_property_cookie_t c =xcb_ewmh_get_active_window( &xcb_ewmh, xcb_screen_nbr);
|
xcb_get_property_cookie_t c = xcb_ewmh_get_active_window ( &xcb_ewmh, xcb_screen_nbr );
|
||||||
if ( !xcb_ewmh_get_active_window_reply ( &xcb_ewmh, c, &curr_win_id, NULL )) {
|
if ( !xcb_ewmh_get_active_window_reply ( &xcb_ewmh, c, &curr_win_id, NULL ) ) {
|
||||||
curr_win_id = 0;
|
curr_win_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current desktop.
|
// Get the current desktop.
|
||||||
unsigned int current_desktop = 0;
|
unsigned int current_desktop = 0;
|
||||||
c = xcb_ewmh_get_current_desktop( &xcb_ewmh, xcb_screen_nbr);
|
c = xcb_ewmh_get_current_desktop ( &xcb_ewmh, xcb_screen_nbr );
|
||||||
if ( !xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh, c, ¤t_desktop, NULL )){
|
if ( !xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh, c, ¤t_desktop, NULL ) ) {
|
||||||
current_desktop = 0;
|
current_desktop = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = xcb_ewmh_get_client_list_stacking ( &xcb_ewmh, 0);
|
c = xcb_ewmh_get_client_list_stacking ( &xcb_ewmh, 0 );
|
||||||
xcb_ewmh_get_windows_reply_t clients;
|
xcb_ewmh_get_windows_reply_t clients;
|
||||||
if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb_ewmh, c, &clients, NULL)){
|
if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb_ewmh, c, &clients, NULL ) ) {
|
||||||
nwins = MIN ( 100, clients.windows_len);
|
nwins = MIN ( 100, clients.windows_len );
|
||||||
memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
|
memcpy ( wins, clients.windows, nwins * sizeof ( xcb_window_t ) );
|
||||||
xcb_ewmh_get_windows_reply_wipe(&clients);
|
xcb_ewmh_get_windows_reply_wipe ( &clients );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c = xcb_ewmh_get_client_list ( &xcb_ewmh, xcb_screen_nbr);
|
c = xcb_ewmh_get_client_list ( &xcb_ewmh, xcb_screen_nbr );
|
||||||
if ( xcb_ewmh_get_client_list_reply ( &xcb_ewmh, c, &clients, NULL)) {
|
if ( xcb_ewmh_get_client_list_reply ( &xcb_ewmh, c, &clients, NULL ) ) {
|
||||||
nwins = MIN ( 100, clients.windows_len);
|
nwins = MIN ( 100, clients.windows_len );
|
||||||
memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
|
memcpy ( wins, clients.windows, nwins * sizeof ( xcb_window_t ) );
|
||||||
xcb_ewmh_get_windows_reply_wipe(&clients);
|
xcb_ewmh_get_windows_reply_wipe ( &clients );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( nwins > 0 ) {
|
if ( nwins > 0 ) {
|
||||||
|
@ -425,7 +423,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
if ( client_has_state ( c, xcb_ewmh._NET_WM_STATE_DEMANDS_ATTENTION ) ) {
|
if ( client_has_state ( c, xcb_ewmh._NET_WM_STATE_DEMANDS_ATTENTION ) ) {
|
||||||
c->demands = TRUE;
|
c->demands = TRUE;
|
||||||
}
|
}
|
||||||
if ( ( c->hint_flags & XCB_ICCCM_WM_HINT_X_URGENCY ) != 0) {
|
if ( ( c->hint_flags & XCB_ICCCM_WM_HINT_X_URGENCY ) != 0 ) {
|
||||||
c->demands = TRUE;
|
c->demands = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,9 +435,9 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create pattern for printing the line.
|
// Create pattern for printing the line.
|
||||||
xcb_get_property_cookie_t c = xcb_ewmh_get_number_of_desktops( &xcb_ewmh, xcb_screen_nbr);
|
xcb_get_property_cookie_t c = xcb_ewmh_get_number_of_desktops ( &xcb_ewmh, xcb_screen_nbr );
|
||||||
if ( !xcb_ewmh_get_number_of_desktops_reply ( &xcb_ewmh, c, &desktops, NULL )){
|
if ( !xcb_ewmh_get_number_of_desktops_reply ( &xcb_ewmh, c, &desktops, NULL ) ) {
|
||||||
desktops= 1;
|
desktops = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pd->config_i3_mode ) {
|
if ( pd->config_i3_mode ) {
|
||||||
|
@ -469,21 +467,23 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
xcb_get_property_cookie_t cookie;
|
xcb_get_property_cookie_t cookie;
|
||||||
xcb_get_property_reply_t *r;
|
xcb_get_property_reply_t *r;
|
||||||
|
|
||||||
cookie = xcb_get_property(xcb_connection, 0, c->window, xcb_ewmh._NET_WM_DESKTOP, XCB_GET_PROPERTY, 0, sizeof(unsigned int));
|
cookie =
|
||||||
r = xcb_get_property_reply(xcb_connection, cookie, NULL);
|
xcb_get_property ( xcb_connection, 0, c->window, xcb_ewmh._NET_WM_DESKTOP, XCB_GET_PROPERTY, 0,
|
||||||
if ( r&& r->type == XCB_ATOM_INTEGER){
|
sizeof ( unsigned int ) );
|
||||||
wmdesktop = *((int *)xcb_get_property_value(r));
|
r = xcb_get_property_reply ( xcb_connection, cookie, NULL );
|
||||||
|
if ( r && r->type == XCB_ATOM_INTEGER ) {
|
||||||
|
wmdesktop = *( (int *) xcb_get_property_value ( r ) );
|
||||||
}
|
}
|
||||||
if ( r&&r->type != XCB_ATOM_INTEGER) {
|
if ( r && r->type != XCB_ATOM_INTEGER ) {
|
||||||
// Assume the client is on all desktops.
|
// Assume the client is on all desktops.
|
||||||
wmdesktop = 0xFFFFFFFF;
|
wmdesktop = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
else if ( cd && wmdesktop != current_desktop ) {
|
else if ( cd && wmdesktop != current_desktop ) {
|
||||||
g_free ( line );
|
g_free ( line );
|
||||||
free(r);
|
free ( r );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
free(r);
|
free ( r );
|
||||||
|
|
||||||
if ( wmdesktop < 0xFFFFFFFF ) {
|
if ( wmdesktop < 0xFFFFFFFF ) {
|
||||||
snprintf ( desktop, 5, "%d", (int) wmdesktop );
|
snprintf ( desktop, 5, "%d", (int) wmdesktop );
|
||||||
|
@ -539,9 +539,9 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
xcb_ewmh_request_change_active_window ( &xcb_ewmh, xcb_screen_nbr, rmpd->ids->array[selected_line],
|
xcb_ewmh_request_change_active_window ( &xcb_ewmh, xcb_screen_nbr, rmpd->ids->array[selected_line],
|
||||||
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER ,
|
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
|
||||||
XCB_CURRENT_TIME, XCB_WINDOW_NONE);
|
XCB_CURRENT_TIME, XCB_WINDOW_NONE );
|
||||||
xcb_flush(xcb_connection);
|
xcb_flush ( xcb_connection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retv;
|
return retv;
|
||||||
|
|
|
@ -511,7 +511,7 @@ void remove_pid_file ( int fd )
|
||||||
*
|
*
|
||||||
* This functions exits the program with 1 when it finds an invalid configuration.
|
* This functions exits the program with 1 when it finds an invalid configuration.
|
||||||
*/
|
*/
|
||||||
int config_sanity_check ( xcb_connection_t* xcb_connection)
|
int config_sanity_check ( xcb_connection_t* xcb_connection )
|
||||||
{
|
{
|
||||||
// If alternative row is not set, copy the normal background color.
|
// If alternative row is not set, copy the normal background color.
|
||||||
// Do this at the beginning as we might use it in the error dialog.
|
// Do this at the beginning as we might use it in the error dialog.
|
||||||
|
|
|
@ -119,7 +119,7 @@ int i3_support_initialize ( xcb_connection_t *xcb_connection )
|
||||||
i3_support_free_internals ();
|
i3_support_free_internals ();
|
||||||
|
|
||||||
// Get atom for I3_SOCKET_PATH
|
// Get atom for I3_SOCKET_PATH
|
||||||
i3_socket_path = window_get_text_prop ( xcb_connection, xcb_screen->root, netatoms[I3_SOCKET_PATH]);
|
i3_socket_path = window_get_text_prop ( xcb_connection, xcb_screen->root, netatoms[I3_SOCKET_PATH] );
|
||||||
// If we find it, go into i3 mode.
|
// If we find it, go into i3 mode.
|
||||||
return ( i3_socket_path != NULL ) ? TRUE : FALSE;
|
return ( i3_socket_path != NULL ) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,7 +324,7 @@ static void cleanup ()
|
||||||
sn_display_unref ( sndisplay );
|
sn_display_unref ( sndisplay );
|
||||||
sndisplay = NULL;
|
sndisplay = NULL;
|
||||||
}
|
}
|
||||||
xcb_disconnect( xcb_connection );
|
xcb_disconnect ( xcb_connection );
|
||||||
xcb_connection = NULL;
|
xcb_connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +473,6 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
|
static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
|
||||||
{
|
{
|
||||||
// Break out of loop.
|
// Break out of loop.
|
||||||
|
@ -494,7 +493,7 @@ static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, xcb_connection_t
|
||||||
exit ( EXIT_FAILURE );
|
exit ( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_flush(xdisplay);
|
xcb_flush ( xdisplay );
|
||||||
--error_trap_depth;
|
--error_trap_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +505,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
//
|
//
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if ( config_sanity_check ( xcb_connection) ) {
|
if ( config_sanity_check ( xcb_connection ) ) {
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
TICK_N ( "Config sanity check" );
|
TICK_N ( "Config sanity check" );
|
||||||
|
@ -634,14 +633,13 @@ int main ( int argc, char *argv[] )
|
||||||
|
|
||||||
xcb_screen = xcb_aux_get_screen ( xcb_connection, xcb_screen_nbr );
|
xcb_screen = xcb_aux_get_screen ( xcb_connection, xcb_screen_nbr );
|
||||||
|
|
||||||
xcb_intern_atom_cookie_t *ac = xcb_ewmh_init_atoms(xcb_connection, &xcb_ewmh);
|
xcb_intern_atom_cookie_t *ac = xcb_ewmh_init_atoms ( xcb_connection, &xcb_ewmh );
|
||||||
xcb_generic_error_t **errors = NULL;
|
xcb_generic_error_t **errors = NULL;
|
||||||
xcb_ewmh_init_atoms_replies(&xcb_ewmh, ac, errors);
|
xcb_ewmh_init_atoms_replies ( &xcb_ewmh, ac, errors );
|
||||||
if (errors){
|
if ( errors ) {
|
||||||
fprintf(stderr, "Failed to create EWMH atoms\n");
|
fprintf ( stderr, "Failed to create EWMH atoms\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( xkb_x11_setup_xkb_extension ( xcb_connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
if ( xkb_x11_setup_xkb_extension ( xcb_connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
||||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
|
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
|
||||||
fprintf ( stderr, "cannot setup XKB extension!\n" );
|
fprintf ( stderr, "cannot setup XKB extension!\n" );
|
||||||
|
@ -712,7 +710,7 @@ int main ( int argc, char *argv[] )
|
||||||
sndisplay = sn_xcb_display_new ( xcb_connection, error_trap_push, error_trap_pop );
|
sndisplay = sn_xcb_display_new ( xcb_connection, error_trap_push, error_trap_pop );
|
||||||
|
|
||||||
if ( sndisplay != NULL ) {
|
if ( sndisplay != NULL ) {
|
||||||
sncontext = sn_launchee_context_new_from_environment ( sndisplay, xcb_screen_nbr);
|
sncontext = sn_launchee_context_new_from_environment ( sndisplay, xcb_screen_nbr );
|
||||||
}
|
}
|
||||||
TICK_N ( "Startup Notification" );
|
TICK_N ( "Startup Notification" );
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,8 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ switch ( type )
|
else{
|
||||||
|
switch ( type )
|
||||||
{
|
{
|
||||||
case XCB_EXPOSE:
|
case XCB_EXPOSE:
|
||||||
state->update = TRUE;
|
state->update = TRUE;
|
||||||
|
@ -492,7 +493,7 @@ static xcb_window_t __create_window ( xcb_connection_t *xcb_connection, xcb_scre
|
||||||
{ 0,
|
{ 0,
|
||||||
0,
|
0,
|
||||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS |
|
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS |
|
||||||
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,map };
|
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION, map };
|
||||||
|
|
||||||
xcb_window_t box = xcb_generate_id ( xcb_connection );
|
xcb_window_t box = xcb_generate_id ( xcb_connection );
|
||||||
xcb_create_window ( xcb_connection,
|
xcb_create_window ( xcb_connection,
|
||||||
|
@ -540,8 +541,8 @@ static xcb_window_t __create_window ( xcb_connection_t *xcb_connection, xcb_scre
|
||||||
// // make it an unmanaged window
|
// // make it an unmanaged window
|
||||||
if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) && !config.fullscreen ) {
|
if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) && !config.fullscreen ) {
|
||||||
window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_STATE, &xcb_ewmh._NET_WM_STATE_ABOVE, 1 );
|
window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_STATE, &xcb_ewmh._NET_WM_STATE_ABOVE, 1 );
|
||||||
uint32_t values[] = {1};
|
uint32_t values[] = { 1 };
|
||||||
xcb_change_window_attributes ( xcb_connection, box, XCB_CW_OVERRIDE_REDIRECT, values);
|
xcb_change_window_attributes ( xcb_connection, box, XCB_CW_OVERRIDE_REDIRECT, values );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_WINDOW_TYPE, &xcb_ewmh._NET_WM_WINDOW_TYPE_NORMAL, 1 );
|
window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_WINDOW_TYPE, &xcb_ewmh._NET_WM_WINDOW_TYPE_NORMAL, 1 );
|
||||||
|
@ -555,8 +556,8 @@ static xcb_window_t __create_window ( xcb_connection_t *xcb_connection, xcb_scre
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the WM_NAME
|
// Set the WM_NAME
|
||||||
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, xcb_ewmh._NET_WM_NAME, xcb_ewmh.UTF8_STRING, 8, 4,"rofi");
|
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, xcb_ewmh._NET_WM_NAME, xcb_ewmh.UTF8_STRING, 8, 4, "rofi" );
|
||||||
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 4,"rofi");
|
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 4, "rofi" );
|
||||||
|
|
||||||
x11_set_window_opacity ( xcb_connection, box, config.window_opacity );
|
x11_set_window_opacity ( xcb_connection, box, config.window_opacity );
|
||||||
return box;
|
return box;
|
||||||
|
@ -994,9 +995,10 @@ void rofi_view_update ( RofiViewState *state )
|
||||||
*/
|
*/
|
||||||
static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t *xse )
|
static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t *xse )
|
||||||
{
|
{
|
||||||
if ( xse->property == XCB_ATOM_NONE ){
|
if ( xse->property == XCB_ATOM_NONE ) {
|
||||||
fprintf ( stderr, "Failed to convert selection\n" );
|
fprintf ( stderr, "Failed to convert selection\n" );
|
||||||
} else if ( xse->property == xcb_ewmh.UTF8_STRING ) {
|
}
|
||||||
|
else if ( xse->property == xcb_ewmh.UTF8_STRING ) {
|
||||||
gchar *text = window_get_text_prop ( xcb_connection, main_window, xcb_ewmh.UTF8_STRING );
|
gchar *text = window_get_text_prop ( xcb_connection, main_window, xcb_ewmh.UTF8_STRING );
|
||||||
if ( text != NULL && text[0] != '\0' ) {
|
if ( text != NULL && text[0] != '\0' ) {
|
||||||
unsigned int dl = strlen ( text );
|
unsigned int dl = strlen ( text );
|
||||||
|
@ -1013,7 +1015,8 @@ static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t
|
||||||
state->refilter = TRUE;
|
state->refilter = TRUE;
|
||||||
}
|
}
|
||||||
g_free ( text );
|
g_free ( text );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
fprintf ( stderr, "Failed\n" );
|
fprintf ( stderr, "Failed\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1343,12 +1346,12 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
||||||
// Handling of paste
|
// Handling of paste
|
||||||
if ( abe_test_action ( PASTE_PRIMARY, modstate, key ) ) {
|
if ( abe_test_action ( PASTE_PRIMARY, modstate, key ) ) {
|
||||||
xcb_convert_selection ( xcb_connection, main_window, XCB_ATOM_PRIMARY,
|
xcb_convert_selection ( xcb_connection, main_window, XCB_ATOM_PRIMARY,
|
||||||
xcb_ewmh.UTF8_STRING,xcb_ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
xcb_ewmh.UTF8_STRING, xcb_ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
||||||
xcb_flush ( xcb_connection );
|
xcb_flush ( xcb_connection );
|
||||||
}
|
}
|
||||||
else if ( abe_test_action ( PASTE_SECONDARY, modstate, key ) ) {
|
else if ( abe_test_action ( PASTE_SECONDARY, modstate, key ) ) {
|
||||||
xcb_convert_selection ( xcb_connection, main_window, XCB_ATOM_SECONDARY,
|
xcb_convert_selection ( xcb_connection, main_window, XCB_ATOM_SECONDARY,
|
||||||
xcb_ewmh.UTF8_STRING,xcb_ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
xcb_ewmh.UTF8_STRING, xcb_ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
||||||
xcb_flush ( xcb_connection );
|
xcb_flush ( xcb_connection );
|
||||||
}
|
}
|
||||||
if ( abe_test_action ( SCREENSHOT, modstate, key ) ) {
|
if ( abe_test_action ( SCREENSHOT, modstate, key ) ) {
|
||||||
|
|
|
@ -78,13 +78,13 @@ extern xcb_connection_t *xcb_connection;
|
||||||
// technically we could use window_get_prop(), but this is better for character set support
|
// technically we could use window_get_prop(), but this is better for character set support
|
||||||
char* window_get_text_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, xcb_atom_t atom )
|
char* window_get_text_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, xcb_atom_t atom )
|
||||||
{
|
{
|
||||||
xcb_get_property_cookie_t c = xcb_get_property( xcb_connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
|
xcb_get_property_cookie_t c = xcb_get_property ( xcb_connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX );
|
||||||
xcb_get_property_reply_t *r = xcb_get_property_reply( xcb_connection, c, NULL);
|
xcb_get_property_reply_t *r = xcb_get_property_reply ( xcb_connection, c, NULL );
|
||||||
if ( r ){
|
if ( r ) {
|
||||||
char *str = g_malloc ( xcb_get_property_value_length(r)+1);
|
char *str = g_malloc ( xcb_get_property_value_length ( r ) + 1 );
|
||||||
memcpy(str, xcb_get_property_value(r), xcb_get_property_value_length(r));
|
memcpy ( str, xcb_get_property_value ( r ), xcb_get_property_value_length ( r ) );
|
||||||
str[xcb_get_property_value_length(r)] = '\0';
|
str[xcb_get_property_value_length ( r )] = '\0';
|
||||||
free(r);
|
free ( r );
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -92,7 +92,7 @@ char* window_get_text_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, x
|
||||||
|
|
||||||
void window_set_atom_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count )
|
void window_set_atom_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count )
|
||||||
{
|
{
|
||||||
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, w, prop, XCB_ATOM_ATOM, 32, count, atoms);
|
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, w, prop, XCB_ATOM_ATOM, 32, count, atoms );
|
||||||
}
|
}
|
||||||
|
|
||||||
extern xcb_screen_t *xcb_screen;
|
extern xcb_screen_t *xcb_screen;
|
||||||
|
@ -100,35 +100,35 @@ extern int xcb_screen_nbr;
|
||||||
int monitor_get_smallest_size ( xcb_connection_t *xcb_connection )
|
int monitor_get_smallest_size ( xcb_connection_t *xcb_connection )
|
||||||
{
|
{
|
||||||
xcb_generic_error_t *error;
|
xcb_generic_error_t *error;
|
||||||
int size = MIN (xcb_screen->width_in_pixels, xcb_screen->height_in_pixels);
|
int size = MIN ( xcb_screen->width_in_pixels, xcb_screen->height_in_pixels );
|
||||||
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active(xcb_connection);
|
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active ( xcb_connection );
|
||||||
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply(xcb_connection, is_active_req, &error);
|
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply ( xcb_connection, is_active_req, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Couldn't query Xinerama\n");
|
fprintf ( stderr, "Couldn't query Xinerama\n" );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
if (!is_active->state) {
|
if ( !is_active->state ) {
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
|
|
||||||
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
||||||
cookie_screen = xcb_xinerama_query_screens(xcb_connection);
|
cookie_screen = xcb_xinerama_query_screens ( xcb_connection );
|
||||||
xcb_xinerama_query_screens_reply_t *query_screens;
|
xcb_xinerama_query_screens_reply_t *query_screens;
|
||||||
query_screens = xcb_xinerama_query_screens_reply(xcb_connection, cookie_screen, &error);
|
query_screens = xcb_xinerama_query_screens_reply ( xcb_connection, cookie_screen, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Error getting screen info\n");
|
fprintf ( stderr, "Error getting screen info\n" );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info(query_screens);
|
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info ( query_screens );
|
||||||
int len = xcb_xinerama_query_screens_screen_info_length(query_screens);
|
int len = xcb_xinerama_query_screens_screen_info_length ( query_screens );
|
||||||
for (int i = 0; i < len; i++) {
|
for ( int i = 0; i < len; i++ ) {
|
||||||
xcb_xinerama_screen_info_t *info = &screens[i];
|
xcb_xinerama_screen_info_t *info = &screens[i];
|
||||||
size = MIN ( info->width, size );
|
size = MIN ( info->width, size );
|
||||||
size = MIN ( info->height, size );
|
size = MIN ( info->height, size );
|
||||||
}
|
}
|
||||||
free(query_screens);
|
free ( query_screens );
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -139,38 +139,38 @@ int monitor_get_dimension ( xcb_connection_t *xcb_connection, xcb_screen_t *scre
|
||||||
mon->w = screen->width_in_pixels;
|
mon->w = screen->width_in_pixels;
|
||||||
mon->h = screen->height_in_pixels;
|
mon->h = screen->height_in_pixels;
|
||||||
|
|
||||||
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active(xcb_connection);
|
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active ( xcb_connection );
|
||||||
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply(xcb_connection, is_active_req, &error);
|
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply ( xcb_connection, is_active_req, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Error getting screen info\n");
|
fprintf ( stderr, "Error getting screen info\n" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!is_active->state) {
|
if ( !is_active->state ) {
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
|
|
||||||
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
||||||
cookie_screen = xcb_xinerama_query_screens(xcb_connection);
|
cookie_screen = xcb_xinerama_query_screens ( xcb_connection );
|
||||||
xcb_xinerama_query_screens_reply_t *query_screens;
|
xcb_xinerama_query_screens_reply_t *query_screens;
|
||||||
query_screens = xcb_xinerama_query_screens_reply(xcb_connection, cookie_screen, &error);
|
query_screens = xcb_xinerama_query_screens_reply ( xcb_connection, cookie_screen, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Error getting screen info\n");
|
fprintf ( stderr, "Error getting screen info\n" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info(query_screens);
|
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info ( query_screens );
|
||||||
int len = xcb_xinerama_query_screens_screen_info_length(query_screens);
|
int len = xcb_xinerama_query_screens_screen_info_length ( query_screens );
|
||||||
if ( monitor < len ) {
|
if ( monitor < len ) {
|
||||||
xcb_xinerama_screen_info_t *info = &screens[monitor];
|
xcb_xinerama_screen_info_t *info = &screens[monitor];
|
||||||
mon->w = info->width;
|
mon->w = info->width;
|
||||||
mon->h = info->height;
|
mon->h = info->height;
|
||||||
mon->x = info->x_org;
|
mon->x = info->x_org;
|
||||||
mon->y = info->y_org;
|
mon->y = info->y_org;
|
||||||
free(query_screens);
|
free ( query_screens );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
free(query_screens);
|
free ( query_screens );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -182,29 +182,29 @@ void monitor_dimensions ( xcb_connection_t *xcb_connection, xcb_screen_t *screen
|
||||||
mon->w = screen->width_in_pixels;
|
mon->w = screen->width_in_pixels;
|
||||||
mon->h = screen->height_in_pixels;
|
mon->h = screen->height_in_pixels;
|
||||||
|
|
||||||
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active(xcb_connection);
|
xcb_xinerama_is_active_cookie_t is_active_req = xcb_xinerama_is_active ( xcb_connection );
|
||||||
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply(xcb_connection, is_active_req, &error);
|
xcb_xinerama_is_active_reply_t *is_active = xcb_xinerama_is_active_reply ( xcb_connection, is_active_req, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Couldn't query Xinerama\n");
|
fprintf ( stderr, "Couldn't query Xinerama\n" );
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_active->state) {
|
if ( !is_active->state ) {
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
free ( is_active );
|
free ( is_active );
|
||||||
|
|
||||||
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
xcb_xinerama_query_screens_cookie_t cookie_screen;
|
||||||
cookie_screen = xcb_xinerama_query_screens(xcb_connection);
|
cookie_screen = xcb_xinerama_query_screens ( xcb_connection );
|
||||||
xcb_xinerama_query_screens_reply_t *query_screens;
|
xcb_xinerama_query_screens_reply_t *query_screens;
|
||||||
query_screens = xcb_xinerama_query_screens_reply(xcb_connection, cookie_screen, &error);
|
query_screens = xcb_xinerama_query_screens_reply ( xcb_connection, cookie_screen, &error );
|
||||||
if (error) {
|
if ( error ) {
|
||||||
fprintf(stderr, "Error getting screen info\n");
|
fprintf ( stderr, "Error getting screen info\n" );
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info(query_screens);
|
xcb_xinerama_screen_info_t *screens = xcb_xinerama_query_screens_screen_info ( query_screens );
|
||||||
int len = xcb_xinerama_query_screens_screen_info_length(query_screens);
|
int len = xcb_xinerama_query_screens_screen_info_length ( query_screens );
|
||||||
for ( int i = 0; i < len; i++){
|
for ( int i = 0; i < len; i++ ) {
|
||||||
xcb_xinerama_screen_info_t *info = &screens[i];
|
xcb_xinerama_screen_info_t *info = &screens[i];
|
||||||
if ( INTERSECT ( x, y, 1, 1, info->x_org, info->y_org, info->width, info->height ) ) {
|
if ( INTERSECT ( x, y, 1, 1, info->x_org, info->y_org, info->width, info->height ) ) {
|
||||||
mon->w = info->width;
|
mon->w = info->width;
|
||||||
|
@ -214,7 +214,7 @@ void monitor_dimensions ( xcb_connection_t *xcb_connection, xcb_screen_t *screen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(query_screens);
|
free ( query_screens );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +234,7 @@ static int pointer_get ( xcb_connection_t *xcb_connection, xcb_window_t root, in
|
||||||
if ( r ) {
|
if ( r ) {
|
||||||
*x = r->root_x;
|
*x = r->root_x;
|
||||||
*y = r->root_y;
|
*y = r->root_y;
|
||||||
free(r);
|
free ( r );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,31 +256,32 @@ void monitor_active ( xcb_connection_t *xcb_connection, workarea *mon )
|
||||||
// Get the current desktop.
|
// Get the current desktop.
|
||||||
unsigned int current_desktop = 0;
|
unsigned int current_desktop = 0;
|
||||||
if ( config.monitor != -2 && xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh,
|
if ( config.monitor != -2 && xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh,
|
||||||
xcb_ewmh_get_current_desktop( &xcb_ewmh, xcb_screen_nbr), ¤t_desktop, NULL )) {
|
xcb_ewmh_get_current_desktop ( &xcb_ewmh, xcb_screen_nbr ),
|
||||||
xcb_get_property_cookie_t c = xcb_ewmh_get_desktop_viewport(&xcb_ewmh, xcb_screen_nbr);
|
¤t_desktop, NULL ) ) {
|
||||||
|
xcb_get_property_cookie_t c = xcb_ewmh_get_desktop_viewport ( &xcb_ewmh, xcb_screen_nbr );
|
||||||
xcb_ewmh_get_desktop_viewport_reply_t vp;
|
xcb_ewmh_get_desktop_viewport_reply_t vp;
|
||||||
if ( xcb_ewmh_get_desktop_viewport_reply ( &xcb_ewmh, c, &vp, NULL)){
|
if ( xcb_ewmh_get_desktop_viewport_reply ( &xcb_ewmh, c, &vp, NULL ) ) {
|
||||||
if ( current_desktop < vp.desktop_viewport_len) {
|
if ( current_desktop < vp.desktop_viewport_len ) {
|
||||||
monitor_dimensions ( xcb_connection, xcb_screen, vp.desktop_viewport[current_desktop].x,
|
monitor_dimensions ( xcb_connection, xcb_screen, vp.desktop_viewport[current_desktop].x,
|
||||||
vp.desktop_viewport[current_desktop].y, mon );
|
vp.desktop_viewport[current_desktop].y, mon );
|
||||||
xcb_ewmh_get_desktop_viewport_reply_wipe(&vp);
|
xcb_ewmh_get_desktop_viewport_reply_wipe ( &vp );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xcb_ewmh_get_desktop_viewport_reply_wipe(&vp);
|
xcb_ewmh_get_desktop_viewport_reply_wipe ( &vp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_window_t active_window;
|
xcb_window_t active_window;
|
||||||
if ( xcb_ewmh_get_active_window_reply ( &xcb_ewmh,
|
if ( xcb_ewmh_get_active_window_reply ( &xcb_ewmh,
|
||||||
xcb_ewmh_get_active_window( &xcb_ewmh, xcb_screen_nbr), &active_window, NULL )) {
|
xcb_ewmh_get_active_window ( &xcb_ewmh, xcb_screen_nbr ), &active_window, NULL ) ) {
|
||||||
// get geometry.
|
// get geometry.
|
||||||
xcb_get_geometry_cookie_t c = xcb_get_geometry ( xcb_connection, active_window);
|
xcb_get_geometry_cookie_t c = xcb_get_geometry ( xcb_connection, active_window );
|
||||||
xcb_get_geometry_reply_t *r = xcb_get_geometry_reply ( xcb_connection, c, NULL);
|
xcb_get_geometry_reply_t *r = xcb_get_geometry_reply ( xcb_connection, c, NULL );
|
||||||
if ( r ) {
|
if ( r ) {
|
||||||
if ( config.monitor == -2 ) {
|
if ( config.monitor == -2 ) {
|
||||||
xcb_translate_coordinates_cookie_t ct = xcb_translate_coordinates(xcb_connection, active_window, root, r->x, r->y);
|
xcb_translate_coordinates_cookie_t ct = xcb_translate_coordinates ( xcb_connection, active_window, root, r->x, r->y );
|
||||||
xcb_translate_coordinates_reply_t *t = xcb_translate_coordinates_reply (xcb_connection, ct, NULL);
|
xcb_translate_coordinates_reply_t *t = xcb_translate_coordinates_reply ( xcb_connection, ct, NULL );
|
||||||
if ( t ){
|
if ( t ) {
|
||||||
// place the menu above the window
|
// place the menu above the window
|
||||||
// if some window is focused, place menu above window, else fall
|
// if some window is focused, place menu above window, else fall
|
||||||
// back to selected monitor.
|
// back to selected monitor.
|
||||||
|
@ -292,13 +293,13 @@ void monitor_active ( xcb_connection_t *xcb_connection, workarea *mon )
|
||||||
mon->b = r->border_width;
|
mon->b = r->border_width;
|
||||||
mon->l = r->border_width;
|
mon->l = r->border_width;
|
||||||
mon->r = r->border_width;
|
mon->r = r->border_width;
|
||||||
free(r);
|
free ( r );
|
||||||
free(t);
|
free ( t );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitor_dimensions ( xcb_connection, xcb_screen, r->x, r->y, mon );
|
monitor_dimensions ( xcb_connection, xcb_screen, r->x, r->y, mon );
|
||||||
free(r);
|
free ( r );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,15 +313,14 @@ void monitor_active ( xcb_connection_t *xcb_connection, workarea *mon )
|
||||||
|
|
||||||
int take_keyboard ( xcb_connection_t *xcb_connection, xcb_window_t w )
|
int take_keyboard ( xcb_connection_t *xcb_connection, xcb_window_t w )
|
||||||
{
|
{
|
||||||
|
|
||||||
for ( int i = 0; i < 500; i++ ) {
|
for ( int i = 0; i < 500; i++ ) {
|
||||||
xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb_connection,
|
xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb_connection,
|
||||||
1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
|
1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
|
||||||
XCB_GRAB_MODE_ASYNC);
|
XCB_GRAB_MODE_ASYNC );
|
||||||
xcb_grab_keyboard_reply_t *r = xcb_grab_keyboard_reply ( xcb_connection, cc, NULL);
|
xcb_grab_keyboard_reply_t *r = xcb_grab_keyboard_reply ( xcb_connection, cc, NULL );
|
||||||
if ( r ) {
|
if ( r ) {
|
||||||
if ( r->status == XCB_GRAB_STATUS_SUCCESS) {
|
if ( r->status == XCB_GRAB_STATUS_SUCCESS ) {
|
||||||
free(r);
|
free ( r );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free ( r );
|
free ( r );
|
||||||
|
@ -333,7 +333,7 @@ int take_keyboard ( xcb_connection_t *xcb_connection, xcb_window_t w )
|
||||||
|
|
||||||
void release_keyboard ( xcb_connection_t *xcb_connection )
|
void release_keyboard ( xcb_connection_t *xcb_connection )
|
||||||
{
|
{
|
||||||
xcb_ungrab_keyboard ( xcb_connection, XCB_CURRENT_TIME);
|
xcb_ungrab_keyboard ( xcb_connection, XCB_CURRENT_TIME );
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int x11_find_mod_mask ( xkb_stuff *xkb, ... )
|
static unsigned int x11_find_mod_mask ( xkb_stuff *xkb, ... )
|
||||||
|
@ -438,7 +438,7 @@ void x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key )
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
xkb_keysym_t sym = xkb_keysym_from_name ( combo + i, XKB_KEYSYM_NO_FLAGS);
|
xkb_keysym_t sym = xkb_keysym_from_name ( combo + i, XKB_KEYSYM_NO_FLAGS );
|
||||||
|
|
||||||
if ( sym == XKB_KEY_NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) {
|
if ( sym == XKB_KEY_NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) {
|
||||||
g_string_append_printf ( str, "Sorry, rofi cannot understand the key combination: <i>%s</i>\n", combo );
|
g_string_append_printf ( str, "Sorry, rofi cannot understand the key combination: <i>%s</i>\n", combo );
|
||||||
|
@ -463,8 +463,8 @@ void x11_set_window_opacity ( xcb_connection_t *xcb_connection, xcb_window_t box
|
||||||
// Scale 0-100 to 0 - UINT32_MAX.
|
// Scale 0-100 to 0 - UINT32_MAX.
|
||||||
unsigned int opacity_set = ( unsigned int ) ( ( opacity / 100.0 ) * UINT32_MAX );
|
unsigned int opacity_set = ( unsigned int ) ( ( opacity / 100.0 ) * UINT32_MAX );
|
||||||
|
|
||||||
xcb_change_property( xcb_connection, XCB_PROP_MODE_REPLACE, box,
|
xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box,
|
||||||
netatoms[_NET_WM_WINDOW_OPACITY], XCB_ATOM_CARDINAL, 32, 1L, &opacity_set);
|
netatoms[_NET_WM_WINDOW_OPACITY], XCB_ATOM_CARDINAL, 32, 1L, &opacity_set );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,16 +476,15 @@ static void x11_create_frequently_used_atoms ( xcb_connection_t *xcb_connection
|
||||||
{
|
{
|
||||||
// X atom values
|
// X atom values
|
||||||
for ( int i = 0; i < NUM_NETATOMS; i++ ) {
|
for ( int i = 0; i < NUM_NETATOMS; i++ ) {
|
||||||
xcb_intern_atom_cookie_t cc = xcb_intern_atom ( xcb_connection, 0, strlen(netatom_names[i]), netatom_names[i]);
|
xcb_intern_atom_cookie_t cc = xcb_intern_atom ( xcb_connection, 0, strlen ( netatom_names[i] ), netatom_names[i] );
|
||||||
xcb_intern_atom_reply_t *r = xcb_intern_atom_reply ( xcb_connection, cc, NULL);
|
xcb_intern_atom_reply_t *r = xcb_intern_atom_reply ( xcb_connection, cc, NULL );
|
||||||
if ( r ) {
|
if ( r ) {
|
||||||
netatoms[i] = r->atom;
|
netatoms[i] = r->atom;
|
||||||
free(r);
|
free ( r );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void x11_setup ( xcb_connection_t *xcb_connection, xkb_stuff *xkb )
|
void x11_setup ( xcb_connection_t *xcb_connection, xkb_stuff *xkb )
|
||||||
{
|
{
|
||||||
// determine numlock mask so we can bind on keys with and without it
|
// determine numlock mask so we can bind on keys with and without it
|
||||||
|
|
|
@ -225,7 +225,7 @@ static void __config_parse_xresource_options ( XrmDatabase xDB )
|
||||||
}
|
}
|
||||||
void config_parse_xresource_options ( xcb_connection_t *xcb_connection, xcb_screen_t *xcb_screen )
|
void config_parse_xresource_options ( xcb_connection_t *xcb_connection, xcb_screen_t *xcb_screen )
|
||||||
{
|
{
|
||||||
char *name = window_get_text_prop ( xcb_connection, xcb_screen->root, XCB_ATOM_RESOURCE_MANAGER);
|
char *name = window_get_text_prop ( xcb_connection, xcb_screen->root, XCB_ATOM_RESOURCE_MANAGER );
|
||||||
if ( name ) {
|
if ( name ) {
|
||||||
// Map Xresource entries to rofi config options.
|
// Map Xresource entries to rofi config options.
|
||||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
||||||
|
@ -331,7 +331,7 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
|
||||||
|
|
||||||
void config_parse_xresource_options_dynamic ( xcb_connection_t *xcb_connection, xcb_screen_t *xcb_screen )
|
void config_parse_xresource_options_dynamic ( xcb_connection_t *xcb_connection, xcb_screen_t *xcb_screen )
|
||||||
{
|
{
|
||||||
char *name = window_get_text_prop ( xcb_connection, xcb_screen->root, XCB_ATOM_RESOURCE_MANAGER);
|
char *name = window_get_text_prop ( xcb_connection, xcb_screen->root, XCB_ATOM_RESOURCE_MANAGER );
|
||||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
||||||
__config_parse_xresource_options_dynamic ( xDB );
|
__config_parse_xresource_options_dynamic ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
XrmDestroyDatabase ( xDB );
|
||||||
|
|
|
@ -24,9 +24,8 @@ unsigned int normal_window_mode = 0;
|
||||||
void rofi_view_queue_redraw ()
|
void rofi_view_queue_redraw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Color color_get (const char *name)
|
Color color_get ( const char *name )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
|
@ -46,8 +45,8 @@ int show_error_message ( const char *msg, int markup )
|
||||||
|
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
|
cairo_surface_t *surf = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, 100, 100 );
|
||||||
cairo_t *draw = cairo_create(surf);
|
cairo_t *draw = cairo_create ( surf );
|
||||||
PangoContext *p = pango_cairo_create_context ( draw );
|
PangoContext *p = pango_cairo_create_context ( draw );
|
||||||
textbox_set_pango_context ( p );
|
textbox_set_pango_context ( p );
|
||||||
|
|
||||||
|
@ -129,5 +128,4 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
|
|
||||||
textbox_free ( box );
|
textbox_free ( box );
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue