From 145abc15d57fb29701a12e8a14dcb9c1fd72e9be Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 7 Dec 2020 22:58:44 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- drkonqi/CMakeLists.txt | 2 +- drkonqi/sha1.cc | 344 -- drkonqi/sha1.cpp | 344 ++ kcontrol/background/CMakeLists.txt | 2 +- kcontrol/background/KCrossBGRender.cc | 363 -- kcontrol/background/KCrossBGRender.cpp | 363 ++ kcontrol/background/bgdialog.cpp | 4 +- kdesktop/CMakeLists.txt | 8 +- kdesktop/Makefile.am | 10 +- kdesktop/bgmanager.cc | 1109 ---- kdesktop/bgmanager.cpp | 1109 ++++ kdesktop/desktop.cc | 1197 ---- kdesktop/desktop.cpp | 1197 ++++ kdesktop/init.cc | 247 - kdesktop/init.cpp | 247 + kdesktop/kcustommenu.cc | 111 - kdesktop/kcustommenu.cpp | 111 + kdesktop/kdesktop.kcfg | 14 +- kdesktop/kdiconview.cc | 2092 ------- kdesktop/kdiconview.cpp | 2092 +++++++ kdesktop/krootwm.cc | 922 --- kdesktop/krootwm.cpp | 922 +++ kdesktop/krootwm.h | 2 +- kdesktop/kwebdesktop/kwebdesktop.kcfg | 2 +- kdesktop/lock/CMakeLists.txt | 4 +- kdesktop/lock/Makefile.am | 2 +- kdesktop/lock/autologout.cc | 132 - kdesktop/lock/autologout.cpp | 132 + kdesktop/lock/infodlg.cc | 149 - kdesktop/lock/infodlg.cpp | 149 + kdesktop/lock/lockdlg.cc | 1027 ---- kdesktop/lock/lockdlg.cpp | 1027 ++++ kdesktop/lock/lockprocess.cc | 3045 ---------- kdesktop/lock/lockprocess.cpp | 3045 ++++++++++ kdesktop/lock/main.cc | 563 -- kdesktop/lock/main.cpp | 563 ++ kdesktop/lock/querydlg.cc | 163 - kdesktop/lock/querydlg.cpp | 163 + kdesktop/lock/sakdlg.cc | 155 - kdesktop/lock/sakdlg.cpp | 155 + kdesktop/lock/securedlg.cc | 217 - kdesktop/lock/securedlg.cpp | 217 + kdesktop/lockeng.cc | 1004 ---- kdesktop/lockeng.cpp | 1004 ++++ kdesktop/main.cc | 294 - kdesktop/main.cpp | 294 + kdesktop/pixmapserver.cc | 254 - kdesktop/pixmapserver.cpp | 254 + kdesktop/xautolock.cc | 289 - kdesktop/xautolock.cpp | 289 + kicker/applets/run/runapplet.cpp | 2 +- kicker/menuext/tom/Makefile.am | 4 +- kicker/menuext/tom/README | 2 +- kicker/menuext/tom/tom.cc | 855 --- kicker/menuext/tom/tom.cpp | 855 +++ konqueror/CMakeLists.txt | 14 +- konqueror/ChangeLog | 126 +- konqueror/KonqMainWindowIface.cc | 175 - konqueror/KonqMainWindowIface.cpp | 175 + konqueror/KonqViewIface.cc | 141 - konqueror/KonqViewIface.cpp | 141 + konqueror/KonquerorIface.cc | 294 - konqueror/KonquerorIface.cpp | 294 + konqueror/Makefile.am | 38 +- konqueror/about/CMakeLists.txt | 2 +- konqueror/about/Makefile.am | 2 +- konqueror/about/konq_aboutpage.cc | 558 -- konqueror/about/konq_aboutpage.cpp | 558 ++ konqueror/client/CMakeLists.txt | 2 +- konqueror/client/Makefile.am | 4 +- konqueror/client/kfmclient.cc | 653 --- konqueror/client/kfmclient.cpp | 653 +++ konqueror/delayedinitializer.cc | 52 - konqueror/delayedinitializer.cpp | 52 + konqueror/iconview/CMakeLists.txt | 2 +- konqueror/iconview/Makefile.am | 2 +- konqueror/iconview/konq_iconview.cc | 1660 ------ konqueror/iconview/konq_iconview.cpp | 1660 ++++++ konqueror/konq_actions.cc | 504 -- konqueror/konq_actions.cpp | 504 ++ konqueror/konq_browseriface.cc | 22 - konqueror/konq_browseriface.cpp | 22 + konqueror/konq_combo.cc | 905 --- konqueror/konq_combo.cpp | 905 +++ konqueror/konq_extensionmanager.cc | 147 - konqueror/konq_extensionmanager.cpp | 147 + konqueror/konq_factory.cc | 264 - konqueror/konq_factory.cpp | 264 + konqueror/konq_frame.cc | 680 --- konqueror/konq_frame.cpp | 680 +++ konqueror/konq_guiclients.cc | 363 -- konqueror/konq_guiclients.cpp | 363 ++ konqueror/konq_main.cc | 222 - konqueror/konq_main.cpp | 222 + konqueror/konq_mainwindow.cc | 5998 -------------------- konqueror/konq_mainwindow.cpp | 5998 ++++++++++++++++++++ konqueror/konq_misc.cc | 281 - konqueror/konq_misc.cpp | 281 + konqueror/konq_misc.h | 2 +- konqueror/konq_profiledlg.cc | 266 - konqueror/konq_profiledlg.cpp | 266 + konqueror/konq_run.cc | 195 - konqueror/konq_run.cpp | 195 + konqueror/konq_tabs.cc | 609 -- konqueror/konq_tabs.cpp | 609 ++ konqueror/konq_view.cc | 1398 ----- konqueror/konq_view.cpp | 1398 +++++ konqueror/konq_viewmgr.cc | 1842 ------ konqueror/konq_viewmgr.cpp | 1842 ++++++ konqueror/konqueror.kcfg | 10 +- konqueror/listview/CMakeLists.txt | 8 +- konqueror/listview/Makefile.am | 10 +- konqueror/listview/konq_infolistviewitem.cc | 280 - konqueror/listview/konq_infolistviewitem.cpp | 280 + konqueror/listview/konq_infolistviewwidget.cc | 384 -- konqueror/listview/konq_infolistviewwidget.cpp | 384 ++ konqueror/listview/konq_listview.cc | 731 --- konqueror/listview/konq_listview.cpp | 731 +++ konqueror/listview/konq_listviewitems.cc | 459 -- konqueror/listview/konq_listviewitems.cpp | 459 ++ konqueror/listview/konq_listviewwidget.cc | 1592 ------ konqueror/listview/konq_listviewwidget.cpp | 1592 ++++++ konqueror/listview/konq_textviewitem.cc | 258 - konqueror/listview/konq_textviewitem.cpp | 258 + konqueror/listview/konq_textviewwidget.cc | 224 - konqueror/listview/konq_textviewwidget.cpp | 224 + konqueror/listview/konq_treeviewitem.cc | 101 - konqueror/listview/konq_treeviewitem.cpp | 101 + konqueror/listview/konq_treeviewwidget.cc | 307 - konqueror/listview/konq_treeviewwidget.cpp | 307 + konqueror/preloader/CMakeLists.txt | 2 +- konqueror/preloader/Makefile.am | 2 +- konqueror/preloader/configure.in.in | 2 +- konqueror/preloader/preloader.cc | 151 - konqueror/preloader/preloader.cpp | 151 + kpersonalizer/Makefile.am | 2 +- ksysguard/gui/CMakeLists.txt | 6 +- ksysguard/gui/KSGAppletSettings.cc | 106 - ksysguard/gui/KSGAppletSettings.cpp | 106 + ksysguard/gui/KSysGuardApplet.cc | 495 -- ksysguard/gui/KSysGuardApplet.cpp | 495 ++ ksysguard/gui/Makefile.am | 16 +- ksysguard/gui/SensorBrowser.cc | 412 -- ksysguard/gui/SensorBrowser.cpp | 412 ++ ksysguard/gui/SensorDisplayLib/BarGraph.cc | 177 - ksysguard/gui/SensorDisplayLib/BarGraph.cpp | 177 + ksysguard/gui/SensorDisplayLib/CMakeLists.txt | 12 +- ksysguard/gui/SensorDisplayLib/DancingBars.cc | 353 -- ksysguard/gui/SensorDisplayLib/DancingBars.cpp | 353 ++ .../gui/SensorDisplayLib/DancingBarsSettings.cc | 398 -- .../gui/SensorDisplayLib/DancingBarsSettings.cpp | 398 ++ ksysguard/gui/SensorDisplayLib/DummyDisplay.cc | 58 - ksysguard/gui/SensorDisplayLib/DummyDisplay.cpp | 58 + ksysguard/gui/SensorDisplayLib/FancyPlotter.cc | 457 -- ksysguard/gui/SensorDisplayLib/FancyPlotter.cpp | 457 ++ .../gui/SensorDisplayLib/FancyPlotterSettings.cc | 637 --- .../gui/SensorDisplayLib/FancyPlotterSettings.cpp | 637 +++ ksysguard/gui/SensorDisplayLib/ListView.cc | 371 -- ksysguard/gui/SensorDisplayLib/ListView.cpp | 371 ++ ksysguard/gui/SensorDisplayLib/ListViewSettings.cc | 73 - .../gui/SensorDisplayLib/ListViewSettings.cpp | 73 + ksysguard/gui/SensorDisplayLib/LogFile.cc | 285 - ksysguard/gui/SensorDisplayLib/LogFile.cpp | 285 + ksysguard/gui/SensorDisplayLib/Makefile.am | 38 +- ksysguard/gui/SensorDisplayLib/MultiMeter.cc | 258 - ksysguard/gui/SensorDisplayLib/MultiMeter.cpp | 258 + .../gui/SensorDisplayLib/MultiMeterSettings.cc | 123 - .../gui/SensorDisplayLib/MultiMeterSettings.cpp | 123 + .../gui/SensorDisplayLib/ProcessController.cc | 472 -- .../gui/SensorDisplayLib/ProcessController.cpp | 472 ++ ksysguard/gui/SensorDisplayLib/ProcessList.cc | 977 ---- ksysguard/gui/SensorDisplayLib/ProcessList.cpp | 977 ++++ ksysguard/gui/SensorDisplayLib/ReniceDlg.cc | 70 - ksysguard/gui/SensorDisplayLib/ReniceDlg.cpp | 70 + ksysguard/gui/SensorDisplayLib/SensorDisplay.cc | 611 -- ksysguard/gui/SensorDisplayLib/SensorDisplay.cpp | 611 ++ ksysguard/gui/SensorDisplayLib/SensorLogger.cc | 437 -- ksysguard/gui/SensorDisplayLib/SensorLogger.cpp | 437 ++ ksysguard/gui/SensorDisplayLib/SensorLoggerDlg.cc | 102 - ksysguard/gui/SensorDisplayLib/SensorLoggerDlg.cpp | 102 + .../gui/SensorDisplayLib/SensorLoggerSettings.cc | 73 - .../gui/SensorDisplayLib/SensorLoggerSettings.cpp | 73 + ksysguard/gui/SensorDisplayLib/SignalPlotter.cc | 648 --- ksysguard/gui/SensorDisplayLib/SignalPlotter.cpp | 648 +++ ksysguard/gui/WorkSheet.cc | 698 --- ksysguard/gui/WorkSheet.cpp | 698 +++ ksysguard/gui/WorkSheetSettings.cc | 153 - ksysguard/gui/WorkSheetSettings.cpp | 153 + ksysguard/gui/Workspace.cc | 463 -- ksysguard/gui/Workspace.cpp | 463 ++ ksysguard/gui/ksgrd/CMakeLists.txt | 6 +- ksysguard/gui/ksgrd/HostConnector.cc | 217 - ksysguard/gui/ksgrd/HostConnector.cpp | 217 + ksysguard/gui/ksgrd/Makefile.am | 16 +- ksysguard/gui/ksgrd/SensorAgent.cc | 260 - ksysguard/gui/ksgrd/SensorAgent.cpp | 260 + ksysguard/gui/ksgrd/SensorManager.cc | 437 -- ksysguard/gui/ksgrd/SensorManager.cpp | 437 ++ ksysguard/gui/ksgrd/SensorShellAgent.cc | 141 - ksysguard/gui/ksgrd/SensorShellAgent.cpp | 141 + ksysguard/gui/ksgrd/SensorSocketAgent.cc | 137 - ksysguard/gui/ksgrd/SensorSocketAgent.cpp | 137 + ksysguard/gui/ksgrd/StyleEngine.cc | 176 - ksysguard/gui/ksgrd/StyleEngine.cpp | 176 + ksysguard/gui/ksgrd/StyleSettings.cc | 201 - ksysguard/gui/ksgrd/StyleSettings.cpp | 201 + ksysguard/gui/ksgrd/TimerSettings.cc | 94 - ksysguard/gui/ksgrd/TimerSettings.cpp | 94 + ksysguard/gui/ksysguard.cc | 650 --- ksysguard/gui/ksysguard.cpp | 650 +++ ksysguard/ksysguardd/Porting-HOWTO | 2 +- libkonq/CMakeLists.txt | 14 +- libkonq/Makefile.am | 26 +- libkonq/kivdirectoryoverlay.cc | 141 - libkonq/kivdirectoryoverlay.cpp | 141 + libkonq/kivfreespaceoverlay.cc | 118 - libkonq/kivfreespaceoverlay.cpp | 118 + libkonq/knewmenu.cc | 621 -- libkonq/knewmenu.cpp | 621 ++ libkonq/konq_bgnddlg.cc | 211 - libkonq/konq_bgnddlg.cpp | 211 + libkonq/konq_dirpart.cc | 761 --- libkonq/konq_dirpart.cpp | 761 +++ libkonq/konq_drag.cc | 284 - libkonq/konq_drag.cpp | 284 + libkonq/konq_events.cc | 8 - libkonq/konq_events.cpp | 8 + libkonq/konq_faviconmgr.cc | 57 - libkonq/konq_faviconmgr.cpp | 57 + libkonq/konq_filetip.cc | 300 - libkonq/konq_filetip.cpp | 300 + libkonq/konq_historycomm.cc | 41 - libkonq/konq_historycomm.cpp | 41 + libkonq/konq_historymgr.cc | 733 --- libkonq/konq_historymgr.cpp | 733 +++ libkonq/konq_iconviewwidget.cc | 1939 ------- libkonq/konq_iconviewwidget.cpp | 1939 +++++++ libkonq/konq_operations.cc | 825 --- libkonq/konq_operations.cpp | 825 +++ libkonq/konq_pixmapprovider.cc | 202 - libkonq/konq_pixmapprovider.cpp | 202 + libkonq/konq_popupmenu.cc | 1250 ---- libkonq/konq_popupmenu.cpp | 1250 ++++ libkonq/konq_propsview.cc | 604 -- libkonq/konq_propsview.cpp | 604 ++ libkonq/konq_propsview.h | 2 +- libkonq/konq_settings.cc | 184 - libkonq/konq_settings.cpp | 184 + libkonq/konq_sound.cc | 135 - libkonq/konq_sound.cpp | 135 + libkonq/konq_undo.cc | 667 --- libkonq/konq_undo.cpp | 667 +++ libkonq/konq_xmlguiclient.cc | 174 - libkonq/konq_xmlguiclient.cpp | 174 + libkonq/tdefileivi.cc | 621 -- libkonq/tdefileivi.cpp | 621 ++ libkonq/tdefileivi.h | 2 +- tdeioslave/filter/CMakeLists.txt | 2 +- tdeioslave/filter/Makefile.am | 2 +- tdeioslave/filter/filter.cc | 167 - tdeioslave/filter/filter.cpp | 167 + tdeioslave/floppy/tdeio_floppy.cpp | 2 +- tdeioslave/home/Makefile.am | 2 +- tdeioslave/info/CMakeLists.txt | 2 +- tdeioslave/info/Makefile.am | 2 +- tdeioslave/info/info.cc | 261 - tdeioslave/info/info.cpp | 261 + tdeioslave/nfs/tdeio_nfs.cpp | 4 +- tdeioslave/pop3/CMakeLists.txt | 2 +- tdeioslave/pop3/Makefile.am | 4 +- tdeioslave/pop3/pop3.cc | 1263 ----- tdeioslave/pop3/pop3.cpp | 1263 +++++ tdeioslave/remote/Makefile.am | 2 +- tdeioslave/settings/CMakeLists.txt | 2 +- tdeioslave/settings/Makefile.am | 4 +- tdeioslave/settings/tdeio_settings.cc | 296 - tdeioslave/settings/tdeio_settings.cpp | 296 + tdeioslave/smtp/CMakeLists.txt | 2 +- tdeioslave/smtp/Makefile.am | 12 +- tdeioslave/smtp/capabilities.cc | 143 - tdeioslave/smtp/capabilities.cpp | 143 + tdeioslave/smtp/command.cc | 606 -- tdeioslave/smtp/command.cpp | 606 ++ tdeioslave/smtp/interactivesmtpserver.cc | 127 - tdeioslave/smtp/interactivesmtpserver.cpp | 127 + tdeioslave/smtp/request.cc | 189 - tdeioslave/smtp/request.cpp | 189 + tdeioslave/smtp/response.cc | 160 - tdeioslave/smtp/response.cpp | 160 + tdeioslave/smtp/smtp.cc | 648 --- tdeioslave/smtp/smtp.cpp | 648 +++ tdeioslave/smtp/test_commands.cc | 728 --- tdeioslave/smtp/test_commands.cpp | 728 +++ tdeioslave/smtp/test_headergeneration.cc | 86 - tdeioslave/smtp/test_headergeneration.cpp | 86 + tdeioslave/smtp/test_responseparser.cc | 107 - tdeioslave/smtp/test_responseparser.cpp | 107 + tdeioslave/smtp/transactionstate.cc | 114 - tdeioslave/smtp/transactionstate.cpp | 114 + tdeioslave/system/Makefile.am | 2 +- tdeioslave/tar/CMakeLists.txt | 2 +- tdeioslave/tar/Makefile.am | 4 +- tdeioslave/tar/tar.cc | 621 -- tdeioslave/tar/tar.cpp | 621 ++ tdeioslave/trash/DESIGN | 2 +- tdeioslave/trash/Makefile.am | 2 +- tdeioslave/trash/trashimpl.cpp | 2 +- tdeprint/tdeprintfax/Makefile.am | 2 +- tdm/cryptocardwatcher/CMakeLists.txt | 2 +- tdm/cryptocardwatcher/watcher.cc | 105 - tdm/cryptocardwatcher/watcher.cpp | 105 + tdm/kfrontend/CMakeLists.txt | 2 +- tdm/kfrontend/sakdlg.cc | 259 - tdm/kfrontend/sakdlg.cpp | 259 + 314 files changed, 63470 insertions(+), 63470 deletions(-) delete mode 100644 drkonqi/sha1.cc create mode 100644 drkonqi/sha1.cpp delete mode 100644 kcontrol/background/KCrossBGRender.cc create mode 100644 kcontrol/background/KCrossBGRender.cpp delete mode 100644 kdesktop/bgmanager.cc create mode 100644 kdesktop/bgmanager.cpp delete mode 100644 kdesktop/desktop.cc create mode 100644 kdesktop/desktop.cpp delete mode 100644 kdesktop/init.cc create mode 100644 kdesktop/init.cpp delete mode 100644 kdesktop/kcustommenu.cc create mode 100644 kdesktop/kcustommenu.cpp delete mode 100644 kdesktop/kdiconview.cc create mode 100644 kdesktop/kdiconview.cpp delete mode 100644 kdesktop/krootwm.cc create mode 100644 kdesktop/krootwm.cpp delete mode 100644 kdesktop/lock/autologout.cc create mode 100644 kdesktop/lock/autologout.cpp delete mode 100644 kdesktop/lock/infodlg.cc create mode 100644 kdesktop/lock/infodlg.cpp delete mode 100644 kdesktop/lock/lockdlg.cc create mode 100644 kdesktop/lock/lockdlg.cpp delete mode 100644 kdesktop/lock/lockprocess.cc create mode 100644 kdesktop/lock/lockprocess.cpp delete mode 100644 kdesktop/lock/main.cc create mode 100644 kdesktop/lock/main.cpp delete mode 100644 kdesktop/lock/querydlg.cc create mode 100644 kdesktop/lock/querydlg.cpp delete mode 100644 kdesktop/lock/sakdlg.cc create mode 100644 kdesktop/lock/sakdlg.cpp delete mode 100644 kdesktop/lock/securedlg.cc create mode 100644 kdesktop/lock/securedlg.cpp delete mode 100644 kdesktop/lockeng.cc create mode 100644 kdesktop/lockeng.cpp delete mode 100644 kdesktop/main.cc create mode 100644 kdesktop/main.cpp delete mode 100644 kdesktop/pixmapserver.cc create mode 100644 kdesktop/pixmapserver.cpp delete mode 100644 kdesktop/xautolock.cc create mode 100644 kdesktop/xautolock.cpp delete mode 100644 kicker/menuext/tom/tom.cc create mode 100644 kicker/menuext/tom/tom.cpp delete mode 100644 konqueror/KonqMainWindowIface.cc create mode 100644 konqueror/KonqMainWindowIface.cpp delete mode 100644 konqueror/KonqViewIface.cc create mode 100644 konqueror/KonqViewIface.cpp delete mode 100644 konqueror/KonquerorIface.cc create mode 100644 konqueror/KonquerorIface.cpp delete mode 100644 konqueror/about/konq_aboutpage.cc create mode 100644 konqueror/about/konq_aboutpage.cpp delete mode 100644 konqueror/client/kfmclient.cc create mode 100644 konqueror/client/kfmclient.cpp delete mode 100644 konqueror/delayedinitializer.cc create mode 100644 konqueror/delayedinitializer.cpp delete mode 100644 konqueror/iconview/konq_iconview.cc create mode 100644 konqueror/iconview/konq_iconview.cpp delete mode 100644 konqueror/konq_actions.cc create mode 100644 konqueror/konq_actions.cpp delete mode 100644 konqueror/konq_browseriface.cc create mode 100644 konqueror/konq_browseriface.cpp delete mode 100644 konqueror/konq_combo.cc create mode 100644 konqueror/konq_combo.cpp delete mode 100644 konqueror/konq_extensionmanager.cc create mode 100644 konqueror/konq_extensionmanager.cpp delete mode 100644 konqueror/konq_factory.cc create mode 100644 konqueror/konq_factory.cpp delete mode 100644 konqueror/konq_frame.cc create mode 100644 konqueror/konq_frame.cpp delete mode 100644 konqueror/konq_guiclients.cc create mode 100644 konqueror/konq_guiclients.cpp delete mode 100644 konqueror/konq_main.cc create mode 100644 konqueror/konq_main.cpp delete mode 100644 konqueror/konq_mainwindow.cc create mode 100644 konqueror/konq_mainwindow.cpp delete mode 100644 konqueror/konq_misc.cc create mode 100644 konqueror/konq_misc.cpp delete mode 100644 konqueror/konq_profiledlg.cc create mode 100644 konqueror/konq_profiledlg.cpp delete mode 100644 konqueror/konq_run.cc create mode 100644 konqueror/konq_run.cpp delete mode 100644 konqueror/konq_tabs.cc create mode 100644 konqueror/konq_tabs.cpp delete mode 100644 konqueror/konq_view.cc create mode 100644 konqueror/konq_view.cpp delete mode 100644 konqueror/konq_viewmgr.cc create mode 100644 konqueror/konq_viewmgr.cpp delete mode 100644 konqueror/listview/konq_infolistviewitem.cc create mode 100644 konqueror/listview/konq_infolistviewitem.cpp delete mode 100644 konqueror/listview/konq_infolistviewwidget.cc create mode 100644 konqueror/listview/konq_infolistviewwidget.cpp delete mode 100644 konqueror/listview/konq_listview.cc create mode 100644 konqueror/listview/konq_listview.cpp delete mode 100644 konqueror/listview/konq_listviewitems.cc create mode 100644 konqueror/listview/konq_listviewitems.cpp delete mode 100644 konqueror/listview/konq_listviewwidget.cc create mode 100644 konqueror/listview/konq_listviewwidget.cpp delete mode 100644 konqueror/listview/konq_textviewitem.cc create mode 100644 konqueror/listview/konq_textviewitem.cpp delete mode 100644 konqueror/listview/konq_textviewwidget.cc create mode 100644 konqueror/listview/konq_textviewwidget.cpp delete mode 100644 konqueror/listview/konq_treeviewitem.cc create mode 100644 konqueror/listview/konq_treeviewitem.cpp delete mode 100644 konqueror/listview/konq_treeviewwidget.cc create mode 100644 konqueror/listview/konq_treeviewwidget.cpp delete mode 100644 konqueror/preloader/preloader.cc create mode 100644 konqueror/preloader/preloader.cpp delete mode 100644 ksysguard/gui/KSGAppletSettings.cc create mode 100644 ksysguard/gui/KSGAppletSettings.cpp delete mode 100644 ksysguard/gui/KSysGuardApplet.cc create mode 100644 ksysguard/gui/KSysGuardApplet.cpp delete mode 100644 ksysguard/gui/SensorBrowser.cc create mode 100644 ksysguard/gui/SensorBrowser.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/BarGraph.cc create mode 100644 ksysguard/gui/SensorDisplayLib/BarGraph.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/DancingBars.cc create mode 100644 ksysguard/gui/SensorDisplayLib/DancingBars.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/DancingBarsSettings.cc create mode 100644 ksysguard/gui/SensorDisplayLib/DancingBarsSettings.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/DummyDisplay.cc create mode 100644 ksysguard/gui/SensorDisplayLib/DummyDisplay.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/FancyPlotter.cc create mode 100644 ksysguard/gui/SensorDisplayLib/FancyPlotter.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/FancyPlotterSettings.cc create mode 100644 ksysguard/gui/SensorDisplayLib/FancyPlotterSettings.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/ListView.cc create mode 100644 ksysguard/gui/SensorDisplayLib/ListView.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/ListViewSettings.cc create mode 100644 ksysguard/gui/SensorDisplayLib/ListViewSettings.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/LogFile.cc create mode 100644 ksysguard/gui/SensorDisplayLib/LogFile.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/MultiMeter.cc create mode 100644 ksysguard/gui/SensorDisplayLib/MultiMeter.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/MultiMeterSettings.cc create mode 100644 ksysguard/gui/SensorDisplayLib/MultiMeterSettings.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/ProcessController.cc create mode 100644 ksysguard/gui/SensorDisplayLib/ProcessController.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/ProcessList.cc create mode 100644 ksysguard/gui/SensorDisplayLib/ProcessList.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/ReniceDlg.cc create mode 100644 ksysguard/gui/SensorDisplayLib/ReniceDlg.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/SensorDisplay.cc create mode 100644 ksysguard/gui/SensorDisplayLib/SensorDisplay.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/SensorLogger.cc create mode 100644 ksysguard/gui/SensorDisplayLib/SensorLogger.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/SensorLoggerDlg.cc create mode 100644 ksysguard/gui/SensorDisplayLib/SensorLoggerDlg.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/SensorLoggerSettings.cc create mode 100644 ksysguard/gui/SensorDisplayLib/SensorLoggerSettings.cpp delete mode 100644 ksysguard/gui/SensorDisplayLib/SignalPlotter.cc create mode 100644 ksysguard/gui/SensorDisplayLib/SignalPlotter.cpp delete mode 100644 ksysguard/gui/WorkSheet.cc create mode 100644 ksysguard/gui/WorkSheet.cpp delete mode 100644 ksysguard/gui/WorkSheetSettings.cc create mode 100644 ksysguard/gui/WorkSheetSettings.cpp delete mode 100644 ksysguard/gui/Workspace.cc create mode 100644 ksysguard/gui/Workspace.cpp delete mode 100644 ksysguard/gui/ksgrd/HostConnector.cc create mode 100644 ksysguard/gui/ksgrd/HostConnector.cpp delete mode 100644 ksysguard/gui/ksgrd/SensorAgent.cc create mode 100644 ksysguard/gui/ksgrd/SensorAgent.cpp delete mode 100644 ksysguard/gui/ksgrd/SensorManager.cc create mode 100644 ksysguard/gui/ksgrd/SensorManager.cpp delete mode 100644 ksysguard/gui/ksgrd/SensorShellAgent.cc create mode 100644 ksysguard/gui/ksgrd/SensorShellAgent.cpp delete mode 100644 ksysguard/gui/ksgrd/SensorSocketAgent.cc create mode 100644 ksysguard/gui/ksgrd/SensorSocketAgent.cpp delete mode 100644 ksysguard/gui/ksgrd/StyleEngine.cc create mode 100644 ksysguard/gui/ksgrd/StyleEngine.cpp delete mode 100644 ksysguard/gui/ksgrd/StyleSettings.cc create mode 100644 ksysguard/gui/ksgrd/StyleSettings.cpp delete mode 100644 ksysguard/gui/ksgrd/TimerSettings.cc create mode 100644 ksysguard/gui/ksgrd/TimerSettings.cpp delete mode 100644 ksysguard/gui/ksysguard.cc create mode 100644 ksysguard/gui/ksysguard.cpp delete mode 100644 libkonq/kivdirectoryoverlay.cc create mode 100644 libkonq/kivdirectoryoverlay.cpp delete mode 100644 libkonq/kivfreespaceoverlay.cc create mode 100644 libkonq/kivfreespaceoverlay.cpp delete mode 100644 libkonq/knewmenu.cc create mode 100644 libkonq/knewmenu.cpp delete mode 100644 libkonq/konq_bgnddlg.cc create mode 100644 libkonq/konq_bgnddlg.cpp delete mode 100644 libkonq/konq_dirpart.cc create mode 100644 libkonq/konq_dirpart.cpp delete mode 100644 libkonq/konq_drag.cc create mode 100644 libkonq/konq_drag.cpp delete mode 100644 libkonq/konq_events.cc create mode 100644 libkonq/konq_events.cpp delete mode 100644 libkonq/konq_faviconmgr.cc create mode 100644 libkonq/konq_faviconmgr.cpp delete mode 100644 libkonq/konq_filetip.cc create mode 100644 libkonq/konq_filetip.cpp delete mode 100644 libkonq/konq_historycomm.cc create mode 100644 libkonq/konq_historycomm.cpp delete mode 100644 libkonq/konq_historymgr.cc create mode 100644 libkonq/konq_historymgr.cpp delete mode 100644 libkonq/konq_iconviewwidget.cc create mode 100644 libkonq/konq_iconviewwidget.cpp delete mode 100644 libkonq/konq_operations.cc create mode 100644 libkonq/konq_operations.cpp delete mode 100644 libkonq/konq_pixmapprovider.cc create mode 100644 libkonq/konq_pixmapprovider.cpp delete mode 100644 libkonq/konq_popupmenu.cc create mode 100644 libkonq/konq_popupmenu.cpp delete mode 100644 libkonq/konq_propsview.cc create mode 100644 libkonq/konq_propsview.cpp delete mode 100644 libkonq/konq_settings.cc create mode 100644 libkonq/konq_settings.cpp delete mode 100644 libkonq/konq_sound.cc create mode 100644 libkonq/konq_sound.cpp delete mode 100644 libkonq/konq_undo.cc create mode 100644 libkonq/konq_undo.cpp delete mode 100644 libkonq/konq_xmlguiclient.cc create mode 100644 libkonq/konq_xmlguiclient.cpp delete mode 100644 libkonq/tdefileivi.cc create mode 100644 libkonq/tdefileivi.cpp delete mode 100644 tdeioslave/filter/filter.cc create mode 100644 tdeioslave/filter/filter.cpp delete mode 100644 tdeioslave/info/info.cc create mode 100644 tdeioslave/info/info.cpp delete mode 100644 tdeioslave/pop3/pop3.cc create mode 100644 tdeioslave/pop3/pop3.cpp delete mode 100644 tdeioslave/settings/tdeio_settings.cc create mode 100644 tdeioslave/settings/tdeio_settings.cpp delete mode 100644 tdeioslave/smtp/capabilities.cc create mode 100644 tdeioslave/smtp/capabilities.cpp delete mode 100644 tdeioslave/smtp/command.cc create mode 100644 tdeioslave/smtp/command.cpp delete mode 100644 tdeioslave/smtp/interactivesmtpserver.cc create mode 100644 tdeioslave/smtp/interactivesmtpserver.cpp delete mode 100644 tdeioslave/smtp/request.cc create mode 100644 tdeioslave/smtp/request.cpp delete mode 100644 tdeioslave/smtp/response.cc create mode 100644 tdeioslave/smtp/response.cpp delete mode 100644 tdeioslave/smtp/smtp.cc create mode 100644 tdeioslave/smtp/smtp.cpp delete mode 100644 tdeioslave/smtp/test_commands.cc create mode 100644 tdeioslave/smtp/test_commands.cpp delete mode 100644 tdeioslave/smtp/test_headergeneration.cc create mode 100644 tdeioslave/smtp/test_headergeneration.cpp delete mode 100644 tdeioslave/smtp/test_responseparser.cc create mode 100644 tdeioslave/smtp/test_responseparser.cpp delete mode 100644 tdeioslave/smtp/transactionstate.cc create mode 100644 tdeioslave/smtp/transactionstate.cpp delete mode 100644 tdeioslave/tar/tar.cc create mode 100644 tdeioslave/tar/tar.cpp delete mode 100644 tdm/cryptocardwatcher/watcher.cc create mode 100644 tdm/cryptocardwatcher/watcher.cpp delete mode 100644 tdm/kfrontend/sakdlg.cc create mode 100644 tdm/kfrontend/sakdlg.cpp diff --git a/drkonqi/CMakeLists.txt b/drkonqi/CMakeLists.txt index a2b643909..ae1be3a87 100644 --- a/drkonqi/CMakeLists.txt +++ b/drkonqi/CMakeLists.txt @@ -33,7 +33,7 @@ tde_add_executable( drkonqi AUTOMOC SOURCES krashdcopinterface.skel main.cpp debugger.cpp bugdescription.cpp bugdescriptiondialog.cpp - sha1.cc krashconf.cpp drbugreport.cpp + sha1.cpp krashconf.cpp drbugreport.cpp backtrace.cpp toplevel.cpp LINK tdeio-shared ${LIBR_LIBRARIES} DESTINATION ${BIN_INSTALL_DIR} diff --git a/drkonqi/sha1.cc b/drkonqi/sha1.cc deleted file mode 100644 index 86dd30a99..000000000 --- a/drkonqi/sha1.cc +++ /dev/null @@ -1,344 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 George Staikos - Based heavily on SHA1 code from GPG 1.0.3 (C) 1998 FSF - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDINT_H -#include /* For uintXX_t on OSX */ -#endif -#ifdef HAVE_SYS_BITYPES_H -#include /* For uintXX_t on Tru64 */ -#endif -#ifdef HAVE_STDINT_H -#include -#endif - -#include "sha1.h" -#include - -// FIXME: this can be optimized to one instruction on most cpus. -#define rol(x,y) ((x << y) | (x >> (32-y))) - - -#define K1 0x5a827999L -#define K2 0x6ed9eba1L -#define K3 0x8f1bbcdcL -#define K4 0xca62c1d6L -#define F1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) -#define F2(x,y,z) ( x ^ y ^ z ) -#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) -#define F4(x,y,z) ( x ^ y ^ z ) - -#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] \ - ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f] \ - , (x[i&0x0f] = (tm << 1) | (tm >> 31))) - -#define R(a,b,c,d,e,f,k,m) do { e += rol(a, 5) \ - + f(b, c, d) \ - + k \ - + m; \ - b = rol(b, 30); \ - } while(0) - - -SHA1::SHA1() { - _hashlen = 160; - _init = false; - reset(); -} - - -int SHA1::reset() { - _h0 = 0x67452301; - _h1 = 0xefcdab89; - _h2 = 0x98badcfe; - _h3 = 0x10325476; - _h4 = 0xc3d2e1f0; - _nblocks = 0; - _count = 0; - memset(_buf, 0, 56); // clear the buffer - - _init = true; - return 0; -} - - -int SHA1::size() const { - return _hashlen; -} - - -SHA1::~SHA1() { - -} - - -void SHA1::transform(void *data) { - unsigned int a, b, c, d, e, tm; - unsigned int x[16]; - unsigned char *_data = (unsigned char *)data; - - a = _h0; - b = _h1; - c = _h2; - d = _h3; - e = _h4; - -#ifdef WORDS_BIGENDIAN - memcpy(x, _data, 64); -#else - int i; - unsigned char *p2; - for (i = 0, p2 = (unsigned char *)x; - i < 16; i++, p2 += 4) { - p2[3] = *_data++; - p2[2] = *_data++; - p2[1] = *_data++; - p2[0] = *_data++; - } -#endif - - R(a, b, c, d, e, F1, K1, x[ 0]); - R(e, a, b, c, d, F1, K1, x[ 1]); - R(d, e, a, b, c, F1, K1, x[ 2]); - R(c, d, e, a, b, F1, K1, x[ 3]); - R(b, c, d, e, a, F1, K1, x[ 4]); - R(a, b, c, d, e, F1, K1, x[ 5]); - R(e, a, b, c, d, F1, K1, x[ 6]); - R(d, e, a, b, c, F1, K1, x[ 7]); - R(c, d, e, a, b, F1, K1, x[ 8]); - R(b, c, d, e, a, F1, K1, x[ 9]); - R(a, b, c, d, e, F1, K1, x[10]); - R(e, a, b, c, d, F1, K1, x[11]); - R(d, e, a, b, c, F1, K1, x[12]); - R(c, d, e, a, b, F1, K1, x[13]); - R(b, c, d, e, a, F1, K1, x[14]); - R(a, b, c, d, e, F1, K1, x[15]); - R(e, a, b, c, d, F1, K1, M(16)); - R(d, e, a, b, c, F1, K1, M(17)); - R(c, d, e, a, b, F1, K1, M(18)); - R(b, c, d, e, a, F1, K1, M(19)); - R(a, b, c, d, e, F2, K2, M(20)); - R(e, a, b, c, d, F2, K2, M(21)); - R(d, e, a, b, c, F2, K2, M(22)); - R(c, d, e, a, b, F2, K2, M(23)); - R(b, c, d, e, a, F2, K2, M(24)); - R(a, b, c, d, e, F2, K2, M(25)); - R(e, a, b, c, d, F2, K2, M(26)); - R(d, e, a, b, c, F2, K2, M(27)); - R(c, d, e, a, b, F2, K2, M(28)); - R(b, c, d, e, a, F2, K2, M(29)); - R(a, b, c, d, e, F2, K2, M(30)); - R(e, a, b, c, d, F2, K2, M(31)); - R(d, e, a, b, c, F2, K2, M(32)); - R(c, d, e, a, b, F2, K2, M(33)); - R(b, c, d, e, a, F2, K2, M(34)); - R(a, b, c, d, e, F2, K2, M(35)); - R(e, a, b, c, d, F2, K2, M(36)); - R(d, e, a, b, c, F2, K2, M(37)); - R(c, d, e, a, b, F2, K2, M(38)); - R(b, c, d, e, a, F2, K2, M(39)); - R(a, b, c, d, e, F3, K3, M(40)); - R(e, a, b, c, d, F3, K3, M(41)); - R(d, e, a, b, c, F3, K3, M(42)); - R(c, d, e, a, b, F3, K3, M(43)); - R(b, c, d, e, a, F3, K3, M(44)); - R(a, b, c, d, e, F3, K3, M(45)); - R(e, a, b, c, d, F3, K3, M(46)); - R(d, e, a, b, c, F3, K3, M(47)); - R(c, d, e, a, b, F3, K3, M(48)); - R(b, c, d, e, a, F3, K3, M(49)); - R(a, b, c, d, e, F3, K3, M(50)); - R(e, a, b, c, d, F3, K3, M(51)); - R(d, e, a, b, c, F3, K3, M(52)); - R(c, d, e, a, b, F3, K3, M(53)); - R(b, c, d, e, a, F3, K3, M(54)); - R(a, b, c, d, e, F3, K3, M(55)); - R(e, a, b, c, d, F3, K3, M(56)); - R(d, e, a, b, c, F3, K3, M(57)); - R(c, d, e, a, b, F3, K3, M(58)); - R(b, c, d, e, a, F3, K3, M(59)); - R(a, b, c, d, e, F4, K4, M(60)); - R(e, a, b, c, d, F4, K4, M(61)); - R(d, e, a, b, c, F4, K4, M(62)); - R(c, d, e, a, b, F4, K4, M(63)); - R(b, c, d, e, a, F4, K4, M(64)); - R(a, b, c, d, e, F4, K4, M(65)); - R(e, a, b, c, d, F4, K4, M(66)); - R(d, e, a, b, c, F4, K4, M(67)); - R(c, d, e, a, b, F4, K4, M(68)); - R(b, c, d, e, a, F4, K4, M(69)); - R(a, b, c, d, e, F4, K4, M(70)); - R(e, a, b, c, d, F4, K4, M(71)); - R(d, e, a, b, c, F4, K4, M(72)); - R(c, d, e, a, b, F4, K4, M(73)); - R(b, c, d, e, a, F4, K4, M(74)); - R(a, b, c, d, e, F4, K4, M(75)); - R(e, a, b, c, d, F4, K4, M(76)); - R(d, e, a, b, c, F4, K4, M(77)); - R(c, d, e, a, b, F4, K4, M(78)); - R(b, c, d, e, a, F4, K4, M(79)); - - _h0 += a; - _h1 += b; - _h2 += c; - _h3 += d; - _h4 += e; - -} - - -bool SHA1::readyToGo() const { - return _init; -} - - -int SHA1::process(const void *block, int len) { - if (!_init) { - return -1; - } - - unsigned char *_block = (unsigned char *)block; - - int cnt = 0; - // Flush the buffer before proceeding - if (_count == 64) { - transform(_buf); - _count = 0; - _nblocks++; - } - - if (!_block) { - return 0; - } - - if (_count) { - for (; len && _count < 64; len--, cnt++) { - _buf[_count++] = *_block++; - } - process(0, 0); // flush the buffer if necessary - if (!len) { - return cnt; - } - } - - while (len >= 64) { - transform(_block); - _count = 0; - _nblocks++; - len -= 64; - cnt += 64; - _block += 64; - } - - for (; len && _count < 64; len--, cnt++) { - _buf[_count++] = *_block++; - } - - return cnt; -} - - -const unsigned char *SHA1::hash() { - unsigned int t, msb, lsb; - unsigned char *p; - - - if (!_init) { - return (unsigned char *)_buf; - } - - process(0, 0); - - msb = 0; - t = _nblocks; - - if ((lsb = t << 6) < t) { - msb++; - } - - msb += t >> 26; - t = lsb; - - if ((lsb = t + _count) < t) { - msb++; - } - - t = lsb; - - if ((lsb = t << 3) < t) { - msb++; - } - - msb += t >> 29; - - _buf[_count++] = 0x80; - - if (_count < 56) { - while (_count < 56) { - _buf[_count++] = 0; - } - } else { - while (_count < 64) { - _buf[_count++] = 0; - } - process(0, 0); - memset(_buf, 0, 56); - } - - _buf[56] = msb >> 24; - _buf[57] = msb >> 16; - _buf[58] = msb >> 8; - _buf[59] = msb; - _buf[60] = lsb >> 24; - _buf[61] = lsb >> 16; - _buf[62] = lsb >> 8; - _buf[63] = lsb; - - transform(_buf); - - p = _buf; - -#ifdef WORDS_BIGENDIAN -#define X( a ) do { *( uint32_t * )p = _h##a; p += 4; } while ( 0 ) -#else -#define X(a) do { *p++ = _h##a >> 24; *p++ = _h##a >> 16; \ - *p++ = _h##a >> 8; *p++ = _h##a; } while (0) -#endif - - X(0); - X(1); - X(2); - X(3); - X(4); - -#undef X - - _init = false; - - return (unsigned char *)_buf; -} - - - - diff --git a/drkonqi/sha1.cpp b/drkonqi/sha1.cpp new file mode 100644 index 000000000..86dd30a99 --- /dev/null +++ b/drkonqi/sha1.cpp @@ -0,0 +1,344 @@ +/* This file is part of the KDE project + Copyright (C) 2001 George Staikos + Based heavily on SHA1 code from GPG 1.0.3 (C) 1998 FSF + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDINT_H +#include /* For uintXX_t on OSX */ +#endif +#ifdef HAVE_SYS_BITYPES_H +#include /* For uintXX_t on Tru64 */ +#endif +#ifdef HAVE_STDINT_H +#include +#endif + +#include "sha1.h" +#include + +// FIXME: this can be optimized to one instruction on most cpus. +#define rol(x,y) ((x << y) | (x >> (32-y))) + + +#define K1 0x5a827999L +#define K2 0x6ed9eba1L +#define K3 0x8f1bbcdcL +#define K4 0xca62c1d6L +#define F1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) +#define F2(x,y,z) ( x ^ y ^ z ) +#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) +#define F4(x,y,z) ( x ^ y ^ z ) + +#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] \ + ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f] \ + , (x[i&0x0f] = (tm << 1) | (tm >> 31))) + +#define R(a,b,c,d,e,f,k,m) do { e += rol(a, 5) \ + + f(b, c, d) \ + + k \ + + m; \ + b = rol(b, 30); \ + } while(0) + + +SHA1::SHA1() { + _hashlen = 160; + _init = false; + reset(); +} + + +int SHA1::reset() { + _h0 = 0x67452301; + _h1 = 0xefcdab89; + _h2 = 0x98badcfe; + _h3 = 0x10325476; + _h4 = 0xc3d2e1f0; + _nblocks = 0; + _count = 0; + memset(_buf, 0, 56); // clear the buffer + + _init = true; + return 0; +} + + +int SHA1::size() const { + return _hashlen; +} + + +SHA1::~SHA1() { + +} + + +void SHA1::transform(void *data) { + unsigned int a, b, c, d, e, tm; + unsigned int x[16]; + unsigned char *_data = (unsigned char *)data; + + a = _h0; + b = _h1; + c = _h2; + d = _h3; + e = _h4; + +#ifdef WORDS_BIGENDIAN + memcpy(x, _data, 64); +#else + int i; + unsigned char *p2; + for (i = 0, p2 = (unsigned char *)x; + i < 16; i++, p2 += 4) { + p2[3] = *_data++; + p2[2] = *_data++; + p2[1] = *_data++; + p2[0] = *_data++; + } +#endif + + R(a, b, c, d, e, F1, K1, x[ 0]); + R(e, a, b, c, d, F1, K1, x[ 1]); + R(d, e, a, b, c, F1, K1, x[ 2]); + R(c, d, e, a, b, F1, K1, x[ 3]); + R(b, c, d, e, a, F1, K1, x[ 4]); + R(a, b, c, d, e, F1, K1, x[ 5]); + R(e, a, b, c, d, F1, K1, x[ 6]); + R(d, e, a, b, c, F1, K1, x[ 7]); + R(c, d, e, a, b, F1, K1, x[ 8]); + R(b, c, d, e, a, F1, K1, x[ 9]); + R(a, b, c, d, e, F1, K1, x[10]); + R(e, a, b, c, d, F1, K1, x[11]); + R(d, e, a, b, c, F1, K1, x[12]); + R(c, d, e, a, b, F1, K1, x[13]); + R(b, c, d, e, a, F1, K1, x[14]); + R(a, b, c, d, e, F1, K1, x[15]); + R(e, a, b, c, d, F1, K1, M(16)); + R(d, e, a, b, c, F1, K1, M(17)); + R(c, d, e, a, b, F1, K1, M(18)); + R(b, c, d, e, a, F1, K1, M(19)); + R(a, b, c, d, e, F2, K2, M(20)); + R(e, a, b, c, d, F2, K2, M(21)); + R(d, e, a, b, c, F2, K2, M(22)); + R(c, d, e, a, b, F2, K2, M(23)); + R(b, c, d, e, a, F2, K2, M(24)); + R(a, b, c, d, e, F2, K2, M(25)); + R(e, a, b, c, d, F2, K2, M(26)); + R(d, e, a, b, c, F2, K2, M(27)); + R(c, d, e, a, b, F2, K2, M(28)); + R(b, c, d, e, a, F2, K2, M(29)); + R(a, b, c, d, e, F2, K2, M(30)); + R(e, a, b, c, d, F2, K2, M(31)); + R(d, e, a, b, c, F2, K2, M(32)); + R(c, d, e, a, b, F2, K2, M(33)); + R(b, c, d, e, a, F2, K2, M(34)); + R(a, b, c, d, e, F2, K2, M(35)); + R(e, a, b, c, d, F2, K2, M(36)); + R(d, e, a, b, c, F2, K2, M(37)); + R(c, d, e, a, b, F2, K2, M(38)); + R(b, c, d, e, a, F2, K2, M(39)); + R(a, b, c, d, e, F3, K3, M(40)); + R(e, a, b, c, d, F3, K3, M(41)); + R(d, e, a, b, c, F3, K3, M(42)); + R(c, d, e, a, b, F3, K3, M(43)); + R(b, c, d, e, a, F3, K3, M(44)); + R(a, b, c, d, e, F3, K3, M(45)); + R(e, a, b, c, d, F3, K3, M(46)); + R(d, e, a, b, c, F3, K3, M(47)); + R(c, d, e, a, b, F3, K3, M(48)); + R(b, c, d, e, a, F3, K3, M(49)); + R(a, b, c, d, e, F3, K3, M(50)); + R(e, a, b, c, d, F3, K3, M(51)); + R(d, e, a, b, c, F3, K3, M(52)); + R(c, d, e, a, b, F3, K3, M(53)); + R(b, c, d, e, a, F3, K3, M(54)); + R(a, b, c, d, e, F3, K3, M(55)); + R(e, a, b, c, d, F3, K3, M(56)); + R(d, e, a, b, c, F3, K3, M(57)); + R(c, d, e, a, b, F3, K3, M(58)); + R(b, c, d, e, a, F3, K3, M(59)); + R(a, b, c, d, e, F4, K4, M(60)); + R(e, a, b, c, d, F4, K4, M(61)); + R(d, e, a, b, c, F4, K4, M(62)); + R(c, d, e, a, b, F4, K4, M(63)); + R(b, c, d, e, a, F4, K4, M(64)); + R(a, b, c, d, e, F4, K4, M(65)); + R(e, a, b, c, d, F4, K4, M(66)); + R(d, e, a, b, c, F4, K4, M(67)); + R(c, d, e, a, b, F4, K4, M(68)); + R(b, c, d, e, a, F4, K4, M(69)); + R(a, b, c, d, e, F4, K4, M(70)); + R(e, a, b, c, d, F4, K4, M(71)); + R(d, e, a, b, c, F4, K4, M(72)); + R(c, d, e, a, b, F4, K4, M(73)); + R(b, c, d, e, a, F4, K4, M(74)); + R(a, b, c, d, e, F4, K4, M(75)); + R(e, a, b, c, d, F4, K4, M(76)); + R(d, e, a, b, c, F4, K4, M(77)); + R(c, d, e, a, b, F4, K4, M(78)); + R(b, c, d, e, a, F4, K4, M(79)); + + _h0 += a; + _h1 += b; + _h2 += c; + _h3 += d; + _h4 += e; + +} + + +bool SHA1::readyToGo() const { + return _init; +} + + +int SHA1::process(const void *block, int len) { + if (!_init) { + return -1; + } + + unsigned char *_block = (unsigned char *)block; + + int cnt = 0; + // Flush the buffer before proceeding + if (_count == 64) { + transform(_buf); + _count = 0; + _nblocks++; + } + + if (!_block) { + return 0; + } + + if (_count) { + for (; len && _count < 64; len--, cnt++) { + _buf[_count++] = *_block++; + } + process(0, 0); // flush the buffer if necessary + if (!len) { + return cnt; + } + } + + while (len >= 64) { + transform(_block); + _count = 0; + _nblocks++; + len -= 64; + cnt += 64; + _block += 64; + } + + for (; len && _count < 64; len--, cnt++) { + _buf[_count++] = *_block++; + } + + return cnt; +} + + +const unsigned char *SHA1::hash() { + unsigned int t, msb, lsb; + unsigned char *p; + + + if (!_init) { + return (unsigned char *)_buf; + } + + process(0, 0); + + msb = 0; + t = _nblocks; + + if ((lsb = t << 6) < t) { + msb++; + } + + msb += t >> 26; + t = lsb; + + if ((lsb = t + _count) < t) { + msb++; + } + + t = lsb; + + if ((lsb = t << 3) < t) { + msb++; + } + + msb += t >> 29; + + _buf[_count++] = 0x80; + + if (_count < 56) { + while (_count < 56) { + _buf[_count++] = 0; + } + } else { + while (_count < 64) { + _buf[_count++] = 0; + } + process(0, 0); + memset(_buf, 0, 56); + } + + _buf[56] = msb >> 24; + _buf[57] = msb >> 16; + _buf[58] = msb >> 8; + _buf[59] = msb; + _buf[60] = lsb >> 24; + _buf[61] = lsb >> 16; + _buf[62] = lsb >> 8; + _buf[63] = lsb; + + transform(_buf); + + p = _buf; + +#ifdef WORDS_BIGENDIAN +#define X( a ) do { *( uint32_t * )p = _h##a; p += 4; } while ( 0 ) +#else +#define X(a) do { *p++ = _h##a >> 24; *p++ = _h##a >> 16; \ + *p++ = _h##a >> 8; *p++ = _h##a; } while (0) +#endif + + X(0); + X(1); + X(2); + X(3); + X(4); + +#undef X + + _init = false; + + return (unsigned char *)_buf; +} + + + + diff --git a/kcontrol/background/CMakeLists.txt b/kcontrol/background/CMakeLists.txt index a62259b8d..5e3670616 100644 --- a/kcontrol/background/CMakeLists.txt +++ b/kcontrol/background/CMakeLists.txt @@ -29,7 +29,7 @@ if( BUILD_KCONTROL OR BUILD_KDESKTOP OR BUILD_TDM ) ##### bgnd (static) ############################# tde_add_library( bgnd STATIC_PIC AUTOMOC - SOURCES bgrender.cpp bgsettings.cpp KCrossBGRender.cc + SOURCES bgrender.cpp bgsettings.cpp KCrossBGRender.cpp LINK ${LIBART_LIBRARIES} ) diff --git a/kcontrol/background/KCrossBGRender.cc b/kcontrol/background/KCrossBGRender.cc deleted file mode 100644 index 489e98d1b..000000000 --- a/kcontrol/background/KCrossBGRender.cc +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (C) 2008 Danilo Cesar Lemes de Paula - * Copyright (C) 2008 Gustavo Boiko - * Mandriva Conectiva - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include - -#include "KCrossBGRender.h" -#include -#include - - -KCrossBGRender::KCrossBGRender(int desk, int screen, bool drawBackgroundPerScreen, TDEConfig *config): KBackgroundRenderer(desk,screen,drawBackgroundPerScreen,config) -{ - useCrossEfect = false; - if ( wallpaperList()[0].endsWith("xml",false) ) { - initCrossFade(wallpaperList()[0]); - } -} - - -void KCrossBGRender::initCrossFade(TQString xmlFile) -{ - useCrossEfect = true; - if (xmlFile.isEmpty()){ - useCrossEfect = false; - return; - } - secs = 0; - timeList.empty(); - - // read the XMLfile - TQDomDocument xmldoc = TQDomDocument(xmlFile); - TQFile file( xmlFile ); - if ( !file.open( IO_ReadOnly ) ) { - useCrossEfect = false; - return; - } - if ( !xmldoc.setContent( &file ) ) { - useCrossEfect = false; - file.close(); - return; - } - file.close(); - - TQDomElement docElem = xmldoc.documentElement(); - TQDomNode n = docElem.firstChild(); - while( !n.isNull() ) { - TQDomElement e = n.toElement(); // try to convert the node to an element. - if( !e.isNull() ) { - if (e.tagName() == "starttime") { - createStartTime(e); - } else if (e.tagName() == "transition") { - createTransition(e); - } else if (e.tagName() == "static") { - createStatic(e); - } - } - n = n.nextSibling(); - } - - // Setting "now" state - setCurrentEvent(true); - pix = getCurrentPixmap(); - - useCrossEfect = true; -} - - -KCrossBGRender::~KCrossBGRender(){ -} - -TQPixmap KCrossBGRender::pixmap() { - fixEnabled(); - if (!useCrossEfect){ - TQPixmap p = KBackgroundRenderer::pixmap(); - kdDebug() << "Inherited " << p.size() << endl; - if (p.width() == 0 && p.height() == 0){ - p.convertFromImage(image()); - } - return p; - } - - return pix; -} - -bool KCrossBGRender::needWallpaperChange(){ - if (!useCrossEfect) { - return KBackgroundRenderer::needWallpaperChange(); - } - - bool forceChange = setCurrentEvent(); // If we change the current state - if (forceChange){ // do not matter what hapens - actualPhase = 0; // we need to change background - return true; - } - - // Return false if it's not a transition - if (!current.transition) { - return false; - } - - double timeLeft, timeTotal; - TQTime now = TQTime::currentTime(); - - timeLeft = now.secsTo(current.etime); - if (timeLeft < 0) { - timeLeft += 86400; // before midnight - } - timeTotal = current.stime.secsTo(current.etime); - if (timeTotal < 0) { - timeTotal += 86400; - } - - double passed = timeTotal - timeLeft; - double timeCell = timeTotal/60; //Time cell size - - //kdDebug() << "\ntimeleft:" << timeLeft << " timeTotal:" << timeTotal - // << "\npassed:" << passed << " timeCell:" << timeCell - // << "\nactualPhase: " << actualPhase << endl; - - int aux = passed/timeCell; - if(actualPhase != aux){ - //kdDebug() << "needWallpaperChange() => returned true" << endl; - actualPhase = passed/timeCell; - return true; - } - - //kdDebug() << "needWallpaperChange() => returned false" << endl; - return false; -} - -/* - * This method change the enabledEffect flag to TRUE of FALSE, according - * with multiWallpaperMode and FileName (it needs to be a XML) - */ -void KCrossBGRender::fixEnabled(){ - - - TQString w = wallpaperList()[0]; - useCrossEfect = false; - if(multiWallpaperMode() == Random || multiWallpaperMode() == InOrder){ - - if ( w != xmlFileName ){ - // New XML File - xmlFileName = w; - if (w.endsWith("xml",false)){ - initCrossFade(wallpaperList()[0]); - //useCrossEfect = true; - }else{ - // Not, it's not a xml file - useCrossEfect = false; - } - }else if (w.endsWith("xml",false)){ - //xmlFile doesn't change - //but it's there - useCrossEfect = true; - }else{ - // it's not a XML file - useCrossEfect = false; - } - } -} - -void KCrossBGRender::changeWallpaper(bool init){ - - - - fixEnabled(); - - if (!useCrossEfect){ - KBackgroundRenderer::changeWallpaper(init); - return; - } - - pix = getCurrentPixmap(); - - -} - - -bool KCrossBGRender::setCurrentEvent(bool init){ - TQTime now = TQTime::currentTime(); - - - //Verify if is need to change - if (!(init || now <= current.stime || now >= current.etime )) { - return false; - } - - TQValueList::iterator it; - for ( it = timeList.begin(); it != timeList.end(); ++it ){ - - // Look for time - if ( ((*it).stime <= now && now <= (*it).etime) || //normal situation - ((*it).etime <= (*it).stime && (now >= (*it).stime || - now <= (*it).etime) ) ) - { - current = *it; - actualPhase = 0; - - //kdDebug() << "Cur: " << current.stime << "< now <" << current.etime << endl; - return true; - } - } - - return false; -} - -TQPixmap KCrossBGRender::getCurrentPixmap() -{ - float alpha; - TQPixmap ret; - TQImage tmp; - TQImage p1; - if (!tmp.load(current.pix1)) - return TQPixmap(); - - // scale the pixmap to fit in the screen - //p1 = TQPixmap(QApplication::desktop()->screenGeometry().size()); - //TQPainter p(&p1); - //p.drawPixmap(p1.rect(), tmp); - // - p1 = tmp.smoothScale(TQApplication::desktop()->screenGeometry().size()); - - if (current.transition){ - TQTime now = TQTime::currentTime(); - double timeLeft,timeTotal; - - TQImage p2; - - if (!tmp.load(current.pix2) ) - return NULL; - - p2 = tmp.smoothScale(TQApplication::desktop()->screenGeometry().size()); - //TQPainter p(&p2); - //p.drawPixmap(p2.rect(), tmp); - - timeLeft = now.secsTo(current.etime); - if (timeLeft < 0) - timeLeft += 86400; - timeTotal = current.stime.secsTo(current.etime); - if (timeTotal < 0) - timeTotal += 86400; - - alpha = (timeTotal - timeLeft)/timeTotal; - - //ret = crossFade(p2,p1,alpha); - tmp = KImageEffect::blend(p2,p1,alpha); - ret.convertFromImage(tmp); - return ret; - }else{ - ret.convertFromImage(p1); - return ret; - } - - -} - -void KCrossBGRender::createStartTime(TQDomElement docElem) -{ - int hour; - int minutes; - - TQDomNode n = docElem.firstChild(); - while( !n.isNull() ) { - TQDomElement e = n.toElement(); - if( !e.isNull() ) { - if (e.tagName() == "hour"){ - hour = e.text().toInt(); - }else if ( e.tagName() == "minute" ){ - minutes = e.text().toInt(); - } - - } - - n = n.nextSibling(); - } - secs = hour*60*60 + minutes*60; -} -void KCrossBGRender::createTransition(TQDomElement docElem) -{ - int duration; - TQString from; - TQString to; - - TQDomNode n = docElem.firstChild(); - while( !n.isNull() ) { - TQDomElement e = n.toElement(); - if( !e.isNull() ) { - if (e.tagName() == "duration"){ - duration = e.text().toFloat(); - }else if ( e.tagName() == "from" ){ - from = e.text(); - } - else if ( e.tagName() == "to" ){ - to = e.text(); - } - - } - n = n.nextSibling(); - } - TQTime startTime(0,0,0); - startTime = startTime.addSecs(secs); - TQTime endTime(0,0,0); - endTime = endTime.addSecs(secs+duration); - - secs += duration; - - KBGCrossEvent l = {true, from, to, startTime,endTime}; - - timeList.append(l); - -} -void KCrossBGRender::createStatic(TQDomElement docElem) -{ - int duration; - TQString file; - - TQDomNode n = docElem.firstChild(); - while( !n.isNull() ) { - TQDomElement e = n.toElement(); - if( !e.isNull() ) { - if (e.tagName() == "duration"){ - duration = e.text().toFloat(); - }else if ( e.tagName() == "file" ){ - file = e.text(); - } - - } - n = n.nextSibling(); - } - - TQTime startTime(0,0,0); - startTime = startTime.addSecs(secs); - TQTime endTime(0,0,0); - endTime = endTime.addSecs(secs+duration); - - secs += duration; - - KBGCrossEvent l = {false, file, NULL, startTime,endTime}; - timeList.append(l); -} - -#include "KCrossBGRender.moc" diff --git a/kcontrol/background/KCrossBGRender.cpp b/kcontrol/background/KCrossBGRender.cpp new file mode 100644 index 000000000..489e98d1b --- /dev/null +++ b/kcontrol/background/KCrossBGRender.cpp @@ -0,0 +1,363 @@ +/* + * Copyright (C) 2008 Danilo Cesar Lemes de Paula + * Copyright (C) 2008 Gustavo Boiko + * Mandriva Conectiva + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include + +#include "KCrossBGRender.h" +#include +#include + + +KCrossBGRender::KCrossBGRender(int desk, int screen, bool drawBackgroundPerScreen, TDEConfig *config): KBackgroundRenderer(desk,screen,drawBackgroundPerScreen,config) +{ + useCrossEfect = false; + if ( wallpaperList()[0].endsWith("xml",false) ) { + initCrossFade(wallpaperList()[0]); + } +} + + +void KCrossBGRender::initCrossFade(TQString xmlFile) +{ + useCrossEfect = true; + if (xmlFile.isEmpty()){ + useCrossEfect = false; + return; + } + secs = 0; + timeList.empty(); + + // read the XMLfile + TQDomDocument xmldoc = TQDomDocument(xmlFile); + TQFile file( xmlFile ); + if ( !file.open( IO_ReadOnly ) ) { + useCrossEfect = false; + return; + } + if ( !xmldoc.setContent( &file ) ) { + useCrossEfect = false; + file.close(); + return; + } + file.close(); + + TQDomElement docElem = xmldoc.documentElement(); + TQDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + TQDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) { + if (e.tagName() == "starttime") { + createStartTime(e); + } else if (e.tagName() == "transition") { + createTransition(e); + } else if (e.tagName() == "static") { + createStatic(e); + } + } + n = n.nextSibling(); + } + + // Setting "now" state + setCurrentEvent(true); + pix = getCurrentPixmap(); + + useCrossEfect = true; +} + + +KCrossBGRender::~KCrossBGRender(){ +} + +TQPixmap KCrossBGRender::pixmap() { + fixEnabled(); + if (!useCrossEfect){ + TQPixmap p = KBackgroundRenderer::pixmap(); + kdDebug() << "Inherited " << p.size() << endl; + if (p.width() == 0 && p.height() == 0){ + p.convertFromImage(image()); + } + return p; + } + + return pix; +} + +bool KCrossBGRender::needWallpaperChange(){ + if (!useCrossEfect) { + return KBackgroundRenderer::needWallpaperChange(); + } + + bool forceChange = setCurrentEvent(); // If we change the current state + if (forceChange){ // do not matter what hapens + actualPhase = 0; // we need to change background + return true; + } + + // Return false if it's not a transition + if (!current.transition) { + return false; + } + + double timeLeft, timeTotal; + TQTime now = TQTime::currentTime(); + + timeLeft = now.secsTo(current.etime); + if (timeLeft < 0) { + timeLeft += 86400; // before midnight + } + timeTotal = current.stime.secsTo(current.etime); + if (timeTotal < 0) { + timeTotal += 86400; + } + + double passed = timeTotal - timeLeft; + double timeCell = timeTotal/60; //Time cell size + + //kdDebug() << "\ntimeleft:" << timeLeft << " timeTotal:" << timeTotal + // << "\npassed:" << passed << " timeCell:" << timeCell + // << "\nactualPhase: " << actualPhase << endl; + + int aux = passed/timeCell; + if(actualPhase != aux){ + //kdDebug() << "needWallpaperChange() => returned true" << endl; + actualPhase = passed/timeCell; + return true; + } + + //kdDebug() << "needWallpaperChange() => returned false" << endl; + return false; +} + +/* + * This method change the enabledEffect flag to TRUE of FALSE, according + * with multiWallpaperMode and FileName (it needs to be a XML) + */ +void KCrossBGRender::fixEnabled(){ + + + TQString w = wallpaperList()[0]; + useCrossEfect = false; + if(multiWallpaperMode() == Random || multiWallpaperMode() == InOrder){ + + if ( w != xmlFileName ){ + // New XML File + xmlFileName = w; + if (w.endsWith("xml",false)){ + initCrossFade(wallpaperList()[0]); + //useCrossEfect = true; + }else{ + // Not, it's not a xml file + useCrossEfect = false; + } + }else if (w.endsWith("xml",false)){ + //xmlFile doesn't change + //but it's there + useCrossEfect = true; + }else{ + // it's not a XML file + useCrossEfect = false; + } + } +} + +void KCrossBGRender::changeWallpaper(bool init){ + + + + fixEnabled(); + + if (!useCrossEfect){ + KBackgroundRenderer::changeWallpaper(init); + return; + } + + pix = getCurrentPixmap(); + + +} + + +bool KCrossBGRender::setCurrentEvent(bool init){ + TQTime now = TQTime::currentTime(); + + + //Verify if is need to change + if (!(init || now <= current.stime || now >= current.etime )) { + return false; + } + + TQValueList::iterator it; + for ( it = timeList.begin(); it != timeList.end(); ++it ){ + + // Look for time + if ( ((*it).stime <= now && now <= (*it).etime) || //normal situation + ((*it).etime <= (*it).stime && (now >= (*it).stime || + now <= (*it).etime) ) ) + { + current = *it; + actualPhase = 0; + + //kdDebug() << "Cur: " << current.stime << "< now <" << current.etime << endl; + return true; + } + } + + return false; +} + +TQPixmap KCrossBGRender::getCurrentPixmap() +{ + float alpha; + TQPixmap ret; + TQImage tmp; + TQImage p1; + if (!tmp.load(current.pix1)) + return TQPixmap(); + + // scale the pixmap to fit in the screen + //p1 = TQPixmap(QApplication::desktop()->screenGeometry().size()); + //TQPainter p(&p1); + //p.drawPixmap(p1.rect(), tmp); + // + p1 = tmp.smoothScale(TQApplication::desktop()->screenGeometry().size()); + + if (current.transition){ + TQTime now = TQTime::currentTime(); + double timeLeft,timeTotal; + + TQImage p2; + + if (!tmp.load(current.pix2) ) + return NULL; + + p2 = tmp.smoothScale(TQApplication::desktop()->screenGeometry().size()); + //TQPainter p(&p2); + //p.drawPixmap(p2.rect(), tmp); + + timeLeft = now.secsTo(current.etime); + if (timeLeft < 0) + timeLeft += 86400; + timeTotal = current.stime.secsTo(current.etime); + if (timeTotal < 0) + timeTotal += 86400; + + alpha = (timeTotal - timeLeft)/timeTotal; + + //ret = crossFade(p2,p1,alpha); + tmp = KImageEffect::blend(p2,p1,alpha); + ret.convertFromImage(tmp); + return ret; + }else{ + ret.convertFromImage(p1); + return ret; + } + + +} + +void KCrossBGRender::createStartTime(TQDomElement docElem) +{ + int hour; + int minutes; + + TQDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + TQDomElement e = n.toElement(); + if( !e.isNull() ) { + if (e.tagName() == "hour"){ + hour = e.text().toInt(); + }else if ( e.tagName() == "minute" ){ + minutes = e.text().toInt(); + } + + } + + n = n.nextSibling(); + } + secs = hour*60*60 + minutes*60; +} +void KCrossBGRender::createTransition(TQDomElement docElem) +{ + int duration; + TQString from; + TQString to; + + TQDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + TQDomElement e = n.toElement(); + if( !e.isNull() ) { + if (e.tagName() == "duration"){ + duration = e.text().toFloat(); + }else if ( e.tagName() == "from" ){ + from = e.text(); + } + else if ( e.tagName() == "to" ){ + to = e.text(); + } + + } + n = n.nextSibling(); + } + TQTime startTime(0,0,0); + startTime = startTime.addSecs(secs); + TQTime endTime(0,0,0); + endTime = endTime.addSecs(secs+duration); + + secs += duration; + + KBGCrossEvent l = {true, from, to, startTime,endTime}; + + timeList.append(l); + +} +void KCrossBGRender::createStatic(TQDomElement docElem) +{ + int duration; + TQString file; + + TQDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + TQDomElement e = n.toElement(); + if( !e.isNull() ) { + if (e.tagName() == "duration"){ + duration = e.text().toFloat(); + }else if ( e.tagName() == "file" ){ + file = e.text(); + } + + } + n = n.nextSibling(); + } + + TQTime startTime(0,0,0); + startTime = startTime.addSecs(secs); + TQTime endTime(0,0,0); + endTime = endTime.addSecs(secs+duration); + + secs += duration; + + KBGCrossEvent l = {false, file, NULL, startTime,endTime}; + timeList.append(l); +} + +#include "KCrossBGRender.moc" diff --git a/kcontrol/background/bgdialog.cpp b/kcontrol/background/bgdialog.cpp index f82ccdd8a..754a2ba9d 100644 --- a/kcontrol/background/bgdialog.cpp +++ b/kcontrol/background/bgdialog.cpp @@ -474,7 +474,7 @@ void BGDialog::initUI() loadWallpaperFilesList(); - // Wallpaper tilings: again they must match the ones from bgrender.cc + // Wallpaper tilings: again they must match the ones from bgrender.cpp m_comboWallpaperPos->insertItem(i18n("Centered")); m_comboWallpaperPos->insertItem(i18n("Tiled")); m_comboWallpaperPos->insertItem(i18n("Center Tiled")); @@ -484,7 +484,7 @@ void BGDialog::initUI() m_comboWallpaperPos->insertItem(i18n("Centered Auto Fit")); m_comboWallpaperPos->insertItem(i18n("Scale & Crop")); - // Blend modes: make sure these match with kdesktop/bgrender.cc !! + // Blend modes: make sure these match with kdesktop/bgrender.cpp !! m_comboBlend->insertItem(i18n("No Blending")); m_comboBlend->insertItem(i18n("Flat")); m_comboBlend->insertItem(i18n("Horizontal")); diff --git a/kdesktop/CMakeLists.txt b/kdesktop/CMakeLists.txt index a4714ce59..5ee2746cc 100644 --- a/kdesktop/CMakeLists.txt +++ b/kdesktop/CMakeLists.txt @@ -81,13 +81,13 @@ tde_add_executable( kcheckrunning ##### kdesktop (tdeinit) ######################## set( target kdesktop ) -set_property( SOURCE lockeng.cc APPEND PROPERTY COMPILE_DEFINITIONS KDE_CONFDIR="${TDE_CONFIG_DIR}" ) +set_property( SOURCE lockeng.cpp APPEND PROPERTY COMPILE_DEFINITIONS KDE_CONFDIR="${TDE_CONFIG_DIR}" ) set( ${target}_SRCS - main.cc krootwm.cc xautolock.cc kdiconview.cc init.cc - desktop.cc lockeng.cc KDesktopIface.skel bgmanager.cc + main.cpp krootwm.cpp xautolock.cpp kdiconview.cpp init.cpp + desktop.cpp lockeng.cpp KDesktopIface.skel bgmanager.cpp KScreensaverIface.skel minicli.cpp KBackgroundIface.skel - pixmapserver.cc kcustommenu.cc startupid.cpp minicli_ui.ui + pixmapserver.cpp kcustommenu.cpp startupid.cpp minicli_ui.ui xautolock_diy.c xautolock_engine.c kshadowengine.cpp kshadowsettings.cpp kdesktopshadowsettings.cpp tdefileividesktop.cpp kdesktopapp.cpp diff --git a/kdesktop/Makefile.am b/kdesktop/Makefile.am index b28d1ee66..b2d4c2b2c 100644 --- a/kdesktop/Makefile.am +++ b/kdesktop/Makefile.am @@ -17,10 +17,10 @@ libkdesktopsettings_la_LDFLAGS = $(all_libraries) -no-undefined libkdesktopsettings_la_LIBADD = $(LIB_TDECORE) libkdesktopsettings_la_SOURCES = kdesktopsettings.kcfgc tdelaunchsettings.kcfgc -kdesktop_la_SOURCES = main.cc krootwm.cc xautolock.cc kdiconview.cc desktop.cc \ - lockeng.cc KDesktopIface.skel \ - bgmanager.cc init.cc KScreensaverIface.skel \ - minicli.cpp KBackgroundIface.skel pixmapserver.cc kcustommenu.cc \ +kdesktop_la_SOURCES = main.cpp krootwm.cpp xautolock.cpp kdiconview.cpp desktop.cpp \ + lockeng.cpp KDesktopIface.skel \ + bgmanager.cpp init.cpp KScreensaverIface.skel \ + minicli.cpp KBackgroundIface.skel pixmapserver.cpp kcustommenu.cpp \ startupid.cpp minicli_ui.ui xautolock_diy.c xautolock_engine.c \ kshadowengine.cpp kshadowsettings.cpp \ kdesktopshadowsettings.cpp tdefileividesktop.cpp \ @@ -59,7 +59,7 @@ startupid.lo: tdelaunchsettings.h messages: rc.cpp $(EXTRACTRC) lock/*.ui >> rc.cpp - $(XGETTEXT) lock/*.cc *.cc *.cpp *.h -o $(podir)/kdesktop.pot + $(XGETTEXT) lock/*.cpp *.cpp *.h -o $(podir)/kdesktop.pot menu_DATA = kdesktop_custom_menu1 kdesktop_custom_menu2 menudir = $(kde_confdir) diff --git a/kdesktop/bgmanager.cc b/kdesktop/bgmanager.cc deleted file mode 100644 index 7e90e8fca..000000000 --- a/kdesktop/bgmanager.cc +++ /dev/null @@ -1,1109 +0,0 @@ -/* - * - * This file is part of the KDE project, module kdesktop. - * Copyright (C) 1999,2000 Geert Jansen - * - * You can Freely distribute this program under the GNU General Public - * License. See the file "COPYING" for the exact licensing terms. - */ - -#include -#include "bgrender.h" -#include "bgmanager.h" -#include "bgdefaults.h" -#include "kdesktopsettings.h" -#include "bgsettings.h" -#include "kdesktopapp.h" - -#include "KCrossBGRender.h" -#include "crossfade.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifndef None -#define None 0L -#endif - -#ifdef COMPOSITE -# include -# include -# include -#endif - -#include "pixmapserver.h" - -template class TQPtrVector; -template class TQPtrVector; -template class TQMemArray; - -static Atom prop_root; -static bool properties_inited = false; - -extern bool argb_visual; -extern KDesktopApp *myApp; - -/**** KBackgroundManager ****/ - -KBackgroundManager::KBackgroundManager(TQWidget *desktop, KWinModule* twinModule) - : KBackgroundIface() -{ - if( !properties_inited ) - { - prop_root = XInternAtom(tqt_xdisplay(), "_XROOTPMAP_ID", False); - properties_inited = true; - } - m_bBgInitDone = false; - m_bEnabled = true; - - m_pDesktop = desktop; - if (desktop == 0L) - desktop = TQT_TQWIDGET(TDEApplication::desktop()->screen()); - - m_Renderer.resize( 1 ); - m_Cache.resize( 1 ); - - m_Serial = 0; m_Hash = 0; - m_pConfig = TDEGlobal::config(); - m_bExport = m_bCommon = m_bInit = false; - m_pKwinmodule = twinModule; - m_pPixmapServer = new KPixmapServer(); - m_xrootpmap = None; - - for (unsigned i=0; ipixmap = 0L; - m_Cache[i]->hash = 0; - m_Cache[i]->exp_from = -1; - m_Renderer.insert (i, new KVirtualBGRenderer(i,m_pConfig)); - connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); - m_Renderer[i]->enableTiling( true ); // optimize - } - -#ifdef COMPOSITE - m_tPixmap = new KPixmap(kapp->desktop()->size()); - m_tPixmap->fill(TQColor(0, 0x0)); - connect(myApp, TQT_SIGNAL(cmBackgroundChanged( bool )), - TQT_SLOT(slotCmBackgroundChanged( bool ))); -#endif - - configure(); - - m_pTimer = new TQTimer(this); - connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout())); - m_pTimer->start( 60000 ); - - /*CrossFade's config*/ - m_crossTimer = new TQTimer(this); - connect(m_crossTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotCrossFadeTimeout())); - resizingDesktop = true; - /*Ends here*/ - - - connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopChanged(int)), - TQT_SLOT(slotChangeDesktop(int))); - connect(m_pKwinmodule, TQT_SIGNAL(numberOfDesktopsChanged(int)), - TQT_SLOT(slotChangeNumberOfDesktops(int))); - connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopViewportChanged(int, const TQPoint&)), - TQT_SLOT(slotChangeViewport(int, const TQPoint&))); - - -#if (TQT_VERSION-0 >= 0x030200) - connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); // RANDR support -#endif - - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { - renderBackground(j); - } -} - - -KBackgroundManager::~KBackgroundManager() -{ - for (unsigned i=0; ipixmap; - delete m_Cache[i]; - } -} - - -void KBackgroundManager::applyExport(bool exp) -{ - if (exp == m_bExport) - return; - - // If export mode changed from true -> false, remove all shared pixmaps. - // If it changed false -> true force a redraw because the current screen - // image might not have an associated pixmap in the cache. - if (!exp) - { - for (unsigned i=0; i true, remove all cache entries, except - // at index 0 if exports are on. - if (m_bCommon) - { - if (!m_bExport) - removeCache(0); - for (unsigned i=1; ireparseConfiguration(); - KDesktopSettings::self()->readConfig(); - - // Read individual settings - KVirtualBGRenderer *r; - for (unsigned i=0; ihash(); - r->load(i,false); - if ((r->hash() != ohash)) - removeCache(i); - } - - applyCommon(KDesktopSettings::commonDesktop()); - - bool limit = KDesktopSettings::limitCache(); - int size = KDesktopSettings::cacheSize() * 1024; - applyCache(limit, size); - - // Repaint desktop - slotChangeDesktop(0); - - // Redraw all desktops so that applications relying on exported data, e.g. kpager, continue to work properly - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { - renderBackground(j); - } -} - - -int KBackgroundManager::realDesktop() -{ - int desk = m_pKwinmodule->currentDesktop(); - if (desk) desk--; - return desk; -} - - -int KBackgroundManager::effectiveDesktop() -{ - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - - if (m_numberOfViewports > 1) { - if (m_bCommon) { - return 0; - } - else { - TQPoint vx(m_pKwinmodule->currentViewport(m_pKwinmodule->currentDesktop())); - return (realDesktop() * m_numberOfViewports) + ((vx.x() * vx.y()) - 1); - } - } - else { - return m_bCommon ? 0 : realDesktop(); - } -} - - -/* - * Number of desktops changed - */ -void KBackgroundManager::slotChangeNumberOfDesktops(int num) -{ - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - num = (num * m_numberOfViewports); - - if (m_Renderer.size() == (unsigned) num) - return; - - if (m_Renderer.size() > (unsigned) num) - { - for (unsigned i=num; iisActive()) - m_Renderer[i]->stop(); - delete m_Renderer[i]; - removeCache(i); - } - for (unsigned i=num; ipixmap = 0L; - m_Cache[i]->hash = 0; - m_Cache[i]->exp_from = -1; - m_Renderer.insert(i, new KVirtualBGRenderer(i,m_pConfig)); - connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); - m_Renderer[i]->enableTiling( true ); // optimize - } - } -} - -/* - * Call this when the desktop has been changed. - * Desk is in KWin convention: [1..desks], instead of [0..desks-1]. - * 0 repaints the current desktop. - */ -void KBackgroundManager::slotChangeDesktop(int desk) -{ - resizingDesktop = true; - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - - if (desk == 0) - desk = realDesktop(); - else - desk--; - - // Lazy initialisation of # of desktops - if ((unsigned)(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size()) - slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports); - - int edesk = effectiveDesktop(); - m_Serial++; - - // If the background is the same: do nothing - if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0)) - { - exportBackground(m_Current, desk); - return; - } - m_Renderer[edesk]->stop(); - m_Renderer[edesk]->cleanup(); - - // If we have the background already rendered: set it - for (unsigned i=0; ipixmap) - continue; - if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) - continue; - if (desk == 0) - continue; -// kdDebug() << "slotChangeDesktop i=" << i << endl; - setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); - m_Cache[i]->atime = m_Serial; - exportBackground(i, desk); - return; - } - - // Do we have this or an identical config already running? - for (unsigned i=0; ihash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0)) { - return; - } - } - - renderBackground(edesk); -} - -/* - * Call this when the viewport has been changed. - * Desk is in KWin convention: [1..desks], instead of [0..desks-1]. - * 0 repaints the current viewport. - */ -void KBackgroundManager::slotChangeViewport(int desk, const TQPoint& viewport) -{ - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - - if (desk == 0) - desk = realDesktop(); - else - desk--; - - // Lazy initialisation of # of desktops - if ((unsigned)(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size()) - slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports ); - - int edesk = effectiveDesktop(); - m_Serial++; - - // If the background is the same: do nothing - if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0)) - { - exportBackground(m_Current, desk); - return; - } - m_Renderer[edesk]->stop(); - m_Renderer[edesk]->cleanup(); - - // If we have the background already rendered: set it - for (unsigned i=0; ipixmap) - continue; - if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) - continue; - if (desk == 0) - continue; -// kdDebug() << "slotChangeDesktop i=" << i << endl; - - //KPixmap * viewport_background = new KPixmap(TQPixmap(m_Cache[i]->pixmap->width()*s.width(), m_Cache[i]->pixmap->height()*s.height())); - //setPixmap(viewport_background, m_Cache[i]->hash, i); - //delete viewport_background; - - setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); - m_Cache[i]->atime = m_Serial; - exportBackground(i, desk); - return; - } - - // Do we have this or an identical config already running? - for (unsigned i=0; ihash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0)) - return; - } - - renderBackground(edesk); -} - - -/* - * Share a desktop pixmap. - */ -void KBackgroundManager::exportBackground(int pixmap, int desk) -{ - if (!m_bExport || (m_Cache[desk]->exp_from == pixmap)) - return; - - m_Cache[desk]->exp_from = pixmap; - m_pPixmapServer->add(KRootPixmap::pixmapName(desk+1), - m_Cache[pixmap]->pixmap); - KIPC::sendMessageAll(KIPC::BackgroundChanged, desk+1); -} - - -/* - * Paint the pixmap to the root window. - */ -void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk) -{ - KPixmap *ep = pm; - -#ifdef COMPOSITE - if (argb_visual && (KDesktopSettings::backgroundOpacity() < 100 - || myApp->cmBackground())) - { - ep = m_tPixmap; - if (KDesktopSettings::backgroundOpacity() > 0 && pm - && !myApp->cmBackground()) - { - XRenderPictFormat *format; - format = XRenderFindStandardFormat (tqt_xdisplay(), PictStandardARGB32); - - XRenderColor fillColor; - - int color = KDesktopSettings::backgroundOpacity() * 0xffff / 100; - fillColor.red = color; - fillColor.green = color; - fillColor.blue = color; - fillColor.alpha = color; - - Picture fill = XRenderCreateSolidFill (tqt_xdisplay(), &fillColor); - Picture src = XRenderCreatePicture(tqt_xdisplay(), pm->handle(), - format, 0, NULL); - Picture dst = XRenderCreatePicture(tqt_xdisplay(), ep->handle(), - format, 0, NULL); - - XRenderComposite (tqt_xdisplay(), PictOpSrc, src, fill, dst, 0, 0, 0, - 0, 0, 0, pm->width(), pm->height()); - - XRenderFreePicture (tqt_xdisplay(), fill); - XRenderFreePicture (tqt_xdisplay(), src); - XRenderFreePicture (tqt_xdisplay(), dst); - } - } -#endif - - if (m_pDesktop) - { - TQScrollView* sv = dynamic_cast( m_pDesktop ); - if ( sv ) { - // Qt eats repaint events in this case :-(( - sv->viewport()->update(); - } - m_pDesktop->setErasePixmap(*ep); - m_pDesktop->repaint(); - static bool root_cleared = false; - if( !root_cleared ) - { // clear the root window pixmap set by tdm - root_cleared = true; - TQTimer::singleShot( 0, this, TQT_SLOT( clearRoot())); - // but make the pixmap visible until m_pDesktop is visible - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); - } - } - else - { - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); - } - - // and export it via Esetroot-style for gnome/GTK apps to share in the pretties - Pixmap bgPm = pm->handle(); // fetch the actual X handle to it - //kdDebug() << "Esetroot compat: setting pixmap to " << bgPm << endl; - - // don't set the ESETROOT_PMAP_ID property - that would result in possible XKillClient() - // done on kdesktop - - XChangeProperty(tqt_xdisplay(), tqt_xrootwin(), prop_root, XA_PIXMAP, 32, PropModeReplace, - (unsigned char *) &bgPm, 1); - m_xrootpmap = bgPm; - - m_Hash = hash; - m_Current = desk; -} - -void KBackgroundManager::clearRoot() -{ - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap( TQPixmap()); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); -} - -/* - * Start the render of a desktop background. - */ -void KBackgroundManager::renderBackground(int desk) -{ - KVirtualBGRenderer *r = m_Renderer[desk]; - if (r->isActive()) - { - kdDebug() << "renderer " << desk << " already active" << endl; - return; - } - - r->start(); -} - - -/* - * This slot is called when the Timeout is executed - */ -void KBackgroundManager::slotCrossFadeTimeout() -{ - KVirtualBGRenderer *r = m_Renderer[fadeDesk]; - if (crossInit) { - mBenchmark.start(); - } - - if (mAlpha <= 0.0 || mBenchmark.elapsed() > 300 ) { - mAlpha = 1; - m_crossTimer->stop(); - KPixmap pixm(mNextScreen); - setPixmap(&pixm, r->hash(), fadeDesk); - return; - } - // Reset Timer - mBenchmark.start(); - - TQPixmap dst = crossFade(*mOldScreen, mNextScreen, mAlpha, crossInit); - KPixmap pixm(dst); - setPixmap(&pixm, r->hash(), fadeDesk); - - mAlpha -=0.03; - crossInit = false; -} - - -/* - * This slot is called when a renderer is done. - */ -void KBackgroundManager::slotImageDone(int desk) -{ - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - - KPixmap *pm = new KPixmap(); - KVirtualBGRenderer *r = m_Renderer[desk]; - bool do_cleanup = true; - fadeDesk = desk; - mAlpha = 1.0; - int width,height; - - - *pm = r->pixmap(); - // If current: paint it - bool current = (r->hash() == m_Renderer[effectiveDesktop()]->hash()); - if (current) - { - //START - if (m_Renderer[effectiveDesktop()]->renderer(0)->crossFadeBg() && !m_Renderer[effectiveDesktop()]->renderer(0)->usingCrossXml() && !resizingDesktop) { - int mode = m_Renderer[effectiveDesktop()]->renderer(0)->wallpaperMode(); - width = TQApplication::desktop()->screenGeometry().width(); - height = TQApplication::desktop()->screenGeometry().height(); - - if (mode == KBackgroundSettings::NoWallpaper || mode == KBackgroundSettings::Tiled || mode == KBackgroundSettings::CenterTiled ){ - mNextScreen = TQPixmap(width,height); - TQPainter p (&mNextScreen); - p.drawTiledPixmap(0,0,width,height,*pm); - } else { - mNextScreen = TQPixmap(*pm); - } - - if (m_pDesktop){ - mOldScreen = const_cast( m_pDesktop->backgroundPixmap() ); - }else{ - mOldScreen = const_cast( - TQApplication::desktop()->screen()->backgroundPixmap() ); - } - - //TODO Find a way to discover if CrossFade effect needs to run - if (mOldScreen){ - crossInit = true; - m_crossTimer->start(70); - } else{ - setPixmap(pm, r->hash(), desk); - } - }else{ - setPixmap(pm, r->hash(), desk); - } - //ENDS HERE */ - - if (!m_bBgInitDone) - { - m_bBgInitDone = true; - emit initDone(); - TQTimer::singleShot( 30000, this, TQT_SLOT( saveImages())); - do_cleanup = false; - } - } - if (m_bExport || !m_bCommon) { - addCache(pm, r->hash(), desk); - } - else { - delete pm; - } - - if (current) { - exportBackground(desk, realDesktop()); - } - - if( do_cleanup ) { - r->saveCacheFile(); - r->cleanup(); - } - - resizingDesktop = false; -} - - -void KBackgroundManager::saveImages() -{ - for (unsigned i=0; isaveCacheFile(); - m_Renderer[i]->cleanup(); - } -} - -/* - * Size in bytes of a TQPixmap. For use in the pixmap cache. - */ -int KBackgroundManager::pixmapSize(TQPixmap *pm) -{ - return (pm->width() * pm->height()) * ((pm->depth() + 7) / 8); -} - - -/* - * Total size of the pixmap cache. - */ -int KBackgroundManager::cacheSize() -{ - int total = 0; - for (unsigned i=0; ipixmap) - total += pixmapSize(m_Cache[i]->pixmap); - } - return total; -} - - -/* - * Remove an entry from the pixmap cache. - */ -void KBackgroundManager::removeCache(int desk) -{ - if (m_bExport) - m_pPixmapServer->remove(KRootPixmap::pixmapName(desk+1)); - else - delete m_Cache[desk]->pixmap; - m_Cache[desk]->pixmap = 0L; - m_Cache[desk]->hash = 0; - m_Cache[desk]->exp_from = -1; - m_Cache[desk]->atime = 0; - - // Remove cache entries pointing to the removed entry - for (unsigned i=0; iexp_from == desk) - { - assert(m_bExport); - m_Cache[i]->exp_from = -1; - m_pPixmapServer->remove(KRootPixmap::pixmapName(i+1)); - } - } -} - - -/* - * Try to free up to size bytes from the cache. - */ -bool KBackgroundManager::freeCache(int size) -{ - if (m_bExport || !m_bLimitCache) - return true; - - // If it doesn't fit at all, return now. - if (size > m_CacheLimit) - return false; - - // If cache is too full, purge it (LRU) - while (size+cacheSize() > m_CacheLimit) - { - int j, min; - min = m_Serial+1; j = 0; - for (unsigned i=0; ipixmap && (m_Cache[i]->atime < min)) - { - min = m_Cache[i]->atime; - j = i; - } - } - removeCache(j); - } - return true; -} - - -/* - * Try to add a pixmap to the pixmap cache. We don't use TQPixmapCache here - * because if we're exporting pixmaps, this needs special care. - */ -void KBackgroundManager::addCache(KPixmap *pm, int hash, int desk) -{ - if (m_Cache[desk]->pixmap) - removeCache(desk); - - if (m_bLimitCache && !m_bExport && !freeCache(pixmapSize(pm))) - { - // pixmap does not fit in cache - delete pm; - return; - } - - m_Cache[desk]->pixmap = pm; - m_Cache[desk]->hash = hash; - m_Cache[desk]->atime = m_Serial; - m_Cache[desk]->exp_from = -1; - exportBackground(desk, desk); -} - -/* - * Called every minute to check if we need to rerun a background program. - * or change a wallpaper. - */ -void KBackgroundManager::slotTimeout() -{ - TQMemArray running(m_Renderer.size()); - running.fill(0); - - int NumDesks = m_Renderer.size(); - if (m_bCommon) - NumDesks = 1; - - int edesk = effectiveDesktop(); - - for (int i=0; ineedProgramUpdate()) - { - r->programUpdate(); - change = true; - } - - if (r->needWallpaperChange()) - { - r->changeWallpaper(); - change = true; - } - - if (change && (i == edesk)) - { - running[i] = r->hash(); - r->start(); - } - } -} - -// Return a valid desk number. -int KBackgroundManager::validateDesk(int desk) -{ - if (desk > (int)m_Renderer.size()) - slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() ); - - if ( (desk <= 0) || (desk > (int)m_Renderer.size()) ) - return realDesktop(); - - return desk - 1; -} - -// DCOP exported -// Return current wallpaper for specified desk. -// 0 is for the current visible desktop. -TQString KBackgroundManager::currentWallpaper(int desk) -{ - //TODO Is the behaviour of this function appropriate for multiple screens? - KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0); - - return r->currentWallpaper(); -} - -// DCOP exported -void KBackgroundManager::changeWallpaper() -{ - KVirtualBGRenderer *r = m_Renderer[effectiveDesktop()]; - - r->changeWallpaper(); - slotChangeDesktop(0); -} - -// DCOP exported -void KBackgroundManager::setExport(int _export) -{ -// kdDebug() << "KBackgroundManager enabling exports.\n"; - bool changed = (_export != m_bExport); - applyExport(_export); - if (changed) { - slotChangeDesktop(0); - } -} - -// DCOP exported -void KBackgroundManager::setCommon(int common) -{ - applyCommon(common); - KDesktopSettings::setCommonDesktop( m_bCommon ); - KDesktopSettings::writeConfig(); - slotChangeDesktop(0); -} - -// DCOP exported -void KBackgroundManager::setWallpaper(TQString wallpaper, int mode) -{ - if (mode < 0 || mode >= KBackgroundSettings::lastWallpaperMode) { - kdDebug() << "Invalid background mode " << mode << " passed to " << k_funcinfo << "\n"; - return; - } - - //TODO Is the behaviour of this function appropriate for multiple screens? - for (unsigned i=0; i < m_Renderer[effectiveDesktop()]->numRenderers(); ++i) - { - KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(i); - r->stop(); - r->setWallpaperMode(mode); - r->setMultiWallpaperMode(KBackgroundSettings::NoMulti); - r->setWallpaper(wallpaper); - r->writeSettings(); - } - slotChangeDesktop(0); -} - -void KBackgroundManager::setWallpaper(TQString wallpaper) -{ - //TODO Is the behaviour of this function appropriate for multiple screens? - KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(0); - int mode = r->wallpaperMode(); - if (mode == KBackgroundSettings::NoWallpaper) - mode = KBackgroundSettings::Tiled; - setWallpaper(wallpaper, mode); -} - -// DCOP exported -// Returns the filenames of all wallpaper entries for specified desk -// 0 is for current visible desktop. -TQStringList KBackgroundManager::wallpaperFiles(int desk) -{ - //TODO Is the behaviour of this function appropriate for multiple screens? - KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0); - - return r->wallpaperFiles(); -} - -// DCOP exported -// Returns the list of wallpaper entries (viewable in background slide -// show window) for specified desk. 0 is for current visible desktop. -TQStringList KBackgroundManager::wallpaperList(int desk) -{ - //TODO Is the behaviour of this function appropriate for multiple screens? - KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0);; - - return r->wallpaperList(); -} - -// DCOP exported -void KBackgroundManager::setCache( int bLimit, int size ) -{ - applyCache( bLimit, size*1024 ); - KDesktopSettings::setLimitCache( (bool) bLimit ); - KDesktopSettings::setCacheSize( size ); - KDesktopSettings::writeConfig(); -} - -// DCOP exported -void KBackgroundManager::setWallpaper(int desk, TQString wallpaper, int mode) -{ - if (mode < 0 || mode >= KBackgroundSettings::lastWallpaperMode) { - kdDebug() << "Invalid background mode " << mode << " passed to " << k_funcinfo << "\n"; - return; - } - - int sdesk = validateDesk(desk); - - //TODO Is the behaviour of this function appropriate for multiple screens? - for (unsigned i=0; i < m_Renderer[sdesk]->numRenderers(); ++i) - { - KCrossBGRender *r = m_Renderer[sdesk]->renderer(i); - - setCommon(false); // Force each desktop to have it's own wallpaper - - r->stop(); - r->setWallpaperMode(mode); - r->setMultiWallpaperMode(KBackgroundSettings::NoMulti); - r->setWallpaper(wallpaper); - r->writeSettings(); - } - slotChangeDesktop(sdesk); -} - -void KBackgroundManager::repaintBackground() -{ - if (m_pDesktop) - m_pDesktop->repaint(); - else - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); -} - -void KBackgroundManager::desktopResized() -{ - resizingDesktop = true; - for (unsigned i=0; iisActive()) - r->stop(); - removeCache(i); - // make the renderer update its desktop size - r->desktopResized(); - for (unsigned j=0; j<(r->numRenderers()); ++j) { - r->renderer(j)->desktopResized(); - } - } - -#ifdef COMPOSITE - if (m_tPixmap) - delete m_tPixmap; - m_tPixmap = new KPixmap(kapp->desktop()->size()); - m_tPixmap->fill(TQColor(0, 0x0)); -#endif - - m_Hash = 0; - if( m_pDesktop ) { - m_pDesktop->resize( kapp->desktop()->geometry().size()); - if (m_Renderer[effectiveDesktop()]->renderer(0)->usingCrossXml()){ - m_Renderer[effectiveDesktop()]->renderer(0)->changeWallpaper(); - } - } - // Repaint desktop - slotChangeDesktop(0); - repaintBackground(); - - // Redraw all desktops so that applications relying on exported data, e.g. kpager, continue to work properly - TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); - m_numberOfViewports = s.width() * s.height(); - if (m_numberOfViewports < 1) { - m_numberOfViewports = 1; - } - for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { - renderBackground(j); - } -} - -// DCOP exported -void KBackgroundManager::setColor(const TQColor & c, bool isColorA) -{ - //TODO Is the behaviour of this function appropriate for multiple screens? - for (unsigned i=0; i < m_Renderer[effectiveDesktop()]->numRenderers(); ++i) - { - KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(i); - r->stop(); - - if (isColorA) - r->setColorA(c); - else - r->setColorB(c); - - int mode = r->backgroundMode(); - if (mode == KBackgroundSettings::Program) - mode = KBackgroundSettings::Flat; - - if (!isColorA && (mode == KBackgroundSettings::Flat)) - mode = KBackgroundSettings::VerticalGradient; - r->setBackgroundMode(mode); - - r->writeSettings(); - } - slotChangeDesktop(0); -} - -void KBackgroundManager::setBackgroundEnabled( const bool enable ) -{ - if (m_bEnabled == enable) - return; - - m_bEnabled= enable; - - int NumDesks = m_Renderer.size(); - if (m_bCommon) - NumDesks = 1; - - for (int i=0; isetEnabled(enable); - } - slotChangeDesktop(0); -} - -#ifdef COMPOSITE -void KBackgroundManager::slotCmBackgroundChanged( bool ) -{ - m_tPixmap->fill(TQColor(0, 0x0)); - m_Hash = 0; - slotChangeDesktop(0); -} -#endif - -#include "bgmanager.moc" diff --git a/kdesktop/bgmanager.cpp b/kdesktop/bgmanager.cpp new file mode 100644 index 000000000..7e90e8fca --- /dev/null +++ b/kdesktop/bgmanager.cpp @@ -0,0 +1,1109 @@ +/* + * + * This file is part of the KDE project, module kdesktop. + * Copyright (C) 1999,2000 Geert Jansen + * + * You can Freely distribute this program under the GNU General Public + * License. See the file "COPYING" for the exact licensing terms. + */ + +#include +#include "bgrender.h" +#include "bgmanager.h" +#include "bgdefaults.h" +#include "kdesktopsettings.h" +#include "bgsettings.h" +#include "kdesktopapp.h" + +#include "KCrossBGRender.h" +#include "crossfade.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifndef None +#define None 0L +#endif + +#ifdef COMPOSITE +# include +# include +# include +#endif + +#include "pixmapserver.h" + +template class TQPtrVector; +template class TQPtrVector; +template class TQMemArray; + +static Atom prop_root; +static bool properties_inited = false; + +extern bool argb_visual; +extern KDesktopApp *myApp; + +/**** KBackgroundManager ****/ + +KBackgroundManager::KBackgroundManager(TQWidget *desktop, KWinModule* twinModule) + : KBackgroundIface() +{ + if( !properties_inited ) + { + prop_root = XInternAtom(tqt_xdisplay(), "_XROOTPMAP_ID", False); + properties_inited = true; + } + m_bBgInitDone = false; + m_bEnabled = true; + + m_pDesktop = desktop; + if (desktop == 0L) + desktop = TQT_TQWIDGET(TDEApplication::desktop()->screen()); + + m_Renderer.resize( 1 ); + m_Cache.resize( 1 ); + + m_Serial = 0; m_Hash = 0; + m_pConfig = TDEGlobal::config(); + m_bExport = m_bCommon = m_bInit = false; + m_pKwinmodule = twinModule; + m_pPixmapServer = new KPixmapServer(); + m_xrootpmap = None; + + for (unsigned i=0; ipixmap = 0L; + m_Cache[i]->hash = 0; + m_Cache[i]->exp_from = -1; + m_Renderer.insert (i, new KVirtualBGRenderer(i,m_pConfig)); + connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); + m_Renderer[i]->enableTiling( true ); // optimize + } + +#ifdef COMPOSITE + m_tPixmap = new KPixmap(kapp->desktop()->size()); + m_tPixmap->fill(TQColor(0, 0x0)); + connect(myApp, TQT_SIGNAL(cmBackgroundChanged( bool )), + TQT_SLOT(slotCmBackgroundChanged( bool ))); +#endif + + configure(); + + m_pTimer = new TQTimer(this); + connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout())); + m_pTimer->start( 60000 ); + + /*CrossFade's config*/ + m_crossTimer = new TQTimer(this); + connect(m_crossTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotCrossFadeTimeout())); + resizingDesktop = true; + /*Ends here*/ + + + connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopChanged(int)), + TQT_SLOT(slotChangeDesktop(int))); + connect(m_pKwinmodule, TQT_SIGNAL(numberOfDesktopsChanged(int)), + TQT_SLOT(slotChangeNumberOfDesktops(int))); + connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopViewportChanged(int, const TQPoint&)), + TQT_SLOT(slotChangeViewport(int, const TQPoint&))); + + +#if (TQT_VERSION-0 >= 0x030200) + connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); // RANDR support +#endif + + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { + renderBackground(j); + } +} + + +KBackgroundManager::~KBackgroundManager() +{ + for (unsigned i=0; ipixmap; + delete m_Cache[i]; + } +} + + +void KBackgroundManager::applyExport(bool exp) +{ + if (exp == m_bExport) + return; + + // If export mode changed from true -> false, remove all shared pixmaps. + // If it changed false -> true force a redraw because the current screen + // image might not have an associated pixmap in the cache. + if (!exp) + { + for (unsigned i=0; i true, remove all cache entries, except + // at index 0 if exports are on. + if (m_bCommon) + { + if (!m_bExport) + removeCache(0); + for (unsigned i=1; ireparseConfiguration(); + KDesktopSettings::self()->readConfig(); + + // Read individual settings + KVirtualBGRenderer *r; + for (unsigned i=0; ihash(); + r->load(i,false); + if ((r->hash() != ohash)) + removeCache(i); + } + + applyCommon(KDesktopSettings::commonDesktop()); + + bool limit = KDesktopSettings::limitCache(); + int size = KDesktopSettings::cacheSize() * 1024; + applyCache(limit, size); + + // Repaint desktop + slotChangeDesktop(0); + + // Redraw all desktops so that applications relying on exported data, e.g. kpager, continue to work properly + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { + renderBackground(j); + } +} + + +int KBackgroundManager::realDesktop() +{ + int desk = m_pKwinmodule->currentDesktop(); + if (desk) desk--; + return desk; +} + + +int KBackgroundManager::effectiveDesktop() +{ + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + + if (m_numberOfViewports > 1) { + if (m_bCommon) { + return 0; + } + else { + TQPoint vx(m_pKwinmodule->currentViewport(m_pKwinmodule->currentDesktop())); + return (realDesktop() * m_numberOfViewports) + ((vx.x() * vx.y()) - 1); + } + } + else { + return m_bCommon ? 0 : realDesktop(); + } +} + + +/* + * Number of desktops changed + */ +void KBackgroundManager::slotChangeNumberOfDesktops(int num) +{ + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + num = (num * m_numberOfViewports); + + if (m_Renderer.size() == (unsigned) num) + return; + + if (m_Renderer.size() > (unsigned) num) + { + for (unsigned i=num; iisActive()) + m_Renderer[i]->stop(); + delete m_Renderer[i]; + removeCache(i); + } + for (unsigned i=num; ipixmap = 0L; + m_Cache[i]->hash = 0; + m_Cache[i]->exp_from = -1; + m_Renderer.insert(i, new KVirtualBGRenderer(i,m_pConfig)); + connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); + m_Renderer[i]->enableTiling( true ); // optimize + } + } +} + +/* + * Call this when the desktop has been changed. + * Desk is in KWin convention: [1..desks], instead of [0..desks-1]. + * 0 repaints the current desktop. + */ +void KBackgroundManager::slotChangeDesktop(int desk) +{ + resizingDesktop = true; + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + + if (desk == 0) + desk = realDesktop(); + else + desk--; + + // Lazy initialisation of # of desktops + if ((unsigned)(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size()) + slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports); + + int edesk = effectiveDesktop(); + m_Serial++; + + // If the background is the same: do nothing + if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0)) + { + exportBackground(m_Current, desk); + return; + } + m_Renderer[edesk]->stop(); + m_Renderer[edesk]->cleanup(); + + // If we have the background already rendered: set it + for (unsigned i=0; ipixmap) + continue; + if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) + continue; + if (desk == 0) + continue; +// kdDebug() << "slotChangeDesktop i=" << i << endl; + setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); + m_Cache[i]->atime = m_Serial; + exportBackground(i, desk); + return; + } + + // Do we have this or an identical config already running? + for (unsigned i=0; ihash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0)) { + return; + } + } + + renderBackground(edesk); +} + +/* + * Call this when the viewport has been changed. + * Desk is in KWin convention: [1..desks], instead of [0..desks-1]. + * 0 repaints the current viewport. + */ +void KBackgroundManager::slotChangeViewport(int desk, const TQPoint& viewport) +{ + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + + if (desk == 0) + desk = realDesktop(); + else + desk--; + + // Lazy initialisation of # of desktops + if ((unsigned)(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size()) + slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports ); + + int edesk = effectiveDesktop(); + m_Serial++; + + // If the background is the same: do nothing + if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0)) + { + exportBackground(m_Current, desk); + return; + } + m_Renderer[edesk]->stop(); + m_Renderer[edesk]->cleanup(); + + // If we have the background already rendered: set it + for (unsigned i=0; ipixmap) + continue; + if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) + continue; + if (desk == 0) + continue; +// kdDebug() << "slotChangeDesktop i=" << i << endl; + + //KPixmap * viewport_background = new KPixmap(TQPixmap(m_Cache[i]->pixmap->width()*s.width(), m_Cache[i]->pixmap->height()*s.height())); + //setPixmap(viewport_background, m_Cache[i]->hash, i); + //delete viewport_background; + + setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); + m_Cache[i]->atime = m_Serial; + exportBackground(i, desk); + return; + } + + // Do we have this or an identical config already running? + for (unsigned i=0; ihash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0)) + return; + } + + renderBackground(edesk); +} + + +/* + * Share a desktop pixmap. + */ +void KBackgroundManager::exportBackground(int pixmap, int desk) +{ + if (!m_bExport || (m_Cache[desk]->exp_from == pixmap)) + return; + + m_Cache[desk]->exp_from = pixmap; + m_pPixmapServer->add(KRootPixmap::pixmapName(desk+1), + m_Cache[pixmap]->pixmap); + KIPC::sendMessageAll(KIPC::BackgroundChanged, desk+1); +} + + +/* + * Paint the pixmap to the root window. + */ +void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk) +{ + KPixmap *ep = pm; + +#ifdef COMPOSITE + if (argb_visual && (KDesktopSettings::backgroundOpacity() < 100 + || myApp->cmBackground())) + { + ep = m_tPixmap; + if (KDesktopSettings::backgroundOpacity() > 0 && pm + && !myApp->cmBackground()) + { + XRenderPictFormat *format; + format = XRenderFindStandardFormat (tqt_xdisplay(), PictStandardARGB32); + + XRenderColor fillColor; + + int color = KDesktopSettings::backgroundOpacity() * 0xffff / 100; + fillColor.red = color; + fillColor.green = color; + fillColor.blue = color; + fillColor.alpha = color; + + Picture fill = XRenderCreateSolidFill (tqt_xdisplay(), &fillColor); + Picture src = XRenderCreatePicture(tqt_xdisplay(), pm->handle(), + format, 0, NULL); + Picture dst = XRenderCreatePicture(tqt_xdisplay(), ep->handle(), + format, 0, NULL); + + XRenderComposite (tqt_xdisplay(), PictOpSrc, src, fill, dst, 0, 0, 0, + 0, 0, 0, pm->width(), pm->height()); + + XRenderFreePicture (tqt_xdisplay(), fill); + XRenderFreePicture (tqt_xdisplay(), src); + XRenderFreePicture (tqt_xdisplay(), dst); + } + } +#endif + + if (m_pDesktop) + { + TQScrollView* sv = dynamic_cast( m_pDesktop ); + if ( sv ) { + // Qt eats repaint events in this case :-(( + sv->viewport()->update(); + } + m_pDesktop->setErasePixmap(*ep); + m_pDesktop->repaint(); + static bool root_cleared = false; + if( !root_cleared ) + { // clear the root window pixmap set by tdm + root_cleared = true; + TQTimer::singleShot( 0, this, TQT_SLOT( clearRoot())); + // but make the pixmap visible until m_pDesktop is visible + TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); + TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + } + } + else + { + TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); + TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + } + + // and export it via Esetroot-style for gnome/GTK apps to share in the pretties + Pixmap bgPm = pm->handle(); // fetch the actual X handle to it + //kdDebug() << "Esetroot compat: setting pixmap to " << bgPm << endl; + + // don't set the ESETROOT_PMAP_ID property - that would result in possible XKillClient() + // done on kdesktop + + XChangeProperty(tqt_xdisplay(), tqt_xrootwin(), prop_root, XA_PIXMAP, 32, PropModeReplace, + (unsigned char *) &bgPm, 1); + m_xrootpmap = bgPm; + + m_Hash = hash; + m_Current = desk; +} + +void KBackgroundManager::clearRoot() +{ + TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap( TQPixmap()); + TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); +} + +/* + * Start the render of a desktop background. + */ +void KBackgroundManager::renderBackground(int desk) +{ + KVirtualBGRenderer *r = m_Renderer[desk]; + if (r->isActive()) + { + kdDebug() << "renderer " << desk << " already active" << endl; + return; + } + + r->start(); +} + + +/* + * This slot is called when the Timeout is executed + */ +void KBackgroundManager::slotCrossFadeTimeout() +{ + KVirtualBGRenderer *r = m_Renderer[fadeDesk]; + if (crossInit) { + mBenchmark.start(); + } + + if (mAlpha <= 0.0 || mBenchmark.elapsed() > 300 ) { + mAlpha = 1; + m_crossTimer->stop(); + KPixmap pixm(mNextScreen); + setPixmap(&pixm, r->hash(), fadeDesk); + return; + } + // Reset Timer + mBenchmark.start(); + + TQPixmap dst = crossFade(*mOldScreen, mNextScreen, mAlpha, crossInit); + KPixmap pixm(dst); + setPixmap(&pixm, r->hash(), fadeDesk); + + mAlpha -=0.03; + crossInit = false; +} + + +/* + * This slot is called when a renderer is done. + */ +void KBackgroundManager::slotImageDone(int desk) +{ + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + + KPixmap *pm = new KPixmap(); + KVirtualBGRenderer *r = m_Renderer[desk]; + bool do_cleanup = true; + fadeDesk = desk; + mAlpha = 1.0; + int width,height; + + + *pm = r->pixmap(); + // If current: paint it + bool current = (r->hash() == m_Renderer[effectiveDesktop()]->hash()); + if (current) + { + //START + if (m_Renderer[effectiveDesktop()]->renderer(0)->crossFadeBg() && !m_Renderer[effectiveDesktop()]->renderer(0)->usingCrossXml() && !resizingDesktop) { + int mode = m_Renderer[effectiveDesktop()]->renderer(0)->wallpaperMode(); + width = TQApplication::desktop()->screenGeometry().width(); + height = TQApplication::desktop()->screenGeometry().height(); + + if (mode == KBackgroundSettings::NoWallpaper || mode == KBackgroundSettings::Tiled || mode == KBackgroundSettings::CenterTiled ){ + mNextScreen = TQPixmap(width,height); + TQPainter p (&mNextScreen); + p.drawTiledPixmap(0,0,width,height,*pm); + } else { + mNextScreen = TQPixmap(*pm); + } + + if (m_pDesktop){ + mOldScreen = const_cast( m_pDesktop->backgroundPixmap() ); + }else{ + mOldScreen = const_cast( + TQApplication::desktop()->screen()->backgroundPixmap() ); + } + + //TODO Find a way to discover if CrossFade effect needs to run + if (mOldScreen){ + crossInit = true; + m_crossTimer->start(70); + } else{ + setPixmap(pm, r->hash(), desk); + } + }else{ + setPixmap(pm, r->hash(), desk); + } + //ENDS HERE */ + + if (!m_bBgInitDone) + { + m_bBgInitDone = true; + emit initDone(); + TQTimer::singleShot( 30000, this, TQT_SLOT( saveImages())); + do_cleanup = false; + } + } + if (m_bExport || !m_bCommon) { + addCache(pm, r->hash(), desk); + } + else { + delete pm; + } + + if (current) { + exportBackground(desk, realDesktop()); + } + + if( do_cleanup ) { + r->saveCacheFile(); + r->cleanup(); + } + + resizingDesktop = false; +} + + +void KBackgroundManager::saveImages() +{ + for (unsigned i=0; isaveCacheFile(); + m_Renderer[i]->cleanup(); + } +} + +/* + * Size in bytes of a TQPixmap. For use in the pixmap cache. + */ +int KBackgroundManager::pixmapSize(TQPixmap *pm) +{ + return (pm->width() * pm->height()) * ((pm->depth() + 7) / 8); +} + + +/* + * Total size of the pixmap cache. + */ +int KBackgroundManager::cacheSize() +{ + int total = 0; + for (unsigned i=0; ipixmap) + total += pixmapSize(m_Cache[i]->pixmap); + } + return total; +} + + +/* + * Remove an entry from the pixmap cache. + */ +void KBackgroundManager::removeCache(int desk) +{ + if (m_bExport) + m_pPixmapServer->remove(KRootPixmap::pixmapName(desk+1)); + else + delete m_Cache[desk]->pixmap; + m_Cache[desk]->pixmap = 0L; + m_Cache[desk]->hash = 0; + m_Cache[desk]->exp_from = -1; + m_Cache[desk]->atime = 0; + + // Remove cache entries pointing to the removed entry + for (unsigned i=0; iexp_from == desk) + { + assert(m_bExport); + m_Cache[i]->exp_from = -1; + m_pPixmapServer->remove(KRootPixmap::pixmapName(i+1)); + } + } +} + + +/* + * Try to free up to size bytes from the cache. + */ +bool KBackgroundManager::freeCache(int size) +{ + if (m_bExport || !m_bLimitCache) + return true; + + // If it doesn't fit at all, return now. + if (size > m_CacheLimit) + return false; + + // If cache is too full, purge it (LRU) + while (size+cacheSize() > m_CacheLimit) + { + int j, min; + min = m_Serial+1; j = 0; + for (unsigned i=0; ipixmap && (m_Cache[i]->atime < min)) + { + min = m_Cache[i]->atime; + j = i; + } + } + removeCache(j); + } + return true; +} + + +/* + * Try to add a pixmap to the pixmap cache. We don't use TQPixmapCache here + * because if we're exporting pixmaps, this needs special care. + */ +void KBackgroundManager::addCache(KPixmap *pm, int hash, int desk) +{ + if (m_Cache[desk]->pixmap) + removeCache(desk); + + if (m_bLimitCache && !m_bExport && !freeCache(pixmapSize(pm))) + { + // pixmap does not fit in cache + delete pm; + return; + } + + m_Cache[desk]->pixmap = pm; + m_Cache[desk]->hash = hash; + m_Cache[desk]->atime = m_Serial; + m_Cache[desk]->exp_from = -1; + exportBackground(desk, desk); +} + +/* + * Called every minute to check if we need to rerun a background program. + * or change a wallpaper. + */ +void KBackgroundManager::slotTimeout() +{ + TQMemArray running(m_Renderer.size()); + running.fill(0); + + int NumDesks = m_Renderer.size(); + if (m_bCommon) + NumDesks = 1; + + int edesk = effectiveDesktop(); + + for (int i=0; ineedProgramUpdate()) + { + r->programUpdate(); + change = true; + } + + if (r->needWallpaperChange()) + { + r->changeWallpaper(); + change = true; + } + + if (change && (i == edesk)) + { + running[i] = r->hash(); + r->start(); + } + } +} + +// Return a valid desk number. +int KBackgroundManager::validateDesk(int desk) +{ + if (desk > (int)m_Renderer.size()) + slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() ); + + if ( (desk <= 0) || (desk > (int)m_Renderer.size()) ) + return realDesktop(); + + return desk - 1; +} + +// DCOP exported +// Return current wallpaper for specified desk. +// 0 is for the current visible desktop. +TQString KBackgroundManager::currentWallpaper(int desk) +{ + //TODO Is the behaviour of this function appropriate for multiple screens? + KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0); + + return r->currentWallpaper(); +} + +// DCOP exported +void KBackgroundManager::changeWallpaper() +{ + KVirtualBGRenderer *r = m_Renderer[effectiveDesktop()]; + + r->changeWallpaper(); + slotChangeDesktop(0); +} + +// DCOP exported +void KBackgroundManager::setExport(int _export) +{ +// kdDebug() << "KBackgroundManager enabling exports.\n"; + bool changed = (_export != m_bExport); + applyExport(_export); + if (changed) { + slotChangeDesktop(0); + } +} + +// DCOP exported +void KBackgroundManager::setCommon(int common) +{ + applyCommon(common); + KDesktopSettings::setCommonDesktop( m_bCommon ); + KDesktopSettings::writeConfig(); + slotChangeDesktop(0); +} + +// DCOP exported +void KBackgroundManager::setWallpaper(TQString wallpaper, int mode) +{ + if (mode < 0 || mode >= KBackgroundSettings::lastWallpaperMode) { + kdDebug() << "Invalid background mode " << mode << " passed to " << k_funcinfo << "\n"; + return; + } + + //TODO Is the behaviour of this function appropriate for multiple screens? + for (unsigned i=0; i < m_Renderer[effectiveDesktop()]->numRenderers(); ++i) + { + KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(i); + r->stop(); + r->setWallpaperMode(mode); + r->setMultiWallpaperMode(KBackgroundSettings::NoMulti); + r->setWallpaper(wallpaper); + r->writeSettings(); + } + slotChangeDesktop(0); +} + +void KBackgroundManager::setWallpaper(TQString wallpaper) +{ + //TODO Is the behaviour of this function appropriate for multiple screens? + KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(0); + int mode = r->wallpaperMode(); + if (mode == KBackgroundSettings::NoWallpaper) + mode = KBackgroundSettings::Tiled; + setWallpaper(wallpaper, mode); +} + +// DCOP exported +// Returns the filenames of all wallpaper entries for specified desk +// 0 is for current visible desktop. +TQStringList KBackgroundManager::wallpaperFiles(int desk) +{ + //TODO Is the behaviour of this function appropriate for multiple screens? + KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0); + + return r->wallpaperFiles(); +} + +// DCOP exported +// Returns the list of wallpaper entries (viewable in background slide +// show window) for specified desk. 0 is for current visible desktop. +TQStringList KBackgroundManager::wallpaperList(int desk) +{ + //TODO Is the behaviour of this function appropriate for multiple screens? + KCrossBGRender *r = m_Renderer[validateDesk(desk)]->renderer(0);; + + return r->wallpaperList(); +} + +// DCOP exported +void KBackgroundManager::setCache( int bLimit, int size ) +{ + applyCache( bLimit, size*1024 ); + KDesktopSettings::setLimitCache( (bool) bLimit ); + KDesktopSettings::setCacheSize( size ); + KDesktopSettings::writeConfig(); +} + +// DCOP exported +void KBackgroundManager::setWallpaper(int desk, TQString wallpaper, int mode) +{ + if (mode < 0 || mode >= KBackgroundSettings::lastWallpaperMode) { + kdDebug() << "Invalid background mode " << mode << " passed to " << k_funcinfo << "\n"; + return; + } + + int sdesk = validateDesk(desk); + + //TODO Is the behaviour of this function appropriate for multiple screens? + for (unsigned i=0; i < m_Renderer[sdesk]->numRenderers(); ++i) + { + KCrossBGRender *r = m_Renderer[sdesk]->renderer(i); + + setCommon(false); // Force each desktop to have it's own wallpaper + + r->stop(); + r->setWallpaperMode(mode); + r->setMultiWallpaperMode(KBackgroundSettings::NoMulti); + r->setWallpaper(wallpaper); + r->writeSettings(); + } + slotChangeDesktop(sdesk); +} + +void KBackgroundManager::repaintBackground() +{ + if (m_pDesktop) + m_pDesktop->repaint(); + else + TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); +} + +void KBackgroundManager::desktopResized() +{ + resizingDesktop = true; + for (unsigned i=0; iisActive()) + r->stop(); + removeCache(i); + // make the renderer update its desktop size + r->desktopResized(); + for (unsigned j=0; j<(r->numRenderers()); ++j) { + r->renderer(j)->desktopResized(); + } + } + +#ifdef COMPOSITE + if (m_tPixmap) + delete m_tPixmap; + m_tPixmap = new KPixmap(kapp->desktop()->size()); + m_tPixmap->fill(TQColor(0, 0x0)); +#endif + + m_Hash = 0; + if( m_pDesktop ) { + m_pDesktop->resize( kapp->desktop()->geometry().size()); + if (m_Renderer[effectiveDesktop()]->renderer(0)->usingCrossXml()){ + m_Renderer[effectiveDesktop()]->renderer(0)->changeWallpaper(); + } + } + // Repaint desktop + slotChangeDesktop(0); + repaintBackground(); + + // Redraw all desktops so that applications relying on exported data, e.g. kpager, continue to work properly + TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); + m_numberOfViewports = s.width() * s.height(); + if (m_numberOfViewports < 1) { + m_numberOfViewports = 1; + } + for (signed j=0;j<(m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);j++) { + renderBackground(j); + } +} + +// DCOP exported +void KBackgroundManager::setColor(const TQColor & c, bool isColorA) +{ + //TODO Is the behaviour of this function appropriate for multiple screens? + for (unsigned i=0; i < m_Renderer[effectiveDesktop()]->numRenderers(); ++i) + { + KCrossBGRender *r = m_Renderer[effectiveDesktop()]->renderer(i); + r->stop(); + + if (isColorA) + r->setColorA(c); + else + r->setColorB(c); + + int mode = r->backgroundMode(); + if (mode == KBackgroundSettings::Program) + mode = KBackgroundSettings::Flat; + + if (!isColorA && (mode == KBackgroundSettings::Flat)) + mode = KBackgroundSettings::VerticalGradient; + r->setBackgroundMode(mode); + + r->writeSettings(); + } + slotChangeDesktop(0); +} + +void KBackgroundManager::setBackgroundEnabled( const bool enable ) +{ + if (m_bEnabled == enable) + return; + + m_bEnabled= enable; + + int NumDesks = m_Renderer.size(); + if (m_bCommon) + NumDesks = 1; + + for (int i=0; isetEnabled(enable); + } + slotChangeDesktop(0); +} + +#ifdef COMPOSITE +void KBackgroundManager::slotCmBackgroundChanged( bool ) +{ + m_tPixmap->fill(TQColor(0, 0x0)); + m_Hash = 0; + slotChangeDesktop(0); +} +#endif + +#include "bgmanager.moc" diff --git a/kdesktop/desktop.cc b/kdesktop/desktop.cc deleted file mode 100644 index 2732bff08..000000000 --- a/kdesktop/desktop.cc +++ /dev/null @@ -1,1197 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include "desktop.h" -#include "krootwm.h" -#include "bgmanager.h" -#include "bgsettings.h" -#include "startupid.h" -#include "kdiconview.h" -#include "minicli.h" -#include "kdesktopsettings.h" -#include "tdelaunchsettings.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// Create the equivalent of TDEAccelBase::connectItem -// and then remove this include and fix reconnects in initRoot() -- ellis -//#include - -extern int kdesktop_screen_number; -extern TQCString kdesktop_name, kicker_name, twin_name; - -KRootWidget::KRootWidget() : TQObject() -{ - kapp->desktop()->installEventFilter(this); - kapp->desktop()->setAcceptDrops( true ); -} - -bool KRootWidget::eventFilter ( TQObject *, TQEvent * e ) -{ - if (e->type() == TQEvent::MouseButtonPress) - { - TQMouseEvent *me = TQT_TQMOUSEEVENT(e); - KRootWm::self()->mousePressed( me->globalPos(), me->button() ); - return true; - } - else if (e->type() == TQEvent::Wheel) - { - TQWheelEvent *we = TQT_TQWHEELEVENT(e); - emit wheelRolled(we->delta()); - return true; - } - else if ( e->type() == TQEvent::DragEnter ) - { - TQDragEnterEvent* de = static_cast( e ); - bool b = !TDEGlobal::config()->isImmutable() && !TDEGlobal::dirs()->isRestrictedResource( "wallpaper" ); - - bool imageURL = false; - if ( KURLDrag::canDecode( de ) ) - { - KURL::List list; - KURLDrag::decode( de, list ); - KURL url = list.first(); - KMimeType::Ptr mime = KMimeType::findByURL( url ); - if ( !KImageIO::type( url.path() ).isEmpty() || - KImageIO::isSupported( mime->name(), KImageIO::Reading ) || mime->is( "image/svg+xml" ) ) - imageURL = true; - } - - b = b && ( KColorDrag::canDecode( de ) || TQImageDrag::canDecode( de ) || imageURL ); - de->accept( b ); - return true; - } - else if ( e->type() == TQEvent::Drop ) - { - TQDropEvent* de = static_cast( e ); - if ( KColorDrag::canDecode( de ) ) - emit colorDropEvent( de ); - else if ( TQImageDrag::canDecode( de ) ) - emit imageDropEvent( de ); - else if ( KURLDrag::canDecode( de ) ) { - KURL::List list; - KURLDrag::decode( de, list ); - KURL url = list.first(); - emit newWallpaper( url ); - } - return true; - } - return false; // Don't filter. -} - -// ----------------------------------------------------------------------------- -#define DEFAULT_DELETEACTION 1 - -KDesktop::WheelDirection KDesktop::m_eWheelDirection = KDesktop::m_eDefaultWheelDirection; -const char* KDesktop::m_wheelDirectionStrings[2] = { "Forward", "Reverse" }; - -KDesktop::KDesktop( SaverEngine* saver, bool x_root_hack, bool wait_for_kded ) : - TQWidget( 0L, "desktop", (WFlags)(WResizeNoErase | ( x_root_hack ? (WStyle_Customize | WStyle_NoBorder) : 0)) ), - KDesktopIface(), - // those two WStyle_ break kdesktop when the root-hack isn't used (no Dnd) - startup_id( NULL ), m_waitForKicker(0) -{ - m_pSaver = saver; - - NETRootInfo i( tqt_xdisplay(), NET::Supported ); - m_wmSupport = i.isSupported( NET::WM2ShowingDesktop ); - - m_bWaitForKded = wait_for_kded; - m_miniCli = 0; // created on demand - keys = 0; // created later - TDEGlobal::locale()->insertCatalogue("kdesktop"); - TDEGlobal::locale()->insertCatalogue("libkonq"); // needed for apps using libkonq - TDEGlobal::locale()->insertCatalogue("libdmctl"); - - setCaption( "KDE Desktop"); - - setAcceptDrops(true); // WStyle_Customize seems to disable that - m_pKwinmodule = new KWinModule( TQT_TQOBJECT(this) ); - - kapp->dcopClient()->setNotifications(true); - kapp->dcopClient()->connectDCOPSignal(kicker_name, kicker_name, "desktopIconsAreaChanged(TQRect, int)", - "KDesktopIface", "desktopIconsAreaChanged(TQRect, int)", false); - - // Dont repaint on configuration changes during construction - m_bInit = true; - - // It's the child widget that gets the focus, not us - setFocusPolicy( TQ_NoFocus ); - - if ( x_root_hack ) - { - // this is a ugly hack to make Dnd work - // Matthias told me that it won't be necessary with twin - // actually my first try with ICCCM (Dirk) :-) - unsigned long data[2]; - data[0] = (unsigned long) 1; - data[1] = (unsigned long) 0; // None; (Werner) - Atom wm_state = XInternAtom(tqt_xdisplay(), "WM_STATE", False); - XChangeProperty(tqt_xdisplay(), winId(), wm_state, wm_state, 32, - PropModeReplace, (unsigned char *)data, 2); - - } - - setGeometry( TQApplication::desktop()->geometry() ); - lower(); - - connect( kapp, TQT_SIGNAL( shutDown() ), - this, TQT_SLOT( slotShutdown() ) ); - - connect(kapp, TQT_SIGNAL(settingsChanged(int)), - this, TQT_SLOT(slotSettingsChanged(int))); - kapp->addKipcEventMask(KIPC::SettingsChanged); - - kapp->addKipcEventMask(KIPC::IconChanged); - connect(kapp, TQT_SIGNAL(iconChanged(int)), this, TQT_SLOT(slotIconChanged(int))); - - connect(KSycoca::self(), TQT_SIGNAL(databaseChanged()), - this, TQT_SLOT(slotDatabaseChanged())); - - m_pIconView = 0; - m_pRootWidget = 0; - bgMgr = 0; - initRoot(); - - TQTimer::singleShot(0, this, TQT_SLOT( slotStart() )); - -#if (TQT_VERSION-0 >= 0x030200) // XRANDR support - connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); -#endif -} - -void -KDesktop::initRoot() -{ - Display *dpy = tqt_xdisplay(); - Window root = RootWindow(dpy, kdesktop_screen_number); - XDefineCursor(dpy, root, cursor().handle()); - - m_bDesktopEnabled = KDesktopSettings::desktopEnabled(); - if ( !m_bDesktopEnabled && !m_pRootWidget ) - { - hide(); - delete bgMgr; - bgMgr = 0; - if ( m_pIconView ) - m_pIconView->saveIconPositions(); - delete m_pIconView; - m_pIconView = 0; - - { // trigger creation of QToolTipManager, it does XSelectInput() on the root window - TQWidget w; - TQToolTip::add( &w, "foo" ); - } - // NOTE: If mouse clicks stop working again, it's most probably something doing XSelectInput() - // on the root window after this, and setting it to some fixed value instead of adding its mask. - XWindowAttributes attrs; - XGetWindowAttributes(dpy, root, &attrs); - XSelectInput(dpy, root, attrs.your_event_mask | ButtonPressMask); - - m_pRootWidget = new KRootWidget; - connect(m_pRootWidget, TQT_SIGNAL(wheelRolled(int)), this, TQT_SLOT(slotSwitchDesktops(int))); - connect(m_pRootWidget, TQT_SIGNAL(colorDropEvent(TQDropEvent*)), this, TQT_SLOT(handleColorDropEvent(TQDropEvent*)) ); - connect(m_pRootWidget, TQT_SIGNAL(imageDropEvent(TQDropEvent*)), this, TQT_SLOT(handleImageDropEvent(TQDropEvent*)) ); - connect(m_pRootWidget, TQT_SIGNAL(newWallpaper(const KURL&)), this, TQT_SLOT(slotNewWallpaper(const KURL&)) ); - - // Geert Jansen: backgroundmanager belongs here - // TODO tell KBackgroundManager if we change widget() - bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); - bgMgr->setExport(1); - connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); - if (!m_bInit) - { - delete KRootWm::self(); - KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) - keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); - keys->updateConnections(); - } - } - else if (m_bDesktopEnabled && !m_pIconView) - { - delete bgMgr; - bgMgr = 0; - delete m_pRootWidget; - m_pRootWidget = 0; - m_pIconView = new KDIconView( this, 0 ); - connect( m_pIconView, TQT_SIGNAL( imageDropEvent( TQDropEvent * ) ), - this, TQT_SLOT( handleImageDropEvent( TQDropEvent * ) ) ); - connect( m_pIconView, TQT_SIGNAL( colorDropEvent( TQDropEvent * ) ), - this, TQT_SLOT( handleColorDropEvent( TQDropEvent * ) ) ); - connect( m_pIconView, TQT_SIGNAL( newWallpaper( const KURL & ) ), - this, TQT_SLOT( slotNewWallpaper( const KURL & ) ) ); - connect( m_pIconView, TQT_SIGNAL( wheelRolled( int ) ), - this, TQT_SLOT( slotSwitchDesktops( int ) ) ); - - // All the QScrollView/QWidget-specific stuff should go here, so that we can use - // another qscrollview/widget instead of the iconview and use the same code - m_pIconView->setVScrollBarMode( TQScrollView::AlwaysOff ); - m_pIconView->setHScrollBarMode( TQScrollView::AlwaysOff ); - m_pIconView->setDragAutoScroll( false ); - m_pIconView->setFrameStyle( TQFrame::NoFrame ); - m_pIconView->viewport()->setBackgroundMode( X11ParentRelative ); - m_pIconView->setFocusPolicy( TQ_StrongFocus ); - m_pIconView->viewport()->setFocusPolicy( TQ_StrongFocus ); - m_pIconView->setGeometry( geometry() ); - m_pIconView->show(); - - // Geert Jansen: backgroundmanager belongs here - // TODO tell KBackgroundManager if we change widget() - bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); - bgMgr->setExport(1); - connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); - - // make sure it is initialized before we first call updateWorkArea() - m_pIconView->initConfig( m_bInit ); - - // set the size of the area for desktop icons placement - { - TQByteArray data, result; - TQDataStream arg(data, IO_WriteOnly); - arg << kdesktop_screen_number; - TQCString replyType; - TQRect area; - - if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", - data, replyType, result, false, 2000) ) - { - TQDataStream res(result, IO_ReadOnly); - res >> area; - - m_pIconView->updateWorkArea(area); - } - else - if ( m_bInit ) - { - // if we failed to get the information from kicker wait a little - probably - // this is the KDE startup and kicker is simply not running yet - m_waitForKicker = new TQTimer(this); - connect(m_waitForKicker, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotNoKicker())); - m_waitForKicker->start(15000, true); - } - else // we are not called from the ctor, so kicker should already run - { - area = twinModule()->workArea(twinModule()->currentDesktop()); - m_pIconView->updateWorkArea(area); - } - } - - if (!m_bInit) - { - m_pIconView->start(); - delete KRootWm::self(); - KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) - keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); - keys->updateConnections(); - } - } else { - DCOPRef r( "ksmserver", "ksmserver" ); - r.send( "resumeStartup", TQCString( "kdesktop" )); - } - - KWin::setType( winId(), NET::Desktop ); - KWin::setState( winId(), NET::SkipPager ); - KWin::setOnAllDesktops( winId(), true ); -} - -void KDesktop::slotNoKicker() -{ - kdDebug(1204) << "KDesktop::slotNoKicker ... kicker did not respond" << endl; - // up till now, we got no desktopIconsArea from kicker - probably - // it's not running, so use the area from KWinModule - TQRect area = twinModule()->workArea(twinModule()->currentDesktop()); - m_pIconView->updateWorkArea(area); -} - -void -KDesktop::backgroundInitDone() -{ - //kdDebug(1204) << "KDesktop::backgroundInitDone" << endl; - // avoid flicker - if (m_bDesktopEnabled) - { - const TQPixmap *bg = TQT_TQWIDGET(TQApplication::desktop()->screen())->backgroundPixmap(); - if ( bg ) - m_pIconView->setErasePixmap( *bg ); - - show(); - kapp->sendPostedEvents(); - } - - DCOPRef r( "ksmserver", "ksmserver" ); - r.send( "resumeStartup", TQCString( "kdesktop" )); -} - -void -KDesktop::slotStart() -{ - //kdDebug(1204) << "KDesktop::slotStart" << endl; - if (!m_bInit) return; - - // In case we started without database - KImageIO::registerFormats(); - - initConfig(); - -// if (m_bDesktopEnabled) -// { -// // We need to be visible in order to insert icons, even if the background isn't ready yet... - -// show(); -// } - - // Now we may react to configuration changes - m_bInit = false; - - if (m_pIconView) - m_pIconView->start(); - - // Global keys - keys = new TDEGlobalAccel( TQT_TQOBJECT(this) ); - (void) new KRootWm( m_pSaver, this ); - -#include "kdesktopbindings.cpp" - - keys->readSettings(); - keys->updateConnections(); - - connect(kapp, TQT_SIGNAL(appearanceChanged()), TQT_SLOT(slotConfigure())); - - TQTimer::singleShot(300, this, TQT_SLOT( slotUpAndRunning() )); -} - -void -KDesktop::runAutoStart() -{ - // now let's execute all the stuff in the autostart folder. - // the stuff will actually be really executed when the event loop is - // entered, since KRun internally uses a QTimer - TQDir dir( TDEGlobalSettings::autostartPath() ); - TQStringList entries = dir.entryList( TQDir::Files ); - TQStringList::Iterator it = entries.begin(); - TQStringList::Iterator end = entries.end(); - for (; it != end; ++it ) - { - // Don't execute backup files - if ( (*it).right(1) != "~" && (*it).right(4) != ".bak" && - ( (*it)[0] != '%' || (*it).right(1) != "%" ) && - ( (*it)[0] != '#' || (*it).right(1) != "#" ) ) - { - KURL url; - url.setPath( dir.absPath() + '/' + (*it) ); - (void) new KRun( url, 0, true ); - } - } -} - -// ----------------------------------------------------------------------------- - -KDesktop::~KDesktop() -{ - delete m_miniCli; - m_miniCli = 0; // see #120382 - delete bgMgr; - bgMgr = 0; - delete startup_id; -} - -// ----------------------------------------------------------------------------- - -void KDesktop::initConfig() -{ - if (m_pIconView) - m_pIconView->initConfig( m_bInit ); - - if ( keys ) - { - keys->readSettings(); - keys->updateConnections(); - } - - TDELaunchSettings::self()->readConfig(); - if( !TDELaunchSettings::busyCursor() ) - { - delete startup_id; - startup_id = NULL; - } - else - { - if( startup_id == NULL ) - startup_id = new StartupId; - startup_id->configure(); - } - - set_vroot = KDesktopSettings::setVRoot(); - slotSetVRoot(); // start timer - - m_bWheelSwitchesWorkspace = KDesktopSettings::wheelSwitchesWorkspace(); - - const char* forward_string = m_wheelDirectionStrings[Forward]; - m_eWheelDirection = - (KDesktopSettings::wheelDirection() == forward_string) ? Forward : Reverse; -} - -// ----------------------------------------------------------------------------- - -void KDesktop::slotExecuteCommand() -{ - // this function needs to be duplicated since it appears that one - // cannot have a 'slot' be a DCOP method. if this changes in the - // future, then 'slotExecuteCommand' and 'popupExecuteCommand' can - // merge into one slot. - popupExecuteCommand(); -} - -/* - Shows minicli - */ -void KDesktop::popupExecuteCommand() -{ - popupExecuteCommand(""); -} - -void KDesktop::popupExecuteCommand(const TQString& command) -{ - if (m_bInit) - return; - - if (!kapp->authorize("run_command")) - return; - - // Created on demand - if ( !m_miniCli ) - { - m_miniCli = new Minicli( this ); - m_miniCli->adjustSize(); // for the centering below - } - - if (!command.isEmpty()) - m_miniCli->setCommand(command); - - // Move minicli to the current desktop - NETWinInfo info( tqt_xdisplay(), m_miniCli->winId(), tqt_xrootwin(), NET::WMDesktop ); - int currentDesktop = twinModule()->currentDesktop(); - if ( info.desktop() != currentDesktop ) - info.setDesktop( currentDesktop ); - - if ( m_miniCli->isVisible() ) { - KWin::forceActiveWindow( m_miniCli->winId() ); - } else { - NETRootInfo i( tqt_xdisplay(), NET::Supported ); - if( !i.isSupported( NET::WM2FullPlacement )) { - TQRect rect = TDEGlobalSettings::desktopGeometry(TQCursor::pos()); - m_miniCli->move(rect.x() + (rect.width() - m_miniCli->width())/2, - rect.y() + (rect.height() - m_miniCli->height())/2); - } - m_miniCli->show(); // non-modal - } -} - -void KDesktop::slotSwitchUser() -{ - KRootWm::self()->slotSwitchUser(); -} - -void KDesktop::slotShowWindowList() -{ - KRootWm::self()->slotWindowList(); -} - -void KDesktop::slotShowTaskManager() -{ - //kdDebug(1204) << "Launching KSysGuard..." << endl; - TDEProcess* p = new TDEProcess; - TQ_CHECK_PTR(p); - - *p << "ksysguard"; - *p << "--showprocesses"; - - p->start(TDEProcess::DontCare); - - delete p; -} - -// ----------------------------------------------------------------------------- - -void KDesktop::rearrangeIcons() -{ - if (m_pIconView) - m_pIconView->rearrangeIcons(); -} - -void KDesktop::lineupIcons() -{ - if (m_pIconView) - m_pIconView->lineupIcons(); -} - -void KDesktop::selectAll() -{ - if (m_pIconView) - m_pIconView->selectAll( true ); -} - -void KDesktop::unselectAll() -{ - if (m_pIconView) - m_pIconView->selectAll( false ); -} - -TQStringList KDesktop::selectedURLs() -{ - if (m_pIconView) - return m_pIconView->selectedURLs(); - return TQStringList(); -} - -void KDesktop::refreshIcons() -{ - if (m_pIconView) - m_pIconView->refreshIcons(); -} - -void KDesktop::setShowDesktop( bool b ) -{ - bool m_showingDesktop = showDesktopState(); - - if (b == m_showingDesktop) - { - return; - } - - if( m_wmSupport ) - { - NETRootInfo i( tqt_xdisplay(), 0 ); - i.setShowingDesktop( b ); - return; - } - - if (b) - { - m_activeWindow = twinModule()->activeWindow(); - m_iconifiedList.clear(); - - const TQValueList windows = twinModule()->windows(); - for (TQValueList::ConstIterator it = windows.begin(); - it != windows.end(); - ++it) - { - WId w = *it; - - NETWinInfo info( tqt_xdisplay(), w, tqt_xrootwin(), - NET::XAWMState | NET::WMDesktop ); - - if (info.mappingState() == NET::Visible && - (info.desktop() == NETWinInfo::OnAllDesktops || - info.desktop() == (int)twinModule()->currentDesktop())) - { - m_iconifiedList.append( w ); - } - } - - // find first, hide later, otherwise transients may get minimized - // with the window they're transient for - for (TQValueVector::Iterator it = m_iconifiedList.begin(); - it != m_iconifiedList.end(); - ++it) - { - KWin::iconifyWindow( *it, false ); - } - - // on desktop changes or when a window is deiconified, we abort the show desktop mode - connect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), - TQT_SLOT(slotCurrentDesktopChanged(int))); - connect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), - TQT_SLOT(slotWindowChanged(WId,unsigned int))); - connect(twinModule(), TQT_SIGNAL(windowAdded(WId)), - TQT_SLOT(slotWindowAdded(WId))); - } - else - { - disconnect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), - this, TQT_SLOT(slotCurrentDesktopChanged(int))); - disconnect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), - this, TQT_SLOT(slotWindowChanged(WId,unsigned int))); - disconnect(twinModule(), TQT_SIGNAL(windowAdded(WId)), - this, TQT_SLOT(slotWindowAdded(WId))); - - for (TQValueVector::ConstIterator it = m_iconifiedList.begin(); - it != m_iconifiedList.end(); - ++it) - { - KWin::deIconifyWindow(*it, false); - } - - KWin::forceActiveWindow(m_activeWindow); - } - - m_showingDesktop = b; - emit desktopShown(m_showingDesktop); -} - -void KDesktop::slotCurrentDesktopChanged(int) -{ - setShowDesktop( false ); -} - -void KDesktop::slotWindowAdded(WId w) -{ - bool m_showingDesktop = showDesktopState(); - - if (!m_showingDesktop) - { - return; - } - - NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(), - NET::XAWMState | NET::WMWindowType); - NET::WindowType windowType = inf.windowType(NET::AllTypesMask); - - if ((windowType == NET::Normal || windowType == NET::Unknown) && - inf.mappingState() == NET::Visible) - { - TDEConfig twincfg( "twinrc", true ); // see in twin - twincfg.setGroup( "Windows" ); - if( twincfg.readBoolEntry( "ShowDesktopIsMinimizeAll", false )) - { - m_iconifiedList.clear(); - m_showingDesktop = false; - emit desktopShown(false); - } - else - { - m_activeWindow = w; - setShowDesktop(false); - } - } -} - -void KDesktop::slotWindowChanged(WId w, unsigned int dirty) -{ - bool m_showingDesktop = showDesktopState(); - - if (!m_showingDesktop) - { - return; - } - - if (dirty & NET::XAWMState) - { - NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(), - NET::XAWMState | NET::WMWindowType); - NET::WindowType windowType = inf.windowType(NET::AllTypesMask); - - if ((windowType == NET::Normal || windowType == NET::Unknown) && - inf.mappingState() == NET::Visible) - { - // a window was deiconified, abort the show desktop mode. - m_iconifiedList.clear(); - m_showingDesktop = false; - emit desktopShown(false); - } - } -} - -bool KDesktop::showDesktopState() -{ - return twinModule()->showingDesktop(); -} - -void KDesktop::toggleShowDesktop() -{ - setShowDesktop(!showDesktopState()); -} - -TDEActionCollection * KDesktop::actionCollection() -{ - if (!m_pIconView) - return 0; - return m_pIconView->actionCollection(); -} - -KURL KDesktop::url() const -{ - if (m_pIconView) - return m_pIconView->url(); - return KURL(); -} - -// ----------------------------------------------------------------------------- - -void KDesktop::slotConfigure() -{ - configure(); -} - -void KDesktop::configure() -{ - // re-read configuration and apply it - TDEGlobal::config()->reparseConfiguration(); - KDesktopSettings::self()->readConfig(); - - // If we have done start() already, then re-configure. - // Otherwise, start() will call initConfig anyway - if (!m_bInit) - { - initRoot(); - initConfig(); - KRootWm::self()->initConfig(); - } - - if (keys) - { - keys->readSettings(); - keys->updateConnections(); - } -} - -void KDesktop::slotSettingsChanged(int category) -{ - //kdDebug(1204) << "KDesktop::slotSettingsChanged" << endl; - if (category == TDEApplication::SETTINGS_PATHS) - { - kdDebug(1204) << "KDesktop::slotSettingsChanged SETTINGS_PATHS" << endl; - if (m_pIconView) - m_pIconView->recheckDesktopURL(); - } - else if (category == TDEApplication::SETTINGS_SHORTCUTS) - { - kdDebug(1204) << "KDesktop::slotSettingsChanged SETTINGS_SHORTCUTS" << endl; - keys->readSettings(); - keys->updateConnections(); - } -} - -void KDesktop::slotIconChanged(int group) -{ - if ( group == TDEIcon::Desktop ) - { - kdDebug(1204) << "KDesktop::slotIconChanged" << endl; - refresh(); - } -} - -void KDesktop::slotDatabaseChanged() -{ - //kdDebug(1204) << "KDesktop::slotDatabaseChanged" << endl; - if (m_bInit) // kded is done, now we can "start" for real - slotStart(); - if (m_pIconView && KSycoca::isChanged("mimetypes")) - m_pIconView->refreshMimeTypes(); -} - -void KDesktop::refresh() -{ - // George Staikos 3/14/01 - // This bit will just refresh the desktop and icons. Now I have code - // in KWin to do a complete refresh so this isn't really needed. - // I'll leave it in here incase the plan is changed again -#if 0 - m_bNeedRepaint |= 1; - updateWorkArea(); -#endif - kapp->dcopClient()->send( twin_name, "", "refresh()", TQString("")); - refreshIcons(); -} - -// ----------------------------------------------------------------------------- - -void KDesktop::slotSetVRoot() -{ - if (!m_pIconView) - return; - - if (KWin::windowInfo(winId()).mappingState() == NET::Withdrawn) { - TQTimer::singleShot(100, this, TQT_SLOT(slotSetVRoot())); - return; - } - - unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); - unsigned long vroot_data[1] = { m_pIconView->viewport()->winId() }; - static Atom vroot = XInternAtom(tqt_xdisplay(), "__SWM_VROOT", False); - - Window rootReturn, parentReturn, *children; - unsigned int numChildren; - Window top = winId(); - while (1) { - /*int ret = */XQueryTree(tqt_xdisplay(), top , &rootReturn, &parentReturn, - &children, &numChildren); - if (children) - XFree((char *)children); - if (parentReturn == rw) { - break; - } else - top = parentReturn; - } - if ( set_vroot ) - XChangeProperty(tqt_xdisplay(), top, vroot, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)vroot_data, 1); - else - XDeleteProperty (tqt_xdisplay(), top, vroot); -} - -// ----------------------------------------------------------------------------- - -void KDesktop::slotShutdown() -{ - if ( m_pIconView ) - m_pIconView->saveIconPositions(); - if ( m_miniCli ) - m_miniCli->saveConfig(); -} - -// don't hide when someone presses Alt-F4 on us -void KDesktop::closeEvent(TQCloseEvent *e) -{ - e->ignore(); -} - -void KDesktop::desktopIconsAreaChanged(const TQRect &area, int screen) -{ - // hurra! kicker is alive - if ( m_waitForKicker ) m_waitForKicker->stop(); - - // -2: all screens - // -1: primary screen - // else: screen number - - if (screen <= -2) - screen = kdesktop_screen_number; - else if (screen == -1) - screen = kapp->desktop()->primaryScreen(); - - // This is pretty broken, mixes Xinerama and non-Xinerama multihead - // and generally doesn't seem to be required anyway => ignore screen. - if ( /*(screen == kdesktop_screen_number) &&*/ m_pIconView ) { - m_pIconView->updateWorkArea(area); - } -} - -void KDesktop::slotSwitchDesktops(int delta) -{ - if(m_bWheelSwitchesWorkspace && KWin::numberOfDesktops() > 1) - { - int newDesk, curDesk = KWin::currentDesktop(); - - if( (delta < 0 && m_eWheelDirection == Forward) || (delta > 0 && m_eWheelDirection == Reverse) ) - newDesk = curDesk % KWin::numberOfDesktops() + 1; - else - newDesk = ( KWin::numberOfDesktops() + curDesk - 2 ) % KWin::numberOfDesktops() + 1; - - KWin::setCurrentDesktop( newDesk ); - } -} - -void KDesktop::handleColorDropEvent(TQDropEvent * e) -{ - TDEPopupMenu popup; - popup.insertItem(SmallIconSet("colors"),i18n("Set as Primary Background Color"), 1); - popup.insertItem(SmallIconSet("colors"),i18n("Set as Secondary Background Color"), 2); - int result = popup.exec(e->pos()); - - TQColor c; - KColorDrag::decode(e, c); - switch (result) { - case 1: bgMgr->setColor(c, true); break; - case 2: bgMgr->setColor(c, false); break; - default: return; - } - bgMgr->setWallpaper(0,0); -} - -void KDesktop::handleImageDropEvent(TQDropEvent * e) -{ - TDEPopupMenu popup; - if ( m_pIconView ) - popup.insertItem(SmallIconSet("document-save"),i18n("&Save to Desktop..."), 1); - if ( ( m_pIconView && m_pIconView->maySetWallpaper() ) || m_pRootWidget ) - popup.insertItem(SmallIconSet("background"),i18n("Set as &Wallpaper"), 2); - popup.insertSeparator(); - popup.insertItem(SmallIconSet("cancel"), i18n("&Cancel")); - int result = popup.exec(e->pos()); - - if (result == 1) - { - bool ok = true; - TQString filename = KInputDialog::getText(TQString::null, i18n("Enter a name for the image below:"), TQString::null, &ok, m_pIconView); - - if (!ok) - { - return; - } - - if (filename.isEmpty()) - { - filename = i18n("image.png"); - } - else if (filename.right(4).lower() != ".png") - { - filename += ".png"; - } - - TQImage i; - TQImageDrag::decode(e, i); - KTempFile tmpFile(TQString::null, filename); - i.save(tmpFile.name(), "PNG"); - // We pass 0 as parent window because passing the desktop is not a good idea - KURL src; - src.setPath( tmpFile.name() ); - KURL dest( KDIconView::desktopURL() ); - dest.addPath( filename ); - TDEIO::NetAccess::copy( src, dest, 0 ); - tmpFile.unlink(); - } - else if (result == 2) - { - TQImage i; - TQImageDrag::decode(e, i); - KTempFile tmpFile(TDEGlobal::dirs()->saveLocation("wallpaper"), ".png"); - i.save(tmpFile.name(), "PNG"); - kdDebug(1204) << "KDesktop::contentsDropEvent " << tmpFile.name() << endl; - bgMgr->setWallpaper(tmpFile.name()); - } -} - -void KDesktop::slotNewWallpaper(const KURL &url) -{ - // This is called when a file containing an image is dropped - // (called by KonqOperations) - if ( url.isLocalFile() ) - bgMgr->setWallpaper( url.path() ); - else - { - // Figure out extension - TQString fileName = url.fileName(); - TQFileInfo fileInfo( fileName ); - TQString ext = fileInfo.extension(); - // Store tempfile in a place where it will still be available after a reboot - KTempFile tmpFile( TDEGlobal::dirs()->saveLocation("wallpaper"), "." + ext ); - KURL localURL; localURL.setPath( tmpFile.name() ); - // We pass 0 as parent window because passing the desktop is not a good idea - TDEIO::NetAccess::file_copy( url, localURL, -1, true /*overwrite*/ ); - bgMgr->setWallpaper( localURL.path() ); - } -} - -// for dcop interface backward compatibility -void KDesktop::logout() -{ - logout( TDEApplication::ShutdownConfirmDefault, - TDEApplication::ShutdownTypeNone ); -} - -void KDesktop::logout( TDEApplication::ShutdownConfirm confirm, - TDEApplication::ShutdownType sdtype ) -{ - if( !kapp->requestShutDown( confirm, sdtype ) ) - // this i18n string is also in kicker/applets/run/runapplet - KMessageBox::error( this, i18n("Could not log out properly.\nThe session manager cannot " - "be contacted. You can try to force a shutdown by pressing " - "Ctrl+Alt+Backspace; note, however, that your current session " - "will not be saved with a forced shutdown." ) ); -} - -void KDesktop::slotLogout() -{ - logout( TDEApplication::ShutdownConfirmDefault, - TDEApplication::ShutdownTypeDefault ); -} - -void KDesktop::slotLogoutNoCnf() -{ - logout( TDEApplication::ShutdownConfirmNo, - TDEApplication::ShutdownTypeNone ); -} - -void KDesktop::slotHaltNoCnf() -{ - logout( TDEApplication::ShutdownConfirmNo, - TDEApplication::ShutdownTypeHalt ); -} - -void KDesktop::slotRebootNoCnf() -{ - logout( TDEApplication::ShutdownConfirmNo, - TDEApplication::ShutdownTypeReboot ); -} - -void KDesktop::setVRoot( bool enable ) -{ - if ( enable == set_vroot ) - return; - - set_vroot = enable; - kdDebug(1204) << "setVRoot " << enable << endl; - KDesktopSettings::setSetVRoot( set_vroot ); - KDesktopSettings::writeConfig(); - slotSetVRoot(); -} - -void KDesktop::clearCommandHistory() -{ - if ( m_miniCli ) - m_miniCli->clearHistory(); -} - -void KDesktop::setIconsEnabled( bool enable ) -{ - if ( enable == m_bDesktopEnabled ) - return; - - m_bDesktopEnabled = enable; - kdDebug(1204) << "setIcons " << enable << endl; - KDesktopSettings::setDesktopEnabled( m_bDesktopEnabled ); - KDesktopSettings::writeConfig(); - if (!enable) { - delete m_pIconView; - m_pIconView = 0; - } - configure(); -} - -void KDesktop::desktopResized() -{ - resize(kapp->desktop()->size()); - - if ( m_pIconView ) - { - // the sequence of actions is important: - // remove all icons, resize desktop, tell kdiconview new iconsArea size - // tell kdiconview to reget all icons - m_pIconView->slotClear(); - m_pIconView->resize(kapp->desktop()->size()); - - // get new desktopIconsArea from kicker - TQByteArray data, result; - TQDataStream arg(data, IO_WriteOnly); - arg << kdesktop_screen_number; - TQCString replyType; - TQRect area; - - if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", - data, replyType, result, false, 2000) ) - { - TQDataStream res(result, IO_ReadOnly); - res >> area; - } - else - { - area = twinModule()->workArea(twinModule()->currentDesktop()); - } - - m_pIconView->updateWorkArea(area); - m_pIconView->startDirLister(); - } -} - -void KDesktop::switchDesktops( int delta ) -{ - bool old = m_bWheelSwitchesWorkspace; - m_bWheelSwitchesWorkspace = true; - slotSwitchDesktops(delta); - m_bWheelSwitchesWorkspace = old; -} - -bool KDesktop::event(TQEvent * e) -{ - if ( e->type() == TQEvent::WindowDeactivate) - { - if (m_pIconView) - m_pIconView->clearSelection(); - } - return TQWidget::event(e); -} - -TQPoint KDesktop::findPlaceForIcon( int column, int row ) -{ - if (m_pIconView) - return m_pIconView->findPlaceForIcon(column, row); - else - return TQPoint(-1, -1); -} - -void KDesktop::addIcon(const TQString & _url, int x, int y) -{ - addIcon( _url, TDEGlobalSettings::desktopPath(), x, y ); -} - -void KDesktop::addIcon(const TQString & _url, const TQString & _dest, int x, int y) -{ - TQString filename = _url.mid(_url.findRev('/') + 1); - - TQValueList files; - TDEIO::CopyInfo i; - i.uSource = KURL::fromPathOrURL( _url ); - i.uDest = KURL::fromPathOrURL( _dest ); - i.uDest.addPath( filename ); - files.append(i); - if (!TQFile::exists(i.uDest.prettyURL().replace("file://",TQString()))) { m_pIconView->slotAboutToCreate( TQPoint( x, y ), files ); - TDEIO::copy( i.uSource, i.uDest, false ); } - -// m_pIconView->addFuturePosition(filename, x, y); - // tqDebug("addIcon %s %s %d %d", _url.latin1(), _dest.latin1(), x, y); -// system(TQString("cp \"%1\" \"%2/%3\"").arg(KURL(_url).path()).arg(KURL(_dest).path()).arg(filename).latin1()); -// m_pIconView->update( _dest ); -} - -void KDesktop::removeIcon(const TQString &_url) -{ - if (_url.at(0) != '/') { - tqDebug("removeIcon with relative path not supported for now"); - return; - } - unlink(KURL(_url).path().latin1()); - TQString dest = _url.left(_url.findRev('/') + 1); - m_pIconView->update( dest ); -} - -#include "desktop.moc" diff --git a/kdesktop/desktop.cpp b/kdesktop/desktop.cpp new file mode 100644 index 000000000..2732bff08 --- /dev/null +++ b/kdesktop/desktop.cpp @@ -0,0 +1,1197 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Torben Weis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include "desktop.h" +#include "krootwm.h" +#include "bgmanager.h" +#include "bgsettings.h" +#include "startupid.h" +#include "kdiconview.h" +#include "minicli.h" +#include "kdesktopsettings.h" +#include "tdelaunchsettings.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Create the equivalent of TDEAccelBase::connectItem +// and then remove this include and fix reconnects in initRoot() -- ellis +//#include + +extern int kdesktop_screen_number; +extern TQCString kdesktop_name, kicker_name, twin_name; + +KRootWidget::KRootWidget() : TQObject() +{ + kapp->desktop()->installEventFilter(this); + kapp->desktop()->setAcceptDrops( true ); +} + +bool KRootWidget::eventFilter ( TQObject *, TQEvent * e ) +{ + if (e->type() == TQEvent::MouseButtonPress) + { + TQMouseEvent *me = TQT_TQMOUSEEVENT(e); + KRootWm::self()->mousePressed( me->globalPos(), me->button() ); + return true; + } + else if (e->type() == TQEvent::Wheel) + { + TQWheelEvent *we = TQT_TQWHEELEVENT(e); + emit wheelRolled(we->delta()); + return true; + } + else if ( e->type() == TQEvent::DragEnter ) + { + TQDragEnterEvent* de = static_cast( e ); + bool b = !TDEGlobal::config()->isImmutable() && !TDEGlobal::dirs()->isRestrictedResource( "wallpaper" ); + + bool imageURL = false; + if ( KURLDrag::canDecode( de ) ) + { + KURL::List list; + KURLDrag::decode( de, list ); + KURL url = list.first(); + KMimeType::Ptr mime = KMimeType::findByURL( url ); + if ( !KImageIO::type( url.path() ).isEmpty() || + KImageIO::isSupported( mime->name(), KImageIO::Reading ) || mime->is( "image/svg+xml" ) ) + imageURL = true; + } + + b = b && ( KColorDrag::canDecode( de ) || TQImageDrag::canDecode( de ) || imageURL ); + de->accept( b ); + return true; + } + else if ( e->type() == TQEvent::Drop ) + { + TQDropEvent* de = static_cast( e ); + if ( KColorDrag::canDecode( de ) ) + emit colorDropEvent( de ); + else if ( TQImageDrag::canDecode( de ) ) + emit imageDropEvent( de ); + else if ( KURLDrag::canDecode( de ) ) { + KURL::List list; + KURLDrag::decode( de, list ); + KURL url = list.first(); + emit newWallpaper( url ); + } + return true; + } + return false; // Don't filter. +} + +// ----------------------------------------------------------------------------- +#define DEFAULT_DELETEACTION 1 + +KDesktop::WheelDirection KDesktop::m_eWheelDirection = KDesktop::m_eDefaultWheelDirection; +const char* KDesktop::m_wheelDirectionStrings[2] = { "Forward", "Reverse" }; + +KDesktop::KDesktop( SaverEngine* saver, bool x_root_hack, bool wait_for_kded ) : + TQWidget( 0L, "desktop", (WFlags)(WResizeNoErase | ( x_root_hack ? (WStyle_Customize | WStyle_NoBorder) : 0)) ), + KDesktopIface(), + // those two WStyle_ break kdesktop when the root-hack isn't used (no Dnd) + startup_id( NULL ), m_waitForKicker(0) +{ + m_pSaver = saver; + + NETRootInfo i( tqt_xdisplay(), NET::Supported ); + m_wmSupport = i.isSupported( NET::WM2ShowingDesktop ); + + m_bWaitForKded = wait_for_kded; + m_miniCli = 0; // created on demand + keys = 0; // created later + TDEGlobal::locale()->insertCatalogue("kdesktop"); + TDEGlobal::locale()->insertCatalogue("libkonq"); // needed for apps using libkonq + TDEGlobal::locale()->insertCatalogue("libdmctl"); + + setCaption( "KDE Desktop"); + + setAcceptDrops(true); // WStyle_Customize seems to disable that + m_pKwinmodule = new KWinModule( TQT_TQOBJECT(this) ); + + kapp->dcopClient()->setNotifications(true); + kapp->dcopClient()->connectDCOPSignal(kicker_name, kicker_name, "desktopIconsAreaChanged(TQRect, int)", + "KDesktopIface", "desktopIconsAreaChanged(TQRect, int)", false); + + // Dont repaint on configuration changes during construction + m_bInit = true; + + // It's the child widget that gets the focus, not us + setFocusPolicy( TQ_NoFocus ); + + if ( x_root_hack ) + { + // this is a ugly hack to make Dnd work + // Matthias told me that it won't be necessary with twin + // actually my first try with ICCCM (Dirk) :-) + unsigned long data[2]; + data[0] = (unsigned long) 1; + data[1] = (unsigned long) 0; // None; (Werner) + Atom wm_state = XInternAtom(tqt_xdisplay(), "WM_STATE", False); + XChangeProperty(tqt_xdisplay(), winId(), wm_state, wm_state, 32, + PropModeReplace, (unsigned char *)data, 2); + + } + + setGeometry( TQApplication::desktop()->geometry() ); + lower(); + + connect( kapp, TQT_SIGNAL( shutDown() ), + this, TQT_SLOT( slotShutdown() ) ); + + connect(kapp, TQT_SIGNAL(settingsChanged(int)), + this, TQT_SLOT(slotSettingsChanged(int))); + kapp->addKipcEventMask(KIPC::SettingsChanged); + + kapp->addKipcEventMask(KIPC::IconChanged); + connect(kapp, TQT_SIGNAL(iconChanged(int)), this, TQT_SLOT(slotIconChanged(int))); + + connect(KSycoca::self(), TQT_SIGNAL(databaseChanged()), + this, TQT_SLOT(slotDatabaseChanged())); + + m_pIconView = 0; + m_pRootWidget = 0; + bgMgr = 0; + initRoot(); + + TQTimer::singleShot(0, this, TQT_SLOT( slotStart() )); + +#if (TQT_VERSION-0 >= 0x030200) // XRANDR support + connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); +#endif +} + +void +KDesktop::initRoot() +{ + Display *dpy = tqt_xdisplay(); + Window root = RootWindow(dpy, kdesktop_screen_number); + XDefineCursor(dpy, root, cursor().handle()); + + m_bDesktopEnabled = KDesktopSettings::desktopEnabled(); + if ( !m_bDesktopEnabled && !m_pRootWidget ) + { + hide(); + delete bgMgr; + bgMgr = 0; + if ( m_pIconView ) + m_pIconView->saveIconPositions(); + delete m_pIconView; + m_pIconView = 0; + + { // trigger creation of QToolTipManager, it does XSelectInput() on the root window + TQWidget w; + TQToolTip::add( &w, "foo" ); + } + // NOTE: If mouse clicks stop working again, it's most probably something doing XSelectInput() + // on the root window after this, and setting it to some fixed value instead of adding its mask. + XWindowAttributes attrs; + XGetWindowAttributes(dpy, root, &attrs); + XSelectInput(dpy, root, attrs.your_event_mask | ButtonPressMask); + + m_pRootWidget = new KRootWidget; + connect(m_pRootWidget, TQT_SIGNAL(wheelRolled(int)), this, TQT_SLOT(slotSwitchDesktops(int))); + connect(m_pRootWidget, TQT_SIGNAL(colorDropEvent(TQDropEvent*)), this, TQT_SLOT(handleColorDropEvent(TQDropEvent*)) ); + connect(m_pRootWidget, TQT_SIGNAL(imageDropEvent(TQDropEvent*)), this, TQT_SLOT(handleImageDropEvent(TQDropEvent*)) ); + connect(m_pRootWidget, TQT_SIGNAL(newWallpaper(const KURL&)), this, TQT_SLOT(slotNewWallpaper(const KURL&)) ); + + // Geert Jansen: backgroundmanager belongs here + // TODO tell KBackgroundManager if we change widget() + bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); + bgMgr->setExport(1); + connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); + if (!m_bInit) + { + delete KRootWm::self(); + KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) + keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); + keys->updateConnections(); + } + } + else if (m_bDesktopEnabled && !m_pIconView) + { + delete bgMgr; + bgMgr = 0; + delete m_pRootWidget; + m_pRootWidget = 0; + m_pIconView = new KDIconView( this, 0 ); + connect( m_pIconView, TQT_SIGNAL( imageDropEvent( TQDropEvent * ) ), + this, TQT_SLOT( handleImageDropEvent( TQDropEvent * ) ) ); + connect( m_pIconView, TQT_SIGNAL( colorDropEvent( TQDropEvent * ) ), + this, TQT_SLOT( handleColorDropEvent( TQDropEvent * ) ) ); + connect( m_pIconView, TQT_SIGNAL( newWallpaper( const KURL & ) ), + this, TQT_SLOT( slotNewWallpaper( const KURL & ) ) ); + connect( m_pIconView, TQT_SIGNAL( wheelRolled( int ) ), + this, TQT_SLOT( slotSwitchDesktops( int ) ) ); + + // All the QScrollView/QWidget-specific stuff should go here, so that we can use + // another qscrollview/widget instead of the iconview and use the same code + m_pIconView->setVScrollBarMode( TQScrollView::AlwaysOff ); + m_pIconView->setHScrollBarMode( TQScrollView::AlwaysOff ); + m_pIconView->setDragAutoScroll( false ); + m_pIconView->setFrameStyle( TQFrame::NoFrame ); + m_pIconView->viewport()->setBackgroundMode( X11ParentRelative ); + m_pIconView->setFocusPolicy( TQ_StrongFocus ); + m_pIconView->viewport()->setFocusPolicy( TQ_StrongFocus ); + m_pIconView->setGeometry( geometry() ); + m_pIconView->show(); + + // Geert Jansen: backgroundmanager belongs here + // TODO tell KBackgroundManager if we change widget() + bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); + bgMgr->setExport(1); + connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); + + // make sure it is initialized before we first call updateWorkArea() + m_pIconView->initConfig( m_bInit ); + + // set the size of the area for desktop icons placement + { + TQByteArray data, result; + TQDataStream arg(data, IO_WriteOnly); + arg << kdesktop_screen_number; + TQCString replyType; + TQRect area; + + if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", + data, replyType, result, false, 2000) ) + { + TQDataStream res(result, IO_ReadOnly); + res >> area; + + m_pIconView->updateWorkArea(area); + } + else + if ( m_bInit ) + { + // if we failed to get the information from kicker wait a little - probably + // this is the KDE startup and kicker is simply not running yet + m_waitForKicker = new TQTimer(this); + connect(m_waitForKicker, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotNoKicker())); + m_waitForKicker->start(15000, true); + } + else // we are not called from the ctor, so kicker should already run + { + area = twinModule()->workArea(twinModule()->currentDesktop()); + m_pIconView->updateWorkArea(area); + } + } + + if (!m_bInit) + { + m_pIconView->start(); + delete KRootWm::self(); + KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) + keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); + keys->updateConnections(); + } + } else { + DCOPRef r( "ksmserver", "ksmserver" ); + r.send( "resumeStartup", TQCString( "kdesktop" )); + } + + KWin::setType( winId(), NET::Desktop ); + KWin::setState( winId(), NET::SkipPager ); + KWin::setOnAllDesktops( winId(), true ); +} + +void KDesktop::slotNoKicker() +{ + kdDebug(1204) << "KDesktop::slotNoKicker ... kicker did not respond" << endl; + // up till now, we got no desktopIconsArea from kicker - probably + // it's not running, so use the area from KWinModule + TQRect area = twinModule()->workArea(twinModule()->currentDesktop()); + m_pIconView->updateWorkArea(area); +} + +void +KDesktop::backgroundInitDone() +{ + //kdDebug(1204) << "KDesktop::backgroundInitDone" << endl; + // avoid flicker + if (m_bDesktopEnabled) + { + const TQPixmap *bg = TQT_TQWIDGET(TQApplication::desktop()->screen())->backgroundPixmap(); + if ( bg ) + m_pIconView->setErasePixmap( *bg ); + + show(); + kapp->sendPostedEvents(); + } + + DCOPRef r( "ksmserver", "ksmserver" ); + r.send( "resumeStartup", TQCString( "kdesktop" )); +} + +void +KDesktop::slotStart() +{ + //kdDebug(1204) << "KDesktop::slotStart" << endl; + if (!m_bInit) return; + + // In case we started without database + KImageIO::registerFormats(); + + initConfig(); + +// if (m_bDesktopEnabled) +// { +// // We need to be visible in order to insert icons, even if the background isn't ready yet... + +// show(); +// } + + // Now we may react to configuration changes + m_bInit = false; + + if (m_pIconView) + m_pIconView->start(); + + // Global keys + keys = new TDEGlobalAccel( TQT_TQOBJECT(this) ); + (void) new KRootWm( m_pSaver, this ); + +#include "kdesktopbindings.cpp" + + keys->readSettings(); + keys->updateConnections(); + + connect(kapp, TQT_SIGNAL(appearanceChanged()), TQT_SLOT(slotConfigure())); + + TQTimer::singleShot(300, this, TQT_SLOT( slotUpAndRunning() )); +} + +void +KDesktop::runAutoStart() +{ + // now let's execute all the stuff in the autostart folder. + // the stuff will actually be really executed when the event loop is + // entered, since KRun internally uses a QTimer + TQDir dir( TDEGlobalSettings::autostartPath() ); + TQStringList entries = dir.entryList( TQDir::Files ); + TQStringList::Iterator it = entries.begin(); + TQStringList::Iterator end = entries.end(); + for (; it != end; ++it ) + { + // Don't execute backup files + if ( (*it).right(1) != "~" && (*it).right(4) != ".bak" && + ( (*it)[0] != '%' || (*it).right(1) != "%" ) && + ( (*it)[0] != '#' || (*it).right(1) != "#" ) ) + { + KURL url; + url.setPath( dir.absPath() + '/' + (*it) ); + (void) new KRun( url, 0, true ); + } + } +} + +// ----------------------------------------------------------------------------- + +KDesktop::~KDesktop() +{ + delete m_miniCli; + m_miniCli = 0; // see #120382 + delete bgMgr; + bgMgr = 0; + delete startup_id; +} + +// ----------------------------------------------------------------------------- + +void KDesktop::initConfig() +{ + if (m_pIconView) + m_pIconView->initConfig( m_bInit ); + + if ( keys ) + { + keys->readSettings(); + keys->updateConnections(); + } + + TDELaunchSettings::self()->readConfig(); + if( !TDELaunchSettings::busyCursor() ) + { + delete startup_id; + startup_id = NULL; + } + else + { + if( startup_id == NULL ) + startup_id = new StartupId; + startup_id->configure(); + } + + set_vroot = KDesktopSettings::setVRoot(); + slotSetVRoot(); // start timer + + m_bWheelSwitchesWorkspace = KDesktopSettings::wheelSwitchesWorkspace(); + + const char* forward_string = m_wheelDirectionStrings[Forward]; + m_eWheelDirection = + (KDesktopSettings::wheelDirection() == forward_string) ? Forward : Reverse; +} + +// ----------------------------------------------------------------------------- + +void KDesktop::slotExecuteCommand() +{ + // this function needs to be duplicated since it appears that one + // cannot have a 'slot' be a DCOP method. if this changes in the + // future, then 'slotExecuteCommand' and 'popupExecuteCommand' can + // merge into one slot. + popupExecuteCommand(); +} + +/* + Shows minicli + */ +void KDesktop::popupExecuteCommand() +{ + popupExecuteCommand(""); +} + +void KDesktop::popupExecuteCommand(const TQString& command) +{ + if (m_bInit) + return; + + if (!kapp->authorize("run_command")) + return; + + // Created on demand + if ( !m_miniCli ) + { + m_miniCli = new Minicli( this ); + m_miniCli->adjustSize(); // for the centering below + } + + if (!command.isEmpty()) + m_miniCli->setCommand(command); + + // Move minicli to the current desktop + NETWinInfo info( tqt_xdisplay(), m_miniCli->winId(), tqt_xrootwin(), NET::WMDesktop ); + int currentDesktop = twinModule()->currentDesktop(); + if ( info.desktop() != currentDesktop ) + info.setDesktop( currentDesktop ); + + if ( m_miniCli->isVisible() ) { + KWin::forceActiveWindow( m_miniCli->winId() ); + } else { + NETRootInfo i( tqt_xdisplay(), NET::Supported ); + if( !i.isSupported( NET::WM2FullPlacement )) { + TQRect rect = TDEGlobalSettings::desktopGeometry(TQCursor::pos()); + m_miniCli->move(rect.x() + (rect.width() - m_miniCli->width())/2, + rect.y() + (rect.height() - m_miniCli->height())/2); + } + m_miniCli->show(); // non-modal + } +} + +void KDesktop::slotSwitchUser() +{ + KRootWm::self()->slotSwitchUser(); +} + +void KDesktop::slotShowWindowList() +{ + KRootWm::self()->slotWindowList(); +} + +void KDesktop::slotShowTaskManager() +{ + //kdDebug(1204) << "Launching KSysGuard..." << endl; + TDEProcess* p = new TDEProcess; + TQ_CHECK_PTR(p); + + *p << "ksysguard"; + *p << "--showprocesses"; + + p->start(TDEProcess::DontCare); + + delete p; +} + +// ----------------------------------------------------------------------------- + +void KDesktop::rearrangeIcons() +{ + if (m_pIconView) + m_pIconView->rearrangeIcons(); +} + +void KDesktop::lineupIcons() +{ + if (m_pIconView) + m_pIconView->lineupIcons(); +} + +void KDesktop::selectAll() +{ + if (m_pIconView) + m_pIconView->selectAll( true ); +} + +void KDesktop::unselectAll() +{ + if (m_pIconView) + m_pIconView->selectAll( false ); +} + +TQStringList KDesktop::selectedURLs() +{ + if (m_pIconView) + return m_pIconView->selectedURLs(); + return TQStringList(); +} + +void KDesktop::refreshIcons() +{ + if (m_pIconView) + m_pIconView->refreshIcons(); +} + +void KDesktop::setShowDesktop( bool b ) +{ + bool m_showingDesktop = showDesktopState(); + + if (b == m_showingDesktop) + { + return; + } + + if( m_wmSupport ) + { + NETRootInfo i( tqt_xdisplay(), 0 ); + i.setShowingDesktop( b ); + return; + } + + if (b) + { + m_activeWindow = twinModule()->activeWindow(); + m_iconifiedList.clear(); + + const TQValueList windows = twinModule()->windows(); + for (TQValueList::ConstIterator it = windows.begin(); + it != windows.end(); + ++it) + { + WId w = *it; + + NETWinInfo info( tqt_xdisplay(), w, tqt_xrootwin(), + NET::XAWMState | NET::WMDesktop ); + + if (info.mappingState() == NET::Visible && + (info.desktop() == NETWinInfo::OnAllDesktops || + info.desktop() == (int)twinModule()->currentDesktop())) + { + m_iconifiedList.append( w ); + } + } + + // find first, hide later, otherwise transients may get minimized + // with the window they're transient for + for (TQValueVector::Iterator it = m_iconifiedList.begin(); + it != m_iconifiedList.end(); + ++it) + { + KWin::iconifyWindow( *it, false ); + } + + // on desktop changes or when a window is deiconified, we abort the show desktop mode + connect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), + TQT_SLOT(slotCurrentDesktopChanged(int))); + connect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), + TQT_SLOT(slotWindowChanged(WId,unsigned int))); + connect(twinModule(), TQT_SIGNAL(windowAdded(WId)), + TQT_SLOT(slotWindowAdded(WId))); + } + else + { + disconnect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), + this, TQT_SLOT(slotCurrentDesktopChanged(int))); + disconnect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), + this, TQT_SLOT(slotWindowChanged(WId,unsigned int))); + disconnect(twinModule(), TQT_SIGNAL(windowAdded(WId)), + this, TQT_SLOT(slotWindowAdded(WId))); + + for (TQValueVector::ConstIterator it = m_iconifiedList.begin(); + it != m_iconifiedList.end(); + ++it) + { + KWin::deIconifyWindow(*it, false); + } + + KWin::forceActiveWindow(m_activeWindow); + } + + m_showingDesktop = b; + emit desktopShown(m_showingDesktop); +} + +void KDesktop::slotCurrentDesktopChanged(int) +{ + setShowDesktop( false ); +} + +void KDesktop::slotWindowAdded(WId w) +{ + bool m_showingDesktop = showDesktopState(); + + if (!m_showingDesktop) + { + return; + } + + NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(), + NET::XAWMState | NET::WMWindowType); + NET::WindowType windowType = inf.windowType(NET::AllTypesMask); + + if ((windowType == NET::Normal || windowType == NET::Unknown) && + inf.mappingState() == NET::Visible) + { + TDEConfig twincfg( "twinrc", true ); // see in twin + twincfg.setGroup( "Windows" ); + if( twincfg.readBoolEntry( "ShowDesktopIsMinimizeAll", false )) + { + m_iconifiedList.clear(); + m_showingDesktop = false; + emit desktopShown(false); + } + else + { + m_activeWindow = w; + setShowDesktop(false); + } + } +} + +void KDesktop::slotWindowChanged(WId w, unsigned int dirty) +{ + bool m_showingDesktop = showDesktopState(); + + if (!m_showingDesktop) + { + return; + } + + if (dirty & NET::XAWMState) + { + NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(), + NET::XAWMState | NET::WMWindowType); + NET::WindowType windowType = inf.windowType(NET::AllTypesMask); + + if ((windowType == NET::Normal || windowType == NET::Unknown) && + inf.mappingState() == NET::Visible) + { + // a window was deiconified, abort the show desktop mode. + m_iconifiedList.clear(); + m_showingDesktop = false; + emit desktopShown(false); + } + } +} + +bool KDesktop::showDesktopState() +{ + return twinModule()->showingDesktop(); +} + +void KDesktop::toggleShowDesktop() +{ + setShowDesktop(!showDesktopState()); +} + +TDEActionCollection * KDesktop::actionCollection() +{ + if (!m_pIconView) + return 0; + return m_pIconView->actionCollection(); +} + +KURL KDesktop::url() const +{ + if (m_pIconView) + return m_pIconView->url(); + return KURL(); +} + +// ----------------------------------------------------------------------------- + +void KDesktop::slotConfigure() +{ + configure(); +} + +void KDesktop::configure() +{ + // re-read configuration and apply it + TDEGlobal::config()->reparseConfiguration(); + KDesktopSettings::self()->readConfig(); + + // If we have done start() already, then re-configure. + // Otherwise, start() will call initConfig anyway + if (!m_bInit) + { + initRoot(); + initConfig(); + KRootWm::self()->initConfig(); + } + + if (keys) + { + keys->readSettings(); + keys->updateConnections(); + } +} + +void KDesktop::slotSettingsChanged(int category) +{ + //kdDebug(1204) << "KDesktop::slotSettingsChanged" << endl; + if (category == TDEApplication::SETTINGS_PATHS) + { + kdDebug(1204) << "KDesktop::slotSettingsChanged SETTINGS_PATHS" << endl; + if (m_pIconView) + m_pIconView->recheckDesktopURL(); + } + else if (category == TDEApplication::SETTINGS_SHORTCUTS) + { + kdDebug(1204) << "KDesktop::slotSettingsChanged SETTINGS_SHORTCUTS" << endl; + keys->readSettings(); + keys->updateConnections(); + } +} + +void KDesktop::slotIconChanged(int group) +{ + if ( group == TDEIcon::Desktop ) + { + kdDebug(1204) << "KDesktop::slotIconChanged" << endl; + refresh(); + } +} + +void KDesktop::slotDatabaseChanged() +{ + //kdDebug(1204) << "KDesktop::slotDatabaseChanged" << endl; + if (m_bInit) // kded is done, now we can "start" for real + slotStart(); + if (m_pIconView && KSycoca::isChanged("mimetypes")) + m_pIconView->refreshMimeTypes(); +} + +void KDesktop::refresh() +{ + // George Staikos 3/14/01 + // This bit will just refresh the desktop and icons. Now I have code + // in KWin to do a complete refresh so this isn't really needed. + // I'll leave it in here incase the plan is changed again +#if 0 + m_bNeedRepaint |= 1; + updateWorkArea(); +#endif + kapp->dcopClient()->send( twin_name, "", "refresh()", TQString("")); + refreshIcons(); +} + +// ----------------------------------------------------------------------------- + +void KDesktop::slotSetVRoot() +{ + if (!m_pIconView) + return; + + if (KWin::windowInfo(winId()).mappingState() == NET::Withdrawn) { + TQTimer::singleShot(100, this, TQT_SLOT(slotSetVRoot())); + return; + } + + unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); + unsigned long vroot_data[1] = { m_pIconView->viewport()->winId() }; + static Atom vroot = XInternAtom(tqt_xdisplay(), "__SWM_VROOT", False); + + Window rootReturn, parentReturn, *children; + unsigned int numChildren; + Window top = winId(); + while (1) { + /*int ret = */XQueryTree(tqt_xdisplay(), top , &rootReturn, &parentReturn, + &children, &numChildren); + if (children) + XFree((char *)children); + if (parentReturn == rw) { + break; + } else + top = parentReturn; + } + if ( set_vroot ) + XChangeProperty(tqt_xdisplay(), top, vroot, XA_WINDOW, 32, + PropModeReplace, (unsigned char *)vroot_data, 1); + else + XDeleteProperty (tqt_xdisplay(), top, vroot); +} + +// ----------------------------------------------------------------------------- + +void KDesktop::slotShutdown() +{ + if ( m_pIconView ) + m_pIconView->saveIconPositions(); + if ( m_miniCli ) + m_miniCli->saveConfig(); +} + +// don't hide when someone presses Alt-F4 on us +void KDesktop::closeEvent(TQCloseEvent *e) +{ + e->ignore(); +} + +void KDesktop::desktopIconsAreaChanged(const TQRect &area, int screen) +{ + // hurra! kicker is alive + if ( m_waitForKicker ) m_waitForKicker->stop(); + + // -2: all screens + // -1: primary screen + // else: screen number + + if (screen <= -2) + screen = kdesktop_screen_number; + else if (screen == -1) + screen = kapp->desktop()->primaryScreen(); + + // This is pretty broken, mixes Xinerama and non-Xinerama multihead + // and generally doesn't seem to be required anyway => ignore screen. + if ( /*(screen == kdesktop_screen_number) &&*/ m_pIconView ) { + m_pIconView->updateWorkArea(area); + } +} + +void KDesktop::slotSwitchDesktops(int delta) +{ + if(m_bWheelSwitchesWorkspace && KWin::numberOfDesktops() > 1) + { + int newDesk, curDesk = KWin::currentDesktop(); + + if( (delta < 0 && m_eWheelDirection == Forward) || (delta > 0 && m_eWheelDirection == Reverse) ) + newDesk = curDesk % KWin::numberOfDesktops() + 1; + else + newDesk = ( KWin::numberOfDesktops() + curDesk - 2 ) % KWin::numberOfDesktops() + 1; + + KWin::setCurrentDesktop( newDesk ); + } +} + +void KDesktop::handleColorDropEvent(TQDropEvent * e) +{ + TDEPopupMenu popup; + popup.insertItem(SmallIconSet("colors"),i18n("Set as Primary Background Color"), 1); + popup.insertItem(SmallIconSet("colors"),i18n("Set as Secondary Background Color"), 2); + int result = popup.exec(e->pos()); + + TQColor c; + KColorDrag::decode(e, c); + switch (result) { + case 1: bgMgr->setColor(c, true); break; + case 2: bgMgr->setColor(c, false); break; + default: return; + } + bgMgr->setWallpaper(0,0); +} + +void KDesktop::handleImageDropEvent(TQDropEvent * e) +{ + TDEPopupMenu popup; + if ( m_pIconView ) + popup.insertItem(SmallIconSet("document-save"),i18n("&Save to Desktop..."), 1); + if ( ( m_pIconView && m_pIconView->maySetWallpaper() ) || m_pRootWidget ) + popup.insertItem(SmallIconSet("background"),i18n("Set as &Wallpaper"), 2); + popup.insertSeparator(); + popup.insertItem(SmallIconSet("cancel"), i18n("&Cancel")); + int result = popup.exec(e->pos()); + + if (result == 1) + { + bool ok = true; + TQString filename = KInputDialog::getText(TQString::null, i18n("Enter a name for the image below:"), TQString::null, &ok, m_pIconView); + + if (!ok) + { + return; + } + + if (filename.isEmpty()) + { + filename = i18n("image.png"); + } + else if (filename.right(4).lower() != ".png") + { + filename += ".png"; + } + + TQImage i; + TQImageDrag::decode(e, i); + KTempFile tmpFile(TQString::null, filename); + i.save(tmpFile.name(), "PNG"); + // We pass 0 as parent window because passing the desktop is not a good idea + KURL src; + src.setPath( tmpFile.name() ); + KURL dest( KDIconView::desktopURL() ); + dest.addPath( filename ); + TDEIO::NetAccess::copy( src, dest, 0 ); + tmpFile.unlink(); + } + else if (result == 2) + { + TQImage i; + TQImageDrag::decode(e, i); + KTempFile tmpFile(TDEGlobal::dirs()->saveLocation("wallpaper"), ".png"); + i.save(tmpFile.name(), "PNG"); + kdDebug(1204) << "KDesktop::contentsDropEvent " << tmpFile.name() << endl; + bgMgr->setWallpaper(tmpFile.name()); + } +} + +void KDesktop::slotNewWallpaper(const KURL &url) +{ + // This is called when a file containing an image is dropped + // (called by KonqOperations) + if ( url.isLocalFile() ) + bgMgr->setWallpaper( url.path() ); + else + { + // Figure out extension + TQString fileName = url.fileName(); + TQFileInfo fileInfo( fileName ); + TQString ext = fileInfo.extension(); + // Store tempfile in a place where it will still be available after a reboot + KTempFile tmpFile( TDEGlobal::dirs()->saveLocation("wallpaper"), "." + ext ); + KURL localURL; localURL.setPath( tmpFile.name() ); + // We pass 0 as parent window because passing the desktop is not a good idea + TDEIO::NetAccess::file_copy( url, localURL, -1, true /*overwrite*/ ); + bgMgr->setWallpaper( localURL.path() ); + } +} + +// for dcop interface backward compatibility +void KDesktop::logout() +{ + logout( TDEApplication::ShutdownConfirmDefault, + TDEApplication::ShutdownTypeNone ); +} + +void KDesktop::logout( TDEApplication::ShutdownConfirm confirm, + TDEApplication::ShutdownType sdtype ) +{ + if( !kapp->requestShutDown( confirm, sdtype ) ) + // this i18n string is also in kicker/applets/run/runapplet + KMessageBox::error( this, i18n("Could not log out properly.\nThe session manager cannot " + "be contacted. You can try to force a shutdown by pressing " + "Ctrl+Alt+Backspace; note, however, that your current session " + "will not be saved with a forced shutdown." ) ); +} + +void KDesktop::slotLogout() +{ + logout( TDEApplication::ShutdownConfirmDefault, + TDEApplication::ShutdownTypeDefault ); +} + +void KDesktop::slotLogoutNoCnf() +{ + logout( TDEApplication::ShutdownConfirmNo, + TDEApplication::ShutdownTypeNone ); +} + +void KDesktop::slotHaltNoCnf() +{ + logout( TDEApplication::ShutdownConfirmNo, + TDEApplication::ShutdownTypeHalt ); +} + +void KDesktop::slotRebootNoCnf() +{ + logout( TDEApplication::ShutdownConfirmNo, + TDEApplication::ShutdownTypeReboot ); +} + +void KDesktop::setVRoot( bool enable ) +{ + if ( enable == set_vroot ) + return; + + set_vroot = enable; + kdDebug(1204) << "setVRoot " << enable << endl; + KDesktopSettings::setSetVRoot( set_vroot ); + KDesktopSettings::writeConfig(); + slotSetVRoot(); +} + +void KDesktop::clearCommandHistory() +{ + if ( m_miniCli ) + m_miniCli->clearHistory(); +} + +void KDesktop::setIconsEnabled( bool enable ) +{ + if ( enable == m_bDesktopEnabled ) + return; + + m_bDesktopEnabled = enable; + kdDebug(1204) << "setIcons " << enable << endl; + KDesktopSettings::setDesktopEnabled( m_bDesktopEnabled ); + KDesktopSettings::writeConfig(); + if (!enable) { + delete m_pIconView; + m_pIconView = 0; + } + configure(); +} + +void KDesktop::desktopResized() +{ + resize(kapp->desktop()->size()); + + if ( m_pIconView ) + { + // the sequence of actions is important: + // remove all icons, resize desktop, tell kdiconview new iconsArea size + // tell kdiconview to reget all icons + m_pIconView->slotClear(); + m_pIconView->resize(kapp->desktop()->size()); + + // get new desktopIconsArea from kicker + TQByteArray data, result; + TQDataStream arg(data, IO_WriteOnly); + arg << kdesktop_screen_number; + TQCString replyType; + TQRect area; + + if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", + data, replyType, result, false, 2000) ) + { + TQDataStream res(result, IO_ReadOnly); + res >> area; + } + else + { + area = twinModule()->workArea(twinModule()->currentDesktop()); + } + + m_pIconView->updateWorkArea(area); + m_pIconView->startDirLister(); + } +} + +void KDesktop::switchDesktops( int delta ) +{ + bool old = m_bWheelSwitchesWorkspace; + m_bWheelSwitchesWorkspace = true; + slotSwitchDesktops(delta); + m_bWheelSwitchesWorkspace = old; +} + +bool KDesktop::event(TQEvent * e) +{ + if ( e->type() == TQEvent::WindowDeactivate) + { + if (m_pIconView) + m_pIconView->clearSelection(); + } + return TQWidget::event(e); +} + +TQPoint KDesktop::findPlaceForIcon( int column, int row ) +{ + if (m_pIconView) + return m_pIconView->findPlaceForIcon(column, row); + else + return TQPoint(-1, -1); +} + +void KDesktop::addIcon(const TQString & _url, int x, int y) +{ + addIcon( _url, TDEGlobalSettings::desktopPath(), x, y ); +} + +void KDesktop::addIcon(const TQString & _url, const TQString & _dest, int x, int y) +{ + TQString filename = _url.mid(_url.findRev('/') + 1); + + TQValueList files; + TDEIO::CopyInfo i; + i.uSource = KURL::fromPathOrURL( _url ); + i.uDest = KURL::fromPathOrURL( _dest ); + i.uDest.addPath( filename ); + files.append(i); + if (!TQFile::exists(i.uDest.prettyURL().replace("file://",TQString()))) { m_pIconView->slotAboutToCreate( TQPoint( x, y ), files ); + TDEIO::copy( i.uSource, i.uDest, false ); } + +// m_pIconView->addFuturePosition(filename, x, y); + // tqDebug("addIcon %s %s %d %d", _url.latin1(), _dest.latin1(), x, y); +// system(TQString("cp \"%1\" \"%2/%3\"").arg(KURL(_url).path()).arg(KURL(_dest).path()).arg(filename).latin1()); +// m_pIconView->update( _dest ); +} + +void KDesktop::removeIcon(const TQString &_url) +{ + if (_url.at(0) != '/') { + tqDebug("removeIcon with relative path not supported for now"); + return; + } + unlink(KURL(_url).path().latin1()); + TQString dest = _url.left(_url.findRev('/') + 1); + m_pIconView->update( dest ); +} + +#include "desktop.moc" diff --git a/kdesktop/init.cc b/kdesktop/init.cc deleted file mode 100644 index 6bf87f333..000000000 --- a/kdesktop/init.cc +++ /dev/null @@ -1,247 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1999 David Faure - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// for multihead -extern int kdesktop_screen_number; - - -/** - * Test if a directory exists, create otherwise - * @param _name full path of the directory - * @param _showMsg show a message box if we created the dir - * @return true if the dir was just created (e.g. so that we can populate it) - */ -static bool testDir( const TQString &_name ) -{ - DIR *dp; - dp = opendir( TQFile::encodeName(_name) ); - if ( dp == NULL ) - { - TQString m = _name; - if ( m.endsWith( "/" ) ) - m.truncate( m.length() - 1 ); - TQCString path = TQFile::encodeName(m); - - bool ok = ::mkdir( path, S_IRWXU ) == 0; - if ( !ok && errno == EEXIST ) { - int ret = KMessageBox::warningYesNo( 0, i18n("%1 is a file, but TDE needs it to be a directory; move it to %2.orig and create directory?").arg(m).arg(m), TQString::null, i18n("Move It"), i18n("Do Not Move") ); - if ( ret == KMessageBox::Yes ) { - if ( ::rename( path, path + ".orig" ) == 0 ) { - ok = ::mkdir( path, S_IRWXU ) == 0; - } else { - // foo.orig existed already. How likely is that? - ok = false; - } - } else { - return false; - } - } - if ( !ok ) - { - KMessageBox::sorry( 0, i18n( "Could not create directory %1; check for permissions or reconfigure the desktop to use another path." ).arg( m ) ); - return false; - } - return true; - } - else // exists already - { - closedir( dp ); - return false; - } -} - -/** - * Copy a standard .directory file to a user's directory - * @param fileName destination file name - * @param dir destination directory - * @param force if false, don't copy if destination file already exists - */ -static void copyDirectoryFile(const TQString &fileName, const TQString& dir, bool force) -{ - if (force || !TQFile::exists(dir + "/.directory")) { - TQString cmd = "cp "; - cmd += TDEProcess::quote(locate("data", TQString("kdesktop/") + fileName)); - cmd += " "; - cmd += TDEProcess::quote(dir+"/.directory"); - system( TQFile::encodeName(cmd) ); - } -} - -static void copyFile( const TQString& src, const TQString& dest ) -{ - TQCString cmd = "cp "; - cmd += TQFile::encodeName(TDEProcess::quote(src)); - cmd += " "; - cmd += TQFile::encodeName(TDEProcess::quote(dest)); - system( cmd ); -} - -static TQString realDesktopPath() -{ - TQString desktopPath = TDEGlobalSettings::desktopPath(); - if (kdesktop_screen_number != 0) { - TQString dn = "Desktop"; - dn += TQString::number(kdesktop_screen_number); - desktopPath.replace("Desktop", dn); - } - return desktopPath; -} - -/** - * Copy all links from DesktopLinks/ to the desktop, appropriately renamed - * (to the contents of the translated Name field) - */ -static void copyDesktopLinks() -{ - TDEConfig *config = kapp->config(); - config->setGroup("General"); - if (!config->readBoolEntry("CopyDesktopLinks", true)) - return; - - TQStringList list = - TDEGlobal::dirs()->findAllResources("appdata", "DesktopLinks/*", false, true); - - TQString desktopPath = realDesktopPath(); - - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); it++) { - KDesktopFile desk( *it ); - if (desk.readBoolEntry("Hidden")) - continue; - copyFile( *it, desktopPath ); - } -} - -/** - * @return true if this is the first time - * kdesktop is run for the current release - * WARNING : call only once !!! (second call will always return false !) - */ -static bool isNewRelease() -{ - bool bNewRelease = false; - - int versionMajor = KDesktopSettings::kDEVersionMajor(); - int versionMinor = KDesktopSettings::kDEVersionMinor(); - int versionRelease = KDesktopSettings::kDEVersionRelease(); - - if( versionMajor < TDE_VERSION_MAJOR ) - bNewRelease = true; - else if( versionMinor < TDE_VERSION_MINOR ) - bNewRelease = true; - else if( versionRelease < TDE_VERSION_RELEASE ) - bNewRelease = true; - - if( bNewRelease ) { - KDesktopSettings::setKDEVersionMajor( TDE_VERSION_MAJOR ); - KDesktopSettings::setKDEVersionMinor( TDE_VERSION_MINOR ); - KDesktopSettings::setKDEVersionRelease( TDE_VERSION_RELEASE ); - KDesktopSettings::writeConfig(); - } - - return bNewRelease; -} - -/** - * Create, if necessary, some directories in user's .kde/, - * copy default .directory files there, as well as templates files. - * Called by kdesktop on startup. - */ -void testLocalInstallation() -{ - const bool newRelease = isNewRelease(); - - const TQString desktopPath = realDesktopPath(); - const bool emptyDesktop = testDir( desktopPath ); - - // Do not force copying that one (it would lose the icon positions) - copyDirectoryFile("directory.desktop", desktopPath, false); - - testDir( TDEGlobalSettings::autostartPath() ); - // we force the copying in case of a new release, to install new translations.... - copyDirectoryFile("directory.autostart", TDEGlobalSettings::autostartPath(), newRelease); - - if (emptyDesktop) - copyDesktopLinks(); - - // Take care of creating or updating trash.desktop - const TQString trashDir = TDEGlobal::dirs()->localxdgdatadir() + "Trash"; - const bool firstTimeWithNewTrash = !TQFile::exists( trashDir ); - const TQString trashDesktopPath = desktopPath + "/trash.desktop"; - const bool trashDesktopExists = TQFile::exists( trashDesktopPath ); - const bool installNewTrashi18n = newRelease && trashDesktopExists; // not if deleted by user - if ( emptyDesktop || firstTimeWithNewTrash || installNewTrashi18n ) { - TQString oldIcon, oldEmptyIcon; - if ( trashDesktopExists ) { - KDesktopFile trashDesktop( trashDesktopPath, true ); - oldIcon = trashDesktop.readIcon(); - oldEmptyIcon = trashDesktop.readEntry( "EmptyIcon" ); - } - copyFile( locate( "data", "kdesktop/directory.trash" ), trashDesktopPath ); - if ( trashDesktopExists ) { - KDesktopFile trashDesktop( trashDesktopPath ); - trashDesktop.writeEntry( "Icon", oldIcon ); - trashDesktop.writeEntry( "EmptyIcon", oldEmptyIcon ); - trashDesktop.sync(); - } - } - - if ( firstTimeWithNewTrash ) { // migrate pre-kde-3.4 trash contents - TQByteArray packedArgs; - TQDataStream stream( packedArgs, IO_WriteOnly ); - stream << (int)2; - TDEIO::Job* job = TDEIO::special( "trash:/", packedArgs ); - (void)TDEIO::NetAccess::synchronousRun( job, 0 ); - - // OK the only thing missing is to convert the icon position... - KSimpleConfig cfg( locateLocal("appdata", "IconPositions") ); - if ( cfg.hasGroup( "IconPosition::Trash" ) && !cfg.hasGroup( "IconPosition::trash.desktop" ) ) { - const TQMap entries = cfg.entryMap( "IconPosition::Trash" ); - cfg.setGroup( "IconPosition::trash.desktop" ); - for( TQMap::ConstIterator it = entries.begin(); it != entries.end(); ++it ) { - cfg.writeEntry( it.key(), it.data() ); - } - } - } -} - diff --git a/kdesktop/init.cpp b/kdesktop/init.cpp new file mode 100644 index 000000000..6bf87f333 --- /dev/null +++ b/kdesktop/init.cpp @@ -0,0 +1,247 @@ +/* This file is part of the KDE project + Copyright (C) 1999 David Faure + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// for multihead +extern int kdesktop_screen_number; + + +/** + * Test if a directory exists, create otherwise + * @param _name full path of the directory + * @param _showMsg show a message box if we created the dir + * @return true if the dir was just created (e.g. so that we can populate it) + */ +static bool testDir( const TQString &_name ) +{ + DIR *dp; + dp = opendir( TQFile::encodeName(_name) ); + if ( dp == NULL ) + { + TQString m = _name; + if ( m.endsWith( "/" ) ) + m.truncate( m.length() - 1 ); + TQCString path = TQFile::encodeName(m); + + bool ok = ::mkdir( path, S_IRWXU ) == 0; + if ( !ok && errno == EEXIST ) { + int ret = KMessageBox::warningYesNo( 0, i18n("%1 is a file, but TDE needs it to be a directory; move it to %2.orig and create directory?").arg(m).arg(m), TQString::null, i18n("Move It"), i18n("Do Not Move") ); + if ( ret == KMessageBox::Yes ) { + if ( ::rename( path, path + ".orig" ) == 0 ) { + ok = ::mkdir( path, S_IRWXU ) == 0; + } else { + // foo.orig existed already. How likely is that? + ok = false; + } + } else { + return false; + } + } + if ( !ok ) + { + KMessageBox::sorry( 0, i18n( "Could not create directory %1; check for permissions or reconfigure the desktop to use another path." ).arg( m ) ); + return false; + } + return true; + } + else // exists already + { + closedir( dp ); + return false; + } +} + +/** + * Copy a standard .directory file to a user's directory + * @param fileName destination file name + * @param dir destination directory + * @param force if false, don't copy if destination file already exists + */ +static void copyDirectoryFile(const TQString &fileName, const TQString& dir, bool force) +{ + if (force || !TQFile::exists(dir + "/.directory")) { + TQString cmd = "cp "; + cmd += TDEProcess::quote(locate("data", TQString("kdesktop/") + fileName)); + cmd += " "; + cmd += TDEProcess::quote(dir+"/.directory"); + system( TQFile::encodeName(cmd) ); + } +} + +static void copyFile( const TQString& src, const TQString& dest ) +{ + TQCString cmd = "cp "; + cmd += TQFile::encodeName(TDEProcess::quote(src)); + cmd += " "; + cmd += TQFile::encodeName(TDEProcess::quote(dest)); + system( cmd ); +} + +static TQString realDesktopPath() +{ + TQString desktopPath = TDEGlobalSettings::desktopPath(); + if (kdesktop_screen_number != 0) { + TQString dn = "Desktop"; + dn += TQString::number(kdesktop_screen_number); + desktopPath.replace("Desktop", dn); + } + return desktopPath; +} + +/** + * Copy all links from DesktopLinks/ to the desktop, appropriately renamed + * (to the contents of the translated Name field) + */ +static void copyDesktopLinks() +{ + TDEConfig *config = kapp->config(); + config->setGroup("General"); + if (!config->readBoolEntry("CopyDesktopLinks", true)) + return; + + TQStringList list = + TDEGlobal::dirs()->findAllResources("appdata", "DesktopLinks/*", false, true); + + TQString desktopPath = realDesktopPath(); + + for (TQStringList::ConstIterator it = list.begin(); it != list.end(); it++) { + KDesktopFile desk( *it ); + if (desk.readBoolEntry("Hidden")) + continue; + copyFile( *it, desktopPath ); + } +} + +/** + * @return true if this is the first time + * kdesktop is run for the current release + * WARNING : call only once !!! (second call will always return false !) + */ +static bool isNewRelease() +{ + bool bNewRelease = false; + + int versionMajor = KDesktopSettings::kDEVersionMajor(); + int versionMinor = KDesktopSettings::kDEVersionMinor(); + int versionRelease = KDesktopSettings::kDEVersionRelease(); + + if( versionMajor < TDE_VERSION_MAJOR ) + bNewRelease = true; + else if( versionMinor < TDE_VERSION_MINOR ) + bNewRelease = true; + else if( versionRelease < TDE_VERSION_RELEASE ) + bNewRelease = true; + + if( bNewRelease ) { + KDesktopSettings::setKDEVersionMajor( TDE_VERSION_MAJOR ); + KDesktopSettings::setKDEVersionMinor( TDE_VERSION_MINOR ); + KDesktopSettings::setKDEVersionRelease( TDE_VERSION_RELEASE ); + KDesktopSettings::writeConfig(); + } + + return bNewRelease; +} + +/** + * Create, if necessary, some directories in user's .kde/, + * copy default .directory files there, as well as templates files. + * Called by kdesktop on startup. + */ +void testLocalInstallation() +{ + const bool newRelease = isNewRelease(); + + const TQString desktopPath = realDesktopPath(); + const bool emptyDesktop = testDir( desktopPath ); + + // Do not force copying that one (it would lose the icon positions) + copyDirectoryFile("directory.desktop", desktopPath, false); + + testDir( TDEGlobalSettings::autostartPath() ); + // we force the copying in case of a new release, to install new translations.... + copyDirectoryFile("directory.autostart", TDEGlobalSettings::autostartPath(), newRelease); + + if (emptyDesktop) + copyDesktopLinks(); + + // Take care of creating or updating trash.desktop + const TQString trashDir = TDEGlobal::dirs()->localxdgdatadir() + "Trash"; + const bool firstTimeWithNewTrash = !TQFile::exists( trashDir ); + const TQString trashDesktopPath = desktopPath + "/trash.desktop"; + const bool trashDesktopExists = TQFile::exists( trashDesktopPath ); + const bool installNewTrashi18n = newRelease && trashDesktopExists; // not if deleted by user + if ( emptyDesktop || firstTimeWithNewTrash || installNewTrashi18n ) { + TQString oldIcon, oldEmptyIcon; + if ( trashDesktopExists ) { + KDesktopFile trashDesktop( trashDesktopPath, true ); + oldIcon = trashDesktop.readIcon(); + oldEmptyIcon = trashDesktop.readEntry( "EmptyIcon" ); + } + copyFile( locate( "data", "kdesktop/directory.trash" ), trashDesktopPath ); + if ( trashDesktopExists ) { + KDesktopFile trashDesktop( trashDesktopPath ); + trashDesktop.writeEntry( "Icon", oldIcon ); + trashDesktop.writeEntry( "EmptyIcon", oldEmptyIcon ); + trashDesktop.sync(); + } + } + + if ( firstTimeWithNewTrash ) { // migrate pre-kde-3.4 trash contents + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)2; + TDEIO::Job* job = TDEIO::special( "trash:/", packedArgs ); + (void)TDEIO::NetAccess::synchronousRun( job, 0 ); + + // OK the only thing missing is to convert the icon position... + KSimpleConfig cfg( locateLocal("appdata", "IconPositions") ); + if ( cfg.hasGroup( "IconPosition::Trash" ) && !cfg.hasGroup( "IconPosition::trash.desktop" ) ) { + const TQMap entries = cfg.entryMap( "IconPosition::Trash" ); + cfg.setGroup( "IconPosition::trash.desktop" ); + for( TQMap::ConstIterator it = entries.begin(); it != entries.end(); ++it ) { + cfg.writeEntry( it.key(), it.data() ); + } + } + } +} + diff --git a/kdesktop/kcustommenu.cc b/kdesktop/kcustommenu.cc deleted file mode 100644 index 2e825c0d9..000000000 --- a/kdesktop/kcustommenu.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include - -#include "kcustommenu.h" - -class KCustomMenu::KCustomMenuPrivate -{ -public: - TQMap entryMap; -}; - -KCustomMenu::KCustomMenu(const TQString &configfile, TQWidget *parent) - : TQPopupMenu(parent, "kcustom_menu") -{ - d = new KCustomMenuPrivate; - - TDEConfig cfg(configfile, true, false); - int count = cfg.readNumEntry("NrOfItems"); - for(int i = 0; i < count; i++) - { - TQString entry = cfg.readEntry(TQString("Item%1").arg(i+1)); - if (entry.isEmpty()) - continue; - - // Try KSycoca first. - KService::Ptr menuItem = KService::serviceByDesktopPath( entry ); - if (!menuItem) - menuItem = KService::serviceByDesktopName( entry ); - if (!menuItem) - menuItem = new KService( entry ); - - if (!menuItem->isValid()) - continue; - - insertMenuItem( menuItem, -1 ); - } - connect(this, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); -} - -KCustomMenu::~KCustomMenu() -{ - delete d; -} - -void -KCustomMenu::slotActivated(int id) -{ - KService::Ptr s = d->entryMap[id]; - if (!s) - return; - kapp->startServiceByDesktopPath(s->desktopEntryPath()); -} - -// The following is copied from kicker's PanelServiceMenu -void -KCustomMenu::insertMenuItem(KService::Ptr & s, int nId, int nIndex/*= -1*/) -{ - TQString serviceName = s->name(); - - // item names may contain ampersands. To avoid them being converted - // to accelators, replace them with two ampersands. - serviceName.replace("&", "&&"); - - TQPixmap normal = TDEGlobal::instance()->iconLoader()->loadIcon(s->icon(), TDEIcon::Small, - 0, TDEIcon::DefaultState, 0L, true); - TQPixmap active = TDEGlobal::instance()->iconLoader()->loadIcon(s->icon(), TDEIcon::Small, - 0, TDEIcon::ActiveState, 0L, true); - // make sure they are not larger than 16x16 - if (normal.width() > 16 || normal.height() > 16) { - TQImage tmp = normal.convertToImage(); - tmp = tmp.smoothScale(16, 16); - normal.convertFromImage(tmp); - } - if (active.width() > 16 || active.height() > 16) { - TQImage tmp = active.convertToImage(); - tmp = tmp.smoothScale(16, 16); - active.convertFromImage(tmp); - } - - TQIconSet iconset; - iconset.setPixmap(normal, TQIconSet::Small, TQIconSet::Normal); - iconset.setPixmap(active, TQIconSet::Small, TQIconSet::Active); - - int newId = insertItem(iconset, serviceName, nId, nIndex); - d->entryMap.insert(newId, s); -} - -#include "kcustommenu.moc" diff --git a/kdesktop/kcustommenu.cpp b/kdesktop/kcustommenu.cpp new file mode 100644 index 000000000..2e825c0d9 --- /dev/null +++ b/kdesktop/kcustommenu.cpp @@ -0,0 +1,111 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Waldo Bastian + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include + +#include "kcustommenu.h" + +class KCustomMenu::KCustomMenuPrivate +{ +public: + TQMap entryMap; +}; + +KCustomMenu::KCustomMenu(const TQString &configfile, TQWidget *parent) + : TQPopupMenu(parent, "kcustom_menu") +{ + d = new KCustomMenuPrivate; + + TDEConfig cfg(configfile, true, false); + int count = cfg.readNumEntry("NrOfItems"); + for(int i = 0; i < count; i++) + { + TQString entry = cfg.readEntry(TQString("Item%1").arg(i+1)); + if (entry.isEmpty()) + continue; + + // Try KSycoca first. + KService::Ptr menuItem = KService::serviceByDesktopPath( entry ); + if (!menuItem) + menuItem = KService::serviceByDesktopName( entry ); + if (!menuItem) + menuItem = new KService( entry ); + + if (!menuItem->isValid()) + continue; + + insertMenuItem( menuItem, -1 ); + } + connect(this, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); +} + +KCustomMenu::~KCustomMenu() +{ + delete d; +} + +void +KCustomMenu::slotActivated(int id) +{ + KService::Ptr s = d->entryMap[id]; + if (!s) + return; + kapp->startServiceByDesktopPath(s->desktopEntryPath()); +} + +// The following is copied from kicker's PanelServiceMenu +void +KCustomMenu::insertMenuItem(KService::Ptr & s, int nId, int nIndex/*= -1*/) +{ + TQString serviceName = s->name(); + + // item names may contain ampersands. To avoid them being converted + // to accelators, replace them with two ampersands. + serviceName.replace("&", "&&"); + + TQPixmap normal = TDEGlobal::instance()->iconLoader()->loadIcon(s->icon(), TDEIcon::Small, + 0, TDEIcon::DefaultState, 0L, true); + TQPixmap active = TDEGlobal::instance()->iconLoader()->loadIcon(s->icon(), TDEIcon::Small, + 0, TDEIcon::ActiveState, 0L, true); + // make sure they are not larger than 16x16 + if (normal.width() > 16 || normal.height() > 16) { + TQImage tmp = normal.convertToImage(); + tmp = tmp.smoothScale(16, 16); + normal.convertFromImage(tmp); + } + if (active.width() > 16 || active.height() > 16) { + TQImage tmp = active.convertToImage(); + tmp = tmp.smoothScale(16, 16); + active.convertFromImage(tmp); + } + + TQIconSet iconset; + iconset.setPixmap(normal, TQIconSet::Small, TQIconSet::Normal); + iconset.setPixmap(active, TQIconSet::Small, TQIconSet::Active); + + int newId = insertItem(iconset, serviceName, nId, nIndex); + d->entryMap.insert(newId, s); +} + +#include "kcustommenu.moc" diff --git a/kdesktop/kdesktop.kcfg b/kdesktop/kdesktop.kcfg index 53a1cc781..5df427c71 100644 --- a/kdesktop/kdesktop.kcfg +++ b/kdesktop/kdesktop.kcfg @@ -52,7 +52,7 @@ true - + @@ -64,9 +64,9 @@ false - + - + @@ -85,7 +85,7 @@ Forward - + @@ -190,7 +190,7 @@ - + @@ -199,14 +199,14 @@ true - + media/nfs_mounted,media/nfs_unmounted,media/hdd_mounted,media/hdd_unmounted,media/floppy_unmounted,media/cdrom_unmounted,media/floppy5_unmounted The device types which you do not want to see on the desktop. - + diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc deleted file mode 100644 index c8c5a1fe6..000000000 --- a/kdesktop/kdiconview.cc +++ /dev/null @@ -1,2092 +0,0 @@ -/* This file is part of the TDE project - Copyright (C) 1998, 1999 Torben Weis - Copyright (C) 2000, 2001 David Faure - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License version 2 as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kdiconview.h" -#include "krootwm.h" -#include "desktop.h" -#include "kdesktopsettings.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include "kshadowengine.h" -#include "kdesktopshadowsettings.h" -#include "tdefileividesktop.h" - -// for multihead -extern int kdesktop_screen_number; - -// ----------------------------------------------------------------------------- - -TQRect KDIconView::desktopRect() -{ - return ( kdesktop_screen_number == 0 ) - ? TQApplication::desktop()->geometry() // simple case, or xinerama - : TQApplication::desktop()->screenGeometry( kdesktop_screen_number ); // multi-head -} - -// ----------------------------------------------------------------------------- - -void KDIconView::saveIconPosition(KSimpleConfig *config, int x, int y) -{ - // save the icon position in absolute coordinates - config->writeEntry("Xabs", x); - config->writeEntry("Yabs", y); - - // save also mentioning desktop size - TQRect desk = desktopRect(); - TQString sizeStr = TQString( "_%1x%2" ).arg(desk.width()).arg(desk.height()); - - config->writeEntry("Xabs" + sizeStr, x); - config->writeEntry("Yabs" + sizeStr, y); -} - -// ----------------------------------------------------------------------------- - -void KDIconView::readIconPosition(KSimpleConfig *config, int &x, int &y) -{ - // check if we have the position for the current desktop size - TQRect desk = desktopRect(); - TQString sizeStr = TQString( "_%1x%2" ).arg(desk.width()).arg(desk.height()); - - x = config->readNumEntry("Xabs" + sizeStr, -99999); - - if ( x != -99999 ) - y = config->readNumEntry("Yabs" + sizeStr); - else - { - // not found; use the resolution independent position - x = config->readNumEntry("Xabs", -99999); - - if ( x != -99999 ) - y = config->readNumEntry("Yabs"); - else // for compatibility, read the old iconArea-relative-position - { - // problem here: when reading a position before we know the correct - // desktopIconsArea, the relative position do not make sense - // workaround: use desktopRect() as the allowed size - - TQRect desk = desktopRect(); - TQString X_w = TQString("X %1").arg(desk.width() ); - TQString Y_h = TQString("Y %1").arg(desk.height()); - - x = config->readNumEntry(X_w, -99999); - if ( x != -99999 ) x = config->readNumEntry("X"); - if ( x < 0 ) x += desk.width(); - - y = config->readNumEntry(Y_h, -99999); - if ( y != -99999 ) y = config->readNumEntry("Y"); - if ( y < 0 ) y += desk.height(); - } - } -} - -// ----------------------------------------------------------------------------- - -KDIconView::KDIconView( TQWidget *parent, const char* name ) - : KonqIconViewWidget( parent, name, (WFlags)WResizeNoErase, true ), - m_actionCollection( this, "KDIconView::m_actionCollection" ), - m_accel( 0L ), - m_bNeedRepaint( false ), - m_bNeedSave( false ), - m_autoAlign( false ), - m_hasExistingPos( false ), - m_bEditableDesktopIcons( kapp->authorize("editable_desktop_icons") ), - m_bShowDot( false ), - m_bVertAlign( true ), - m_dirLister( 0L ), - m_mergeDirs(), - m_dotDirectory( 0L ), - m_lastDeletedIconPos(), - m_eSortCriterion( NameCaseInsensitive ), - m_bSortDirectoriesFirst( true ), - m_itemsAlwaysFirst(), - m_enableMedia(false), - m_gotIconsArea(false), - m_needDesktopAlign(true), - m_paOutstandingFreeSpaceOverlaysTimer( 0L ) -{ - setResizeMode( Fixed ); - setIconArea( desktopRect() ); // the default is the whole desktop - - // Initialise the shadow data objects... - m_shadowEngine = new KShadowEngine(new KDesktopShadowSettings(TDEGlobal::config())); - - // Initialize media handler - mMediaListView = new TQListView(); - - connect( TQApplication::clipboard(), TQT_SIGNAL(dataChanged()), this, TQT_SLOT(slotClipboardDataChanged()) ); - - setURL( desktopURL() ); // sets m_url - - m_desktopDirs = TDEGlobal::dirs()->findDirs( "appdata", "Desktop" ); - initDotDirectories(); - - connect( this, TQT_SIGNAL( executed( TQIconViewItem * ) ), - TQT_SLOT( slotExecuted( TQIconViewItem * ) ) ); - connect( this, TQT_SIGNAL( returnPressed( TQIconViewItem * ) ), - TQT_SLOT( slotReturnPressed( TQIconViewItem * ) ) ); - connect( this, TQT_SIGNAL( mouseButtonPressed(int, TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotMouseButtonPressed(int, TQIconViewItem*, const TQPoint&)) ); - connect( this, TQT_SIGNAL( mouseButtonClicked(int, TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotMouseButtonClickedKDesktop(int, TQIconViewItem*, const TQPoint&)) ); - connect( this, TQT_SIGNAL( contextMenuRequested(TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotContextMenuRequested(TQIconViewItem*, const TQPoint&)) ); - - connect( this, TQT_SIGNAL( enableAction( const char * , bool ) ), - TQT_SLOT( slotEnableAction( const char * , bool ) ) ); - - // Hack: KonqIconViewWidget::slotItemRenamed is not virtual :-( - disconnect( this, TQT_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), - this, TQT_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); - connect( this, TQT_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), - this, TQT_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); - - if (!m_bEditableDesktopIcons) - { - setItemsMovable(false); - setAcceptDrops(false); - viewport()->setAcceptDrops(false); - } -} - -KDIconView::~KDIconView() -{ - if (m_dotDirectory && !m_bEditableDesktopIcons) { - m_dotDirectory->rollback(false); // Don't save positions - } - - delete m_dotDirectory; - delete m_dirLister; - delete m_shadowEngine; -} - -void KDIconView::initDotDirectories() -{ - TQStringList dirs = m_desktopDirs; - KURL u = desktopURL(); - if (u.isLocalFile()) { - dirs.prepend(u.path()); - } - - TQString prefix = iconPositionGroupPrefix(); - TQString dotFileName = locateLocal("appdata", "IconPositions"); - if (kdesktop_screen_number != 0) { - dotFileName += "_Desktop" + TQString::number(kdesktop_screen_number); - } - - if (m_dotDirectory && !m_bEditableDesktopIcons) { - m_dotDirectory->rollback(false); // Don't save positions - } - - delete m_dotDirectory; - - m_dotDirectory = new KSimpleConfig( dotFileName ); - // If we don't allow editable desktop icons, empty m_dotDirectory - if (!m_bEditableDesktopIcons) - { - TQStringList groups = m_dotDirectory->groupList(); - TQStringList::ConstIterator gIt = groups.begin(); - TQStringList::ConstIterator gEnd = groups.end(); - for (; gIt != gEnd; ++gIt ) - { - m_dotDirectory->deleteGroup(*gIt, true); - } - } - TQRect desk = desktopRect(); - TQString X_w = TQString( "X %1" ).arg( desk.width() ); - TQString Y_h = TQString( "Y %1" ).arg( desk.height() ); - for ( TQStringList::ConstIterator it = dirs.begin() ; it != dirs.end() ; ++it ) - { - kdDebug(1204) << "KDIconView::initDotDirectories found dir " << *it << endl; - TQString localDotFileName = *it + "/.directory"; - - if (TQFile::exists(localDotFileName)) - { - KSimpleConfig dotDir(localDotFileName, true); // Read only - - TQStringList groups = dotDir.groupList(); - TQStringList::ConstIterator gIt = groups.begin(); - TQStringList::ConstIterator gEnd = groups.end(); - for (; gIt != gEnd; ++gIt ) - { - if ( (*gIt).startsWith(prefix) ) - { - dotDir.setGroup( *gIt ); - m_dotDirectory->setGroup( *gIt ); - - if (!m_dotDirectory->hasKey( X_w )) - { - int x,y; - readIconPosition(&dotDir, x, y); - m_dotDirectory->writeEntry( X_w, x ); - m_dotDirectory->writeEntry( Y_h, y ); // Not persistent! - } - } - } - } - } -} - -void KDIconView::initConfig( bool init ) -{ - //kdDebug() << "initConfig " << init << endl; - - if ( !init ) { - KonqFMSettings::reparseConfiguration(); - KDesktopSettings::self()->readConfig(); - } - - TDEConfig * config = TDEGlobal::config(); - - if ( !init ) { - KDesktopShadowSettings *shadowSettings = static_cast(m_shadowEngine->shadowSettings()); - shadowSettings->setConfig(config); - } - - setMaySetWallpaper(!config->isImmutable() && !TDEGlobal::dirs()->isRestrictedResource("wallpaper")); - m_bShowDot = KDesktopSettings::showHidden(); - m_bVertAlign = KDesktopSettings::vertAlign(); - TQStringList oldPreview = previewSettings(); - setPreviewSettings( KDesktopSettings::preview() ); - - // read arrange configuration - m_eSortCriterion = (SortCriterion)KDesktopSettings::sortCriterion(); - m_bSortDirectoriesFirst = KDesktopSettings::directoriesFirst(); - m_itemsAlwaysFirst = KDesktopSettings::alwaysFirstItems(); // Distributor plug-in - - if (KProtocolInfo::isKnownProtocol(TQString::fromLatin1("media"))) { - m_enableMedia=KDesktopSettings::mediaEnabled(); - } - else { - m_enableMedia=false; - } - TQString tmpList=KDesktopSettings::exclude(); - kdDebug(1204)<<"m_excludeList"<setShowingDotFiles( m_bShowDot ); - m_dirLister->emitChanges(); - } - slotFreeSpaceOverlaySettingChanged(); - - setArrangement(m_bVertAlign ? TopToBottom : LeftToRight); - - if ( KonqIconViewWidget::initConfig( init ) ) - lineupIcons(); // called if the font changed. - - setAutoArrange( false ); - - if ( previewSettings().count() ) - { - for ( TQStringList::ConstIterator it = oldPreview.begin(); it != oldPreview.end(); ++it) - if ( !previewSettings().contains( *it ) ){ - kdDebug(1204) << "Disabling preview for " << *it << endl; - if ( *it == "audio/" ) - disableSoundPreviews(); - else - { - KService::Ptr serv = KService::serviceByDesktopName( *it ); - Q_ASSERT( serv != 0L ); - if ( serv ) - { - setIcons( iconSize( ), serv->property("MimeTypes").toStringList() /* revert no-longer wanted previews to icons */ ); - } - } - } - startImagePreview( TQStringList(), true ); - } - else - { - stopImagePreview(); - setIcons( iconSize(), "*" /* stopImagePreview */ ); - } - - if ( !init ) - updateContents(); -} - -void KDIconView::start() -{ - // We can only start once - Q_ASSERT(!m_dirLister); - if (m_dirLister) { - return; - } - - kdDebug(1204) << "KDIconView::start" << endl; - - // Create the directory lister - m_dirLister = new KDirLister(); - - m_bNeedSave = false; - - connect( m_dirLister, TQT_SIGNAL( clear() ), this, TQT_SLOT( slotClear() ) ); - connect( m_dirLister, TQT_SIGNAL( started(const KURL&) ), this, TQT_SLOT( slotStarted(const KURL&) ) ); - connect( m_dirLister, TQT_SIGNAL( completed() ), this, TQT_SLOT( slotCompleted() ) ); - connect( m_dirLister, TQT_SIGNAL( newItems( const KFileItemList & ) ), this, TQT_SLOT( slotNewItems( const KFileItemList & ) ) ); - connect( m_dirLister, TQT_SIGNAL( deleteItem( KFileItem * ) ), this, TQT_SLOT( slotDeleteItem( KFileItem * ) ) ); - connect( m_dirLister, TQT_SIGNAL( refreshItems( const KFileItemList & ) ), this, TQT_SLOT( slotRefreshItems( const KFileItemList & ) ) ); - - // Start the directory lister ! - m_dirLister->setShowingDotFiles( m_bShowDot ); - kapp->allowURLAction("list", KURL(), url()); - startDirLister(); - createActions(); -} - -void KDIconView::configureMedia() -{ - kdDebug(1204) << "***********KDIconView::configureMedia() " <setMimeExcludeFilter(m_excludedMedia); - m_dirLister->emitChanges(); - updateContents(); - if (m_enableMedia) { - for (KURL::List::Iterator it1=m_mergeDirs.begin();it1!=m_mergeDirs.end();++it1) { - if ((*it1).url()=="media:/") { - return; - } - } - m_mergeDirs.append(KURL("media:/")); - m_dirLister->openURL(KURL("media:/"), true); - } - else { - for (KURL::List::Iterator it2=m_mergeDirs.begin();it2!=m_mergeDirs.end();++it2) { - if ((*it2).url()=="media:/") { - delete m_dirLister; - m_dirLister=0; - start(); - if (m_mergeDirs.contains(*it2)) { - m_mergeDirs.remove(*it2); - m_dirLister->stop("media"); - } - return; - } - } - return; - } -} - -void KDIconView::createActions() -{ - if (m_bEditableDesktopIcons) - { - TDEAction *undo = KStdAction::undo( KonqUndoManager::self(), TQT_SLOT( undo() ), &m_actionCollection, "undo" ); - connect( KonqUndoManager::self(), TQT_SIGNAL( undoAvailable( bool ) ), - undo, TQT_SLOT( setEnabled( bool ) ) ); - connect( KonqUndoManager::self(), TQT_SIGNAL( undoTextChanged( const TQString & ) ), - undo, TQT_SLOT( setText( const TQString & ) ) ); - undo->setEnabled( KonqUndoManager::self()->undoAvailable() ); - - TDEAction* paCut = KStdAction::cut( TQT_TQOBJECT(this), TQT_SLOT( slotCut() ), &m_actionCollection, "cut" ); - TDEShortcut cutShortCut = paCut->shortcut(); - cutShortCut.remove( KKey( SHIFT + Key_Delete ) ); // used for deleting files - paCut->setShortcut( cutShortCut ); - - KStdAction::copy( TQT_TQOBJECT(this), TQT_SLOT( slotCopy() ), &m_actionCollection, "copy" ); - KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotPaste() ), &m_actionCollection, "paste" ); - TDEAction *pasteTo = KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotPopupPasteTo() ), &m_actionCollection, "pasteto" ); - pasteTo->setEnabled( false ); // only enabled during popupMenu() - - TDEShortcut reloadShortcut = TDEStdAccel::shortcut(TDEStdAccel::Reload); - new TDEAction( i18n( "&Reload" ), "reload", reloadShortcut, TQT_TQOBJECT(this), TQT_SLOT( refreshIcons() ), &m_actionCollection, "reload" ); - - (void) new TDEAction( i18n( "&Rename" ), /*"editrename",*/ Key_F2, TQT_TQOBJECT(this), TQT_SLOT( renameSelectedItem() ), &m_actionCollection, "rename" ); - (void) new TDEAction( i18n( "&Properties" ), ALT+Key_Return, TQT_TQOBJECT(this), TQT_SLOT( slotProperties() ), &m_actionCollection, "properties" ); - TDEAction* trash = new TDEAction( i18n( "&Move to Trash" ), "edittrash", Key_Delete, &m_actionCollection, "trash" ); - connect( trash, TQT_SIGNAL( activated( TDEAction::ActivationReason, TQt::ButtonState ) ), - this, TQT_SLOT( slotTrashActivated( TDEAction::ActivationReason, TQt::ButtonState ) ) ); - - TDEConfig config("kdeglobals", true, false); - config.setGroup( "KDE" ); - (void) new TDEAction( i18n( "&Delete" ), "edit-delete", SHIFT+Key_Delete, TQT_TQOBJECT(this), TQT_SLOT( slotDelete() ), &m_actionCollection, "del" ); - - // Initial state of the actions (cut/copy/paste/...) - slotSelectionChanged(); - //init paste action - slotClipboardDataChanged(); - } -} - -void KDIconView::rearrangeIcons( SortCriterion sc, bool bSortDirectoriesFirst ) -{ - m_eSortCriterion = sc; - m_bSortDirectoriesFirst = bSortDirectoriesFirst; - rearrangeIcons(); -} - -void KDIconView::rearrangeIcons() -{ - setupSortKeys(); - sort(); // calls arrangeItemsInGrid() which does not honor iconArea() - - if ( m_autoAlign ) - lineupIcons( m_bVertAlign ? TQIconView::TopToBottom : TQIconView::LeftToRight ); // also saves position - else - { - KonqIconViewWidget::lineupIcons(m_bVertAlign ? TQIconView::TopToBottom : TQIconView::LeftToRight); - saveIconPositions(); - } -} - -void KDIconView::lineupIcons() -{ - if ( !m_gotIconsArea ) return; - KonqIconViewWidget::lineupIcons(); - saveIconPositions(); -} - -void KDIconView::setAutoAlign( bool b ) -{ - m_autoAlign = b; - - // Auto line-up icons - if ( b ) { - // set maxItemWidth to ensure sane initial icon layout before the auto align code is fully activated - int sz = iconSize() ? iconSize() : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop ); - setMaxItemWidth( TQMAX( TQMAX( sz, previewIconSize( iconSize() ) ), KonqFMSettings::settings()->iconTextWidth() ) ); - setFont( font() ); // Force calcRect() - - if (!KRootWm::self()->startup) { - lineupIcons(); - } - else { - KRootWm::self()->startup = false; - } - connect( this, TQT_SIGNAL( iconMoved() ), - this, TQT_SLOT( lineupIcons() ) ); - } - else { - // change maxItemWidth, because when grid-align was active, it changed this for the grid - int sz = iconSize() ? iconSize() : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop ); - setMaxItemWidth( TQMAX( TQMAX( sz, previewIconSize( iconSize() ) ), KonqFMSettings::settings()->iconTextWidth() ) ); - setFont( font() ); // Force calcRect() - - disconnect( this, TQT_SIGNAL( iconMoved() ), - this, TQT_SLOT( lineupIcons() ) ); - } -} - -void KDIconView::startDirLister() -{ - // if desktop is resized before start() is called (XRandr) - if (!m_dirLister) return; - - m_dirLister->openURL( url() ); - - // Gather the list of directories to merge into the desktop - // (the main URL is desktopURL(), no need for it in the m_mergeDirs list) - m_mergeDirs.clear(); - for ( TQStringList::ConstIterator it = m_desktopDirs.begin() ; it != m_desktopDirs.end() ; ++it ) - { - kdDebug(1204) << "KDIconView::desktopResized found merge dir " << *it << endl; - KURL u; - u.setPath( *it ); - m_mergeDirs.append( u ); - // And start listing this dir right now - kapp->allowURLAction("list", KURL(), u); - m_dirLister->openURL( u, true ); - } - configureMedia(); -} - -void KDIconView::lineupIcons(TQIconView::Arrangement align) -{ - m_bVertAlign = ( align == TQIconView::TopToBottom ); - setArrangement( m_bVertAlign ? TopToBottom : LeftToRight ); - - if ( m_autoAlign ) - { - KonqIconViewWidget::lineupIcons( align ); - saveIconPositions(); - } - else - rearrangeIcons(); // also saves the position - - KDesktopSettings::setVertAlign( m_bVertAlign ); - KDesktopSettings::writeConfig(); -} - -// Only used for DCOP -TQStringList KDIconView::selectedURLs() -{ - TQStringList seq; - - TQIconViewItem *it = firstItem(); - for (; it; it = it->nextItem() ) - if ( it->isSelected() ) { - KFileItem *fItem = ((KFileIVI *)it)->item(); - seq.append( fItem->url().url() ); // copy the URL - } - - return seq; -} - -void KDIconView::recheckDesktopURL() -{ - // Did someone change the path to the desktop ? - kdDebug(1204) << desktopURL().url() << endl; - kdDebug(1204) << url().url() << endl; - if ( desktopURL() != url() ) - { - kdDebug(1204) << "Desktop path changed from " << url().url() << - " to " << desktopURL().url() << endl; - setURL( desktopURL() ); // sets m_url - initDotDirectories(); - m_dirLister->openURL( url() ); - } -} - -KURL KDIconView::desktopURL() -{ - // Support both paths and URLs - TQString desktopPath = TDEGlobalSettings::desktopPath(); - if (kdesktop_screen_number != 0) { - TQString dn = "Desktop"; - dn += TQString::number(kdesktop_screen_number); - desktopPath.replace("Desktop", dn); - } - - KURL desktopURL; - if (desktopPath[0] == '/') - desktopURL.setPath(desktopPath); - else - desktopURL = desktopPath; - - Q_ASSERT( desktopURL.isValid() ); - if ( !desktopURL.isValid() ) { // should never happen - KURL u; - u.setPath( TQDir::homeDirPath() + "/" + "Desktop" + "/" ); - return u; - } - - return desktopURL; -} - -void KDIconView::contentsMousePressEvent( TQMouseEvent *e ) -{ - if (!m_dirLister) return; - //kdDebug(1204) << "KDIconView::contentsMousePressEvent" << endl; - // TQIconView, as of Qt 2.2, doesn't emit mouseButtonPressed for LMB on background - if ( e->button() == Qt::LeftButton && KRootWm::self()->hasLeftButtonMenu() ) - { - TQIconViewItem *item = findItem( e->pos() ); - if ( !item ) - { - // Left click menu - KRootWm::self()->mousePressed( e->globalPos(), e->button() ); - return; - } - } - KonqIconViewWidget::contentsMousePressEvent( e ); -} - -void KDIconView::mousePressEvent( TQMouseEvent *e ) -{ - KRootWm::self()->mousePressed( e->globalPos(), e->button() ); -} - -void KDIconView::wheelEvent( TQWheelEvent* e ) -{ - if (!m_dirLister) return; - //kdDebug(1204) << "KDIconView::wheelEvent" << endl; - - TQIconViewItem *item = findItem( e->pos() ); - if ( !item ) - { - emit wheelRolled( e->delta() ); - return; - } - - KonqIconViewWidget::wheelEvent( e ); -} - -void KDIconView::slotProperties() -{ - KFileItemList selectedFiles = selectedFileItems(); - - if( selectedFiles.isEmpty() ) - return; - - (void) new KPropertiesDialog( selectedFiles ); -} - -void KDIconView::slotContextMenuRequested(TQIconViewItem *_item, const TQPoint& _global) -{ - if (_item) - { - ((KFileIVI*)_item)->setSelected( true ); - popupMenu( _global, selectedFileItems() ); - } -} - -void KDIconView::slotMouseButtonPressed(int _button, TQIconViewItem* _item, const TQPoint& _global) -{ - //kdDebug(1204) << "KDIconView::slotMouseButtonPressed" << endl; - if (!m_dirLister) return; - m_lastDeletedIconPos = TQPoint(); // user action -> not renaming an icon - if(!_item) { - KRootWm::self()->mousePressed( _global, _button ); - } -} - -void KDIconView::slotMouseButtonClickedKDesktop(int _button, TQIconViewItem* _item, const TQPoint&) -{ - if (!m_dirLister) return; - //kdDebug(1204) << "KDIconView::slotMouseButtonClickedKDesktop" << endl; - if ( _item && _button == Qt::MidButton ) { - slotExecuted(_item); - } -} - -// ----------------------------------------------------------------------------- - -void KDIconView::slotReturnPressed( TQIconViewItem *item ) -{ - if (item && item->isSelected()) { - slotExecuted(item); - } -} - -// ----------------------------------------------------------------------------- - -void KDIconView::slotExecuted( TQIconViewItem *item ) -{ - kapp->propagateSessionManager(); - m_lastDeletedIconPos = TQPoint(); // user action -> not renaming an icon - if (item) { - visualActivate(item); - ((KFileIVI*)item)->returnPressed(); - } -} - -// ----------------------------------------------------------------------------- - -void KDIconView::slotCut() -{ - cutSelection(); -} - -// ----------------------------------------------------------------------------- - -void KDIconView::slotCopy() -{ - copySelection(); -} - -// ----------------------------------------------------------------------------- - -void KDIconView::slotPaste() -{ - KonqOperations::doPaste(this, url(), KRootWm::self()->desktopMenuPosition()); -} - -void KDIconView::slotPopupPasteTo() -{ - Q_ASSERT( !m_popupURL.isEmpty() ); - if ( !m_popupURL.isEmpty() ) - paste( m_popupURL ); -} - -// These two functions and the following class are all lifted from desktopbehavior_impl.cpp to handle the media icons -class DesktopBehaviorMediaItem : public TQCheckListItem -{ -public: - DesktopBehaviorMediaItem(TQListView *parent, const TQString name, const TQString mimetype, bool on) - : TQCheckListItem(parent, name, CheckBox), - m_mimeType(mimetype){setOn(on);} - - const TQString &mimeType() const { return m_mimeType; } - -private: - TQString m_mimeType; -}; - -void KDIconView::fillMediaListView() -{ - g_pConfig = new TDEConfig("kdesktoprc"); - mMediaListView->hide(); - mMediaListView->clear(); - KMimeType::List mimetypes = KMimeType::allMimeTypes(); - TQValueListIterator it2(mimetypes.begin()); - g_pConfig->setGroup( "Media" ); - TQString excludedMedia=g_pConfig->readEntry("exclude","media/hdd_mounted,media/hdd_unmounted,media/floppy_unmounted,media/cdrom_unmounted,media/floppy5_unmounted"); - for (; it2 != mimetypes.end(); ++it2) { - if ( ((*it2)->name().startsWith("media/")) ) - { - bool ok=excludedMedia.contains((*it2)->name())==0; - new DesktopBehaviorMediaItem (mMediaListView, (*it2)->comment(), (*it2)->name(),ok); - } - } - delete g_pConfig; -} - -void KDIconView::saveMediaListView() -{ - g_pConfig = new TDEConfig("kdesktoprc"); - g_pConfig->setGroup( "Media" ); - TQStringList exclude; - for (DesktopBehaviorMediaItem *it=static_cast(mMediaListView->firstChild()); - it; it=static_cast(it->nextSibling())) - { - if (!it->isOn()) exclude << it->mimeType(); - } - g_pConfig->writeEntry("exclude",exclude); - g_pConfig->sync(); - - // Reload kdesktop configuration to apply changes - TQByteArray data; - int konq_screen_number = TDEApplication::desktop()->primaryScreen(); - TQCString appname; - if (konq_screen_number == 0) - appname = "kdesktop"; - else - appname.sprintf("kdesktop-screen-%d", konq_screen_number); - kapp->dcopClient()->send( appname, "KDesktopIface", "configure()", data ); - delete g_pConfig; -} - -void KDIconView::removeBuiltinIcon(TQString iconName) -{ - DesktopBehaviorMediaItem *changeItem; - fillMediaListView(); - changeItem = static_cast(mMediaListView->findItem(iconName, 0)); - if (changeItem != 0) { - changeItem->setOn(false); - } - saveMediaListView(); - KMessageBox::information(0, i18n("You have chosen to remove a system icon") + TQString(".\n") + i18n("You can restore this icon in the future through the") + TQString(" \"") + ("Device Icons") + TQString("\" ") + i18n("tab in the") + TQString(" \"") + i18n("Behavior") + TQString("\" ") + i18n("pane of the Desktop Settings control module."), "System Icon Removed", "sysiconremovedwarning"); -} - -/** - * The files on the desktop come from a variety of sources. - * If an attempt is made to delete a .desktop file that does - * not originate from the users own Desktop directory then - * a .desktop file with "Hidden=true" is written to the users - * own Desktop directory to hide the file. - * - * Returns true if all selected items have been deleted. - * Returns false if there are selected items remaining that - * still need to be deleted in a regular fashion. - */ -bool KDIconView::deleteGlobalDesktopFiles() -{ - KURL desktop_URL = desktopURL(); - if (!desktop_URL.isLocalFile()) - return false; // Dunno how to do this. - - TQString desktopPath = desktop_URL.path(); - - bool itemsLeft = false; - TQIconViewItem *it = 0; - TQIconViewItem *nextIt = firstItem(); - for (; (it = nextIt); ) - { - nextIt = it->nextItem(); - if ( !it->isSelected() ) - continue; - - KFileItem *fItem = ((KFileIVI *)it)->item(); - if (fItem->url().path().startsWith(desktopPath)) - { - itemsLeft = true; - continue; // File is in users own Desktop directory - } - - if (!isDesktopFile(fItem)) - { - itemsLeft = true; - continue; // Not a .desktop file - } - - // Ignore these special files - // Name URL Type OnlyShowIn - // My Documents XDG_DOCUMENTS_DIR Application TDE; - // My Computer media:/ Link TDE; - // My Network Places remote:/ Link TDE; - // Printers [exec] kjobviewer --all --show %i %m Application TDE; - // Trash trash:/ Link TDE; - // Web Browser kfmclient openBrowser %u Application TDE; - - if ( isDesktopFile(fItem) ) { - KSimpleConfig cfg( fItem->url().path(), true ); - cfg.setDesktopGroup(); - if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" ) { - removeBuiltinIcon(cfg.readEntry( "Name" )); - continue; - } - } - - KDesktopFile df(desktopPath + fItem->url().fileName()); - df.writeEntry("Hidden", true); - df.sync(); - - delete it; - } - return !itemsLeft; -} - -void KDIconView::slotTrashActivated( TDEAction::ActivationReason reason, TQt::ButtonState state ) -{ - if (deleteGlobalDesktopFiles()) - return; // All items deleted - - if ( reason == TDEAction::PopupMenuActivation && ( state & TQt::ShiftButton ) ) - KonqOperations::del(this, KonqOperations::DEL, selectedUrls()); - else - KonqOperations::del(this, KonqOperations::TRASH, selectedUrls()); -} - -void KDIconView::slotDelete() -{ - if (deleteGlobalDesktopFiles()) - return; // All items deleted - KonqOperations::del(this, KonqOperations::DEL, selectedUrls()); -} - -// ----------------------------------------------------------------------------- - -// This method is called when right-clicking over one or more items -// Not to be confused with the global popup-menu, KRootWm, when doing RMB on the desktop -void KDIconView::popupMenu( const TQPoint &_global, const KFileItemList& _items ) -{ - if (!kapp->authorize("action/kdesktop_rmb")) return; - if (!m_dirLister) return; - if ( _items.count() == 1 ) - m_popupURL = _items.getFirst()->url(); - - TDEAction* pasteTo = m_actionCollection.action( "pasteto" ); - if (pasteTo) - pasteTo->setEnabled( m_actionCollection.action( "paste" )->isEnabled() ); - - bool hasMediaFiles = false; - KFileItemListIterator it(_items); - for (; it.current() && !hasMediaFiles; ++it) { - hasMediaFiles = it.current()->url().protocol() == "media"; - } - - KParts::BrowserExtension::PopupFlags itemFlags = KParts::BrowserExtension::DefaultPopupItems; - if ( hasMediaFiles ) - itemFlags |= KParts::BrowserExtension::NoDeletion; - KonqPopupMenu * popupMenu = new KonqPopupMenu( KonqBookmarkManager::self(), _items, - url(), - m_actionCollection, - KRootWm::self()->newMenu(), - this, - KonqPopupMenu::ShowProperties | KonqPopupMenu::ShowNewWindow, - itemFlags ); - - popupMenu->exec( _global ); - delete popupMenu; - m_popupURL = KURL(); - if (pasteTo) - pasteTo->setEnabled( false ); -} - -void KDIconView::slotNewMenuActivated() -{ - //kdDebug(1204) << "KDIconView::slotNewMenuActivated" << endl; - // New /