[GB.DESKTOP.X11]

* NEW: Embed icons directly in the specified window.


git-svn-id: svn://localhost/gambas/trunk@6352 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-06-30 22:08:22 +00:00
parent 9ac97418a0
commit e2a2762f15
4 changed files with 41 additions and 26 deletions

View File

@ -63,8 +63,10 @@ void *send_delayed_confirmation(void *dummy)
int embedder_embed(struct TrayIcon *ti) int embedder_embed(struct TrayIcon *ti)
{ {
int x, y, rc; int rc;
//XSetWindowAttributes xswa; //XSetWindowAttributes xswa;
/* If the icon is being embedded as hidden, /* If the icon is being embedded as hidden,
* we just start listening for property changes * we just start listening for property changes
* to track _XEMBED mapped state */ * to track _XEMBED mapped state */
@ -72,38 +74,47 @@ int embedder_embed(struct TrayIcon *ti)
XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask); XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask);
return x11_ok(); return x11_ok();
} }
/* 0. Start listening for events on icon window */ /* 0. Start listening for events on icon window */
XSelectInput(tray_data.dpy, ti->wid, StructureNotifyMask | PropertyChangeMask); XSelectInput(tray_data.dpy, ti->wid, StructureNotifyMask | PropertyChangeMask);
if (!x11_ok()) RETURN_STATUS(FAILURE); if (!x11_ok()) RETURN_STATUS(FAILURE);
/* 1. Calculate position of mid-parent window */ /* 1. Calculate position of mid-parent window */
CALC_INNER_POS(x, y, ti); //CALC_INNER_POS(x, y, ti);
LOG_TRACE(("position of icon 0x%x inside the tray: (%d, %d)\n", ti->wid, x, y)); //LOG_TRACE(("position of icon 0x%x inside the tray: (%d, %d)\n", ti->wid, x, y));
/* 2. Create mid-parent window */ /* 2. Create mid-parent window */
ti->mid_parent = XCreateSimpleWindow(tray_data.dpy, tray_data.tray,
/*ti->mid_parent = XCreateSimpleWindow(tray_data.dpy, tray_data.tray,
ti->l.icn_rect.x + x, ti->l.icn_rect.y + y, ti->l.icn_rect.x + x, ti->l.icn_rect.y + y,
ti->l.wnd_sz.x, ti->l.wnd_sz.y, 0, 0, 0); ti->l.wnd_sz.x, ti->l.wnd_sz.y, 0, 0, 0);*/
/* 2.5. Setup mid-parent window properties */ /* 2.5. Setup mid-parent window properties */
//xswa.win_gravity = settings.bit_gravity; //xswa.win_gravity = settings.bit_gravity;
//XChangeWindowAttributes(tray_data.dpy, ti->mid_parent, CWWinGravity, &xswa); //XChangeWindowAttributes(tray_data.dpy, ti->mid_parent, CWWinGravity, &xswa);
#ifndef DEBUG_HIGHLIGHT_MIDPARENT
XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, ParentRelative); //XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, ParentRelative);
#else
XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, 0); //if (!x11_ok() || ti->mid_parent == None) RETURN_STATUS(FAILURE);
#endif if (!x11_ok())
if (!x11_ok() || ti->mid_parent == None) RETURN_STATUS(FAILURE); RETURN_STATUS(FAILURE);
LOG_TRACE(("created mid-parent window 0x%x\n", ti->mid_parent));
//LOG_TRACE(("created mid-parent window 0x%x\n", ti->mid_parent));
/* 3. Embed window into mid-parent */ /* 3. Embed window into mid-parent */
switch (ti->cmode) { switch (ti->cmode) {
case CM_KDE: case CM_KDE:
case CM_FDO: case CM_FDO:
XReparentWindow(tray_data.dpy, ti->wid, ti->mid_parent, 0, 0); XReparentWindow(tray_data.dpy, ti->wid, tray_data.tray, 0, 0);
XMapRaised(tray_data.dpy, ti->wid); XMapRaised(tray_data.dpy, ti->wid);
break; break;
default: default:
break; break;
} }
XSetWindowBackgroundPixmap(tray_data.dpy, ti->wid, ParentRelative);
/* 4. Show mid-parent */ /* 4. Show mid-parent */
XMapWindow(tray_data.dpy, ti->mid_parent); //XMapWindow(tray_data.dpy, ti->mid_parent);
/* mid-parent must be lowered so that it does not osbcure /* mid-parent must be lowered so that it does not osbcure
* scollbar windows */ * scollbar windows */
//XLowerWindow(tray_data.dpy, ti->mid_parent); //XLowerWindow(tray_data.dpy, ti->mid_parent);
@ -145,10 +156,10 @@ int embedder_unembed(struct TrayIcon *ti)
if (!x11_ok()) LOG_ERROR(("failed to move icon 0x%x out of the tray\n")); if (!x11_ok()) LOG_ERROR(("failed to move icon 0x%x out of the tray\n"));
} }
/* Destroy mid-parent */ /* Destroy mid-parent */
if (ti->mid_parent != None) { /*if (ti->mid_parent != None) {
XDestroyWindow(tray_data.dpy, ti->mid_parent); XDestroyWindow(tray_data.dpy, ti->mid_parent);
if (!x11_ok()) LOG_ERROR(("failed to destroy icon mid-parent 0x%x\n", ti->mid_parent)); if (!x11_ok()) LOG_ERROR(("failed to destroy icon mid-parent 0x%x\n", ti->mid_parent));
} }*/
break; break;
default: default:
LOG_ERR_IE(("Error: the compatibility mode %d is not supported (should not happen)\n", ti->cmode)); LOG_ERR_IE(("Error: the compatibility mode %d is not supported (should not happen)\n", ti->cmode));
@ -160,7 +171,8 @@ int embedder_unembed(struct TrayIcon *ti)
int embedder_hide(struct TrayIcon *ti) int embedder_hide(struct TrayIcon *ti)
{ {
XUnmapWindow(tray_data.dpy, ti->mid_parent); //XUnmapWindow(tray_data.dpy, ti->mid_parent);
XUnmapWindow(tray_data.dpy, ti->wid);
/* We do not wany any StructureNotify events for icon window anymore */ /* We do not wany any StructureNotify events for icon window anymore */
XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask); XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask);
if (!x11_ok()) { if (!x11_ok()) {
@ -176,8 +188,9 @@ int embedder_hide(struct TrayIcon *ti)
static void move_icon(struct TrayIcon *ti) static void move_icon(struct TrayIcon *ti)
{ {
XMoveResizeWindow(tray_data.dpy, ti->mid_parent, ti->x, ti->y, ti->w, ti->h); //XMoveResizeWindow(tray_data.dpy, ti->mid_parent, ti->x, ti->y, ti->w, ti->h);
XMoveWindow(tray_data.dpy, ti->wid, 0, 0); //XMoveWindow(tray_data.dpy, ti->wid, 0, 0);
XMoveResizeWindow(tray_data.dpy, ti->wid, ti->x, ti->y, ti->w, ti->h);
} }
int embedder_show(struct TrayIcon *ti) int embedder_show(struct TrayIcon *ti)
@ -185,7 +198,8 @@ int embedder_show(struct TrayIcon *ti)
//unsigned int x, y; //unsigned int x, y;
/* If the window has never been embedded, /* If the window has never been embedded,
* perform real embedding */ * perform real embedding */
if (ti->mid_parent == None) { //if (ti->mid_parent == None) {
if (!ti->is_embedded) {
ti->is_visible = True; ti->is_visible = True;
return embedder_embed(ti); return embedder_embed(ti);
} }
@ -203,7 +217,7 @@ int embedder_show(struct TrayIcon *ti)
/* 3. map icon ? */ /* 3. map icon ? */
XMapRaised(tray_data.dpy, ti->wid); XMapRaised(tray_data.dpy, ti->wid);
/* 4. map mid-parent */ /* 4. map mid-parent */
XMapWindow(tray_data.dpy, ti->mid_parent); //XMapWindow(tray_data.dpy, ti->mid_parent);
XSelectInput(tray_data.dpy, ti->wid, StructureNotifyMask | PropertyChangeMask); XSelectInput(tray_data.dpy, ti->wid, StructureNotifyMask | PropertyChangeMask);
if (!x11_ok()) { if (!x11_ok()) {
ti->is_invalid = True; ti->is_invalid = True;
@ -261,7 +275,7 @@ int embedder_update_positions(int forced)
int embedder_refresh(struct TrayIcon *ti) int embedder_refresh(struct TrayIcon *ti)
{ {
if (!ti->is_visible) return NO_MATCH; if (!ti->is_visible) return NO_MATCH;
XClearWindow(tray_data.dpy, ti->mid_parent); //XClearWindow(tray_data.dpy, ti->mid_parent);
x11_refresh_window(tray_data.dpy, ti->wid, ti->l.wnd_sz.x, ti->l.wnd_sz.y, True); x11_refresh_window(tray_data.dpy, ti->wid, ti->l.wnd_sz.x, ti->l.wnd_sz.y, True);
/* Check if the icon has survived all these manipulations */ /* Check if the icon has survived all these manipulations */
if (!x11_ok()) { if (!x11_ok()) {

View File

@ -44,7 +44,7 @@ struct TrayIcon *icon_list_new(Window wid, int cmode)
new_icon->wid = wid; new_icon->wid = wid;
new_icon->l.wnd_sz.x = 0; new_icon->l.wnd_sz.x = 0;
new_icon->l.wnd_sz.y = 0; new_icon->l.wnd_sz.y = 0;
new_icon->mid_parent = None; //new_icon->mid_parent = None;
new_icon->cmode = cmode; new_icon->cmode = cmode;
new_icon->is_embedded = False; new_icon->is_embedded = False;
new_icon->is_layed_out = False; new_icon->is_layed_out = False;
@ -160,7 +160,7 @@ struct TrayIcon *icon_list_find_ex(Window wid)
/* Traverse the whole list */ /* Traverse the whole list */
struct TrayIcon *tmp; struct TrayIcon *tmp;
for (tmp = icons_head; tmp != NULL; tmp = tmp->next) for (tmp = icons_head; tmp != NULL; tmp = tmp->next)
if (tmp->wid == wid || tmp->mid_parent == wid) if (tmp->wid == wid) // || tmp->mid_parent == wid)
return tmp; return tmp;
return NULL; return NULL;
} }

View File

@ -31,7 +31,7 @@ struct TrayIcon {
struct TrayIcon *next; struct TrayIcon *next;
struct TrayIcon *prev; struct TrayIcon *prev;
Window wid; /* Window ID */ Window wid; /* Window ID */
Window mid_parent; /* Mid-parent ID */ //Window mid_parent; /* Mid-parent ID */
int x, y, w, h; int x, y, w, h;
int iw, ih; int iw, ih;
int cmode; /* Compatibility mode: CM_FDO/CM_KDE (see embed.h) */ int cmode; /* Compatibility mode: CM_FDO/CM_KDE (see embed.h) */

View File

@ -435,7 +435,8 @@ void reparent_notify(XReparentEvent ev)
if (ti == NULL) return; if (ti == NULL) return;
/* Reparenting out of the tray is one of non-destructive /* Reparenting out of the tray is one of non-destructive
* ways to end XEMBED protocol (see spec) */ * ways to end XEMBED protocol (see spec) */
if (ti->is_embedded && ti->mid_parent != ev.parent) { //if (ti->is_embedded && ti->mid_parent != ev.parent) {
if (ti->is_embedded && tray_data.tray != ev.parent) {
LOG_TRACE(("will now unembed 0x%x\n", ti->wid)); LOG_TRACE(("will now unembed 0x%x\n", ti->wid));
#ifdef DEBUG #ifdef DEBUG
print_icon_data(ti); print_icon_data(ti);