Include netinet/in.h for connections to be portable to BSD.

Added the atom declarations for the NetWM application window properties.
Created ecore_x_window_prop_string_{set,get}.
Changed ecore_x_window_prop_title_{set,get} to use the new string functions.


SVN revision: 7531
This commit is contained in:
rbdpngn 2003-10-11 22:14:22 +00:00 committed by rbdpngn
parent e664c4eaa3
commit d4613c5c70
5 changed files with 109 additions and 28 deletions

View File

@ -3,6 +3,7 @@
#include "ecore_con_private.h"
#include "Ecore_Con.h"
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <arpa/inet.h>

View File

@ -489,6 +489,8 @@ void ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h);
void ecore_x_window_cursor_show(Ecore_X_Window win, int show);
void ecore_x_window_prop_property_set(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_Atom format, int size, void *data, int number);
void ecore_x_window_prop_string_set(Ecore_X_Window win, Ecore_X_Atom type, char *str);
char *ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type);
void ecore_x_window_prop_title_set(Ecore_X_Window win, const char *t);
char *ecore_x_window_prop_title_get(Ecore_X_Window win);
void ecore_x_window_prop_name_class_set(Ecore_X_Window win, const char *n, const char *c);

View File

@ -33,9 +33,22 @@ Atom _ecore_x_atom_motif_wm_hints = 0;
Atom _ecore_x_atom_win_layer = 0;
Atom _ecore_x_atom_net_wm_desktop = 0;
Atom _ecore_x_atom_net_current_desktop = 0;
Atom _ecore_x_atom_net_wm_name = 0;
Atom _ecore_x_atom_net_wm_visible_name = 0;
Atom _ecore_x_atom_net_wm_icon_name = 0;
Atom _ecore_x_atom_net_wm_window_type = 0;
Atom _ecore_x_atom_net_wm_state = 0;
Atom _ecore_x_atom_net_wm_state_above = 0;
Atom _ecore_x_atom_net_wm_state_below = 0;
Atom _ecore_x_atom_net_wm_allowed_actions = 0;
Atom _ecore_x_atom_net_wm_strut = 0;
Atom _ecore_x_atom_net_wm_strut_partial = 0;
Atom _ecore_x_atom_net_wm_icon_geometry = 0;
Atom _ecore_x_atom_net_wm_icon = 0;
Atom _ecore_x_atom_net_wm_pid = 0;
Atom _ecore_x_atom_net_wm_handle_icons = 0;
Atom _ecore_x_atom_net_wm_user_time = 0;
Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM] = {0};
@ -229,11 +242,22 @@ ecore_x_init(const char *name)
_ecore_x_atom_wm_name = XInternAtom(_ecore_x_disp, "WM_NAME", False);
_ecore_x_atom_motif_wm_hints = XInternAtom(_ecore_x_disp, "_MOTIF_WM_HINTS", False);
_ecore_x_atom_win_layer = XInternAtom(_ecore_x_disp, "_WIN_LAYER", False);
_ecore_x_atom_net_wm_desktop = XInternAtom(_ecore_x_disp, "_NET_WM_DESKTOP", False);
_ecore_x_atom_net_current_desktop = XInternAtom(_ecore_x_disp, "_NET_CURRENT_DESKTOP", False);
_ecore_x_atom_net_wm_name = XInternAtom(_ecore_x_disp, "_NET_WM_NAME", False);
_ecore_x_atom_net_wm_visible_name = XInternAtom(_ecore_x_disp, "_NET_WM_VISIBLE_NAME", False);
_ecore_x_atom_net_wm_icon_name = XInternAtom(_ecore_x_disp, "_NET_WM_ICON_NAME", False);
_ecore_x_atom_net_wm_desktop = XInternAtom(_ecore_x_disp, "_NET_WM_DESKTOP", False);
_ecore_x_atom_net_wm_window_type = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE", False);
_ecore_x_atom_net_wm_state = XInternAtom(_ecore_x_disp, "_NET_WM_STATE", False);
_ecore_x_atom_net_wm_state_above = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_ABOVE", False);
_ecore_x_atom_net_wm_state_below = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_BELOW", False);
_ecore_x_atom_net_wm_allowed_actions = XInternAtom(_ecore_x_disp, "_NET_WM_ALLOWED_ACTIONS", False);
_ecore_x_atom_net_wm_strut = XInternAtom(_ecore_x_disp, "_NET_WM_STRUT", False);
_ecore_x_atom_net_wm_strut_partial = XInternAtom(_ecore_x_disp, "_NET_WM_STRUT_PARTIAL", False);
_ecore_x_atom_net_wm_icon_geometry = XInternAtom(_ecore_x_disp, "_NET_WM_ICON_GEOMETRY", False);
_ecore_x_atom_net_wm_icon = XInternAtom(_ecore_x_disp, "_NET_WM_ICON", False);
_ecore_x_atom_net_wm_pid = XInternAtom(_ecore_x_disp, "_NET_WM_PID", False);
_ecore_x_atom_net_wm_user_time = XInternAtom(_ecore_x_disp, "_NET_WM_USER_TIME", False);
_ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] = _ecore_x_atom_wm_delete_window;
_ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] = _ecore_x_atom_wm_take_focus;

View File

@ -64,6 +64,21 @@ extern Atom _ecore_x_atom_net_wm_state;
extern Atom _ecore_x_atom_net_wm_state_above;
extern Atom _ecore_x_atom_net_wm_state_below;
extern Atom _ecore_x_atom_net_wm_name;
extern Atom _ecore_x_atom_net_wm_visible_name;
extern Atom _ecore_x_atom_net_wm_icon_name;
extern Atom _ecore_x_atom_net_wm_desktop;
extern Atom _ecore_x_atom_net_wm_window_type;
extern Atom _ecore_x_atom_net_wm_state;
extern Atom _ecore_x_atom_net_wm_allowed_actions;
extern Atom _ecore_x_atom_net_wm_strut;
extern Atom _ecore_x_atom_net_wm_strut_partial;
extern Atom _ecore_x_atom_net_wm_icon_geometry;
extern Atom _ecore_x_atom_net_wm_icon;
extern Atom _ecore_x_atom_net_wm_pid;
extern Atom _ecore_x_atom_net_wm_handle_icons;
extern Atom _ecore_x_atom_net_wm_user_time;
extern Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
void _ecore_x_error_handler_init(void);

View File

@ -84,6 +84,65 @@ ecore_x_window_prop_property_get(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_
return 1;
}
/**
* Set a window string property.
* @param win The window
* @param type The property
* @param str The string
*
* Set a window string property
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_x_window_prop_string_set(Ecore_X_Window win, Ecore_X_Atom type, char *str)
{
XTextProperty xtp;
xtp.value = str;
xtp.format = 8;
xtp.encoding = XA_STRING;
xtp.nitems = strlen(str);
XSetTextProperty(_ecore_x_disp, win, &xtp, type);
}
/**
* Get a window string property.
* @param win The window
* @param type The property
*
* Get a window string property
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
char *
ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type)
{
XTextProperty xtp;
char *str = NULL;
if (XGetTextProperty(_ecore_x_disp, win, &xtp, type))
{
int items;
char **list;
Status s;
if (xtp.format == 8)
{
s = Xutf8TextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items);
if ((s == Success) && (items > 0))
{
str = strdup(*list);
XFreeStringList(list);
}
else
str = strdup((char *)xtp.value);
}
else
str = strdup((char *)xtp.value);
XFree(xtp.value);
}
return str;
}
/**
* Set a window title.
* @param win The window
@ -95,7 +154,8 @@ ecore_x_window_prop_property_get(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_
void
ecore_x_window_prop_title_set(Ecore_X_Window win, const char *t)
{
XStoreName(_ecore_x_disp, win, t);
ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_name, t);
ecore_x_window_prop_string_set(win, _ecore_x_atom_net_wm_name, t);
}
/**
@ -109,32 +169,11 @@ ecore_x_window_prop_title_set(Ecore_X_Window win, const char *t)
char *
ecore_x_window_prop_title_get(Ecore_X_Window win)
{
XTextProperty xtp;
if (XGetWMName(_ecore_x_disp, win, &xtp))
{
int items;
char **list;
Status s;
char *title = NULL;
if (xtp.format == 8)
{
s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items);
if ((s == Success) && (items > 0))
{
title = strdup(*list);
XFreeStringList(list);
}
else
title = strdup((char *)xtp.value);
}
else
title = strdup((char *)xtp.value);
XFree(xtp.value);
return title;
}
return NULL;
char *title;
title = ecore_x_window_prop_string_get(win, _ecore_x_atom_net_wm_name);
if (!title) title = ecore_x_window_prop_string_get(win, _ecore_x_atom_wm_name);
return title;
}
/**