@@ -977,6 +977,30 @@ workspaceview_float_rowview(Workspaceview *wview, Rowview *rview)
977977 vobject_refresh (VOBJECT (wview -> old_sview ));
978978}
979979
980+ static void
981+ workspaceview_undo_row_drag (Workspaceview * wview )
982+ {
983+ Rowview * rview = wview -> drag_rview ;
984+
985+ g_object_ref (rview );
986+
987+ g_assert (IS_SUBCOLUMNVIEW (wview -> old_sview ));
988+ g_assert (IS_ROWVIEW (rview ));
989+
990+ view_child_remove (VIEW (rview ));
991+ // the row number has to be wrong or reattach is skipped
992+ rview -> rnum = -1 ;
993+ view_child_add (VIEW (wview -> old_sview ), VIEW (rview ));
994+
995+ g_object_unref (rview );
996+
997+ // the row and the old containing column need to refresh
998+ Row * row = ROW (VOBJECT (rview )-> iobject );
999+ iobject_changed (IOBJECT (row ));
1000+ Subcolumn * scol = SUBCOLUMN (ICONTAINER (row )-> parent );
1001+ iobject_changed (IOBJECT (scol ));
1002+ }
1003+
9801004static void
9811005workspaceview_drop_rowview (Workspaceview * wview )
9821006{
@@ -1013,17 +1037,7 @@ workspaceview_drop_rowview(Workspaceview *wview)
10131037
10141038 // reparent the rowview back to the original column ... this is where
10151039 // icontainer_reparent() expects to find it
1016- g_object_ref (rview );
1017-
1018- g_assert (IS_SUBCOLUMNVIEW (wview -> old_sview ));
1019- g_assert (IS_ROWVIEW (rview ));
1020-
1021- view_child_remove (VIEW (rview ));
1022- // the row number has to be wrong or reattach is skipped
1023- rview -> rnum = -1 ;
1024- view_child_add (VIEW (wview -> old_sview ), VIEW (rview ));
1025-
1026- g_object_unref (rview );
1040+ workspaceview_undo_row_drag (wview );
10271041
10281042 // update the model
10291043 if (col == row_col ) {
@@ -1172,7 +1186,9 @@ workspaceview_drag_update(GtkEventControllerMotion *self,
11721186 mouse_x , mouse_y );
11731187
11741188 if (cview ) {
1175- // row we are over
1189+ int pos ;
1190+
1191+ // row we are over, if any
11761192 Rowview * local = columnview_find_rowview (cview ,
11771193 mouse_x , mouse_y );
11781194
@@ -1185,14 +1201,29 @@ workspaceview_drag_update(GtkEventControllerMotion *self,
11851201 return ;
11861202
11871203 Row * row = ROW (VOBJECT (top )-> iobject );
1188- int pos = 2 * ICONTAINER (row )-> pos + 1 ;
1204+ pos = 2 * ICONTAINER (row )-> pos + 1 ;
11891205 if (mouse_y > bounds .origin .y + bounds .size .height / 2 )
1190- workspaceview_move_row_shadow (wview ,
1191- cview , pos + 1 );
1206+ pos += 1 ;
11921207 else
1193- workspaceview_move_row_shadow (wview ,
1194- cview , pos - 1 );
1208+ pos -= 1 ;
11951209 }
1210+ else {
1211+ // we are over a column, but not over a row ... we
1212+ // could be over the titlebar, or over the entry area
1213+ // at the bottom
1214+ Columnview * title =
1215+ workspaceview_find_columnview_title (wview ,
1216+ mouse_x , mouse_y );
1217+
1218+ if (title )
1219+ pos = 0 ;
1220+ else
1221+ // not in the title, append to end of column
1222+ // this will get renumbered on drop
1223+ pos = 100000 ;
1224+ }
1225+
1226+ workspaceview_move_row_shadow (wview , cview , pos );
11961227 }
11971228 else
11981229 workspaceview_move_row_shadow (wview , NULL , -1 );
@@ -1302,6 +1333,39 @@ workspaceview_alert_close_clicked(GtkButton *button, void *user_data)
13021333 workspace_set_alert (ws , FALSE);
13031334}
13041335
1336+ static gboolean
1337+ workspaceview_key_pressed (GtkEventControllerKey * self ,
1338+ guint keyval , guint keycode , GdkModifierType state , gpointer user_data )
1339+ {
1340+ Workspaceview * wview = WORKSPACEVIEW (user_data );
1341+ Workspace * ws = WORKSPACE (VOBJECT (wview )-> iobject );
1342+
1343+ switch (keyval ) {
1344+ case GDK_KEY_Escape :
1345+ if (wview -> state == WVIEW_DRAG ) {
1346+ wview -> state = WVIEW_WAIT ;
1347+
1348+ if (wview -> drag_rview ) {
1349+ // cancel row drag, remove the floating column we made
1350+ workspaceview_undo_row_drag (wview );
1351+ workspaceview_unfloat (wview );
1352+ workspaceview_remove_row_shadow (wview );
1353+ workspace_queue_layout (ws );
1354+ }
1355+ else if (wview -> drag_cview ) {
1356+ // undo column drag is tricky
1357+ }
1358+ }
1359+
1360+ break ;
1361+
1362+ default :
1363+ break ;
1364+ }
1365+
1366+ return FALSE;
1367+ }
1368+
13051369static void
13061370workspaceview_class_init (WorkspaceviewClass * class )
13071371{
@@ -1332,6 +1396,7 @@ workspaceview_class_init(WorkspaceviewClass *class)
13321396 BIND_CALLBACK (workspaceview_drag_end );
13331397 BIND_CALLBACK (workspaceview_error_close_clicked );
13341398 BIND_CALLBACK (workspaceview_alert_close_clicked );
1399+ BIND_CALLBACK (workspaceview_key_pressed );
13351400
13361401 object_class -> dispose = workspaceview_dispose ;
13371402
0 commit comments