/* Handler for "clicked" signal on main widget. */ static gboolean wincmd_button_clicked(GtkWidget * widget, GdkEventButton * event, LXPanel * panel) { WinCmdPlugin * wc = lxpanel_plugin_get_data(widget); /* Left-click to iconify. */ if (event->button == 1) { GdkScreen* screen = gtk_widget_get_screen(widget); static GdkAtom atom = 0; if( G_UNLIKELY(0 == atom) ) atom = gdk_atom_intern("_NET_SHOWING_DESKTOP", FALSE); /* If window manager supports _NET_SHOWING_DESKTOP, use it. * Otherwise, fall back to iconifying windows individually. */ if (gdk_x11_screen_supports_net_wm_hint(screen, atom)) { int showing_desktop = ((( ! wc->toggle_preference) || ( ! wc->toggle_state)) ? 1 : 0); Xclimsg(DefaultRootWindow(GDK_DISPLAY_XDISPLAY(gdk_display_get_default())), a_NET_SHOWING_DESKTOP, showing_desktop, 0, 0, 0, 0); wincmd_adjust_toggle_state(wc); } else wincmd_execute(wc, WC_ICONIFY); } /* Middle-click to shade. */ else if (event->button == 2) wincmd_execute(wc, WC_SHADE); return TRUE; }
static gint desk_button_press_event(GtkWidget * widget, GdkEventButton * event, desk *d) { ENTER; DBG("s=%d\n", d->no); Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, d->no, 0, 0, 0, 0); RET(TRUE); }
/* Handler for "button-press-event" on drawing area. */ static gboolean desk_button_press_event(GtkWidget * widget, GdkEventButton * event, PagerDesk * d) { /* Standard right-click handling. */ if (plugin_button_press_event(widget, event, d->pg->plugin)) return TRUE; /* Ask the window manager to make the new desktop current. */ Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, d->desktop_number, 0, 0, 0, 0); return TRUE; }
static gint desk_button_press_event(GtkWidget * widget, GdkEventButton * event, desk *d) { ENTER; if (event->type == GDK_BUTTON_PRESS && event->button == 3 && event->state & GDK_CONTROL_MASK) { RET(FALSE); } DBG("s=%d\n", d->no); Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, d->no, 0, 0, 0, 0); RET(TRUE); }
static gint desk_button_press_event(GtkWidget * widget, GdkEventButton * event, desk *d) { ENTER; if( event->button == 3 ) { /* right button */ GtkMenu* popup =(GtkMenu*) lxpanel_get_panel_menu ( d->pg->plugin->panel, d->pg->plugin, FALSE ); gtk_menu_popup( popup, NULL, NULL, NULL, NULL, event->button, event->time ); return TRUE; } Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, d->no, 0, 0, 0, 0); RET(TRUE); }
/* Execute a window command. */ static void wincmd_execute(WinCmdPlugin * wc, WindowCommand command) { /* Get the list of all windows. */ int client_count; Window * client_list = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_CLIENT_LIST, XA_WINDOW, &client_count); Display *xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); if (client_list != NULL) { /* Loop over all windows. */ int current_desktop = get_net_current_desktop(); int i; for (i = 0; i < client_count; i++) { /* Get the desktop and window type properties. */ NetWMWindowType nwwt; int task_desktop = get_net_wm_desktop(client_list[i]); get_net_wm_window_type(client_list[i], &nwwt); /* If the task is visible on the current desktop and it is an ordinary window, * execute the requested Iconify or Shade change. */ if (((task_desktop == -1) || (task_desktop == current_desktop)) && (( ! nwwt.dock) && ( ! nwwt.desktop) && ( ! nwwt.splash))) { switch (command) { case WC_NONE: break; case WC_ICONIFY: if (( ! wc->toggle_preference) || ( ! wc->toggle_state)) XIconifyWindow(xdisplay, client_list[i], DefaultScreen(xdisplay)); else XMapWindow (xdisplay, client_list[i]); break; case WC_SHADE: Xclimsg(client_list[i], a_NET_WM_STATE, ((( ! wc->toggle_preference) || ( ! wc->toggle_state)) ? a_NET_WM_STATE_ADD : a_NET_WM_STATE_REMOVE), a_NET_WM_STATE_SHADED, 0, 0, 0); break; } } } XFree(client_list); /* Adjust toggle state. */ wincmd_adjust_toggle_state(wc); } }
static void clicked( GtkWidget *widget, gpointer data) { int desknum = get_net_current_desktop(); int desks = get_net_number_of_desktops(); int newdesk; ENTER; if(desknum == (desks - 1)) newdesk = 0; else newdesk = desknum + 1; g_assert(data != NULL); Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, newdesk, 0, 0, 0, 0); RET(); }
static void toggle_shaded(wincmd *wc, guint32 action) { Window *win = NULL; int num, i; guint32 tmp2, dno; net_wm_window_type nwwt; ENTER; win = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_CLIENT_LIST, XA_WINDOW, &num); if (!win) RET(); if (!num) goto end; //tmp = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, XA_CARDINAL, 0); //dno = *tmp; dno = get_net_current_desktop(); DBG("wincmd: #desk=%d\n", dno); //XFree(tmp); for (i = 0; i < num; i++) { int skip; tmp2 = get_net_wm_desktop(win[i]); DBG("wincmd: win=0x%x dno=%d...", win[i], tmp2); if ((tmp2 != -1) && (tmp2 != dno)) { DBG("skip - not cur desk\n"); continue; } get_net_wm_window_type(win[i], &nwwt); skip = (nwwt.dock || nwwt.desktop || nwwt.splash); if (skip) { DBG("skip - omnipresent window type\n"); continue; } Xclimsg(win[i], a_NET_WM_STATE, action ? a_NET_WM_STATE_ADD : a_NET_WM_STATE_REMOVE, a_NET_WM_STATE_SHADED, 0, 0, 0); DBG("ok\n"); } end: XFree(win); RET(); }
static gint desk_scroll_event (GtkWidget *widget, GdkEventScroll *event, desk *d) { int i; ENTER; DBG("scroll direction = %d\n", event->direction); i = d->pg->curdesk; if (event->direction == GDK_SCROLL_UP ||event->direction == GDK_SCROLL_LEFT) { i--; if (i < 0) i = d->pg->desknum - 1; } else { i++; if (i >= d->pg->desknum) i = 0; } Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, i, 0, 0, 0, 0); RET(TRUE); }
/* Handler for "scroll-event" on drawing area. */ static gboolean desk_scroll_event(GtkWidget * widget, GdkEventScroll * event, PagerDesk * d) { /* Compute the new desktop from the scroll direction, wrapping at either extreme. */ int current_desktop = d->pg->current_desktop; if ((event->direction == GDK_SCROLL_UP) || (event->direction == GDK_SCROLL_RIGHT)) { current_desktop += 1; if (current_desktop >= d->pg->number_of_desktops) current_desktop = 0; } else { current_desktop -= 1; if (current_desktop < 0) current_desktop = d->pg->number_of_desktops - 1; } /* Ask the window manager to make the new desktop current. */ Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, current_desktop, 0, 0, 0, 0); return 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(); }