Пример #1
0
int Panel::handle(int e) {
	switch(e) {
		case FL_PUSH:
			clicked = Fl::belowmouse();

			if(clicked == this)
				clicked = 0;
			else if(clicked && clicked->takesevents())
				clicked->handle(e);

			/* record push position for possible child drag */
			sx = Fl::event_x();
			sy = Fl::event_y();
			return 1;

		case FL_DRAG: {
			if(!can_drag) return 1;

			/* are moving the panel; only vertical moving is supported */
			cursor(FL_CURSOR_MOVE);

			/* snap it to the top or bottom, depending on pressed mouse location */
			if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
				position(x(), screen_y);
				if(width_perc >= 100)
					netwm_window_set_strut(fl_xid(this), 0, 0, h(), 0);
				vpos = PANEL_POSITION_TOP;
			} 
				
			if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
				position(x(), screen_h - h());
				if(width_perc >= 100)
					netwm_window_set_strut(fl_xid(this), 0, 0, 0, h());
				vpos = PANEL_POSITION_BOTTOM;
			}

			return 1;
		}

		case FL_RELEASE:
			cursor(FL_CURSOR_DEFAULT);

			if(clicked && clicked->takesevents()) {
				clicked->handle(e);
				clicked = 0;
			}

			return 1;

		case FL_KEYBOARD:
			/* do not quit on Esc key */
			if(Fl::event_key() == FL_Escape)
				return 1;
			/* fallthrough */
	}

	return Fl_Window::handle(e);
}
Пример #2
0
void Panel::show(void) {
	if(shown()) {
		Fl_Window::show();
		return;
	}

	int X, Y, W, H;

	fl_open_display();

	/* 
	 * hush known FLTK bug with XGetImage; a lot of errors will be print when menu icons goes
	 * outside screen; this also make ede-panel, at some point, unresponsible
	 */
	XSetErrorHandler((XErrorHandler) xerror_handler);

	/* position it */
	if(!netwm_workarea_get_size(X, Y, W, H))
		Fl::screen_xywh(X, Y, W, H);

	screen_x = X;
	screen_y = Y;
	screen_w = W;
	screen_h = H;
	screen_h_half = screen_h / 2;

	/* calculate panel percentage width if given */
	if(width_perc < 100) {
		W = (width_perc * screen_w) / 100;
		X = (screen_w / 2) - (W / 2);
	}

	/* set size as soon as possible, since do_layout() depends on it */
	size(W, DEFAULT_PANEL_H);

	do_layout();
	window_xid_create(this, make_me_dock);

	/* position it, this is done after XID was created */
	if(vpos == PANEL_POSITION_BOTTOM) {
		position(X, screen_h - h());
		if(width_perc >= 100)
			netwm_window_set_strut(fl_xid(this), 0, 0, 0, h());
	} else {
		/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
		position(X, Y);
		if(width_perc >= 100)
			netwm_window_set_strut(fl_xid(this), 0, 0, h(), 0);
	}
}
Пример #3
0
/* TODO: can be better */
void Panel::apply_struts(bool apply) {
	if(!(width_perc >= 100)) return;

	int bottom = 0, top = 0;

	if(vpos == PANEL_POSITION_TOP)
		top = !apply ? 1 : h();
	else
		bottom = !apply ? 1 : h();

	netwm_window_set_strut(fl_xid(this), 0, 0, top, bottom);
}
Пример #4
0
void Panel::set_strut(short state) {
	if(state & PANEL_STRUT_REMOVE)
		netwm_window_remove_strut(fl_xid(this));

	/* no other flags */
	if(state == PANEL_STRUT_REMOVE) return;

	int sizes[4] = {0, 0, 0, 0};

	if(state & PANEL_STRUT_BOTTOM)
		sizes[3] = h();
	else
		sizes[2] = h();

	/* TODO: netwm_window_set_strut_partial() */
	netwm_window_set_strut(fl_xid(this), sizes[0], sizes[1], sizes[2], sizes[3]);
}