-static void cur_row_col(guint *r, guint *c)
-{
- switch (screen_desktop_layout.orientation) {
- case OB_ORIENTATION_HORZ:
- switch (screen_desktop_layout.start_corner) {
- case OB_CORNER_TOPLEFT:
- *r = screen_desktop / screen_desktop_layout.columns;
- *c = screen_desktop % screen_desktop_layout.columns;
- break;
- case OB_CORNER_BOTTOMLEFT:
- *r = screen_desktop_layout.rows - 1 -
- screen_desktop / screen_desktop_layout.columns;
- *c = screen_desktop % screen_desktop_layout.columns;
- break;
- case OB_CORNER_TOPRIGHT:
- *r = screen_desktop / screen_desktop_layout.columns;
- *c = screen_desktop_layout.columns - 1 -
- screen_desktop % screen_desktop_layout.columns;
- break;
- case OB_CORNER_BOTTOMRIGHT:
- *r = screen_desktop_layout.rows - 1 -
- screen_desktop / screen_desktop_layout.columns;
- *c = screen_desktop_layout.columns - 1 -
- screen_desktop % screen_desktop_layout.columns;
- break;
- }
- break;
- case OB_ORIENTATION_VERT:
- switch (screen_desktop_layout.start_corner) {
- case OB_CORNER_TOPLEFT:
- *r = screen_desktop % screen_desktop_layout.rows;
- *c = screen_desktop / screen_desktop_layout.rows;
- break;
- case OB_CORNER_BOTTOMLEFT:
- *r = screen_desktop_layout.rows - 1 -
- screen_desktop % screen_desktop_layout.rows;
- *c = screen_desktop / screen_desktop_layout.rows;
- break;
- case OB_CORNER_TOPRIGHT:
- *r = screen_desktop % screen_desktop_layout.rows;
- *c = screen_desktop_layout.columns - 1 -
- screen_desktop / screen_desktop_layout.rows;
- break;
- case OB_CORNER_BOTTOMRIGHT:
- *r = screen_desktop_layout.rows - 1 -
- screen_desktop % screen_desktop_layout.rows;
- *c = screen_desktop_layout.columns - 1 -
- screen_desktop / screen_desktop_layout.rows;
- break;
- }
- break;
- }
-}
-
-static guint translate_row_col(guint r, guint c)
-{
- switch (screen_desktop_layout.orientation) {
- case OB_ORIENTATION_HORZ:
- switch (screen_desktop_layout.start_corner) {
- case OB_CORNER_TOPLEFT:
- return r % screen_desktop_layout.rows *
- screen_desktop_layout.columns +
- c % screen_desktop_layout.columns;
- case OB_CORNER_BOTTOMLEFT:
- return (screen_desktop_layout.rows - 1 -
- r % screen_desktop_layout.rows) *
- screen_desktop_layout.columns +
- c % screen_desktop_layout.columns;
- case OB_CORNER_TOPRIGHT:
- return r % screen_desktop_layout.rows *
- screen_desktop_layout.columns +
- (screen_desktop_layout.columns - 1 -
- c % screen_desktop_layout.columns);
- case OB_CORNER_BOTTOMRIGHT:
- return (screen_desktop_layout.rows - 1 -
- r % screen_desktop_layout.rows) *
- screen_desktop_layout.columns +
- (screen_desktop_layout.columns - 1 -
- c % screen_desktop_layout.columns);
- }
- case OB_ORIENTATION_VERT:
- switch (screen_desktop_layout.start_corner) {
- case OB_CORNER_TOPLEFT:
- return c % screen_desktop_layout.columns *
- screen_desktop_layout.rows +
- r % screen_desktop_layout.rows;
- case OB_CORNER_BOTTOMLEFT:
- return c % screen_desktop_layout.columns *
- screen_desktop_layout.rows +
- (screen_desktop_layout.rows - 1 -
- r % screen_desktop_layout.rows);
- case OB_CORNER_TOPRIGHT:
- return (screen_desktop_layout.columns - 1 -
- c % screen_desktop_layout.columns) *
- screen_desktop_layout.rows +
- r % screen_desktop_layout.rows;
- case OB_CORNER_BOTTOMRIGHT:
- return (screen_desktop_layout.columns - 1 -
- c % screen_desktop_layout.columns) *
- screen_desktop_layout.rows +
- (screen_desktop_layout.rows - 1 -
- r % screen_desktop_layout.rows);
- }
- }
- g_assert_not_reached();
- return 0;
-}
-
-void action_desktop_right(union ActionData *data)
-{
- guint r, c, d;
-
- cur_row_col(&r, &c);
- ++c;
- if (c >= screen_desktop_layout.columns) {
- if (!data->desktopdir.wrap) return;
- c = 0;
- }
- d = translate_row_col(r, c);
- if (d >= screen_num_desktops) {
- if (!data->desktopdir.wrap) return;
- ++c;
- }
- d = translate_row_col(r, c);
- if (d < screen_num_desktops)
- screen_set_desktop(d);
-}
-
-void action_send_to_desktop_right(union ActionData *data)
-{
- ObClient *cl = data->sendto.c;
- guint r, c, d;
-
- if (!cl || !client_normal(cl)) return;
-
- cur_row_col(&r, &c);
- ++c;
- if (c >= screen_desktop_layout.columns) {
- if (!data->sendtodir.wrap) return;
- c = 0;
- }
- d = translate_row_col(r, c);
- if (d >= screen_num_desktops) {
- if (!data->sendtodir.wrap) return;
- ++c;
- }
- d = translate_row_col(r, c);
- if (d < screen_num_desktops) {
- client_set_desktop(cl, d, data->sendtodir.follow);
- if (data->sendtodir.follow) screen_set_desktop(d);
- }
-}
-
-void action_desktop_left(union ActionData *data)
-{
- guint r, c, d;
-
- cur_row_col(&r, &c);
- --c;
- if (c >= screen_desktop_layout.columns) {
- if (!data->desktopdir.wrap) return;
- c = screen_desktop_layout.columns - 1;
- }
- d = translate_row_col(r, c);
- if (d >= screen_num_desktops) {
- if (!data->desktopdir.wrap) return;
- --c;
- }
- d = translate_row_col(r, c);
- if (d < screen_num_desktops)
- screen_set_desktop(d);
-}
-
-void action_send_to_desktop_left(union ActionData *data)
-{
- ObClient *cl = data->sendto.c;
- guint r, c, d;
-
- if (!cl || !client_normal(cl)) return;
-
- cur_row_col(&r, &c);
- --c;
- if (c >= screen_desktop_layout.columns) {
- if (!data->sendtodir.wrap) return;
- c = screen_desktop_layout.columns - 1;
- }
- d = translate_row_col(r, c);
- if (d >= screen_num_desktops) {
- if (!data->sendtodir.wrap) return;
- --c;
- }
- d = translate_row_col(r, c);
- if (d < screen_num_desktops) {
- client_set_desktop(cl, d, data->sendtodir.follow);
- if (data->sendtodir.follow) screen_set_desktop(d);
- }
-}
-
-void action_desktop_down(union ActionData *data)