[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 x, y, rc;
int rc;
//XSetWindowAttributes xswa;
/* If the icon is being embedded as hidden,
* we just start listening for property changes
* to track _XEMBED mapped state */
@ -72,38 +74,47 @@ int embedder_embed(struct TrayIcon *ti)
XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask);
return x11_ok();
}
/* 0. Start listening for events on icon window */
XSelectInput(tray_data.dpy, ti->wid, StructureNotifyMask | PropertyChangeMask);
if (!x11_ok()) RETURN_STATUS(FAILURE);
/* 1. Calculate position of mid-parent window */
CALC_INNER_POS(x, y, ti);
LOG_TRACE(("position of icon 0x%x inside the tray: (%d, %d)\n", ti->wid, x, y));
//CALC_INNER_POS(x, y, ti);
//LOG_TRACE(("position of icon 0x%x inside the tray: (%d, %d)\n", ti->wid, x, y));
/* 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.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 */
//xswa.win_gravity = settings.bit_gravity;
//XChangeWindowAttributes(tray_data.dpy, ti->mid_parent, CWWinGravity, &xswa);
#ifndef DEBUG_HIGHLIGHT_MIDPARENT
XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, ParentRelative);
#else
XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, 0);
#endif
if (!x11_ok() || ti->mid_parent == None) RETURN_STATUS(FAILURE);
LOG_TRACE(("created mid-parent window 0x%x\n", ti->mid_parent));
//XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, ParentRelative);
//if (!x11_ok() || ti->mid_parent == None) RETURN_STATUS(FAILURE);
if (!x11_ok())
RETURN_STATUS(FAILURE);
//LOG_TRACE(("created mid-parent window 0x%x\n", ti->mid_parent));
/* 3. Embed window into mid-parent */
switch (ti->cmode) {
case CM_KDE:
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);
break;
default:
break;
}
XSetWindowBackgroundPixmap(tray_data.dpy, ti->wid, ParentRelative);
/* 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
* scollbar windows */
//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"));
}
/* Destroy mid-parent */
if (ti->mid_parent != None) {
/*if (ti->mid_parent != None) {
XDestroyWindow(tray_data.dpy, ti->mid_parent);
if (!x11_ok()) LOG_ERROR(("failed to destroy icon mid-parent 0x%x\n", ti->mid_parent));
}
}*/
break;
default:
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)
{
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 */
XSelectInput(tray_data.dpy, ti->wid, PropertyChangeMask);
if (!x11_ok()) {
@ -176,8 +188,9 @@ int embedder_hide(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);
XMoveWindow(tray_data.dpy, ti->wid, 0, 0);
//XMoveResizeWindow(tray_data.dpy, ti->mid_parent, ti->x, ti->y, ti->w, ti->h);
//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)
@ -185,7 +198,8 @@ int embedder_show(struct TrayIcon *ti)
//unsigned int x, y;
/* If the window has never been embedded,
* perform real embedding */
if (ti->mid_parent == None) {
//if (ti->mid_parent == None) {
if (!ti->is_embedded) {
ti->is_visible = True;
return embedder_embed(ti);
}
@ -203,7 +217,7 @@ int embedder_show(struct TrayIcon *ti)
/* 3. map icon ? */
XMapRaised(tray_data.dpy, ti->wid);
/* 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);
if (!x11_ok()) {
ti->is_invalid = True;
@ -261,7 +275,7 @@ int embedder_update_positions(int forced)
int embedder_refresh(struct TrayIcon *ti)
{
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);
/* Check if the icon has survived all these manipulations */
if (!x11_ok()) {

View File

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

View File

@ -31,7 +31,7 @@ struct TrayIcon {
struct TrayIcon *next;
struct TrayIcon *prev;
Window wid; /* Window ID */
Window mid_parent; /* Mid-parent ID */
//Window mid_parent; /* Mid-parent ID */
int x, y, w, h;
int iw, ih;
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;
/* Reparenting out of the tray is one of non-destructive
* 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));
#ifdef DEBUG
print_icon_data(ti);