"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libsn/sn-common.c" between
xfe-1.42.tar.gz and xfe-1.43.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

sn-common.c  (xfe-1.42):sn-common.c  (xfe-1.43)
skipping to change at line 30 skipping to change at line 30
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <config.h> #include <config.h>
#include "sn-common.h" #include "sn-common.h"
#include "sn-internals.h" #include "sn-internals.h"
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_event.h>
#include <X11/Xlib-xcb.h>
struct SnDisplay struct SnDisplay
{ {
int refcount; int refcount;
enum SnDisplayType type; Display *xdisplay;
union xcb_connection_t *xconnection;
{ xcb_screen_t **screens;
struct xcb_atom_t UTF8_STRING, NET_STARTUP_ID,
{ NET_STARTUP_INFO, NET_STARTUP_INFO_BEGIN;
Display *xdisplay; SnDisplayErrorTrapPush push_trap_func;
Screen **screens; SnDisplayErrorTrapPop pop_trap_func;
SnDisplayErrorTrapPush push_trap_func; SnXcbDisplayErrorTrapPush xcb_push_trap_func;
SnDisplayErrorTrapPop pop_trap_func; SnXcbDisplayErrorTrapPop xcb_pop_trap_func;
} xlib; int n_screens;
} x; SnList *xmessage_funcs;
int n_screens; SnList *pending_messages;
SnList *xmessage_funcs;
SnList *pending_messages;
}; };
/** /**
* sn_display_new: * sn_display_new:
* @xdisplay: an X window system display * @xdisplay: an X window system display
* @push_trap_func: function to push an X error trap * @push_trap_func: function to push an X error trap
* @pop_trap_func: function to pop an X error trap * @pop_trap_func: function to pop an X error trap
* *
* Creates a new #SnDisplay object, containing * Creates a new #SnDisplay object, containing
* data that libsn associates with an X display. * data that libsn associates with an X display.
skipping to change at line 73 skipping to change at line 77
* fact occurred. These functions are used to avoid X errors due to * fact occurred. These functions are used to avoid X errors due to
* BadWindow and such. * BadWindow and such.
* *
* Return value: the new #SnDisplay * Return value: the new #SnDisplay
**/ **/
SnDisplay* SnDisplay*
sn_display_new (Display *xdisplay, sn_display_new (Display *xdisplay,
SnDisplayErrorTrapPush push_trap_func, SnDisplayErrorTrapPush push_trap_func,
SnDisplayErrorTrapPop pop_trap_func) SnDisplayErrorTrapPop pop_trap_func)
{ {
SnDisplay *display; SnDisplay *display = sn_xcb_display_new(XGetXCBConnection(xdisplay),
int i; NULL, NULL);
display = sn_new0 (SnDisplay, 1); display->xdisplay = xdisplay;
display->push_trap_func = push_trap_func;
display->pop_trap_func = pop_trap_func;
display->type = SN_DISPLAY_TYPE_XLIB; return display;
display->x.xlib.xdisplay = xdisplay; }
display->n_screens = ScreenCount (xdisplay);
display->x.xlib.screens = sn_new (Screen*, display->n_screens);
display->refcount = 1;
display->x.xlib.push_trap_func = push_trap_func;
display->x.xlib.pop_trap_func = pop_trap_func;
for (i = 0; i < display->n_screens; ++i) /**
display->x.xlib.screens[i] = ScreenOfDisplay (display->x.xlib.xdisplay, * sn_xcb_display_new:
i); * @xdisplay: an X window system connection
* @push_trap_func: function to push an X error trap
* @pop_trap_func: function to pop an X error trap
*
* Creates a new #SnDisplay object, containing
* data that libsn associates with an X connection.
*
* @push_trap_func should be a function that causes X errors to be
* ignored until @pop_trap_func is called as many times as
* @push_trap_func has been called. (Nested push/pop pairs must be
* supported.)
* These functions are used to avoid X errors due to BadWindow and
* such.
*
* Return value: the new #SnDisplay
**/
SnDisplay*
sn_xcb_display_new (xcb_connection_t *xconnection,
SnXcbDisplayErrorTrapPush push_trap_func,
SnXcbDisplayErrorTrapPop pop_trap_func)
{
SnDisplay *display;
int i;
/* Get all atoms we will need in the future */
xcb_intern_atom_cookie_t atom_utf8_string_c =
xcb_intern_atom(xconnection, FALSE,
sizeof("UTF8_STRING") - 1, "UTF8_STRING");
xcb_intern_atom_cookie_t atom_net_startup_info_begin_c =
xcb_intern_atom(xconnection, FALSE,
sizeof("_NET_STARTUP_INFO_BEGIN") - 1,
"_NET_STARTUP_INFO_BEGIN");
xcb_intern_atom_cookie_t atom_net_startup_info_c =
xcb_intern_atom(xconnection, FALSE,
sizeof("_NET_STARTUP_INFO") - 1, "_NET_STARTUP_INFO");
xcb_intern_atom_cookie_t atom_net_startup_id_c =
xcb_intern_atom(xconnection, FALSE,
sizeof("_NET_STARTUP_ID") - 1, "_NET_STARTUP_ID");
display = sn_new0 (SnDisplay, 1);
display->xconnection = xconnection;
display->n_screens = xcb_setup_roots_length (xcb_get_setup (xconnection));
display->screens = sn_new (xcb_screen_t*, display->n_screens);
display->refcount = 1;
display->xcb_push_trap_func = push_trap_func;
display->xcb_pop_trap_func = pop_trap_func;
for (i = 0; i < display->n_screens; ++i)
display->screens[i] = xcb_aux_get_screen(xconnection, i);
xcb_intern_atom_reply_t *atom_reply;
atom_reply = xcb_intern_atom_reply(display->xconnection,
atom_utf8_string_c,
NULL);
display->UTF8_STRING = atom_reply->atom;
free(atom_reply);
atom_reply = xcb_intern_atom_reply(display->xconnection,
atom_net_startup_info_begin_c,
NULL);
display->NET_STARTUP_INFO_BEGIN = atom_reply->atom;
free(atom_reply);
atom_reply = xcb_intern_atom_reply(display->xconnection,
atom_net_startup_info_c,
NULL);
display->NET_STARTUP_INFO = atom_reply->atom;
free(atom_reply);
atom_reply = xcb_intern_atom_reply(display->xconnection,
atom_net_startup_id_c,
NULL);
display->NET_STARTUP_ID = atom_reply->atom;
free(atom_reply);
return display; return display;
} }
/** /**
* sn_display_ref: * sn_display_ref:
* @display: an #SnDisplay * @display: an #SnDisplay
* *
* Increment the reference count for @display * Increment the reference count for @display
**/ **/
void void
sn_display_ref (SnDisplay *display) sn_display_ref (SnDisplay *display)
{ {
display->refcount += 1; display->refcount += 1;
} }
/** /**
* sn_display_unref: * sn_display_unref:
* @display: an #SnDisplay * @display: an #SnDisplay
* *
* Decrement the reference count for @display, freeing * Decrement the reference count for @display, freeing
* display if the reference count reaches zero. * display if the reference count reaches zero.
**/ **/
void void
sn_display_unref (SnDisplay *display) sn_display_unref (SnDisplay *display)
{ {
display->refcount -= 1; display->refcount -= 1;
if (display->refcount == 0) if (display->refcount == 0)
{ {
if (display->xmessage_funcs) if (display->xmessage_funcs)
sn_list_free (display->xmessage_funcs); sn_list_free (display->xmessage_funcs);
if (display->pending_messages) if (display->pending_messages)
sn_list_free (display->pending_messages); sn_list_free (display->pending_messages);
switch (display->type) sn_free (display->screens);
{ sn_free (display);
case SN_DISPLAY_TYPE_XLIB:
sn_free (display->x.xlib.screens);
break;
}
sn_free (display);
} }
} }
/** /**
* sn_display_get_x_display: * sn_display_get_x_display:
* @display: an #SnDisplay * @display: an #SnDisplay
* This function only returns a value if the SnDisplay
* has been created with sn_display_new().
* *
* *
* *
* Return value: X display for this #SnDisplay * Return value: X display for this #SnDisplay
**/ **/
Display* Display*
sn_display_get_x_display (SnDisplay *display) sn_display_get_x_display (SnDisplay *display)
{ {
if(display->type == SN_DISPLAY_TYPE_XLIB) return display->xdisplay;
return display->x.xlib.xdisplay; }
return NULL;
/**
* sn_display_get_x_connection:
* @display: an #SnDisplay
* This function only returns a value if the SnDisplay
* has been created with sn_xcb_display_new().
*
*
*
* Return value: X connection for this #SnDisplay
**/
xcb_connection_t*
sn_display_get_x_connection(SnDisplay *display)
{
return display->xconnection;
} }
/** /**
* sn_internal_display_get_id: * sn_internal_display_get_id:
* @display: an #SnDisplay * @display: an #SnDisplay
* *
* *
* *
* Return value: X display id. * Return value: X display id.
**/ **/
void * void *
sn_internal_display_get_id (SnDisplay *display) sn_internal_display_get_id (SnDisplay *display)
{ {
switch (display->type) return display->xconnection;
{
case SN_DISPLAY_TYPE_XLIB:
return display->x.xlib.xdisplay;
}
return NULL;
} }
/** /**
* sn_internal_display_get_x_screen: * sn_internal_display_get_x_screen:
* @display: an #SnDisplay * @display: an #SnDisplay
* @number: screen number to get * @number: screen number to get
* *
* Gets a screen by number; if the screen number * Gets a screen by number; if the screen number
* does not exist, returns %NULL. * does not exist, returns %NULL.
* *
* Return value: X screen or %NULL * Return value: X screen or %NULL
**/ **/
Screen* xcb_screen_t*
sn_internal_display_get_x_screen (SnDisplay *display, sn_internal_display_get_x_screen (SnDisplay *display,
int number) int number)
{ {
if (display->type != SN_DISPLAY_TYPE_XLIB || number < 0 || number >= display if (number < 0 || number >= display->n_screens)
->n_screens) return NULL;
return NULL; else
else return display->screens[number];
return display->x.xlib.screens[number];
} }
/** /**
* sn_internal_display_get_root_window: * sn_internal_display_get_root_window:
* @display: an #SnDisplay * @display: an #SnDisplay
* @number: screen number to get root window from * @number: screen number to get root window from
* *
* Gets a root window; if the screen number * Gets a root window; if the screen number
* does not exist, returns %NULL. * does not exist, returns %NULL.
* *
* Return value: X root window or %NULL * Return value: X root window or %NULL
**/ **/
Window xcb_window_t
sn_internal_display_get_root_window (SnDisplay *display, sn_internal_display_get_root_window (SnDisplay *display,
int number) int number)
{ {
if (number >= 0 && number < display->n_screens) if (number >= 0 && number < display->n_screens)
switch (display->type) return display->screens[number]->root;
{
case SN_DISPLAY_TYPE_XLIB:
return RootWindow (display->x.xlib.xdisplay, number);
}
return None; return None;
} }
/** /**
* sn_internal_display_get_type
* @display: an #SnDisplay
*
*
*
* Return value: X connection type
*/
enum SnDisplayType
sn_internal_display_get_type (SnDisplay *display)
{
return display->type;
}
/**
* sn_internal_display_get_screen_number: * sn_internal_display_get_screen_number:
* @display an #SnDisplay * @display an #SnDisplay
* *
* *
* *
* Return value: The number of screen for this #SnDisplay * Return value: The number of screen for this #SnDisplay
**/ **/
int int
sn_internal_display_get_screen_number (SnDisplay *display) sn_internal_display_get_screen_number (SnDisplay *display)
{ {
skipping to change at line 258 skipping to change at line 326
* only launchers and launch feedback displayers. The function returns * only launchers and launch feedback displayers. The function returns
* false for mapping, unmapping, window destruction, and selection * false for mapping, unmapping, window destruction, and selection
* events even if they were involved in launch feedback. * events even if they were involved in launch feedback.
* *
* Return value: true if the event was a property notify or client message invol ved in launch feedback * Return value: true if the event was a property notify or client message invol ved in launch feedback
**/ **/
sn_bool_t sn_bool_t
sn_display_process_event (SnDisplay *display, sn_display_process_event (SnDisplay *display,
XEvent *xevent) XEvent *xevent)
{ {
sn_bool_t retval; sn_bool_t retval;
retval = FALSE; retval = FALSE;
if (sn_internal_monitor_process_event (display)) if (sn_internal_monitor_process_event (display))
retval = TRUE; retval = TRUE;
if (sn_internal_xmessage_process_event (display, xevent)) switch(xevent->xany.type)
retval = TRUE; {
case ClientMessage:
if (sn_internal_xmessage_process_client_message (display,
xevent->xclient.window,
xevent->xclient.message_t
ype,
xevent->xclient.data.b))
retval = TRUE;
break;
default:
break;
}
return retval; return retval;
}
/**
* sn_xcb_display_process_event:
* @display: a display
* @xevent: X event
*
* libsn should be given a chance to see all X events by passing them
* to this function. If the event was a property notify or client
* message related to the launch feedback protocol, the
* sn_display_process_event() returns true. Calling
* sn_display_process_event() is not currently required for launchees,
* only launchers and launch feedback displayers. The function returns
* false for mapping, unmapping, window destruction, and selection
* events even if they were involved in launch feedback.
*
* Return value: true if the event was a property notify or client message invol
ved in launch feedback
**/
sn_bool_t
sn_xcb_display_process_event (SnDisplay *display,
xcb_generic_event_t *xevent)
{
sn_bool_t retval;
retval = FALSE;
if (sn_internal_monitor_process_event (display))
retval = TRUE;
switch(XCB_EVENT_RESPONSE_TYPE(xevent))
{
case XCB_CLIENT_MESSAGE:
{
xcb_client_message_event_t *ev = (xcb_client_message_event_t *) xevent;
if (sn_internal_xmessage_process_client_message (display,
ev->window,
ev->type,
(const char *) ev->data
.data8))
retval = TRUE;
}
break;
default:
break;
}
return retval;
} }
/** /**
* sn_display_error_trap_push: * sn_display_error_trap_push:
* @display: a display * @display: a display
* *
* Calls the push_trap_func from sn_display_new() if non-NULL. * Calls the push_trap_func from sn_display_new() if non-NULL.
**/ **/
void void
sn_display_error_trap_push (SnDisplay *display) sn_display_error_trap_push (SnDisplay *display)
{ {
switch (display->type) /* SnDisplay has been created for Xlib */
{ if (display->xdisplay)
case SN_DISPLAY_TYPE_XLIB: {
if (display->x.xlib.push_trap_func) if (display->push_trap_func)
(* display->x.xlib.push_trap_func) (display, display->x.xlib.xdispla (* display->push_trap_func) (display, display->xdisplay);
y); }
break; else
} {
if (display->xcb_push_trap_func)
(* display->xcb_push_trap_func) (display, display->xconnection);
}
} }
/** /**
* sn_display_error_trap_pop: * sn_display_error_trap_pop:
* @display: a display * @display: a display
* *
* Calls the pop_trap_func from sn_display_new() if non-NULL. * Calls the pop_trap_func from sn_display_new() if non-NULL.
**/ **/
void void
sn_display_error_trap_pop (SnDisplay *display) sn_display_error_trap_pop (SnDisplay *display)
{ {
switch (display->type) /* SnDisplay has been created for Xlib */
{ if (display->xdisplay)
case SN_DISPLAY_TYPE_XLIB: {
if (display->x.xlib.pop_trap_func) if (display->pop_trap_func)
(* display->x.xlib.pop_trap_func) (display, display->x.xlib.xdisplay (* display->pop_trap_func) (display, display->xdisplay);
); }
break; else
} {
if (display->xcb_pop_trap_func)
(* display->xcb_pop_trap_func) (display, display->xconnection);
}
} }
void void
sn_internal_display_get_xmessage_data (SnDisplay *display, sn_internal_display_get_xmessage_data (SnDisplay *display,
SnList **funcs, SnList **funcs,
SnList **pending) SnList **pending)
{ {
if (display->xmessage_funcs == NULL) if (display->xmessage_funcs == NULL)
display->xmessage_funcs = sn_list_new (); display->xmessage_funcs = sn_list_new ();
if (display->pending_messages == NULL) if (display->pending_messages == NULL)
display->pending_messages = sn_list_new (); display->pending_messages = sn_list_new ();
if (funcs) if (funcs)
*funcs = display->xmessage_funcs; *funcs = display->xmessage_funcs;
if (pending) if (pending)
*pending = display->pending_messages; *pending = display->pending_messages;
}
xcb_atom_t
sn_internal_get_utf8_string_atom(SnDisplay *display)
{
return display->UTF8_STRING;
}
xcb_atom_t
sn_internal_get_net_startup_id_atom(SnDisplay *display)
{
return display->NET_STARTUP_ID;
}
xcb_atom_t
sn_internal_get_net_startup_info_atom(SnDisplay *display)
{
return display->NET_STARTUP_INFO;
}
xcb_atom_t
sn_internal_get_net_startup_info_begin_atom(SnDisplay *display)
{
return display->NET_STARTUP_INFO_BEGIN;
} }
 End of changes. 28 change blocks. 
110 lines changed or deleted 265 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)