static gboolean panel_configure_event(GtkWidget *widget, GdkEventConfigure *e, panel *p) { ENTER; DBG("cur geom: %dx%d+%d+%d\n", e->width, e->height, e->x, e->y); DBG("req geom: %dx%d+%d+%d\n", p->aw, p->ah, p->ax, p->ay); if (e->width == p->cw && e->height == p->ch && e->x == p->cx && e->y == p->cy) { DBG("dup. exiting\n"); RET(FALSE); } /* save current geometry */ p->cw = e->width; p->ch = e->height; p->cx = e->x; p->cy = e->y; /* if panel size is not what we have requested, just wait, it will */ if (e->width != p->aw || e->height != p->ah) { DBG("size_req not yet ready. exiting\n"); RET(FALSE); } /* if panel wasn't at requested position, then send another request */ if (e->x != p->ax || e->y != p->ay) { DBG("move %d,%d\n", p->ax, p->ay); gtk_window_move(GTK_WINDOW(widget), p->ax, p->ay); RET(FALSE); } /* panel is at right place, lets go on */ DBG("panel is at right place, lets go on\n"); if (p->transparent) { DBG("remake bg image\n"); fb_bg_notify_changed_bg(p->bg); } if (p->setstrut) { DBG("set_wm_strut\n"); panel_set_wm_strut(p); } if (p->round_corners) { DBG("make_round_corners\n"); make_round_corners(p); } gtk_widget_show(p->topgwin); if (p->setstrut) { DBG("set_wm_strut\n"); panel_set_wm_strut(p); } RET(FALSE); }
static gint panel_size_alloc(GtkWidget *widget, GtkAllocation *a, panel *p) { static gint x, y; ENTER; DBG("gtk: size (%d, %d). pos (%d, %d)\n", a->width, a->height, a->x, a->y); DBG("our: size (%d, %d). pos (%d, %d)\n", p->aw, p->ah, p->ax, p->ay); if (p->widthtype == WIDTH_REQUEST) p->width = (p->orientation == ORIENT_HORIZ) ? a->width : a->height; if (p->heighttype == HEIGHT_REQUEST) p->height = (p->orientation == ORIENT_HORIZ) ? a->height : a->width; calculate_position(p); DBG("our: size (%d, %d). pos (%d, %d)\n", p->aw, p->ah, p->ax, p->ay); if (a->width == p->aw && a->height == p->ah && x == p->ax && y == p ->ay) { DBG("actual coords eq to preffered. just returning\n"); RET(TRUE); } x = p->ax; y = p->ay; gtk_window_move(GTK_WINDOW(p->topgwin), p->ax, p->ay); DBG("moving to %d %d\n", p->ax, p->ay); if (p->setstrut) panel_set_wm_strut(p); RET(TRUE); }
static gboolean panel_monitors_changed(GdkScreen* s, panel* p) { ENTER; p->monitor = gdk_screen_get_primary_monitor(s); calculate_position(p, distance,distancefrom); gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah); if (p->setstrut) panel_set_wm_strut(p); RET(TRUE); }
void panel_start_gui(panel *p) { ENTER; //gtk_rc_parse_string(transparent_rc); p->topgwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0); gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE); gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "trayer"); gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel"); gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_CENTER); g_signal_connect ( G_OBJECT(p->topgwin) , "delete-event" , G_CALLBACK(panel_delete_event) , p); g_signal_connect ( G_OBJECT(p->topgwin) , "destroy-event", G_CALLBACK(panel_destroy_event), p); g_signal_connect ( G_OBJECT (p->topgwin), "size-request" , G_CALLBACK(panel_size_req) , p); g_signal_connect ( G_OBJECT (p->topgwin), "size-allocate", G_CALLBACK(panel_size_alloc), p); if (p->transparent) { g_signal_connect (G_OBJECT (p->topgwin), "configure-event", G_CALLBACK(panel_configure_event), p); g_signal_connect (G_OBJECT (p->topgwin), "style-set", G_CALLBACK( panel_style_set), p); } if (p->on_primary) { GdkDisplay *display = gdk_display_get_default (); GdkScreen *screen = gdk_display_get_screen(display, 0); g_signal_connect ( screen, "monitors-changed", G_CALLBACK(panel_monitors_changed), (gpointer)p ); p->monitor = gdk_screen_get_primary_monitor(screen); } gtk_widget_realize(p->topgwin); gdk_window_set_decorations(p->topgwin->window, 0); gtk_widget_set_app_paintable(p->topgwin, TRUE); p->lbox = p->my_box_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0); gtk_container_add(GTK_CONTAINER(p->topgwin), p->lbox); gtk_widget_show(p->lbox); if (p->allign == ALLIGN_RIGHT) { GtkWidget * expander = p->my_box_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(p->lbox), expander, TRUE, TRUE, 0); gtk_widget_show(expander); } p->box = p->my_box_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(p->box), 1); gtk_box_pack_start(GTK_BOX(p->lbox), p->box, FALSE, TRUE, padding); gtk_widget_show(p->box); // get properties on topgwin p->topGdkWindow = gtk_widget_get_window(p->topgwin); p->topxwin = GDK_WINDOW_XWINDOW(GTK_WIDGET(p->topgwin)->window); bg_init(gdk_helper_display()); /* make our window unfocusable */ gdk_window_set_accept_focus(p->topGdkWindow,False); if (p->setdocktype) { gdk_window_set_type_hint(p->topGdkWindow,GDK_WINDOW_TYPE_HINT_DOCK); } Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0); /************************/ /* Window Mapping Point */ gtk_widget_show_all(p->topgwin); Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0); gdk_window_stick ( p->topGdkWindow); gdk_window_set_skip_pager_hint ( p->topGdkWindow, True ); gdk_window_set_skip_taskbar_hint ( p->topGdkWindow, True ); XSelectInput (gdk_helper_display(), GDK_ROOT_WINDOW(), PropertyChangeMask); XSelectInput (gdk_helper_display(), p->topxwin, PropertyChangeMask | FocusChangeMask | StructureNotifyMask); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_wm_events, p); calculate_position(p, distance,distancefrom); gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah); if (p->setstrut) panel_set_wm_strut(p); if (p->lower) XLowerWindow(gdk_helper_display(), p->topxwin); RET(); }
void panel_start_gui(panel *p) { Atom state[3]; XWMHints wmhints; guint32 val; ENTER; // main toplevel window p->topgwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0); gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE); gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "fbpanel"); gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel"); gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_NONE); gtk_window_set_decorated(GTK_WINDOW(p->topgwin), FALSE); g_signal_connect(G_OBJECT(p->topgwin), "delete-event", G_CALLBACK(panel_delete_event), p); g_signal_connect(G_OBJECT(p->topgwin), "destroy-event", G_CALLBACK(panel_destroy_event), p); g_signal_connect (G_OBJECT (p->topgwin), "size-request", (GCallback) panel_size_req, p); g_signal_connect (G_OBJECT (p->topgwin), "size-allocate", (GCallback) panel_size_alloc, p); g_signal_connect (G_OBJECT (p->topgwin), "configure-event", (GCallback) panel_configure_event, p); g_signal_connect (G_OBJECT (p->topgwin), "realize", (GCallback) panel_realize, p); g_signal_connect (G_OBJECT (p->topgwin), "style-set", (GCallback) panel_style_set, p); gtk_widget_realize(p->topgwin); //gdk_window_set_decorations(p->topgwin->window, 0); gtk_widget_set_app_paintable(p->topgwin, TRUE); // background box all over toplevel p->bbox = gtk_bgbox_new(); gtk_container_add(GTK_CONTAINER(p->topgwin), p->bbox); gtk_widget_show(p->bbox); gtk_container_set_border_width(GTK_CONTAINER(p->bbox), 0); if (p->transparent) { p->bg = fb_bg_get_for_display(); gtk_bgbox_set_background(p->bbox, BG_ROOT, p->tintcolor, p->alpha); } // main layout manager as a single child of background widget box p->lbox = p->my_box_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0); gtk_container_add(GTK_CONTAINER(p->bbox), p->lbox); gtk_widget_show(p->lbox); if (p->round_corners) make_round_corners(p); p->box = p->my_box_new(FALSE, p->spacing); gtk_container_set_border_width(GTK_CONTAINER(p->box), 0); gtk_box_pack_start(GTK_BOX(p->lbox), p->box, TRUE, TRUE, 0); gtk_widget_show(p->box); p->topxwin = GDK_WINDOW_XWINDOW(GTK_WIDGET(p->topgwin)->window); DBG("topxwin = %x\n", p->topxwin); /* the settings that should be done before window is mapped */ wmhints.flags = InputHint; wmhints.input = 0; XSetWMHints (GDK_DISPLAY(), p->topxwin, &wmhints); #define WIN_HINTS_SKIP_FOCUS (1<<0) /* "alt-tab" skips this win */ val = WIN_HINTS_SKIP_FOCUS; XChangeProperty(GDK_DISPLAY(), p->topxwin, XInternAtom(GDK_DISPLAY(), "_WIN_HINTS", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); if (p->setdocktype) { state[0] = a_NET_WM_WINDOW_TYPE_DOCK; XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 1); } /* window mapping point */ gtk_widget_show_all(p->topgwin); /* the settings that should be done after window is mapped */ /* send it to running wm */ Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0); /* and assign it ourself just for case when wm is not running */ val = 0xFFFFFFFF; XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); state[0] = a_NET_WM_STATE_SKIP_PAGER; state[1] = a_NET_WM_STATE_SKIP_TASKBAR; state[2] = a_NET_WM_STATE_STICKY; XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 3); XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(), PropertyChangeMask); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, p); calculate_position(p); gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah); if (p->setstrut) panel_set_wm_strut(p); RET(); }
static void panel_start_gui(panel *p) { ENTER; // main toplevel window p->topgwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0); g_signal_connect(G_OBJECT(p->topgwin), "destroy-event", (GCallback) panel_destroy_event, p); g_signal_connect(G_OBJECT(p->topgwin), "size-request", (GCallback) panel_size_req, p); g_signal_connect(G_OBJECT(p->topgwin), "map-event", (GCallback) panel_mapped, p); g_signal_connect(G_OBJECT(p->topgwin), "configure-event", (GCallback) panel_configure_event, p); g_signal_connect(G_OBJECT(p->topgwin), "button-press-event", (GCallback) panel_button_press_event, p); g_signal_connect(G_OBJECT(p->topgwin), "scroll-event", (GCallback) panel_scroll_event, p); gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE); gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "fbpanel"); gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel"); gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_NONE); gtk_window_set_decorated(GTK_WINDOW(p->topgwin), FALSE); gtk_window_set_accept_focus(GTK_WINDOW(p->topgwin), FALSE); if (p->setdocktype) gtk_window_set_type_hint(GTK_WINDOW(p->topgwin), GDK_WINDOW_TYPE_HINT_DOCK); if (p->layer == LAYER_ABOVE) gtk_window_set_keep_above(GTK_WINDOW(p->topgwin), TRUE); else if (p->layer == LAYER_BELOW) gtk_window_set_keep_below(GTK_WINDOW(p->topgwin), TRUE); gtk_window_stick(GTK_WINDOW(p->topgwin)); gtk_widget_realize(p->topgwin); p->topxwin = GDK_WINDOW_XWINDOW(p->topgwin->window); DBG("topxwin = %lx\n", p->topxwin); /* ensure configure event */ XMoveWindow(GDK_DISPLAY(), p->topxwin, 20, 20); XSync(GDK_DISPLAY(), False); gtk_widget_set_app_paintable(p->topgwin, TRUE); calculate_position(p); gtk_window_move(GTK_WINDOW(p->topgwin), p->ax, p->ay); gtk_window_resize(GTK_WINDOW(p->topgwin), p->aw, p->ah); DBG("move-resize x %d y %d w %d h %d\n", p->ax, p->ay, p->aw, p->ah); //XSync(GDK_DISPLAY(), False); //gdk_flush(); // background box all over toplevel p->bbox = gtk_bgbox_new(); gtk_container_add(GTK_CONTAINER(p->topgwin), p->bbox); gtk_container_set_border_width(GTK_CONTAINER(p->bbox), 0); if (p->transparent) { p->bg = fb_bg_get_for_display(); gtk_bgbox_set_background(p->bbox, BG_ROOT, p->tintcolor, p->alpha); } // main layout manager as a single child of background widget box p->lbox = p->my_box_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0); gtk_container_add(GTK_CONTAINER(p->bbox), p->lbox); p->box = p->my_box_new(FALSE, p->spacing); gtk_container_set_border_width(GTK_CONTAINER(p->box), 0); gtk_box_pack_start(GTK_BOX(p->lbox), p->box, TRUE, TRUE, (p->round_corners) ? p->round_corners_radius : 0); if (p->round_corners) { make_round_corners(p); DBG("make_round_corners\n"); } /* start window creation process */ gtk_widget_show_all(p->topgwin); /* .. and hide it from user until everything is done */ gtk_widget_hide(p->topgwin); p->menu = panel_make_menu(p); if (p->setstrut) panel_set_wm_strut(p); XSelectInput(GDK_DISPLAY(), GDK_ROOT_WINDOW(), PropertyChangeMask); gdk_window_add_filter(gdk_get_default_root_window(), (GdkFilterFunc)panel_event_filter, p); //XSync(GDK_DISPLAY(), False); gdk_flush(); RET(); }