int c_get_window_role(lua_State *lua) { int top = lua_gettop(lua); if (top != 0) { luaL_error(lua, "get_window_role: %s", no_indata_expected_error); return 0; } WnckWindow *window = get_current_window(); gchar *result = NULL; if (window) { result = my_wnck_get_string_property_latin1(wnck_window_get_xid(window), my_wnck_atom_get("WM_WINDOW_ROLE")); } if (result) { lua_pushstring(lua, result); } else { lua_pushstring(lua, ""); } g_free(result); return 1; }
int c_set_window_type(lua_State *lua) { int top = lua_gettop(lua); if (top != 1) { luaL_error(lua, "set_window_type: %s", one_indata_expected_error); return 0; } int type = lua_type(lua, 1); if (type != LUA_TSTRING) { luaL_error(lua, "set_window_type: %s", string_expected_as_indata_error); return 0; } gchar *indata = (gchar*)lua_tostring(lua, 1); WnckWindow *window = get_current_window(); if (window) { gulong xid = wnck_window_get_xid(window); my_window_set_window_type(xid, indata); } return 0; }
int c_set_opacity(lua_State *lua) { int top = lua_gettop(lua); //WnckScreen *screen; if (top != 1) { luaL_error(lua, "set_opacity: %s", one_indata_expected_error); return 0; } int type = lua_type(lua, 1); if (type != LUA_TNUMBER) { luaL_error(lua, "set_opacity: %s", number_expected_as_indata_error); return 0; } double value = (double)lua_tonumber(lua, 1); WnckWindow *window = get_current_window(); gulong xid = wnck_window_get_xid(window); if (window) my_window_set_opacity(xid, value); return 0; }
static void window_set_state(WnckWindow *window, const char *state, gboolean add) { XEvent xev; Atom atom; Atom type; atom = XInternAtom(main_dpy, state, FALSE); type = XInternAtom(main_dpy, "_NET_WM_STATE", FALSE); xev.xclient.type = ClientMessage; xev.xclient.serial = 0; xev.xclient.send_event = TRUE; xev.xclient.display = main_dpy; xev.xclient.window = wnck_window_get_xid(window); xev.xclient.message_type = type; xev.xclient.format = 32; xev.xclient.data.l[0] = add ? 1 : 0; xev.xclient.data.l[1] = atom; xev.xclient.data.l[2] = 0; XSendEvent(main_dpy, DefaultRootWindow(main_dpy), FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &xev); }
static void update_name (WnckApplication *app) { g_assert (app->priv->name_from_leader || app->priv->name == NULL); if (app->priv->name == NULL) { /* if only one window, get name from there. If more than one and * they all have the same res_class, use that. Else we want to * use the fallback name, since using the title of one of the * windows would look wrong. */ if (app->priv->windows && app->priv->windows->next == NULL) { app->priv->name = g_strdup (wnck_window_get_name (app->priv->windows->data)); app->priv->name_window = app->priv->windows->data; emit_name_changed (app); } else if (app->priv->windows) { /* more than one */ app->priv->name = _wnck_get_res_class_utf8 (wnck_window_get_xid (app->priv->windows->data)); if (app->priv->name) { app->priv->name_window = app->priv->windows->data; emit_name_changed (app); } } } }
// This code can only run after thumbnailer's drawing_area has been realized, // and after the main loop has run so that wnck_window is initialized. static void initialize_thumbnailer_pictures (SSThumbnailer *thumbnailer) { Display *display; GdkScreen *screen; XRenderPictFormat *format; XRenderPictureAttributes pa; display = gdk_x11_get_default_xdisplay (); screen = gtk_widget_get_screen (thumbnailer->drawing_area); format = XRenderFindVisualFormat (display, DefaultVisual ( display, gdk_screen_get_number (screen))); thumbnailer->thumbnail_pixmap = gdk_pixmap_new ( thumbnailer->drawing_area->window, THUMBNAIL_SIZE, THUMBNAIL_SIZE, -1); thumbnailer->thumbnail_picture = XRenderCreatePicture (display, GDK_DRAWABLE_XID (thumbnailer->thumbnail_pixmap), format, 0, NULL); pa.subwindow_mode = IncludeInferiors; thumbnailer->window_picture = XRenderCreatePicture (display, wnck_window_get_xid (thumbnailer->wnck_window), format, CPSubwindowMode, &pa); XRenderSetPictureFilter (display, thumbnailer->window_picture, "good", NULL, 0); }
int c_set_window_position2(lua_State *lua) { int top = lua_gettop(lua); if (top != 2) { luaL_error(lua,"set_window_position2: %s", two_indata_expected_error); return 0; } int type1 = lua_type(lua, 1); int type2 = lua_type(lua, 2); if ((type1 != LUA_TNUMBER) || (type2 != LUA_TNUMBER)) { luaL_error(lua,"set_window_position2: %s", two_indata_expected_error); return 0; } int x = lua_tonumber(lua,1); int y = lua_tonumber(lua,2); if (!devilspie2_emulate) { WnckWindow *window = get_current_window(); if (window) { XMoveWindow(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), wnck_window_get_xid(window), x, y); } } return 0; }
static gboolean is_menubar(WnckWindow* window) { gboolean ret = FALSE; if (wnck_window_get_window_type(window) != WNCK_WINDOW_DOCK) ret = FALSE; else if (strcmp(wnck_window_get_name(window), "GTK MENUBAR") == 0) ret = TRUE; else { Atom type; int format; gulong nitems; gulong bytes_after; Atom *data; if (XGetWindowProperty(gdk_display, wnck_window_get_xid(window), XInternAtom(gdk_display, "_NET_WM_WINDOW_TYPE", FALSE), 0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems, &bytes_after, (void*) &data) == Success && data != NULL) { if (data[0] == XInternAtom(gdk_display, "_KDE_NET_WM_WINDOW_TYPE_TOPMENU", FALSE)) ret = TRUE; XFree (data); } } return ret; }
/** * undecorates a window */ int c_decorate_window(lua_State *lua) { gboolean result = TRUE; int top = lua_gettop(lua); if (top != 0) { luaL_error(lua,"decorate_window: %s",no_indata_expected_error); return 0; } if (!devilspie2_emulate) { WnckWindow *window = get_current_window(); if (window) { if (!devilspie2_emulate) { gulong xid = wnck_window_get_xid(window); if (!decorate_window(xid)) { result=FALSE; } } } } lua_pushboolean(lua,result); return 1; }
static void kill_window (WnckWindow *win) { WnckApplication *app; app = wnck_window_get_application (win); if (app) { gchar buf[257], *client_machine; int pid; pid = wnck_application_get_pid (app); client_machine = get_client_machine (wnck_application_get_xid (app)); if (client_machine && pid > 0) { if (gethostname (buf, sizeof (buf) - 1) == 0) { if (strcmp (buf, client_machine) == 0) kill (pid, 9); } } if (client_machine) g_free (client_machine); } gdk_error_trap_push (); XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win)); gdk_display_sync (gdk_display_get_default ()); gdk_error_trap_pop_ignored (); }
void window_activate(WnckWindow *window) { XEvent xev; Window xwindow; g_return_if_fail (WNCK_IS_WINDOW (window)); if (wnck_window_is_minimized(window)) { return; } xwindow = wnck_window_get_xid(window); xev.xclient.type = ClientMessage; xev.xclient.serial = 0; xev.xclient.send_event = TRUE; xev.xclient.display = main_dpy; xev.xclient.window = xwindow; xev.xclient.message_type = XInternAtom(main_dpy, "_NET_ACTIVE_WINDOW",FALSE); xev.xclient.format = 32; xev.xclient.data.l[0] = 2; /* WNCK_CLIENT_TYPE_PAGER */ xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; XSendEvent (main_dpy, DefaultRootWindow(main_dpy), FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &xev); }
int c_center(lua_State *lua) { int top = lua_gettop(lua); int workspace_width, workspace_height, window_width, window_height; int xoffset, yoffset; WnckScreen *screen; WnckWorkspace *workspace; if (top != 0) { luaL_error(lua, "center: %s", no_indata_expected_error); return 0; } WnckWindow *window = get_current_window(); if (!window) { lua_pushboolean(lua, FALSE); return 1; } wnck_window_get_geometry(window, NULL, NULL, &window_width, &window_height); screen = wnck_window_get_screen(window); workspace = wnck_screen_get_active_workspace(screen); if (workspace == NULL) { workspace = wnck_screen_get_workspace(screen,0); } if (workspace == NULL) { g_printerr(_("Could not get workspace")); lua_pushboolean(lua, FALSE); return 1; } workspace_width = wnck_workspace_get_width(workspace); workspace_height = wnck_workspace_get_height(workspace); xoffset = (workspace_width - window_width) / 2; yoffset = (workspace_height - window_height) / 2; devilspie2_error_trap_push(); XMoveWindow (gdk_x11_get_default_xdisplay(), wnck_window_get_xid(window), xoffset, yoffset); if (devilspie2_error_trap_pop()) { g_printerr("center: %s", failed_string); lua_pushboolean(lua, FALSE); return 1; } lua_pushboolean(lua, TRUE); return 1; }
static void add_menubar(MacMenu* mmb, WnckWindow* mbarwin) { Window mbar = wnck_window_get_xid(mbarwin); GtkWidget* sck = gtk_socket_new(); g_signal_connect(sck, "destroy", G_CALLBACK(socket_destroyed), mmb); gtk_notebook_append_page(mmb->notebook, GTK_WIDGET(sck), NULL); gtk_socket_steal(GTK_SOCKET(sck), mbar); gtk_widget_show_all(sck); g_hash_table_insert(mmb->mbars_scks, (gpointer) mbar, sck); }
static void force_quit_dialog_realize (GtkWidget *dialog, void *data) { WnckWindow *win = data; gdk_error_trap_push (); XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_WINDOW_XID (gtk_widget_get_window (dialog)), wnck_window_get_xid (win)); gdk_display_sync (gdk_display_get_default ()); gdk_error_trap_pop_ignored (); }
static void wnck_selector_drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint time, WnckWindow *window) { gulong xid; xid = wnck_window_get_xid (window); gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *)&xid, sizeof (gulong)); }
void move_resize_window (WnckWindow *win, int direction, decor_event *gtkwd_event) { Display *xdisplay; GdkDisplay *gdkdisplay; GdkScreen *screen; Window xroot; XEvent ev; gdkdisplay = gdk_display_get_default (); xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay); screen = gdk_display_get_default_screen (gdkdisplay); xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); if (action_menu_mapped) { gtk_object_destroy (GTK_OBJECT (action_menu)); return; } ev.xclient.type = ClientMessage; ev.xclient.display = xdisplay; ev.xclient.serial = 0; ev.xclient.send_event = TRUE; ev.xclient.window = wnck_window_get_xid (win); ev.xclient.message_type = wm_move_resize_atom; ev.xclient.format = 32; ev.xclient.data.l[0] = gtkwd_event->x_root; ev.xclient.data.l[1] = gtkwd_event->y_root; ev.xclient.data.l[2] = direction; ev.xclient.data.l[3] = gtkwd_event->button; ev.xclient.data.l[4] = 1; XUngrabPointer (xdisplay, gtkwd_event->time); XUngrabKeyboard (xdisplay, gtkwd_event->time); XSendEvent (xdisplay, xroot, FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &ev); XSync (xdisplay, FALSE); }
static Bool get_window_strut(WnckWindow *wnckwindow, int *left, int *right, int *top, int *bottom) { Atom actual_type_return; int actual_format_return = 0; unsigned long nitems_return = 0; unsigned char *prop_return = NULL; unsigned long bytes_after_return = 0; int result = 0; unsigned long *lresult = NULL; Window window = wnck_window_get_xid(wnckwindow); result = XGetWindowProperty(main_dpy, window, XInternAtom(main_dpy, "_NET_WM_STRUT_PARTIAL", False), 0, /* long_offset */ 12, /* long_length */ False, /* delete */ AnyPropertyType, /* req_type */ &actual_type_return, &actual_format_return, &nitems_return, &bytes_after_return, &prop_return); if ( (result != Success)) { fprintf(stderr, "[bonnye] _NET_WM_STRUT_PARTIAL failure\n"); XFree(prop_return); return False; } if (nitems_return < 12) { XFree(prop_return); return False; } lresult = (unsigned long *)prop_return; *left = (int)lresult[0]; *right = (int)lresult[1]; *top = (int)lresult[2]; *bottom = (int)lresult[3]; XFree(prop_return); return True; }
void window_decorate(WnckWindow *window, gboolean set) { Atom atom; MwmHints hints = { MWM_HINTS_DECORATIONS, 0, 0, 0, 0 }; if (set) { hints.decorations = 1; } atom = XInternAtom(main_dpy, _XA_MWM_HINTS, FALSE); XChangeProperty(main_dpy, wnck_window_get_xid(window), atom, atom, 32, PropModeReplace, (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); }
static void wnck_pid_read_resource_usage_no_cache (GdkDisplay *gdisplay, gulong pid, WnckResourceUsage *usage) { Display *xdisplay; int i; xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay); i = 0; while (i < ScreenCount (xdisplay)) { WnckScreen *screen; GList *windows; GList *tmp; screen = wnck_screen_get (i); g_assert (screen != NULL); windows = wnck_screen_get_windows (screen); tmp = windows; while (tmp != NULL) { if (wnck_window_get_pid (tmp->data) == pid) { wnck_xid_read_resource_usage (gdisplay, wnck_window_get_xid (tmp->data), usage); /* stop on first window found */ return; } tmp = tmp->next; } ++i; } }
gboolean request_update_window_decoration_size (WnckWindow *win) { decor_t *d; gint width, height; gint x, y, w, h, name_width; if (win == NULL) return FALSE; d = g_object_get_data (G_OBJECT (win), "decor"); if (!d->decorated) return FALSE; /* Get the geometry of the window, we'll need it later */ wnck_window_get_client_window_geometry (win, &x, &y, &w, &h); /* Get the width of the name */ name_width = max_window_name_width (win); /* Ask the theme to tell us how much space it needs. If this is not successful * update the decoration name and return false */ if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height)) { update_window_decoration_name (win); return FALSE; } d->width = width; d->height = height; decor_post_pending (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), wnck_window_get_xid (win), populate_frame_type (d), populate_frame_state (d), populate_frame_actions (d)); return TRUE; }
/** * Set the Window Geometry2 * set_window_geometry2(x,y,xsize,ysize); */ int c_set_window_geometry2(lua_State *lua) { int top = lua_gettop(lua); if (top != 4) { luaL_error(lua,"set_window_geometry: %s", four_indata_expected_error); return 0; } int type1 = lua_type(lua, 1); int type2 = lua_type(lua, 2); int type3 = lua_type(lua, 3); int type4 = lua_type(lua, 4); if ((type1 != LUA_TNUMBER) || (type2 != LUA_TNUMBER) || (type3 != LUA_TNUMBER) || (type4 != LUA_TNUMBER)) { luaL_error(lua, "set_window_geometry: %s", four_indata_expected_error); return 0; } int x = lua_tonumber(lua, 1); int y = lua_tonumber(lua, 2); int xsize = lua_tonumber(lua, 3); int ysize = lua_tonumber(lua, 4); if (!devilspie2_emulate) { WnckWindow *window = get_current_window(); if (window) { XMoveResizeWindow(gdk_x11_get_default_xdisplay(), wnck_window_get_xid(window), x, y, xsize, ysize); } } return 0; }
int c_get_window_property(lua_State *lua) { int top = lua_gettop(lua); if (top != 1) { luaL_error(lua, "get_window_property: %s", one_indata_expected_error); return 0; } // gchar *property= int type = lua_type(lua, 1); if (type != LUA_TSTRING) { luaL_error(lua, "get_window_property: %s", string_expected_as_indata_error); return 0; } const gchar *value = lua_tostring(lua, 1); WnckWindow *window = get_current_window(); gchar *result = NULL; if (window) { result = my_wnck_get_string_property_latin1(wnck_window_get_xid(window), my_wnck_atom_get(value)); } else { result = g_strdup_printf("NO RESULT"); } if (result) { lua_pushstring(lua, result); } else { lua_pushstring(lua, ""); } g_free(result); return 1; }
int c_get_window_xid(lua_State *lua) { int top = lua_gettop(lua); if (top != 0) { luaL_error(lua, "get_window_xid: %s", no_indata_expected_error); return 0; } WnckWindow *window = get_current_window(); gulong result; if (window) { result = wnck_window_get_xid(window); } else { result = 0; } lua_pushnumber(lua, result); return 1; }
static void desktop_active_window_changed(WnckScreen* screen, WnckWindow *previous_window, MacMenu* mmb) { WnckWindow* awin = wnck_screen_get_active_window(screen); GtkWidget* sck = NULL; if (awin != NULL && wnck_window_get_window_type(awin) != WNCK_WINDOW_DESKTOP) { long inout[2] = {0, 0}; inout[0] = wnck_window_get_xid(awin); if (inout[0]) { g_hash_table_foreach(mmb->mbars_scks, find_mbar_by_mwin, inout); if (inout[1]) sck = g_hash_table_lookup(mmb->mbars_scks, (gpointer) inout[1]); } if (sck == NULL) { sck = mmb->dummysck; gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10); } else { gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS); } gtk_label_set_text(mmb->label, get_application_name(awin, mmb)); } else { sck = mmb->mainsck; gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10); gtk_label_set_text(mmb->label, MAIN_LABEL_TEXT); } gtk_notebook_set_current_page( mmb->notebook, gtk_notebook_page_num(mmb->notebook, sck) ); }
/** * Sets the window strut */ int c_set_window_strut(lua_State *lua) { int top = lua_gettop(lua); if (top < 4) { luaL_error(lua,"set_window_strut: %s", four_indata_expected_error); return 0; } if (!devilspie2_emulate) { #if __x86_64__ int64_t struts[12]; #else int32_t struts[12]; #endif int i; for (i = 0; i < 12; i++) { struts[i] = i < top ? lua_tonumber(lua, i + 1) : 0; } Display *dpy = gdk_x11_get_default_xdisplay(); WnckWindow *window = get_current_window(); if (window) { XChangeProperty(dpy, wnck_window_get_xid(window), XInternAtom(dpy, "_NET_WM_STRUT_PARTIAL", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char*)struts, 12); XSync(dpy, False); } } return 0; }
int c_set_window_below(lua_State *lua) { int top = lua_gettop(lua); gboolean set_below; if (top > 1) { luaL_error(lua, "set_window_below: %s", one_indata_expected_error); return 0; } else if (top == 1) { int type = lua_type(lua, 1); if (type != LUA_TBOOLEAN) { luaL_error(lua, "set_window_below: %s", boolean_expected_as_indata_error); return 0; } int value = lua_toboolean(lua, 1); set_below = (gboolean)(value); } else { set_below = TRUE; } WnckWindow *window = get_current_window(); if (!devilspie2_emulate) { Window xid = wnck_window_get_xid(window); devilspie2_change_state(devilspie2_window_get_xscreen(xid), xid, set_below, my_wnck_atom_get("_NET_WM_STATE_BELOW"), 0); } return 0; }
gboolean update_window_decoration_size (WnckWindow *win) { decor_t *d; cairo_surface_t *surface, *buffer_surface = NULL; Picture picture; Display *xdisplay; XRenderPictFormat *format; if (win == NULL) return FALSE; d = g_object_get_data (G_OBJECT (win), "decor"); if (!d->decorated) return FALSE; xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); gdk_error_trap_push (); /* Get the correct depth for the frame window in reparenting mode, otherwise * enforce 32 */ if (d->frame_window) surface = create_native_surface_and_wrap (d->width, d->height, d->frame->style_window_rgb); else surface = create_native_surface_and_wrap (d->width, d->height, d->frame->style_window_rgba); gdk_flush (); /* Handle failure */ if (!surface || gdk_error_trap_pop ()) { if (surface) cairo_surface_destroy (surface); return FALSE; } gdk_error_trap_push (); if (d->frame_window) buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgb); else buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba); gdk_flush (); /* Handle failure */ if (!buffer_surface || gdk_error_trap_pop ()) { if (buffer_surface) cairo_surface_destroy (buffer_surface); cairo_surface_destroy (surface); return FALSE; } /* Create XRender context */ format = get_format_for_surface (d, buffer_surface); picture = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (buffer_surface), format, 0, NULL); /* Destroy the old pixmaps and pictures */ if (d->surface) cairo_surface_destroy (d->surface); if (d->x11Pixmap) decor_post_delete_pixmap (xdisplay, wnck_window_get_xid (d->win), d->x11Pixmap); if (d->buffer_surface) cairo_surface_destroy (d->buffer_surface); if (d->picture) XRenderFreePicture (xdisplay, d->picture); if (d->cr) cairo_destroy (d->cr); /* Assign new pixmaps and pictures */ d->surface = surface; d->x11Pixmap = cairo_xlib_surface_get_drawable (d->surface); d->buffer_surface = buffer_surface; d->cr = cairo_create (surface); d->picture = picture; d->prop_xid = wnck_window_get_xid (win); update_window_decoration_name (win); /* Redraw decoration on idle */ queue_decor_draw (d); return TRUE; }
gboolean on_title_pressed(GtkWidget *title, GdkEventButton *event, WindowckPlugin *wckp) { if (!wckp->win->controlwindow) return FALSE; if (event->button == 1 && (wnck_window_get_window_type (wckp->win->controlwindow) != WNCK_WINDOW_DESKTOP)) { /* double/tripple click */ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { toggle_maximize(wckp->win->controlwindow); } else /* left-click */ { wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); // WnckScreen *screen = wnck_screen_get_default (); // wnck_screen_force_update (screen); WnckWindow *active_window = wckp->win->controlwindow; if (!wnck_window_is_maximized(active_window)) return TRUE; GdkDisplay *gdkdisp = gdk_display_get_default (); // Gdk 3 // GdkDevice *mouse = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdkdisp)); GdkDevice *mouse = gdk_device_get_core_pointer(); Display *d = gdk_x11_display_get_xdisplay(gdkdisp); XEvent xev; Atom netMoveResize = XInternAtom(d, "_NET_WM_MOVERESIZE", FALSE); xev.xclient.type = ClientMessage; xev.xclient.message_type = netMoveResize; xev.xclient.display = d; xev.xclient.window = wnck_window_get_xid(active_window); xev.xclient.format = 32; // Gdk 3 // int x, y; // gdk_device_get_position(mouse, NULL, &x, &y); // TODO: Provide a second argument to gdk_device_get_state gdouble xy[2]; gdk_device_get_state(mouse, NULL, xy, NULL); xev.xclient.data.l[0] = xy[0]; xev.xclient.data.l[1] = xy[1]; xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE xev.xclient.data.l[3] = Button1; xev.xclient.data.l[4] = 0; XUngrabPointer(d, CurrentTime); XSendEvent(d, RootWindow(d, 0), FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } return TRUE; } if (event->button == 3) { /* right-click */ wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); /* let the panel show the menu */ return TRUE; } return FALSE; }
void tile(int workspace_id) { GList *item; int i = 0; int x = 0; int y = 0; int height = 0; int width = 0; int left_count = workspace_get_left_count(workspace_id); int right_count = 0; int space_x = 0; int space_y = 0; int space_width = 0; int space_height = 0; /* I may have used a new temporary list containing only tileable windows (ie not minimized), but wnck_window_is_minimized is cheap and less error prone than alloc/free */ GList *tiled_windows = workspace_windows(workspace_id); int windows_count = workspace_get_tileable_count(workspace_id); get_workspace_geometry(workspace_id, &space_x, &space_y, &space_width, &space_height); /* distribute windows in both columns, while left one is not full */ if (windows_count < 2 * left_count) { left_count = (windows_count + 1) / 2; } right_count = windows_count - left_count; int frontier = space_width * workspace_get_left_width(workspace_id) / 100 + configuration.width_offset; for (item = g_list_first(tiled_windows); item != NULL; item = g_list_next(item)) { WnckWindow *window = (WnckWindow *)item->data; if (wnck_window_is_minimized(window)) { continue; } if (i < left_count) { x = space_x; y = space_y + (space_height / left_count) * i; height = space_height / left_count; width = frontier; } else { x = space_x + frontier; y = space_y + (space_height / right_count) * (i - left_count); height = space_height / right_count; width = space_width - frontier; } XMoveResizeWindow(main_dpy, wnck_window_get_xid (window), x + 1, y + 1, width - 2, height - 2); i++; } }
int c_set_viewport(lua_State *lua) { int top = lua_gettop(lua); WnckScreen *screen; int x,y,width,height, viewport_start; if (top != 1) { luaL_error(lua, "set_viewport: %s", one_indata_expected_error); return 0; } int type = lua_type(lua, 1); if (type != LUA_TNUMBER) { luaL_error(lua, "set_viewport: %s", number_expected_as_indata_error); return 0; } int num = lua_tonumber(lua,1); if (num <= 0) { g_error("set_viewport: %s", integer_greater_than_zero_expected_error); lua_pushboolean(lua, FALSE); return 1; } WnckWindow *window = get_current_window(); if (!window) { lua_pushboolean(lua, FALSE); return 1; } screen = wnck_window_get_screen(window); wnck_window_get_geometry(window, &x, &y, &width, &height); gulong xid = wnck_window_get_xid(window); viewport_start = devilspie2_get_viewport_start(xid); if (viewport_start < 0) { g_printerr("set_viewport: %s", could_not_find_current_viewport_error); lua_pushboolean(lua, FALSE); return 1; } x=((num-1) * wnck_screen_get_width(screen)) - viewport_start + x; devilspie2_error_trap_push(); XMoveResizeWindow(gdk_x11_get_default_xdisplay(), wnck_window_get_xid(window), x, y, width, height); if (devilspie2_error_trap_pop()) { g_printerr("set_viewport: %s", setting_viewport_failed_error); lua_pushboolean(lua, FALSE); return 1; } lua_pushboolean(lua, TRUE); return 1; }