Esempio n. 1
0
WScreen *clientwin_find_suitable_screen(WClientWin *cwin,
                                        const WManageParams *param)
{
    WScreen *scr=NULL, *found=NULL;
    bool respectpos=(param->tfor!=NULL || param->userpos);

    FOR_ALL_SCREENS(scr){
        if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
            continue;
        if(REGION_IS_ACTIVE(scr)){
            found=scr;
            if(!respectpos)
                break;
        }

        if(rectangle_contains(&REGION_GEOM(scr),
                    param->geom.x, param->geom.y)){
            found=scr;
            if(respectpos)
                break;
        }

        if(found==NULL)
            found=scr;
    }

    return found;
}
Esempio n. 2
0
File: editor.c Progetto: Blei/weston
static void
button_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       uint32_t button,
	       enum wl_pointer_button_state state, void *data)
{
	struct editor *editor = data;
	struct rectangle allocation;
	int32_t x, y;
	struct wl_seat *seat;

	if (state != WL_POINTER_BUTTON_STATE_PRESSED || button != BTN_LEFT) {
		return;
	}

	input_get_position(input, &x, &y);

	widget_get_allocation(editor->widget, &allocation);
	x -= allocation.x;
	y -= allocation.y;

	int32_t activate_entry = rectangle_contains(&editor->entry->allocation, x, y);
	int32_t activate_editor = rectangle_contains(&editor->editor->allocation, x, y);
	assert(!(activate_entry && activate_editor));

	seat = input_get_seat(input);

	if (activate_entry) {
		text_entry_activate(editor->entry, seat);
	} else if (activate_editor) {
		text_entry_activate(editor->editor, seat);
	} else {
		text_entry_deactivate(editor->entry, seat);
		text_entry_deactivate(editor->editor, seat);
	}

	widget_schedule_redraw(widget);
}
Esempio n. 3
0
int frame_press(WFrame *frame, XButtonEvent *ev, WRegion **reg_ret)
{
    WRegion *sub=NULL;
    WRectangle g;
    
    p_tabnum=-1;

    window_p_resize_prepare((WWindow*)frame, ev);
    
    /* Check tab */
    
    frame_bar_geom(frame, &g);
    
    /* Borders act like tabs at top of the parent region */
    if(REGION_GEOM(frame).y==0){
        g.h+=g.y;
        g.y=0;
    }

    if(frame->barmode!=FRAME_BAR_NONE && 
       rectangle_contains(&g, ev->x, ev->y)){
        p_tabnum=frame_tab_at_x(frame, ev->x);

        region_rootpos((WRegion*)frame, &p_tab_x, &p_tab_y);
        p_tab_x+=frame_nth_tab_x(frame, p_tabnum);
        p_tab_y+=g.y;
        
        sub=mplex_mx_nth(&(frame->mplex), p_tabnum);

        if(reg_ret!=NULL)
            *reg_ret=sub;
        
        return FRAME_AREA_TAB;
    }else{
        WLListIterTmp tmp;
        FRAME_MX_FOR_ALL(sub, frame, tmp){
            p_tabnum++;
            if(sub==FRAME_CURRENT(frame))
                break;
        }
        
        if(sub!=NULL){
            p_tab_x=ev->x_root-frame_nth_tab_w(frame, p_tabnum)/2;
            p_tab_y=ev->y_root-frame->bar_h/2;
        }else{
            p_tabnum=-1;
        }
    }