예제 #1
0
/*
    建立 Tray 
*/
void gui_tray_init(void)
{
    winlist_t *win = NULL;

    if (gui->tray_win)
    {
	//return;
	win = gui->tray_win;
    }
    else
    {
#if 0
	//manager_window = XGetSelectionOwner(gui->display, selection_atom);
	manager_window = ManagerWindow(gui->display, gui->screen);

	if (manager_window != None)
	{
	    Atom visual_atom = XInternAtom(gui->display, "_NET_SYSTEM_TRAY_VISUAL", False);

	    Atom type;
	    int format;
	    union {
		    unsigned long *prop;
		    unsigned char *prop_ch;
	    } prop = { NULL };
	    unsigned long nitems;
	    unsigned long bytes_after;
	    int result;

	    type = None;
	    result = XGetWindowProperty (gui->display,
					manager_window,
					visual_atom,
					0, sizeof(long), False,
					XA_VISUALID,
					&type, &format, &nitems,
					&bytes_after, &(prop.prop_ch));

	    Visual *default_xvisual;
	    
	    if (result == 0 &&
		type == XA_VISUALID && nitems == 1 && format == 32)
		{
		    VisualID visual_id = prop.prop[0];
		    visual = x11_screen_lookup_visual (visual_id);
		}
	}
#endif
#if 1
/*        Atom actual_type;
        int actual_format;
        unsigned long nitems, bytes_remaining;
        unsigned char *data = 0;
        int result = XGetWindowProperty(gui->display, manager_window, visual_atom, 0, 1,
                                        False, XA_VISUALID, &actual_type,
                                        &actual_format, &nitems, &bytes_remaining, &data);
        VisualID vid = 0;
        if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 &&
                nitems == 1 && bytes_remaining == 0)
            vid = *(VisualID*)data;
        if (data)
            XFree(data);
        if (vid == 0)
            return;
*/
        uint mask = VisualScreenMask;
        XVisualInfo *vi, rvi;
        int count=0, i;
        //rvi.visualid = vid;
	rvi.screen = gui->screen;
        vi = XGetVisualInfo(gui->display, mask, &rvi, &count);
	for(i=0; i<count; i++)
	{
	      if (vi[i].depth == 32 &&
		  (vi[i].red_mask   == 0xff0000 &&
		   vi[i].green_mask == 0x00ff00 &&
		   vi[i].blue_mask  == 0x0000ff))
		{
			//printf("rgba_visual=%d\n", vi[i].visual->visualid);
			visual = &vi[i];
			break;
		}
	}
        /*if (vi) {
            //visual = vi[0];
	    visual = &vi[0];
	    //return;
            //XFree((char*)vi);
        }*/
#endif

	if(visual && visual->visual)
	    win = gui_new_win_tray((XVisualInfo*)visual);
	else
	    win = gui_new_win();
    }

    /* Tray 不需要邊框 */
    XSetWindowBorderWidth(gui->display, win->window, 0);

    XSetWindowAttributes win_attr;
    win_attr.override_redirect = True;
    XChangeWindowAttributes(gui->display, win->window,
			CWOverrideRedirect, &win_attr);

    Pixmap tray, mask;
    XpmAttributes attributes;
    attributes.valuemask = 0;

    if (!ProcessTrayIcon(gui->display, win->window, oxim_tray, &icon, &icon_mask,
				&picon)) 
    {
	//fprintf(stderr, "failed to get inactive icon image\n");
	return;
    }
#if 1
    if(visual && visual->visual)
    {
	/* GCs for copy and drawing on mask */
	XGCValues gv;
	gv.foreground = BlackPixel(gui->display, gui->screen);
	gv.background = BlackPixel(gui->display, gui->screen);
	//GC gc = XCreateGC(gui->display, win->window, GCBackground|GCForeground, &gv);
	GC gc = XCreateGC(gui->display, aw, GCBackground|GCForeground, &gv);

	XSetClipMask(gui->display, gc, icon_mask);
    }
#endif
    XpmCreatePixmapFromData(gui->display, win->window,
		oxim_tray, &tray, &mask, &attributes);
    tray_w = attributes.width;
    tray_h = attributes.height;

    win->width  = tray_w;
    win->height = tray_h;

    XpmFreeAttributes(&attributes);
    XFreePixmap(gui->display, tray);
    if (mask)
    {
	XFreePixmap(gui->display, mask);
    }
    win->pos_x = 0;
    win->pos_y = 0;

    win->win_draw_func = NULL;
    win->win_event_func = gui_focus_event;

    XSizeHints *size_hints = XAllocSizeHints();
    size_hints->flags = PMinSize | PMaxSize;
    size_hints->min_width = win->width;
    size_hints->min_height = win->height;
    size_hints->max_width = win->width;
    size_hints->max_height = win->height;
    XSetWMNormalHints(gui->display, win->window, size_hints);
    XFree(size_hints);

    Atom xembed_info = XInternAtom(gui->display, "_XEMBED_INFO", False);
    unsigned int mapping[2];
    mapping[0] = 0; /* ver 0 */
    mapping[1] = 1; /* request mapping */
    XChangeProperty(gui->display, win->window, xembed_info, xembed_info,
			32, PropModeReplace, (unsigned char *)mapping, 2);
    gui->tray_win = win;
}
예제 #2
0
파일: gui_menusel.c 프로젝트: lewtds/vxim
winlist_t *
gui_menusel_init(gui_t *gui, int imid, greq_win_t *gw)
{
    winlist_t *win;
    greq_menusel_t *info;
    XSetWindowAttributes win_attr;
    const int border=4;

    if (gw->greq_data->type != GREQ_MENUSEL)
	return NULL;
    info = &(gw->greq_data->menusel);

    win = gui_new_win();
    win->wtype = (xtype_t)WTYPE_GUIREQ;
    win->imid  = imid;

    win->font = gui_create_fontset(gui->font, 1);
    win->c_height = (info->n_item<=MENUSEL_NROW) ? info->n_item : MENUSEL_NROW;
    win->height   = win->c_height * (win->font->ef_height + LINE_STEP);
    if (gui->mainwin) {
	win->c_width = gui->mainwin->c_width;
	win->width   = gui->mainwin->width;
	win->pos_x   = gui->mainwin->pos_x - border;
	win->pos_y   = gui->mainwin->pos_y - win->height - 10*FIELD_STEP;
    }
    else {
	win->c_width = gui->mainwin2->c_width * 2;
	win->width   = gui->mainwin2->width * 2;
	win->pos_x   = gui->mainwin2->pos_x - border - gui->mainwin2->width/2;
	win->pos_y   = gui->mainwin2->pos_y - win->height - 10*FIELD_STEP;
    }
    if (win->pos_y <= 0)
	win->pos_y = 1;
    if (win->pos_x <=0)
	win->pos_x = 1;
    else if (win->pos_x+win->width > gui->display_width)
	win->pos_x = gui->display_width - win->width - border;

    win->data = (void *)gw;
    win->win_draw_func = gui_menusel_draw;
    win->win_attrib_func = gui_menusel_attrib;
    win->win_destroy_func = gui_menusel_destroy;
    win->window = XCreateSimpleWindow(gui->display, gui->root,
		win->pos_x, win->pos_y, win->width, win->height, border,
		gui->fg_color, gui->bg_color);
    XSelectInput(gui->display, win->window, (ExposureMask|StructureNotifyMask));
    win_attr.override_redirect = True;
    XChangeWindowAttributes(gui->display, win->window,
			CWOverrideRedirect, &win_attr);
/*  Setup GC  */
    win->n_gc = 3;
    win->wingc = malloc(sizeof(GC) * win->n_gc);

    win->wingc[GC_idx] = XCreateGC(gui->display, win->window, 0, NULL);
    XSetForeground(gui->display, win->wingc[GC_idx], gui->fg_color);
    XSetBackground(gui->display, win->wingc[GC_idx], gui->bg_color);

    win->wingc[GCM_idx] = XCreateGC(gui->display, win->window, 0, NULL);
    XSetForeground(gui->display, win->wingc[GCM_idx], gui->fg_color);
    XSetBackground(gui->display, win->wingc[GCM_idx], gui->mbg_color);

    win->wingc[GCGRID_idx] = XCreateGC(gui->display, win->window, 0, NULL);
    XSetForeground(gui->display, win->wingc[GCGRID_idx], gui->grid_color);
    XSetBackground(gui->display, win->wingc[GCGRID_idx], gui->bg_color);

    gui_winmap_change(win, 1);
    gui_menusel_draw(gui, win);
    return win;
}