summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Udaltsov <svu@gnome.org>2006-02-18 03:04:43 +0000
committerSergey Udaltsov <svu@gnome.org>2006-02-18 03:04:43 +0000
commit7fba3ab53a6b17e39245cffffda2f24448a35614 (patch)
tree9f6fe75158b9baeaef90e1b466ff9336ac088f61
parent2f0d15353f51996b8b099862687260ddad4047cc (diff)
downloadlibxklavier-7fba3ab53a6b17e39245cffffda2f24448a35614.tar.gz
first compilable version, no more
-rw-r--r--libxklavier/xklavier.c6
-rw-r--r--libxklavier/xklavier_evt.c36
-rw-r--r--libxklavier/xklavier_private.h11
-rw-r--r--libxklavier/xklavier_util.c172
4 files changed, 113 insertions, 112 deletions
diff --git a/libxklavier/xklavier.c b/libxklavier/xklavier.c
index 3756c4c..117c3ab 100644
--- a/libxklavier/xklavier.c
+++ b/libxklavier/xklavier.c
@@ -342,7 +342,7 @@ gint xkl_get_restore_group( void )
xkl_debug( 150,
"Unbelievable: current client " WINID_FORMAT
", '%s' has no group\n", xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ) );
+ xkl_window_get_debug_title( xkl_current_client ) );
return 0;
}
@@ -386,7 +386,7 @@ gboolean xkl_load_window_tree( void )
XGetInputFocus( xkl_display, &focused, &revert );
xkl_debug( 160, "initially focused: " WINID_FORMAT ", '%s'\n",
- focused, xkl_get_debug_window_title( focused ) );
+ focused, xkl_window_get_debug_title( focused ) );
have_toplevel_win = xkl_toplevel_window_find( focused, &xkl_current_client );
@@ -397,7 +397,7 @@ gboolean xkl_load_window_tree( void )
xkl_debug( 160,
"initial xkl_cur_client: " WINID_FORMAT
", '%s' %s state %d/%X\n", xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ),
+ xkl_window_get_debug_title( xkl_current_client ),
( have_state ? "with" : "without" ),
( have_state ? xkl_current_state.group : -1 ),
( have_state ? xkl_current_state.indicators : -1 ) );
diff --git a/libxklavier/xklavier_evt.c b/libxklavier/xklavier_evt.c
index 30ec1d8..f77280a 100644
--- a/libxklavier/xklavier_evt.c
+++ b/libxklavier/xklavier_evt.c
@@ -36,16 +36,16 @@ gint xkl_filter_events( XEvent *xev )
case MapNotify:
case GravityNotify:
case ReparentNotify:
- xkl_debug( 200, "%s\n", xkl_get_event_name( xev->type ) );
+ xkl_debug( 200, "%s\n", xkl_event_get_name( xev->type ) );
break; /* Ignore these events */
case MappingNotify:
- xkl_debug( 200, "%s\n", xkl_get_event_name( xev->type ) );
+ xkl_debug( 200, "%s\n", xkl_event_get_name( xev->type ) );
xkl_reset_all_info( "X event: MappingNotify" );
break;
default:
{
xkl_debug( 200, "Unknown event %d [%s]\n",
- xev->type, xkl_get_event_name( xev->type ) );
+ xev->type, xkl_event_get_name( xev->type ) );
return 1;
}
}
@@ -81,7 +81,7 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
}
xkl_debug( 150, "Window " WINID_FORMAT ", '%s' has got focus\n", win,
- xkl_get_debug_window_title( win ) );
+ xkl_window_get_debug_title( win ) );
if( !xkl_toplevel_window_find( win, &toplevel_win ) )
{
@@ -89,7 +89,7 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
}
xkl_debug( 150, "Appwin " WINID_FORMAT ", '%s' has got focus\n",
- toplevel_win, xkl_get_debug_window_title( toplevel_win ) );
+ toplevel_win, xkl_window_get_debug_title( toplevel_win ) );
if( xkl_state_get( toplevel_win, &selected_window_state ) )
{
@@ -110,7 +110,7 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
if ( !old_win_transparent &&
xkl_state_get( xkl_current_client, &tmp_state ) )
{
- xkl_update_current_state( tmp_state.group,
+ xkl_current_state_update( tmp_state.group,
tmp_state.indicators,
"Loading current (previous) state from the current (previous) window" );
}
@@ -118,7 +118,7 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
xkl_current_client = toplevel_win;
xkl_debug( 150, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ) );
+ xkl_window_get_debug_title( xkl_current_client ) );
new_win_transparent = xkl_toplevel_window_is_transparent( toplevel_win );
if( new_win_transparent )
@@ -153,7 +153,7 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
* (because of the group change notification being late).
* so we'll enforce the update. But this should only happen in GPA mode
*/
- xkl_update_current_state( selected_window_state.group,
+ xkl_current_state_update( selected_window_state.group,
selected_window_state.indicators,
"Enforcing fast update of the current state" );
xkl_group_lock( selected_window_state.group );
@@ -189,13 +189,13 @@ void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
} else
{
xkl_debug( 150, "But it does not have xklavier_state\n" );
- if( xkl_has_wm_state( win ) )
+ if( xkl_window_has_wm_state( win ) )
{
xkl_debug( 150, "But it does have wm_state so we'll add it\n" );
xkl_current_client = toplevel_win;
xkl_debug( 150, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ) );
+ xkl_window_get_debug_title( xkl_current_client ) );
xkl_toplevel_window_add( xkl_current_client, ( Window ) NULL, FALSE,
&xkl_current_state );
} else
@@ -221,7 +221,7 @@ void xkl_process_focus_out_evt( XFocusChangeEvent * fev )
}
xkl_debug( 160, "Window " WINID_FORMAT ", '%s' has lost focus\n",
- fev->window, xkl_get_debug_window_title( fev->window ) );
+ fev->window, xkl_window_get_debug_title( fev->window ) );
if( xkl_window_is_transparent( fev->window ) )
{
@@ -314,7 +314,7 @@ void xkl_process_create_evt( XCreateWindowEvent * cev )
xkl_debug( 200,
"Under-root window " WINID_FORMAT
"/%s (%d,%d,%d x %d) is created\n", cev->window,
- xkl_get_debug_window_title( cev->window ), cev->x, cev->y,
+ xkl_window_get_debug_title( cev->window ), cev->x, cev->y,
cev->width, cev->height );
if( !cev->override_redirect )
@@ -329,7 +329,7 @@ void xkl_process_create_evt( XCreateWindowEvent * cev )
xkl_select_input_merging( cev->window,
PropertyChangeMask | FocusChangeMask );
- if( xkl_has_wm_state( cev->window ) )
+ if( xkl_window_has_wm_state( cev->window ) )
{
xkl_debug( 200,
"Just created window already has WM_STATE - so I'll add it" );
@@ -394,12 +394,12 @@ void xkl_process_state_modification( XklStateChange change_type,
focused_toplevel = xkl_current_client; /* what else can I do */
xkl_debug( 150, "Focused window: " WINID_FORMAT ", '%s'\n",
- focused_toplevel, xkl_get_debug_window_title( focused_toplevel ) );
+ focused_toplevel, xkl_window_get_debug_title( focused_toplevel ) );
if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
{
xkl_debug( 150, "CurClient: " WINID_FORMAT ", '%s'\n",
xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ) );
+ xkl_window_get_debug_title( xkl_current_client ) );
if( focused_toplevel != xkl_current_client )
{
@@ -408,7 +408,7 @@ void xkl_process_state_modification( XklStateChange change_type,
*/
if ( !xkl_toplevel_window_get_state( focused_toplevel, &old_state ) )
{
- xkl_update_current_state( grp, inds,
+ xkl_current_state_update( grp, inds,
"Updating the state from new focused window" );
if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
xkl_toplevel_window_add( focused_toplevel, ( Window ) NULL,
@@ -425,7 +425,7 @@ void xkl_process_state_modification( XklStateChange change_type,
xkl_current_client = focused_toplevel;
xkl_debug( 160, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
xkl_current_client,
- xkl_get_debug_window_title( xkl_current_client ) );
+ xkl_window_get_debug_title( xkl_current_client ) );
}
/* If the window already has this this state - we are just restoring it!
(see the second parameter of stateCallback */
@@ -439,7 +439,7 @@ void xkl_process_state_modification( XklStateChange change_type,
if( set_group || have_old_state )
{
- xkl_update_current_state( set_group ? grp : old_state.group,
+ xkl_current_state_update( set_group ? grp : old_state.group,
set_inds ? inds : old_state.indicators,
"Restoring the state from the window" );
}
diff --git a/libxklavier/xklavier_private.h b/libxklavier/xklavier_private.h
index 488a277..ce0393e 100644
--- a/libxklavier/xklavier_private.h
+++ b/libxklavier/xklavier_private.h
@@ -219,7 +219,7 @@ extern gboolean xkl_load_subtree( Window window,
gint level,
XklState *init_state );
-extern gboolean xkl_has_wm_state( Window win );
+extern gboolean xkl_window_has_wm_state( Window win );
/**
@@ -249,10 +249,9 @@ extern void xkl_toplevel_window_save_state( Window toplevel_win, XklState *state
extern void xkl_select_input_merging( Window win, gulong mask );
-extern gchar *xkl_get_debug_window_title( Window win );
+extern gchar *xkl_window_get_debug_title( Window win );
-extern Status xkl_status_query_tree( Display * display,
- Window w,
+extern Status xkl_status_query_tree( Window w,
Window * root_out,
Window * parent_out,
Window ** children_out,
@@ -301,9 +300,9 @@ extern void xkl_config_rec_split_options( XklConfigRec * data,
extern void xkl_config_dump( FILE* file,
XklConfigRec * data );
-extern const gchar *xkl_get_event_name( gint type );
+extern const gchar *xkl_event_get_name( gint type );
-extern void xkl_update_current_state( gint group,
+extern void xkl_current_state_update( gint group,
unsigned indicators,
const gchar reason[] );
diff --git a/libxklavier/xklavier_util.c b/libxklavier/xklavier_util.c
index d87247e..feb35d1 100644
--- a/libxklavier/xklavier_util.c
+++ b/libxklavier/xklavier_util.c
@@ -7,94 +7,94 @@
#include "xklavier_private.h"
-XklState *XklGetCurrentState( )
+XklState *xkl_state_get_current( )
{
- return &_xklCurState;
+ return &xkl_current_state;
}
-const char *XklGetLastError( )
+const gchar *_xkl_get_last_error( )
{
- return _xklLastErrorMsg;
+ return xkl_last_error_message;
}
-unsigned char *XklGetWindowTitle( Window w )
+gchar *xkl_window_get_title( Window w )
{
Atom type_ret;
int format_ret;
unsigned long nitems, rest;
unsigned char *prop;
- if( Success == XGetWindowProperty( _xklDpy, w, _xklAtoms[WM_NAME], 0L,
+ if( Success == XGetWindowProperty( xkl_display, w, xkl_atoms[WM_NAME], 0L,
-1L, False, XA_STRING, &type_ret,
&format_ret, &nitems, &rest, &prop ) )
- return prop;
+ return (gchar *)prop;
else
return NULL;
}
-Bool XklIsSameApp( Window win1, Window win2 )
+gboolean xkl_windows_is_same_application( Window win1, Window win2 )
{
Window app1, app2;
- return _XklGetAppWindow( win1, &app1 ) &&
- _XklGetAppWindow( win2, &app2 ) && app1 == app2;
+ return xkl_toplevel_window_find( win1, &app1 ) &&
+ xkl_toplevel_window_find( win2, &app2 ) && app1 == app2;
}
-Bool XklGetState( Window win, XklState * state_return )
+gboolean xkl_state_get( Window win, XklState * state_out )
{
- Window appWin;
+ Window app_win;
- if( !_XklGetAppWindow( win, &appWin ) )
+ if( !xkl_toplevel_window_find( win, &app_win ) )
{
- if( state_return != NULL )
- state_return->group = -1;
- return False;
+ if( state_out != NULL )
+ state_out->group = -1;
+ return FALSE;
}
- return _XklGetAppState( appWin, state_return );
+ return xkl_toplevel_window_get_state( app_win, state_out );
}
-void XklDelState( Window win )
+void xkl_state_delete( Window win )
{
- Window appWin;
+ Window app_win;
- if( _XklGetAppWindow( win, &appWin ) )
- _XklDelAppState( appWin );
+ if( xkl_toplevel_window_find( win, &app_win ) )
+ xkl_toplevel_window_remove_state( app_win );
}
-void XklSaveState( Window win, XklState * state )
+void xkl_state_save( Window win, XklState * state )
{
- Window appWin;
+ Window app_win;
- if( !( _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) )
+ if( !( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES ) )
return;
- if( _XklGetAppWindow( win, &appWin ) )
- _XklSaveAppState( appWin, state );
+ if( xkl_toplevel_window_find( win, &app_win ) )
+ xkl_toplevel_window_save_state( app_win, state );
}
/**
* Prepares the name of window suitable for debugging (32characters long).
*/
-char *_XklGetDebugWindowTitle( Window win )
+gchar *xkl_window_get_debug_title( Window win )
{
- static char sname[33];
- unsigned char *name;
+ static gchar sname[33];
+ gchar *name;
strcpy( sname, "NULL" );
if( win != ( Window ) NULL )
{
- name = XklGetWindowTitle( win );
+ name = xkl_window_get_title( win );
if( name != NULL )
{
snprintf( sname, sizeof( sname ), "%.32s", name );
- free( name );
+ g_free( name );
}
}
return sname;
}
-Window XklGetCurrentWindow( )
+Window xkl_window_get_current( )
{
- return _xklCurClient;
+ return xkl_current_client;
}
/**
@@ -102,44 +102,44 @@ Window XklGetCurrentWindow( )
* All the windows with WM_STATE are added.
* All the windows within level 0 are listened for focus and property
*/
-Bool _XklLoadSubtree( Window window, int level, XklState * initState )
+gboolean __xkl_load_subtree( Window window, gint level, XklState * init_state )
{
Window rwin = ( Window ) NULL,
parent = ( Window ) NULL, *children = NULL, *child;
- unsigned int num = 0;
- Bool retval = True;
+ guint num = 0;
+ gboolean retval = True;
- _xklLastErrorCode =
- _XklStatusQueryTree( _xklDpy, window, &rwin, &parent, &children, &num );
+ xkl_last_error_code =
+ xkl_status_query_tree( window, &rwin, &parent, &children, &num );
- if( _xklLastErrorCode != Success )
+ if( xkl_last_error_code != Success )
{
- return False;
+ return FALSE;
}
child = children;
while( num )
{
- if( _XklHasWmState( *child ) )
+ if( xkl_window_has_wm_state( *child ) )
{
- XklDebug( 160, "Window " WINID_FORMAT " '%s' has WM_STATE so we'll add it\n",
- *child, _XklGetDebugWindowTitle( *child ) );
- _XklAddAppWindow( *child, window, True, initState );
+ xkl_debug( 160, "Window " WINID_FORMAT " '%s' has WM_STATE so we'll add it\n",
+ *child, xkl_window_get_debug_title( *child ) );
+ xkl_toplevel_window_add( *child, window, TRUE, init_state );
} else
{
- XklDebug( 200, "Window " WINID_FORMAT " '%s' does not have have WM_STATE so we'll not add it\n",
- *child, _XklGetDebugWindowTitle( *child ) );
+ xkl_debug( 200, "Window " WINID_FORMAT " '%s' does not have have WM_STATE so we'll not add it\n",
+ *child, xkl_window_get_debug_title( *child ) );
if( level == 0 )
{
- XklDebug( 200, "But we are at level 0 so we'll spy on it\n" );
- _XklSelectInputMerging( *child,
- FocusChangeMask | PropertyChangeMask );
+ xkl_debug( 200, "But we are at level 0 so we'll spy on it\n" );
+ xkl_select_input_merging( *child,
+ FocusChangeMask | PropertyChangeMask );
} else
- XklDebug( 200, "And we are at level %d so we'll not spy on it\n",
- level );
+ xkl_debug( 200, "And we are at level %d so we'll not spy on it\n",
+ level );
- retval = _XklLoadSubtree( *child, level + 1, initState );
+ retval = xkl_load_subtree( *child, level + 1, init_state );
}
child++;
@@ -155,7 +155,7 @@ Bool _XklLoadSubtree( Window window, int level, XklState * initState )
/**
* Checks whether given window has WM_STATE property (i.e. "App window").
*/
-Bool _XklHasWmState( Window win )
+gboolean xkl_window_has_wm_state( Window win )
{ /* ICCCM 4.1.3.1 */
Atom type = None;
int format;
@@ -163,8 +163,8 @@ Bool _XklHasWmState( Window win )
unsigned long after;
unsigned char *data = NULL; /* Helps in the case of BadWindow error */
- XGetWindowProperty( _xklDpy, win, _xklAtoms[WM_STATE], 0, 0, False,
- _xklAtoms[WM_STATE], &type, &format, &nitems, &after,
+ XGetWindowProperty( xkl_display, win, xkl_atoms[WM_STATE], 0, 0, False,
+ xkl_atoms[WM_STATE], &type, &format, &nitems, &after,
&data );
if( data != NULL )
XFree( data ); /* To avoid an one-byte memory leak because after successfull return
@@ -175,53 +175,55 @@ Bool _XklHasWmState( Window win )
/**
* Finds out the official parent window (accortind to XQueryTree)
*/
-Window _XklGetRegisteredParent( Window win )
+Window xkl_get_registered_parent( Window win )
{
Window parent = ( Window ) NULL, rw = ( Window ) NULL, *children = NULL;
- unsigned int nchildren = 0;
+ guint nchildren = 0;
- _xklLastErrorCode =
- _XklStatusQueryTree( _xklDpy, win, &rw, &parent, &children, &nchildren );
+ xkl_last_error_code =
+ xkl_status_query_tree( win, &rw, &parent, &children, &nchildren );
if( children != NULL )
XFree( children );
- return _xklLastErrorCode == Success ? parent : ( Window ) NULL;
+ return xkl_last_error_code == Success ? parent : ( Window ) NULL;
}
/**
* Make sure about the result. Origial XQueryTree is pretty stupid beast:)
*/
-Status _XklStatusQueryTree( Display * display,
- Window w,
- Window * root_return,
- Window * parent_return,
- Window ** children_return,
- unsigned int *nchildren_return )
+Status xkl_status_query_tree( Window w,
+ Window * root_out,
+ Window * parent_out,
+ Window ** children_out,
+ guint *nchildren_out )
{
- Bool result;
+ gboolean result;
+ unsigned int nc;
- result = ( Bool ) XQueryTree( display,
+ result = ( gboolean ) XQueryTree( xkl_display,
w,
- root_return,
- parent_return,
- children_return, nchildren_return );
+ root_out,
+ parent_out,
+ children_out, &nc );
+ *nchildren_out = nc;
+
if( !result )
{
- XklDebug( 160,
- "Could not get tree info for window " WINID_FORMAT ": %d\n", w,
- result );
- _xklLastErrorMsg = "Could not get the tree info";
+ xkl_debug( 160,
+ "Could not get tree info for window " WINID_FORMAT ": %d\n", w,
+ result );
+ xkl_last_error_message = "Could not get the tree info";
}
return result ? Success : FirstExtensionError;
}
-const char *_XklGetEventName( int type )
+const gchar *xkl_event_get_name( gint type )
{
/* Not really good to use the fact of consecutivity
but X protocol is already standartized so... */
- static const char *evtNames[] = {
+ static const gchar *evt_names[] = {
"KeyPress",
"KeyRelease",
"ButtonPress",
@@ -256,16 +258,16 @@ const char *_XklGetEventName( int type )
};
type -= KeyPress;
if( type < 0 ||
- type >= ( sizeof( evtNames ) / sizeof( evtNames[0] ) ) )
+ type >= ( sizeof( evt_names ) / sizeof( evt_names[0] ) ) )
return "UNKNOWN";
- return evtNames[type];
+ return evt_names[type];
}
-void _XklUpdateCurState( int group, unsigned indicators, const char reason[] )
+void xkl_current_state_update( int group, unsigned indicators, const char reason[] )
{
- XklDebug( 150,
- "Updating the current state with [g:%d/i:%u], reason: %s\n",
- group, indicators, reason );
- _xklCurState.group = group;
- _xklCurState.indicators = indicators;
+ xkl_debug( 150,
+ "Updating the current state with [g:%d/i:%u], reason: %s\n",
+ group, indicators, reason );
+ xkl_current_state.group = group;
+ xkl_current_state.indicators = indicators;
}