void title_event (WnckWindow *win, decor_event *gtkwd_event, decor_event_type gtkwd_type) { static Window last_button_xwindow = None; static Time last_button_time = 0; gint titlebar_action = 0; decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); if (d->frame_window && gtkwd_type == GEnterNotify) { GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR); gdk_window_set_cursor (d->frame_window, cursor); gdk_cursor_unref (cursor); } if (gtkwd_type != GButtonPress) return; if (gtkwd_event->button == 1) { static int last_button_num = 0; static int last_button_x = 0; static int last_button_y = 0; if (gtkwd_event->button == last_button_num && gtkwd_event->window == last_button_xwindow && gtkwd_event->time < last_button_time + double_click_timeout && dist (gtkwd_event->x, gtkwd_event->y, last_button_x, last_button_y) < DOUBLE_CLICK_DISTANCE) { g_object_get (settings, "titlebar-double-click-action", &titlebar_action, NULL); handle_title_button_event (win, titlebar_action, gtkwd_event); last_button_num = 0; last_button_xwindow = None; last_button_time = 0; last_button_x = 0; last_button_y = 0; } else { last_button_num = gtkwd_event->button; last_button_xwindow = gtkwd_event->window; last_button_time = gtkwd_event->time; last_button_x = gtkwd_event->x; last_button_y = gtkwd_event->y; restack_window (win, Above); move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event); } } else if (gtkwd_event->button == 2) { g_object_get (settings, "titlebar-middle-click-action", &titlebar_action, NULL); handle_title_button_event (win, titlebar_action, gtkwd_event); } else if (gtkwd_event->button == 3) { g_object_get (settings, "titlebar-right-click-action", &titlebar_action, NULL); handle_title_button_event (win, titlebar_action, gtkwd_event); } else if (gtkwd_event->button == 4 || gtkwd_event->button == 5) { handle_mouse_wheel_title_event (win, gtkwd_event->button); } }
void frame_common_event (WnckWindow *win, int direction, decor_event *gtkwd_event, decor_event_type gtkwd_type) { gint titlebar_action = 0; decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); if (d->frame_window && gtkwd_type == GEnterNotify) { GdkCursor *cursor = NULL; switch (direction) { case WM_MOVERESIZE_SIZE_TOPLEFT: cursor = gdk_cursor_new (GDK_TOP_LEFT_CORNER); break; case WM_MOVERESIZE_SIZE_LEFT: cursor = gdk_cursor_new (GDK_LEFT_SIDE); break; case WM_MOVERESIZE_SIZE_BOTTOMLEFT: cursor = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER); break; case WM_MOVERESIZE_SIZE_BOTTOM: cursor = gdk_cursor_new (GDK_BOTTOM_SIDE); break; case WM_MOVERESIZE_SIZE_BOTTOMRIGHT: cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER); break; case WM_MOVERESIZE_SIZE_RIGHT: cursor = gdk_cursor_new (GDK_RIGHT_SIDE); break; case WM_MOVERESIZE_SIZE_TOPRIGHT: cursor = gdk_cursor_new (GDK_TOP_RIGHT_CORNER); break; case WM_MOVERESIZE_SIZE_TOP: cursor = gdk_cursor_new (GDK_TOP_SIDE); break; default: break; } if (cursor) { gdk_window_set_cursor (d->frame_window, cursor); gdk_cursor_unref (cursor); } } if (gtkwd_type != GButtonPress) return; switch (gtkwd_event->button) { case 1: move_resize_window (win, direction, gtkwd_event); restack_window (win, Above); break; case 2: g_object_get (settings, "titlebar-middle-click-action", &titlebar_action, NULL); handle_title_button_event (win, titlebar_action, gtkwd_event); break; case 3: g_object_get (settings, "titlebar-right-click-action", &titlebar_action, NULL); handle_title_button_event (win, titlebar_action, gtkwd_event); break; } }
void layout_mirror(Wm *wm) { Workspace *cur = &wm->workspaces[wm->cwrksp]; t_list *clients = &cur->windows; t_elem *tmp; Client *client; unsigned int win_width; unsigned int win_width_master; unsigned int left_num; unsigned int right_num; Bool left = True; unsigned int yleft; unsigned int yright; unsigned int left_height; unsigned int right_height; if (clients->size == 1) { move_resize_window(wm, clients->head->data, 0, wm->bar_height, wm->scr_width - 2, wm->scr_height - 2); } else if (clients->size == 2) { win_width = wm->scr_width * cur->master_width; move_resize_window(wm, clients->head->data, 0, wm->bar_height, win_width - 2, wm->scr_height - 2); move_resize_window(wm, clients->tail->data, win_width, wm->bar_height, wm->scr_width - win_width - 2, wm->scr_height - 2); } else if (clients->size >= 3) { win_width_master = wm->scr_width * cur->master_width; win_width = (wm->scr_width - win_width_master) / 2; right_num = (clients->size - 1) / 2; left_num = clients->size - 1 - right_num; yleft = wm->bar_height; yright = wm->bar_height; left_height = wm->scr_height / left_num; right_height = wm->scr_height / right_num; list_foreach_as(clients->head, tmp, (Client *), client) { if (tmp == clients->head) { move_resize_window(wm, client, win_width, wm->bar_height, win_width_master - 2, wm->scr_height - 2); } else { if (left) { move_resize_window(wm, client, 0, yleft, win_width - 2, left_height - 2); yleft += left_height; } else { move_resize_window(wm, client, win_width + wm->scr_width - (2 * win_width), yright, win_width - 2, right_height - 2); yright += right_height; } left = !left; } } }