+static Eina_Bool
+_e_border_rotation_change_floating_pos(E_Border *bd, int *x, int *y)
+{
+ int new_x, new_y;
+ int min_title_width=96;
+
+ if (!bd) return EINA_FALSE;
+ if (!x || !y) return EINA_FALSE;
+
+ new_x = bd->x;
+ new_y = bd->y;
+
+ // Portrait -> Landscape, x= pre_x*2, y=pre_y/2
+ // Landscape -> Portrait, x= pre_x/2, y=pre_y*2
+ // guaranteeing the minimum size of titlebar shown, min_title_width
+ // so user can initiate drag&drop action after rotation changed.
+ if (bd->client.e.state.rot.curr == 0)
+ {
+ if (bd->client.e.state.rot.prev == 90)
+ {
+ new_x = (bd->zone->h - bd->h - bd->y) / 2;
+ new_y = 2 * bd->x;
+ }
+ else if (bd->client.e.state.rot.prev == 270)
+ {
+ new_x = bd->y / 2;
+ new_y = (bd->zone->w - bd->w - bd->x) * 2;
+ }
+ else if (bd->client.e.state.rot.prev == 180)
+ {
+ new_x = bd->zone->w - bd->x - bd->w;
+ new_y = bd->zone->h - bd->y - bd->h;
+ }
+
+ if(new_x + bd->w < min_title_width)
+ {
+ new_x = min_title_width - bd->w;
+ }
+ else if(new_x > bd->zone->w - min_title_width)
+ {
+ new_x = bd->zone->w - min_title_width;
+ }
+ }
+ else if (bd->client.e.state.rot.curr == 90)
+ {
+ if (bd->client.e.state.rot.prev == 0)
+ {
+ new_x = bd->y / 2;
+ new_y = bd->zone->h - (2 * bd->x) - bd->w;
+ }
+ else if (bd->client.e.state.rot.prev == 270)
+ {
+ new_x = bd->zone->w - bd->x - bd->w;
+ new_y = bd->zone->h - bd->y - bd->h;
+ }
+ else if (bd->client.e.state.rot.prev == 180)
+ {
+ new_x = (bd->zone->h - bd->y - bd->h) / 2;
+ new_y = bd->zone->h - (2 * (bd->zone->w - bd->x - bd->w)) - bd->w;
+ }
+
+ if(new_y > bd->zone->h - min_title_width)
+ {
+ new_y = bd->zone->h - min_title_width;
+ }
+ else if(new_y < min_title_width - bd->w)
+ {
+ new_y = min_title_width - bd->w;
+ }
+ }
+ else if (bd->client.e.state.rot.curr == 270)
+ {
+ if (bd->client.e.state.rot.prev == 0)
+ {
+ new_x = bd->zone->w - bd->h - (bd->y / 2);
+ new_y = bd->x * 2;
+ }
+ else if (bd->client.e.state.rot.prev == 90)
+ {
+ new_x = bd->zone->w - bd->x - bd->w;
+ new_y = bd->zone->h - bd->y - bd->h;
+ }
+ else if (bd->client.e.state.rot.prev == 180)
+ {
+ new_x = bd->zone->w - bd->x - bd->w;
+ new_y = bd->zone->h - bd->y - bd->h;
+
+ new_x = bd->zone->w - bd->h - ((bd->zone->h - bd->y - bd->h) / 2);
+ new_y = (bd->zone->w - bd->x - bd->w) * 2;
+ }
+
+ if(new_y > bd->zone->h - min_title_width)
+ {
+ new_y = bd->zone->h - min_title_width;
+ }
+ else if( new_y + bd->w < min_title_width)
+ {
+ new_y = min_title_width - bd->w ;
+ }
+ }
+ else if (bd->client.e.state.rot.curr == 180)
+ {
+ if (bd->client.e.state.rot.prev == 0)
+ {
+ new_x = bd->zone->w - bd->x - bd->w;
+ new_y = bd->zone->h - bd->y - bd->h;
+ }
+ else if (bd->client.e.state.rot.prev == 90)
+ {
+ new_x = bd->zone->w - ((bd->zone->h - bd->h - bd->y) / 2) - bd->h;
+ new_y = bd->zone->h - (2 * bd->x) - bd->w;
+ }
+ else if (bd->client.e.state.rot.prev == 270)
+ {
+ new_x = bd->zone->w - (bd->y / 2) - bd->h;
+ new_y = bd->zone->h - ((bd->zone->w - bd->w - bd->x) * 2) - bd->w;
+ }
+
+ if(new_x + bd->w < min_title_width)
+ {
+ new_x = min_title_width - bd->w;
+ }
+ else if(new_x > bd->zone->w - min_title_width)
+ {
+ new_x = bd->zone->w - min_title_width;
+ }
+ }
+
+ ELBF(ELBT_ROT, 0, bd->client.win,
+ "Floating Mode. ANGLE (%d->%d), POS (%d,%d) -> (%d,%d)",
+ bd->client.e.state.rot.prev, bd->client.e.state.rot.curr,
+ bd->x, bd->y, new_x, new_y);
+
+ if ((new_x == *x) &&
+ (new_y == *y))
+ {
+ return EINA_FALSE;
+ }
+
+ *x = new_x;
+ *y = new_y;
+
+ return EINA_TRUE;
+}
+