예제 #1
0
파일: Panel.cpp 프로젝트: GustavoMOG/ede
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)
					set_strut(PANEL_STRUT_TOP);
				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)
					set_strut(PANEL_STRUT_BOTTOM);
				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
파일: Panel.cpp 프로젝트: GustavoMOG/ede
void Panel::hide(void) {
	Fl::remove_handler(x_events);
	set_strut(PANEL_STRUT_REMOVE);

	/* clear loaded widgets */
	mgr.clear(this);

	/* clear whatever was left out, but was not part of applet manager */
	clear();

	save_config();
	Fl_Window::hide();
}
예제 #3
0
/* At some point subclass GtkWindow instead. */
static void
on_realize(GtkWidget *win, gpointer data) {
	guint width;
	GtkAllocation allocation;
	gtk_widget_get_allocation(win, &allocation);
	width = gdk_screen_width();
	gtk_window_set_decorated (GTK_WINDOW (win), FALSE);
	set_strut(GTK_WINDOW(win), width, 0, allocation.height, allocation.height, 0, width);
	// We don't care about showing the panel on all desktops just yet.
	gtk_window_stick (GTK_WINDOW (win));
	gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DOCK);
	gdk_window_set_geometry_hints (gtk_widget_get_window(win), NULL, GDK_HINT_POS);
	gdk_window_move_resize(gtk_widget_get_window(win), 0, 0, width, allocation.height);
	gtk_window_set_has_resize_grip(GTK_WINDOW(win), FALSE);
}
예제 #4
0
파일: Panel.cpp 프로젝트: GustavoMOG/ede
void Panel::update_size_and_pos(bool create_xid, bool update_strut, int X, int Y, int W, int H) {
	/* do not update ourself if we screen sizes are the same */
	if(screen_x == X && screen_y == Y && screen_w == W && screen_h == H)
		return;

	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();

	if(create_xid) 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 && update_strut)
			set_strut(PANEL_STRUT_REMOVE | PANEL_STRUT_BOTTOM);
	} else {
		/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
		position(X, Y);
		if(width_perc >= 100 && update_strut)
			set_strut(PANEL_STRUT_REMOVE | PANEL_STRUT_TOP);
	}
}