Beispiel #1
0
gboolean get_key_win(gpointer data)
{
    AConvert *aconv = (AConvert *)data;
    XEvent xev;
    WInfo *info;
    Window w;


    info = win_find(aconv->keyboard->win,aconv);

    if(info)
    {
        if(aconv->sxkb->cur_group!=info->cur_group)
        {
            XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd, info->cur_group);
            update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv);
        }

        w=get_active_window(aconv->keyboard->dpy);
        if(info->win!=w)
            free_keysym_to_list(aconv);
    }
    {
        if (XPending(aconv->keyboard->dpy))
        {
            XNextEvent (aconv->keyboard->dpy, &xev);
            switch (xev.type)
            {
            case KeyPress:
                if (xev.xkey.send_event == TRUE)
                    return False;

                get_key_pres(aconv,&xev);
                info = win_find(aconv->keyboard->win,aconv);
                if(info)
                    auto_convert_text(aconv,info);
                break;
            case DestroyNotify:

                if((xev.xdestroywindow.event == aconv->keyboard->root)) break;
                /*	XGetInputFocus (aconv->keyboard->dpy,&w, &(aconv->keyboard->cur_status));
                	DEBUG_MSG("DestroyNotify ID %#x == ID %#x ++ ID %#x == ID %#x == ID %#x \n",(unsigned int) aconv->keyboard->win,(unsigned int)info->win,(unsigned int)w,(unsigned int)xev.xdestroywindow.window,(unsigned int)xev.xdestroywindow.event);*/

                info = win_find(xev.xdestroywindow.event,aconv);
                if (info)
                {
                    //printf ("Dest window: ID %#x \n",(unsigned int)info->win);
                    win_free(info,aconv);
                }
                break;
            }
        }
    }
    return TRUE;
}
Beispiel #2
0
/*
 *  Routine to change the current virtual row being viewed
 *  in the upper left corner based on a new slide amount.
 */
void win_arrow(WORD wh, WORD arrow_type)
{
    WNODE *pw;
    WORD  newcv;

    pw = win_find(wh);
    if (!pw)
        return;

    switch(arrow_type)
    {
    case WA_UPPAGE:
        newcv = pw->w_cvrow - pw->w_pnrow;
        break;
    case WA_DNPAGE:
        newcv = pw->w_cvrow + pw->w_pnrow;
        break;
    case WA_UPLINE:
        newcv = pw->w_cvrow - 1;
        break;
    case WA_DNLINE:
        newcv = pw->w_cvrow + 1;
        break;
    default:
        return;     /* ignore WA_LFPAGE, WA_RTPAGE, WA_LFLINE, WA_RTLINE */
    }
    win_blt(pw, newcv);
}
Beispiel #3
0
/*
 *  Routine to call when several icons have been dragged from a
 *  window to another window (it might be the same window) and
 *  dropped on a particular icon or open space.
 *
 *  Note that, for DESK1, this is NEVER called if either the source
 *  or destination is the desktop.  Therefore 'datype' can ONLY be
 *  AT_ISFILE or AT_ISFOLD.
 */
void fun_drag(WORD src_wh, WORD dst_wh, WORD dst_ob, WORD dulx, WORD duly, WORD keystate)
{
    WORD  ret, datype, op;
    WNODE *psw, *pdw;
    ANODE *pda;
    FNODE *pdf;
    BYTE  destpath[MAXPATHLEN];

    op = (keystate&MODE_CTRL) ? OP_MOVE : OP_COPY;
    psw = win_find(src_wh);
    if (!psw)
        return;
    pdw = win_find(dst_wh);
    if (!pdw)
        return;

    pda = i_find(dst_wh, dst_ob, &pdf, NULL);
    datype = (pda) ? pda->a_type : AT_ISFILE;

    /* set up default destination path name */
    strcpy(destpath, pdw->w_path->p_spec);

    /* if destination is folder, insert folder name in path */
    if (datype == AT_ISFOLD)
        add_path(destpath, pdf->f_name);

    ret = fun_op(op, -1, psw->w_path, destpath);

    if (ret)
    {
        if (src_wh != dst_wh)
            desk_clear(src_wh);
        if (op == OP_MOVE)
            fun_rebld(psw);
        fun_rebld(pdw);
        /*
         * if we copied into a folder, we must check to see if it's
         * open in a window and, if so, redraw it too
         */
        if (datype == AT_ISFOLD) {
            pdw = fold_wind(destpath);
            if (pdw)
                fun_rebld(pdw);
        }
    }
}
Beispiel #4
0
static WORD hndl_button(WORD clicks, WORD mx, WORD my, WORD button, WORD keystate)
{
    WORD done, junk;
    GRECT c;
    WORD wh, dobj, dest_wh;
    WORD root;
    WNODE *wn;

    done = FALSE;

    wh = wind_find(mx, my);

    if (wh != G.g_cwin)
        desk_clear(G.g_cwin);

    desk_verify(wh, FALSE);

    wind_get_grect(wh, WF_WXYWH, &c);

    if (clicks == 1)
    {
        act_bsclick(G.g_cwin, G.g_screen, G.g_croot, mx, my,
                    keystate, &c, FALSE);
        graf_mkstate(&junk, &junk, &button, &junk);
        if (button & 0x0001)
        {
            dest_wh = act_bdown(G.g_cwin, G.g_screen, G.g_croot, &mx, &my,
                                &keystate, &c, &dobj);
            if (dest_wh != NIL)
            {
                root = 1;
                if (dest_wh != 0)
                {
                    wn = win_find(dest_wh);
                    if (wn)
                        root = wn->w_root;
                }
                desk1_drag(wh, dest_wh, root, dobj, mx, my, keystate);
                desk_clear(wh);
            }
        }
    }
    else
    {
        act_bsclick(G.g_cwin, G.g_screen, G.g_croot, mx, my, keystate, &c, TRUE);
        done = do_filemenu(OPENITEM);
    }

    men_update(G.a_trees[ADMENU]);

    return done;
}
Beispiel #5
0
void xConvert_text (gpointer data)
{
	int mod=0;
	size_t slen;
	AConvert *aconv = (AConvert *)data;
	if(aconv==NULL)
		return;
		
	aconv->keyboard->win=get_active_window(aconv->keyboard->dpy);

	WInfo *info = win_find(aconv->keyboard->win,aconv);
	if (!info) 
		return;
	
	slen =aconv->keyboard->gstr->len;//g_list_length (info->ks);

	if(slen<=0)
	{
		free_keysym_to_list(aconv);
		return ;
	}
		
	if(info->cur_group==(aconv->sxkb->ngroups-1))
		info->cur_group=0;
	else if (info->cur_group < (aconv->sxkb->ngroups-1))
		info->cur_group++;
	else
		info->cur_group=0;
			
	mod=(8192*info->cur_group);
	XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,info->cur_group);
	update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv);
	
	delete_char_in_win(info->win,aconv->keyboard->iterator);
	backspace_char_in_win(info->win,slen-aconv->keyboard->iterator);
	aconv->keyboard->iterator=0;
	
	{
		GList *p = g_list_first (aconv->keyboard->ks);

		while (p)
	        {
			Skeysym *sks=(Skeysym *)p->data;
			send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod);
			p = g_list_next (p);
	        }
	}
}
Beispiel #6
0
/* Simulate WM_ARROWED using arrow keys */
static void kbd_arrow(WORD type)
{
    WORD wh;
    WORD dummy;
    WNODE *pw;

    wind_get(0, WF_TOP, &wh, &dummy, &dummy, &dummy);
    if (!wh)
        return;

    pw = win_find(wh);
    if (!pw)
        return;

    desk_clear(wh);
    win_arrow(wh, type);
}
Beispiel #7
0
/*
 *  Routine to change the current virtual row being viewed
 *  in the upper left corner based on a new slide amount
 */
void win_slide(WORD wh, WORD sl_value)
{
    WNODE *pw;
    WORD  newcv;
    WORD  vn, pn, i, sls, sl_size;

    pw = win_find(wh);
    if (!pw)
        return;

    vn = pw->w_vnrow;
    pn = pw->w_pnrow;
    sls = WF_VSLSIZ;
    wind_get(wh, sls, &sl_size, &i, &i, &i);
    newcv = mul_div(sl_value, vn - pn, 1000);
    win_blt(pw, newcv);
}
Beispiel #8
0
int grab_wind_event(AConvert *aconv)
{
    gboolean isSameScreen;
    int dummy;
    unsigned int dummyU;
    Window rootW = 0, childW = 0;

    WInfo *info = win_find(aconv->keyboard->win,aconv);
    if(info)
    {
        childW = aconv->keyboard->win;
        XGetInputFocus (aconv->keyboard->dpy,&childW, &(aconv->keyboard->cur_status));

        if ( (childW == None) || (childW == PointerRoot))
            return -1;

        //printf ("window: ID %#x \n",(unsigned int)childW);

        XSelectInput(aconv->keyboard->dpy, childW,  SubstructureNotifyMask|KeyPressMask);

        isSameScreen = XQueryPointer(aconv->keyboard->dpy,childW, &rootW, &childW, &dummy,&dummy, &(dummy), &(dummy), &dummyU);

        if ( (childW == None) || (childW == PointerRoot))
            return -1;

        XSelectInput(aconv->keyboard->dpy, childW, KeyPressMask);

        if (isSameScreen == TRUE)
        {
            while (childW != 0)
            {
                if ( (childW == None) || (childW == PointerRoot))
                    break;

                isSameScreen = XQueryPointer (aconv->keyboard->dpy,childW, &rootW,&childW, &dummy,&dummy, &(dummy), &(dummy), &dummyU);

                if ( (childW == None) || (childW == PointerRoot))
                    break;

                XSelectInput(aconv->keyboard->dpy, childW, KeyPressMask);
            }
        }
    }
    return 1;
}
Beispiel #9
0
/*
 *  This routine is called when the 'Delete' menu item is selected
 */
void fun_del(WORD sobj)
{
    ANODE *pa;
    WNODE *pw;
    WORD disk_found = 0;

    /*
     * if the item selected is on the desktop, there may be other desktop
     * items that have been selected; make sure we process all of them
     */
    if ( (pa = i_find(0, sobj, NULL, NULL)) )
    {
        if (wants_to_delete_files() == FALSE)   /* i.e. remove icons or cancel */
            return;
        for ( ; sobj; sobj = win_isel(G.g_screen, DROOT, sobj))
        {
            pa = i_find(0,sobj,NULL,NULL);
            if (!pa)
                continue;
            if (pa->a_type == AT_ISDISK)
            {
                disk_found++;
                if (delete_disk(pa))
                    do_refresh_drive(pa->a_letter);
            }
        }
        if (disk_found)
        {
            desk_clear(0);
            return;
        }
    }

    /*
     * otherwise, process path associated with selected window icon, if any
     */
    pw = win_find(G.g_cwin);

    if (pw)
    {
        if (fun_op(OP_DELETE, -1, pw->w_path, NULL))
            fun_rebld(pw);
    }
}
Beispiel #10
0
void get_key_pres(gpointer data,XEvent *event)
{
    AConvert *aconv = (AConvert *)data;
    WInfo *info = win_find(aconv->keyboard->win,aconv);
    if(info)
    {
        int action=0;
        int slen;


        if(!info)
        {
            return ;
        }

        action=get_key_action (event);
        slen = aconv->keyboard->gstr->len;//g_list_length(aconv->keyboard->ks);

        switch (action)
        {
        case KLB_NO_ACTION:
            free_keysym_to_list(aconv);
            return ;
        case KLB_CLEAR:
            free_keysym_to_list(aconv);
            return ;
        case KLB_ENTER:
            free_keysym_to_list(aconv);
            return ;
        case KLB_FLUSH:
            add_char_to_win(aconv,event,info);
            break;
        case KLB_SWITCH_MODE:
            if (KLB_INSERT_MODE == info->mode)
                info->mode = KLB_REPLACE_MODE;
            else
                info->mode = KLB_INSERT_MODE;
            return ;
        case KLB_MOVE_LEFT:
            if ((slen >0) && (aconv->keyboard->iterator <= slen))
                aconv->keyboard->iterator++;
            else
            {
                free_keysym_to_list(aconv);
            }
            return ;
        case KLB_MOVE_RIGHT:
            if (aconv->keyboard->iterator <= slen)
                aconv->keyboard->iterator--;
            else
            {
                free_keysym_to_list(aconv);
            }
            return;
        case KLB_DEL_SYM_LEFT:
            if (aconv->keyboard->iterator <= 0)
            {
                if(slen>0)
                {
                    dell_keysym_to_list(aconv,slen);
                }
            }
            else if (aconv->keyboard->iterator >= 1)
            {
                if(slen>0)
                {
                    dell_keysym_to_list(aconv,slen-aconv->keyboard->iterator);
                }
            }
            else
            {
                free_keysym_to_list(aconv);
            }
            break;
        case KLB_DEL_SYM_RIGHT:
            if (aconv->keyboard->iterator <= 0)
            {
                free_keysym_to_list(aconv);
            }
            else if (aconv->keyboard->iterator >= 1)
            {
                dell_keysym_to_list(aconv,(slen-aconv->keyboard->iterator)+1);
                aconv->keyboard->iterator--;
            }
            break;
        case KLB_ADD_SYM:
            add_char_to_win(aconv,event,info);
            break;
        default:
            break;
        }
    }
}
Beispiel #11
0
void xConvert_text_case (gpointer data)
{
	int mod=0;
	size_t slen;
	AConvert *aconv = (AConvert *)data;

	if ((aconv==NULL))
		return;

	aconv->keyboard->win=get_active_window(aconv->keyboard->dpy);

	WInfo *info = win_find(aconv->keyboard->win,aconv);
	if (!info) 
		return;
	
	slen =aconv->keyboard->gstr->len;//g_list_length (info->ks);

	if(slen<=0)
	{
		free_keysym_to_list(aconv);
		return ;
	}
	
	if(aconv->dbase->count_case > 2)
		aconv->dbase->count_case=0;
	
	
	if(aconv->dbase->count_case==0)
	{
		aconv->dbase->count_case++;
	
		mod=(8192*info->cur_group);

		delete_char_in_win(info->win,aconv->keyboard->iterator);
		backspace_char_in_win(info->win,slen-aconv->keyboard->iterator);
		aconv->keyboard->iterator=0;
		
		{
			GList *p = g_list_first (aconv->keyboard->ks);
	
			while (p)
			{
				Skeysym *sks=(Skeysym *)p->data;
				send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+1);
				p = g_list_next (p);
			}
		}
		return ;
	}
	else if(aconv->dbase->count_case==1)
	{
		aconv->dbase->count_case++;
	
		mod=(8192*info->cur_group);
		
		delete_char_in_win(info->win,aconv->keyboard->iterator);
		backspace_char_in_win(info->win,slen-aconv->keyboard->iterator);
		aconv->keyboard->iterator=0;
		
		{
			int i=1;
			GList *p = g_list_first (aconv->keyboard->ks);
	
			while (p)
			{
				Skeysym *sks=(Skeysym *)p->data;
				send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+i);
				p = g_list_next (p);
				i=0;
			}
		}
	}
	else if(aconv->dbase->count_case==2)
	{
		aconv->dbase->count_case++;
	
		mod=(8192*info->cur_group);

		delete_char_in_win(info->win,aconv->keyboard->iterator);
		backspace_char_in_win(info->win,slen-aconv->keyboard->iterator);
		aconv->keyboard->iterator=0;
		
		{
			GList *p = g_list_first (aconv->keyboard->ks);
	
			while (p)
			{
				Skeysym *sks=(Skeysym *)p->data;
				send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod);
				p = g_list_next (p);
			}
		}
		return ;
	}
	else
	   aconv->dbase->count_case=0;
}