您尚未登录。

#1 2012-06-04 13:53:08

ljj_jjl2008
会员
注册时间: 2012-06-02
帖子: 33

第一次发贴,就要给大家出难题了。关于C语言开发的。关于我的icon de桌面环境的。

我就是ubuntu中文论坛的ljj_jjl2008,第一次来此论坛,大家多关照。
http://forum.ubuntu.org.cn/viewtopic.php?f=168&t=372366
如上,我在ubuntu环境下开发了一套个性化的linux桌面环境,并且在ubuntu12.04的32/64环境下,都能稳定运行。
这个de,主要使用imlib2库来显示界面,使用feh的功能来显示桌面壁纸,和使用wmctrl的源码来管理窗口布局和切换窗口。
有人建议在Arch里面,也打包安装,于是我为Arch写了个pkgbuile文件和install脚本,已经可以安装运行了。
现在发现了严重的问题,是:引用的wmctrl源码,居然在编译后几乎无效,窗口不能依据需要来切换和布局。但是wmctrl命令本身是有效的。
我是使用的wmctrl1.07的源码,然后把1.07-6的补丁也打直接写进去了。然后把他当头文件,引用进我的程序中,通过调用wmctrl的函数,实现了对窗口的控制。

下面引用一点wmctrl里面,肯定有问题的函数。这两个函数作用是将活动窗口id生成一个数组列表,然后我的程序调用这个数组,分别处理窗口位置布局什么的。这个在ubuntu下工作正常,在Arch下却不能形成这个数组了。

static int list_windows (Display *disp,char *skip) {
    Window *client_list;
    unsigned long client_list_size;
    int i,n;
    n=0;
    for (i = 0; i < 500; i++)
        win_pid_list[i]=0;
    if ((client_list = get_client_list(disp, &client_list_size)) == NULL) {
        return EXIT_FAILURE; 
    }
    
    /* find the longest client_machine name */
    for (i = 0; i < client_list_size / sizeof(Window); i++) {
        gchar *client_machine;
        if ((client_machine = get_property(disp, client_list[i],
                XA_STRING, "WM_CLIENT_MACHINE", NULL))) {
        }
        g_free(client_machine);
    }
    
    /* print the list */
    for (i = 0; i < client_list_size / sizeof(Window); i++) {
        gchar *class_out = get_window_class(disp, client_list[i]); /* UTF8 */

      
        /* special desktop ID -1 means "all desktops", so we 
           have to convert the desktop value to signed long */
        if (class_out!=NULL)
        if (strstr(skip,class_out)==NULL )
        {
          win_pid_list[n]=(int)client_list[i];
          n=n+1;
        }
    }
    g_free(client_list);
    max_win_id=win_pid_list[n-1];
    win_count=n;
    return EXIT_SUCCESS;
}

static gchar *get_window_class (Display *disp, Window win) {
    gchar *class_utf8;
    gchar *wm_class;
    unsigned long size;

    wm_class = get_property(disp, win, XA_STRING, "WM_CLASS", &size);
    if (wm_class) {
        gchar *p_0 = strchr(wm_class, '\0');
        if (wm_class + size - 1 > p_0) {
            *(p_0) = '.';
        }
        class_utf8 = g_locale_to_utf8(wm_class, -1, NULL, NULL, NULL);
    }
    else {
        class_utf8 = NULL;
    }

    g_free(wm_class);
    
    return class_utf8;
}

static gchar *get_property (Display *disp, Window win, /*{{{*/
        Atom xa_prop_type, gchar *prop_name, unsigned long *size) {
    Atom xa_prop_name;
    Atom xa_ret_type;
    int ret_format;
    unsigned long ret_nitems;
    unsigned long ret_bytes_after;
    unsigned long tmp_size;
    unsigned char *ret_prop;
    gchar *ret;
    
    xa_prop_name = XInternAtom(disp, prop_name, False);
    
    /* MAX_PROPERTY_VALUE_LEN / 4 explanation (XGetWindowProperty manpage):
     *
     * long_length = Specifies the length in 32-bit multiples of the
     *               data to be retrieved.
     */
    if (XGetWindowProperty(disp, win, xa_prop_name, 0, MAX_PROPERTY_VALUE_LEN / 4, False,
            xa_prop_type, &xa_ret_type, &ret_format,     
            &ret_nitems, &ret_bytes_after, &ret_prop) != Success) {
        p_verbose("Cannot get %s property.\n", prop_name);
        return NULL;
    }
  
    if (xa_ret_type != xa_prop_type) {
        p_verbose("Invalid type of %s property.\n", prop_name);
        XFree(ret_prop);
        return NULL;
    }

    /* null terminate the result to make string handling easier */
    tmp_size = (ret_format / 8) * ret_nitems;
    if(ret_format==32) tmp_size *= sizeof(long)/4;
    ret = (gchar*)g_malloc(tmp_size + 1);
    memcpy(ret, ret_prop, tmp_size);
    ret[tmp_size] = '\0';

    if (size) {
        *size = tmp_size;
    }
    
    XFree(ret_prop);
    return ret;
}/*}}}*/

最近编辑记录 ljj_jjl2008 (2012-06-04 14:02:58)

离线

#2 2012-06-04 14:17:44

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,431
个人网站

Re: 第一次发贴,就要给大家出难题了。关于C语言开发的。关于我的icon de桌面环境的。

完整的程序在哪里?

离线

#3 2012-06-04 14:53:23

ljj_jjl2008
会员
注册时间: 2012-06-02
帖子: 33

Re: 第一次发贴,就要给大家出难题了。关于C语言开发的。关于我的icon de桌面环境的。

这是所有程序(二进制包、源码)
https://sourceforge.net/projects/icon-de/files/

这是wiki。
https://sourceforge.net/p/icon-de/wiki/Home/

最近编辑记录 ljj_jjl2008 (2012-06-04 14:56:07)

离线

#4 2012-06-04 15:46:50

ljj_jjl2008
会员
注册时间: 2012-06-02
帖子: 33

Re: 第一次发贴,就要给大家出难题了。关于C语言开发的。关于我的icon de桌面环境的。

找到原因了:是我自己arch系统的安装和配置的不好。我对Arch不熟,系统装的不好,造成了问题。语句没有错误,开发的程序是没有问题的。

离线

页脚