[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] Ecore_X_Icccm patch



Christopher Michael wrote:
Hey All,

I'm sending this as diff to list, without actual commitsies, so it can get proper review before going in as the icccm stuff is new to me.

Well, since you ask... :)

XGetIconSizes returns an array of XIconSize structures. If you want to be able to handle more than the first you'll have to change your API.

In ecore_x_icccm_icon_size_set you set the suggested icon size to anywhere between 8x8 and 48x48. That's fine and all, but what if say e17 wants to suggest something else, maybe { 16x16, 32x32, 64x64 }?

Nitpicks below.

/Kim

Cheers,
dh


------------------------------------------------------------------------

Index: Ecore_X.h
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.174
diff -u -r1.174 Ecore_X.h
--- Ecore_X.h	29 Sep 2006 05:49:13 -0000	1.174
+++ Ecore_X.h	31 Oct 2006 13:13:06 -0000
@@ -70,6 +70,12 @@
    unsigned int *data;
 } Ecore_X_Icon;
+typedef struct _Ecore_X_Icon_Size {
+   int min_width, min_height;
+   int max_width, max_height;
+   int width_inc, height_inc;
+} Ecore_X_Icon_Size;
+ typedef enum _Ecore_X_Window_State {
     /** The window is iconified. */
     ECORE_X_WINDOW_STATE_ICONIFIED,
@@ -1241,6 +1247,8 @@
 EAPI void  ecore_x_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv);
 EAPI char *ecore_x_icccm_icon_name_get(Ecore_X_Window win);
 EAPI void  ecore_x_icccm_icon_name_set(Ecore_X_Window win, const char *t);
+EAPI Ecore_X_Icon_Size *ecore_x_icccm_icon_size_get(Ecore_X_Window win);
+EAPI void  ecore_x_icccm_icon_size_set(Ecore_X_Window win);
 EAPI void  ecore_x_icccm_colormap_window_set(Ecore_X_Window win, Ecore_X_Window subwin);
 EAPI void  ecore_x_icccm_colormap_window_unset(Ecore_X_Window win, Ecore_X_Window subwin);
 EAPI void  ecore_x_icccm_transient_for_set(Ecore_X_Window win, Ecore_X_Window forwin);


------------------------------------------------------------------------

Index: ecore_x_icccm.c
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x_icccm.c,v
retrieving revision 1.45
diff -u -r1.45 ecore_x_icccm.c
--- ecore_x_icccm.c	10 Jun 2006 19:26:25 -0000	1.45
+++ ecore_x_icccm.c	31 Oct 2006 13:13:41 -0000
@@ -30,6 +30,7 @@
 EAPI Ecore_X_Atom  ECORE_X_ATOM_WM_CLIENT_LEADER = 0;
 EAPI Ecore_X_Atom  ECORE_X_ATOM_WM_TRANSIENT_FOR = 0;
 EAPI Ecore_X_Atom  ECORE_X_ATOM_WM_SAVE_YOURSELF = 0;
+EAPI Ecore_X_Atom  ECORE_X_ATOM_WM_ICON_SIZE = 0;
EAPI void
 ecore_x_icccm_init(void)
@@ -64,6 +65,8 @@
       XInternAtom(_ecore_x_disp, "WM_TRANSIENT_FOR", False);
    ECORE_X_ATOM_WM_SAVE_YOURSELF =
       XInternAtom(_ecore_x_disp, "WM_SAVE_YOURSELF", False);
+   ECORE_X_ATOM_WM_ICON_SIZE =
+      XInternAtom(_ecore_x_disp, "WM_ICON_SIZE", False);
 }
EAPI void
@@ -1020,7 +1023,6 @@
       return (Ecore_X_Window) forwin;
    else
       return 0;
-
 }
/**
@@ -1095,6 +1097,58 @@
XSendEvent(_ecore_x_disp, root, False,
               SubstructureNotifyMask | SubstructureRedirectMask, &xev);
+}
+
+/**
+ * Get the window's icon size.
+ * @param win The window, or NULL for Root Window
NULL is a pointer. win is not. None would be the X choice, in Ecore_X land it should probably just be 0 (I'm not a big fan of the 0->DefaultRoot mapping used inconsistently throughout ecore_x, though).

+ * @return The window's icon size, or 0 if unset */
+EAPI Ecore_X_Icon_Size *
+ecore_x_icccm_icon_size_get(Ecore_X_Window win)
+{
+   int count;
+   Ecore_X_Icon_Size *esize;
+   XIconSize *size;
+ + if (win == 0)
+     win = DefaultRootWindow(_ecore_x_disp);
+ + if (XGetIconSizes(_ecore_x_disp, win, &size, &count)) + {
+	esize = calloc(1, sizeof(Ecore_X_Icon_Size));
No big deal but why not use malloc when you are writing the entire structure anyway.

+	esize->min_height = size->min_height;
+	esize->min_width = size->min_width;
+	esize->max_height = size->max_height;
+	esize->max_width = size->max_width;
+	esize->width_inc = size->width_inc;
+	esize->height_inc = size->height_inc;
+	if (size) XFree(size);
There is not much point in checking size here, you have already been dereferencing it.

+	return esize;
+     }
+   else
+     return NULL;
+}
+
+/**
+ * Set the window's icon size.
+ * @param win The window, or NULL for Root Window */
+EAPI void
+ecore_x_icccm_icon_size_set(Ecore_X_Window win) +{
+   XIconSize *size;
+
+   if (win == 0)
+     win = DefaultRootWindow(_ecore_x_disp);
+ + size = XAllocIconSize();
No checking?

+   size->min_width = 8;
+   size->min_height = 8;
+   size->max_width = 48;
+   size->max_height = 48;
+   size->width_inc = 1;
+   size->height_inc = 1;
+   XSetIconSizes(_ecore_x_disp, win, size, 1);
+   XFree(size);
 }
/* FIXME: there are older E hints, gnome hints and mwm hints and new netwm */