Skip to content

設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window)#144

Merged
Freeesia merged 11 commits into
masterfrom
copilot/add-desktop-ordering-feature
Oct 22, 2025
Merged

設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window)#144
Freeesia merged 11 commits into
masterfrom
copilot/add-desktop-ordering-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 20, 2025

  • Understand the codebase structure and requirements
  • Add IsSupportedMoveDesktop property to check Windows version >= 10.0.22000.0
  • Add MoveDesktop method to IVirualDesktopService interface
  • Implement MoveDesktop method in VirtualDesktopService class
  • Revert changes to DesktopCatalog files
  • Add drag-and-drop functionality to MainWindow.xaml ListView
  • Implement drag-and-drop event handlers in MainWindow.xaml.cs
  • Expose IsSupportedMoveDesktop property in MainViewModel
  • Disable drag-and-drop when OS version < 10.0.22000.0
  • Refactor to use GongSolutions.WPF.DragDrop library
  • Prevent dragging/dropping "All Desktops" item
  • Adjust desktop insertion index to account for "All Desktops" offset
  • Fix index calculation bug when moving items downward

Summary of Changes

Fixed a bug where moving desktop items downward in the list would place them at incorrect positions.

Issue:

When dragging an item down in the list, the InsertIndex provided by GongSolutions.WPF.DragDrop reflects the position in the current list state (before removal). After the source item is removed, all indices below it shift up by 1, causing the target index to be off by one position.

Fix:

Updated the Drop method in DesktopListDragDropHandler.cs to:

  1. Find the source item's current index in the collection
  2. Compare source and target indices
  3. When moving down (sourceIndex < targetInsertIndex), adjust by -1 to account for the index shift after removal
  4. Then apply the "All Desktops" offset adjustment (-1)

Result:

  • Moving items upward: Works correctly ✓
  • Moving items downward: Now works correctly ✓
  • Proper handling of "All Desktops" offset in both directions ✓
Original prompt

This section details on the original issue you should resolve

<issue_title>設定ダイアログからデスクトップの順序を変更する</issue_title>
<issue_description>* リストからドラッグアンドドロップで移動したい

  • デスクトップの入れ替え対応しているのは10.0.22000.0以降なので、それ未満は無効化する</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #143


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits October 20, 2025 15:43
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to change desktop order from settings dialog 設定ダイアログからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings dialog) Oct 20, 2025
Copilot AI requested a review from Freeesia October 20, 2025 15:46
@Freeesia
Copy link
Copy Markdown
Owner

@copilot
DesktopCatalogではなく、MainWindowに実装して。

Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 21, 2025

@copilot
DesktopCatalogではなく、MainWindowに実装して。

実装をDesktopCatalogからMainWindowに移動しました。デスクトップ設定タブの左側のリストからドラッグアンドドロップでデスクトップの順序を変更できます。(754df05)

Copilot AI changed the title 設定ダイアログからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings dialog) 設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window) Oct 21, 2025
@Freeesia
Copy link
Copy Markdown
Owner

@copilot
ドラッグ中にドロップした時の挿入位置が可視化できるアドナーを実装して。
また、ドラッグ中はドラッグしている要素を薄くしてマウスに追従させて。(要素をVisual化してマウスに追従するアドナーとして実装して)

Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 21, 2025

@copilot
ドラッグ中にドロップした時の挿入位置が可視化できるアドナーを実装して。
また、ドラッグ中はドラッグしている要素を薄くしてマウス�...

ドラッグアンドドロップのビジュアルフィードバックを実装しました。(787d182)

実装内容:

  1. ドラッグ中のアイテムを50%透明度でマウスに追従させる DragAdorner
  2. ドロップ位置を青い線で示す InsertionAdorner

ドラッグ開始時にアイテムのビジュアルコピーを作成し、マウスカーソルに追従します。ドロップ可能な位置にマウスを移動すると、挿入位置を示す青い線が表示されます。

Copilot AI changed the title 設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window) 設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window with visual feedback) Oct 21, 2025
@Freeesia
Copy link
Copy Markdown
Owner

@copilot
ドラッグアンドドロップはGongSolutions.WPF.DragDropを使って実装して。
また、一番上の「全デスクトップ」は実際のデスクトップではないので、それより上にドロップ不可かつ実際のデスクトップの挿入位置はリストの挿入位置より-1して。

…" protection

Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 21, 2025

@copilot
ドラッグアンドドロップはGongSolutions.WPF.DragDropを使って実装して。
また、一番上の「全デスクトップ」は実際のデスクトップではないので��...

GongSolutions.WPF.DragDropライブラリを使用するように実装を変更しました。(6b48851)

実装内容:

  1. GongSolutions.WPF.DragDropパッケージを追加
  2. DesktopListDragDropHandlerクラスを作成し、IDragSourceとIDropTargetを実装
  3. 「全デスクトップ」(Guid.Empty)のドラッグとドロップを禁止
  4. リストの挿入位置から-1して実際のデスクトップインデックスを計算

「全デスクトップ」アイテムはドラッグ不可、かつドロップターゲットとしても使用できないようになっています。

Copilot AI changed the title 設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window with visual feedback) 設定ウィンドウからデスクトップの順序を変更する (Add desktop reordering via drag-and-drop in settings window) Oct 21, 2025
@Freeesia
Copy link
Copy Markdown
Owner

@copilot
要素を上に移動させると正常に動作するが、下に移動させると指定した位置より下に移動する。修正して。

Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 22, 2025

@copilot
要素を上に移動させると正常に動作するが、下に移動させると指定した位置より下に移動する。修正して。

下方向への移動時のインデックス計算バグを修正しました。(55dcadd)

問題の原因:
ドラッグ元のアイテムが削除されると、それより下のインデックスが全て1つ上にシフトするため、下方向に移動する場合はInsertIndexを-1する必要がありました。

修正内容:

  • ドラッグ元の現在位置を取得
  • sourceIndex < targetInsertIndex の場合(下方向への移動)は、targetIndexを-1調整
  • その後、「全デスクトップ」オフセット分をさらに-1調整

これで上下どちらの方向でも正しい位置に移動するようになりました。

@Freeesia Freeesia marked this pull request as ready for review October 22, 2025 11:27
@Freeesia Freeesia merged commit 3551638 into master Oct 22, 2025
6 checks passed
@Freeesia Freeesia deleted the copilot/add-desktop-ordering-feature branch October 22, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

設定ダイアログからデスクトップの順序を変更する

2 participants