summaryrefslogtreecommitdiffstats
path: root/kscreensaver/xsavers
diff options
context:
space:
mode:
Diffstat (limited to 'kscreensaver/xsavers')
-rw-r--r--kscreensaver/xsavers/KSpace.desktop250
-rw-r--r--kscreensaver/xsavers/KSwarm.desktop245
-rw-r--r--kscreensaver/xsavers/Makefile.am36
-rw-r--r--kscreensaver/xsavers/demowin.cpp11
-rw-r--r--kscreensaver/xsavers/demowin.h44
-rw-r--r--kscreensaver/xsavers/helpers.cpp38
-rw-r--r--kscreensaver/xsavers/helpers.h23
-rw-r--r--kscreensaver/xsavers/main.cpp108
-rw-r--r--kscreensaver/xsavers/mode.h692
-rw-r--r--kscreensaver/xsavers/saver.cpp31
-rw-r--r--kscreensaver/xsavers/saver.h28
-rw-r--r--kscreensaver/xsavers/space.cpp735
-rw-r--r--kscreensaver/xsavers/space.h62
-rw-r--r--kscreensaver/xsavers/swarm.cpp419
-rw-r--r--kscreensaver/xsavers/swarm.h65
-rw-r--r--kscreensaver/xsavers/xlock.cpp86
-rw-r--r--kscreensaver/xsavers/xlock.h229
-rw-r--r--kscreensaver/xsavers/xlockmore.h261
-rw-r--r--kscreensaver/xsavers/xs_colors.c693
-rw-r--r--kscreensaver/xsavers/xs_colors.h140
-rw-r--r--kscreensaver/xsavers/xs_hsv.c81
-rw-r--r--kscreensaver/xsavers/xs_hsv.h27
-rw-r--r--kscreensaver/xsavers/xs_utils.h22
-rw-r--r--kscreensaver/xsavers/xs_visual.c473
-rw-r--r--kscreensaver/xsavers/xs_visual.h27
-rw-r--r--kscreensaver/xsavers/xs_yarandom.h52
26 files changed, 4878 insertions, 0 deletions
diff --git a/kscreensaver/xsavers/KSpace.desktop b/kscreensaver/xsavers/KSpace.desktop
new file mode 100644
index 00000000..820a86c8
--- /dev/null
+++ b/kscreensaver/xsavers/KSpace.desktop
@@ -0,0 +1,250 @@
+[Desktop Entry]
+Exec=kspace.kss
+Icon=kscreensaver
+Type=Application
+Actions=Setup;InWindow;Root;
+X-KDE-Category=OpenGL Screen Savers
+X-KDE-Type=OpenGL
+Name=Space (GL)
+Name[af]=Spasie (Gl)
+Name[bg]=Космос (GL)
+Name[br]=Egor (GL)
+Name[ca]=Espai (GL)
+Name[cs]=Vesmír (GL)
+Name[cy]=Gofod (GL)
+Name[da]=Rum (GL)
+Name[de]=Weltraum
+Name[el]=Διάστημα (GL)
+Name[es]=Espacio (GL)
+Name[et]=Kosmos (GL)
+Name[eu]=Espazioa (GL)
+Name[fa]=فاصله (GL)
+Name[fi]=Avaruus (GL)
+Name[fo]=Rúmd (GL)
+Name[fr]=Espace (GL)
+Name[fy]=Romte (GL)
+Name[gl]=Espazo (GL)
+Name[he]=חלל (GL)
+Name[hi]=अंतरिक्ष (जीएल)
+Name[hu]=Világűr (OpenGL)
+Name[is]=Geimur (GL)
+Name[it]=Spazio (GL)
+Name[ja]=宇宙 (GL)
+Name[ka]=კოსმოსი (GL)
+Name[lt]=Visata (GL)
+Name[lv]=Kosmoss (GL)
+Name[mk]=Вселена (GL)
+Name[mt]=Spazju (GL)
+Name[nb]=Rommet (GL)
+Name[nds]=Weltruum (GL)
+Name[ne]=खाली ठाउँ (GL)
+Name[nl]=Ruimte (GL)
+Name[nn]=Rom (GL)
+Name[pl]=Przestrzeń (GL)
+Name[pt]=Espaço (GL)
+Name[pt_BR]=Espaço (GL)
+Name[ro]=Spaţiu (GL)
+Name[ru]=Космос (GL)
+Name[sk]=Vesmír (GL)
+Name[sl]=Vesolje (GL)
+Name[sr]=Свемир (GL)
+Name[sr@Latn]=Svemir (GL)
+Name[sv]=Rymden (GL)
+Name[ta]=வெற்று(GL)
+Name[tg]=Кайҳон (GL)
+Name[th]=อวกาศ (GL)
+Name[tr]=Uzay (GL)
+Name[uk]=Всесвіт (GL)
+Name[uz]=Koinot (GL)
+Name[uz@cyrillic]=Коинот (GL)
+Name[ven]=Tshikhala (GL)
+Name[vi]=Vũ trụ (GL)
+Name[xh]=Isithuba (GL)
+Name[zh_CN]=星际空间(GL)
+Name[zh_TW]=太空 (GL)
+Name[zu]=Isikhala (GL)
+
+[Desktop Action Setup]
+Exec=kspace.kss -setup
+Name=Setup...
+Name[af]=Opstelling...
+Name[bg]=Настройки...
+Name[br]=Kefluniadur ...
+Name[bs]=Postavke...
+Name[ca]=Arranjament...
+Name[cs]=Nastavení...
+Name[cy]=Gosod ...
+Name[da]=Opsætning...
+Name[de]=Einrichtung ...
+Name[el]=Ρύθμιση...
+Name[eo]=Agordo...
+Name[es]=Configuración...
+Name[et]=Seadistamine...
+Name[eu]=Konfiguratu...
+Name[fa]=برپایی...
+Name[fi]=Asetukset...
+Name[fo]=Uppseting...
+Name[fr]=Configuration...
+Name[fy]=Opset...
+Name[ga]=Cumraigh...
+Name[gl]=Configuración...
+Name[he]=הגדרות...
+Name[hi]=सेटअप...
+Name[hu]=Beállítás...
+Name[is]=Stillingar...
+Name[it]=Impostazioni...
+Name[ja]=設定...
+Name[ka]=გამართვა...
+Name[lt]=Sąranka ...
+Name[lv]=Uzstādīšana...
+Name[mk]=Поставување...
+Name[ms]=Setkan...
+Name[mt]=Konfigurazzjoni...
+Name[nb]=Innstillinger …
+Name[nds]=Instellen...
+Name[ne]=सेटअप...
+Name[nl]=Instellingen...
+Name[nn]=Oppsett …
+Name[nso]=Beakanya...
+Name[pa]=ਸੈਟਅੱਪ...
+Name[pl]=Ustawienia...
+Name[pt]=Configurar...
+Name[pt_BR]=Configurar...
+Name[ro]=Setează...
+Name[ru]=Настройка...
+Name[rw]=Iboneza...
+Name[sk]=Nastavenie...
+Name[sl]=Nastavi ...
+Name[sr]=Подеси...
+Name[sr@Latn]=Podesi...
+Name[sv]=Inställningar...
+Name[ta]=அமைப்பு...
+Name[tg]=Барпосозӣ...
+Name[th]=ติดตั้ง...
+Name[tr]=Kurulum...
+Name[uk]=Встановити...
+Name[uz]=Oʻrnatish
+Name[uz@cyrillic]=Ўрнатиш
+Name[ven]=Vhekanya...
+Name[vi]=Thiết lập...
+Name[xh]=Iyacwangciswa...
+Name[zh_CN]=设置...
+Name[zh_TW]=設定...
+Name[zu]=Iyalungiselela...
+Icon=kscreensaver
+
+[Desktop Action InWindow]
+Exec=kspace.kss -window-id %w
+Name=Display in Specified Window
+Name[bg]=Стартиране в избран прозорец
+Name[br]=Diskwel er prenestr spisaet
+Name[bs]=Prikaži u navedenom prozoru
+Name[ca]=Mostra a la finestra especificada
+Name[cs]=Zobrazit v určeném okně
+Name[cy]=Dangos mewn Ffenestr Benodol
+Name[da]=Visning i angivet vindue
+Name[de]=In bestimmten Fenster anzeigen
+Name[el]=Προβολή στο καθορισμένο παράθυρο
+Name[eo]=Montri en indikita fenestro
+Name[es]=Mostrar en la ventana especificada
+Name[et]=Määratud aknas näitamine
+Name[eu]=Bistaratu zehaztutako lehioan
+Name[fa]=نمایش در پنجرۀ مشخص‌شده
+Name[fi]=Näytä määrätyssä ikkunassa
+Name[fr]=Affichage dans la fenêtre spécifiée
+Name[fy]=Werjefte yn in definiearre finster
+Name[ga]=Taispeáin san Fhuinneog Sonraithe
+Name[gl]=Mostrar na fiestra indicada
+Name[he]=הצג בחלון המצוין
+Name[hi]=निर्दिष्ट विंडो में प्रदर्शित करें
+Name[hu]=Megjelenítés a megadott ablakban
+Name[is]=Birta í völdum glugga
+Name[it]=Mostra nella finestra specificata
+Name[ja]=特定のウィンドウで表示
+Name[ka]=ჩვენება მითითებულ ფანჯარაში
+Name[lt]=Rodyti nurodytame lange
+Name[mk]=Прикажи во наведениот прозорец
+Name[ms]=Papar dalam Tetingkap Yang Dinyatakan
+Name[nb]=Vis i angitt vindu
+Name[nds]=In utsöcht Finster wiesen
+Name[ne]=निर्दिष्ट सञ्झ्यालमा प्रदर्शन
+Name[nl]=Weergeven in een opgegeven venster
+Name[nn]=Vis i oppgjeve vindauge
+Name[pa]=ਦੱਸੇ ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ
+Name[pl]=Wyświetl w zadanym oknie
+Name[pt]=Mostrar na Janela Indicada
+Name[pt_BR]=Mostrar em janela especificada
+Name[ro]=Afişează în fereastra specificată
+Name[ru]=Показывать в указанном окне
+Name[rw]=Kwerekana mu Idirishya Ryihariye
+Name[sk]=Zobraziť v zadanom okne
+Name[sl]=Prikaz v določenemu oknu
+Name[sr]=Прикажи у наведеном прозору
+Name[sr@Latn]=Prikaži u navedenom prozoru
+Name[sv]=Visa i angivet fönster
+Name[ta]=குறித்த சாளரத்தில் காட்டு
+Name[tg]=Дар тирезаи нишондода намоиш намоед
+Name[tr]=Belirtilen Pencerede Göster
+Name[uk]=Відобразити у вказаному вікні
+Name[vi]=Hiển thị trong Cửa sổ Đã định
+Name[zh_CN]=在指定的窗口中显示
+Name[zh_TW]=在指定的視窗中顯示
+NoDisplay=true
+
+[Desktop Action Root]
+Exec=kspace.kss -root
+Name=Display in Root Window
+Name[bg]=Стартиране в главния прозорец
+Name[br]=Diskwel er prenestr gwrizienn
+Name[bs]=Prikaži u korijenskom prozoru
+Name[ca]=Mostra a la finestra arrel
+Name[cs]=Zobrazit na pozadí plochy
+Name[cy]=Dangos mewn Ffenestr Wraidd
+Name[da]=Visning i root-vindue
+Name[de]=In Hintergrundfenster anzeigen
+Name[el]=Προβολή στο βασικό παράθυρο
+Name[eo]=Montri en radika fenestro
+Name[es]=Mostrar en la ventana raíz
+Name[et]=Juuraknas näitamine
+Name[eu]=Bistaratu erro lehioan
+Name[fa]=نمایش در پنجرۀ ریشه
+Name[fi]=Näytä juuri-ikkunassa
+Name[fr]=Affichage dans la fenêtre racine
+Name[fy]=Werjefte yn haadfinster
+Name[ga]=Taispeáin sa bhFréamhfhuinneog
+Name[gl]=Mostrar na fiestra raiz
+Name[he]=הצג בחלון השורש
+Name[hi]=रूट विंडो में प्रदर्शित करें
+Name[hu]=Megjelenítés a gyökérablakban
+Name[is]=Birta í rótarglugganum
+Name[it]=Mostra sullo sfondo
+Name[ja]=ルートウィンドウで表示
+Name[ka]=ჩვენება ძირითად ფანჯარაში
+Name[lt]=Rodyti root lange
+Name[mk]=Прикажи во коренскиот прозорец
+Name[ms]=Papar dalam Tetingkap Root
+Name[nb]=Vis i root-vindu
+Name[nds]=In Hööftfinster wiesen
+Name[ne]=मूल सञ्झ्यालमा प्रदर्शन
+Name[nl]=Weergeven in hoofdvenster
+Name[nn]=Vis i rotvindauget
+Name[pa]=Root ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ
+Name[pl]=Wyświetl w oknie głównym
+Name[pt]=Mostrar na Janela de Fundo
+Name[pt_BR]=Mostrar na janela raiz
+Name[ro]=Afişează în fereastra rădăcină
+Name[ru]=Показывать в корневом окне
+Name[rw]=Kwerekana mu Idirishya Umuzi
+Name[sk]=Zobraziť v koreňovom okne
+Name[sl]=Prikaz v korenskem oknu
+Name[sr]=Прикажи у главном (root) прозору
+Name[sr@Latn]=Prikaži u glavnom (root) prozoru
+Name[sv]=Visa i rotfönstret
+Name[ta]=ஆரம்ப சாளரத்தில் காட்டு
+Name[tg]=Дар тирезаи решагӣ намоиш намоед
+Name[tr]=Kök Pencerede Göster
+Name[uk]=Відобразити в кореневому вікні
+Name[vi]=Hiển thị trong Cửa sổ Gốc
+Name[zh_CN]=在根窗口中显示
+Name[zh_TW]=在根視窗中顯示
+NoDisplay=true
diff --git a/kscreensaver/xsavers/KSwarm.desktop b/kscreensaver/xsavers/KSwarm.desktop
new file mode 100644
index 00000000..ba852ef5
--- /dev/null
+++ b/kscreensaver/xsavers/KSwarm.desktop
@@ -0,0 +1,245 @@
+[Desktop Entry]
+Exec=kswarm.kss
+Icon=kscreensaver
+Type=Application
+Actions=Setup;InWindow;Root;
+X-KDE-Category=Flying Things
+Name=Swarm
+Name[af]=Swerm
+Name[bg]=Рояк
+Name[br]=Hed-gwenan
+Name[bs]=Roj
+Name[ca]=Eixam
+Name[cs]=Roj
+Name[cy]=Haid
+Name[da]=Sværm
+Name[de]=Schwarm
+Name[el]=Σμήνος
+Name[es]=Enjambre
+Name[et]=Sülem
+Name[eu]=Erlekumea
+Name[fa]=ازدحام
+Name[fi]=Hyönteiset
+Name[fr]=Fourmillement
+Name[fy]=Swaarm
+Name[gl]=Enxame
+Name[he]=נחיל דבורים
+Name[hi]=मत्स्य गुच्छ
+Name[hu]=Méhraj
+Name[is]=Sveimur
+Name[it]=Sciame
+Name[ja]=スワーム
+Name[ka]=ფუტკრის ნაყარი
+Name[lt]=Spiečius
+Name[lv]=Spiets
+Name[mk]=Рој
+Name[ms]=Paya
+Name[mt]=Ferħ naħal
+Name[nb]=Sverm
+Name[ne]=स्वार्म
+Name[nl]=Zwermen
+Name[nn]=Sverm
+Name[pl]=Rój
+Name[pt]=Enxame
+Name[pt_BR]=Enxame
+Name[ro]=Roi
+Name[ru]=Пчелиный рой
+Name[sl]=Roj
+Name[sr]=Рој
+Name[sr@Latn]=Roj
+Name[sv]=Svärm
+Name[ta]=புயல்
+Name[tg]=Оилаи занбурони асал
+Name[th]=หนอนผึ้ง
+Name[tr]=Sürü
+Name[uk]=Рій
+Name[ven]=Gogo
+Name[vi]=Bầy ong
+Name[xh]=Unyuko usebenzisa imilenze neengalo
+Name[zh_CN]=蜂群
+Name[zh_TW]=蜂群
+
+[Desktop Action Setup]
+Exec=kswarm.kss -setup
+Name=Setup...
+Name[af]=Opstelling...
+Name[bg]=Настройки...
+Name[br]=Kefluniadur ...
+Name[bs]=Postavke...
+Name[ca]=Arranjament...
+Name[cs]=Nastavení...
+Name[cy]=Gosod ...
+Name[da]=Opsætning...
+Name[de]=Einrichtung ...
+Name[el]=Ρύθμιση...
+Name[eo]=Agordo...
+Name[es]=Configuración...
+Name[et]=Seadistamine...
+Name[eu]=Konfiguratu...
+Name[fa]=برپایی...
+Name[fi]=Asetukset...
+Name[fo]=Uppseting...
+Name[fr]=Configuration...
+Name[fy]=Opset...
+Name[ga]=Cumraigh...
+Name[gl]=Configuración...
+Name[he]=הגדרות...
+Name[hi]=सेटअप...
+Name[hu]=Beállítás...
+Name[is]=Stillingar...
+Name[it]=Impostazioni...
+Name[ja]=設定...
+Name[ka]=გამართვა...
+Name[lt]=Sąranka ...
+Name[lv]=Uzstādīšana...
+Name[mk]=Поставување...
+Name[ms]=Setkan...
+Name[mt]=Konfigurazzjoni...
+Name[nb]=Innstillinger …
+Name[nds]=Instellen...
+Name[ne]=सेटअप...
+Name[nl]=Instellingen...
+Name[nn]=Oppsett …
+Name[nso]=Beakanya...
+Name[pa]=ਸੈਟਅੱਪ...
+Name[pl]=Ustawienia...
+Name[pt]=Configurar...
+Name[pt_BR]=Configurar...
+Name[ro]=Setează...
+Name[ru]=Настройка...
+Name[rw]=Iboneza...
+Name[sk]=Nastavenie...
+Name[sl]=Nastavi ...
+Name[sr]=Подеси...
+Name[sr@Latn]=Podesi...
+Name[sv]=Inställningar...
+Name[ta]=அமைப்பு...
+Name[tg]=Барпосозӣ...
+Name[th]=ติดตั้ง...
+Name[tr]=Kurulum...
+Name[uk]=Встановити...
+Name[uz]=Oʻrnatish
+Name[uz@cyrillic]=Ўрнатиш
+Name[ven]=Vhekanya...
+Name[vi]=Thiết lập...
+Name[xh]=Iyacwangciswa...
+Name[zh_CN]=设置...
+Name[zh_TW]=設定...
+Name[zu]=Iyalungiselela...
+Icon=kscreensaver
+
+[Desktop Action InWindow]
+Exec=kswarm.kss -window-id %w
+Name=Display in Specified Window
+Name[bg]=Стартиране в избран прозорец
+Name[br]=Diskwel er prenestr spisaet
+Name[bs]=Prikaži u navedenom prozoru
+Name[ca]=Mostra a la finestra especificada
+Name[cs]=Zobrazit v určeném okně
+Name[cy]=Dangos mewn Ffenestr Benodol
+Name[da]=Visning i angivet vindue
+Name[de]=In bestimmten Fenster anzeigen
+Name[el]=Προβολή στο καθορισμένο παράθυρο
+Name[eo]=Montri en indikita fenestro
+Name[es]=Mostrar en la ventana especificada
+Name[et]=Määratud aknas näitamine
+Name[eu]=Bistaratu zehaztutako lehioan
+Name[fa]=نمایش در پنجرۀ مشخص‌شده
+Name[fi]=Näytä määrätyssä ikkunassa
+Name[fr]=Affichage dans la fenêtre spécifiée
+Name[fy]=Werjefte yn in definiearre finster
+Name[ga]=Taispeáin san Fhuinneog Sonraithe
+Name[gl]=Mostrar na fiestra indicada
+Name[he]=הצג בחלון המצוין
+Name[hi]=निर्दिष्ट विंडो में प्रदर्शित करें
+Name[hu]=Megjelenítés a megadott ablakban
+Name[is]=Birta í völdum glugga
+Name[it]=Mostra nella finestra specificata
+Name[ja]=特定のウィンドウで表示
+Name[ka]=ჩვენება მითითებულ ფანჯარაში
+Name[lt]=Rodyti nurodytame lange
+Name[mk]=Прикажи во наведениот прозорец
+Name[ms]=Papar dalam Tetingkap Yang Dinyatakan
+Name[nb]=Vis i angitt vindu
+Name[nds]=In utsöcht Finster wiesen
+Name[ne]=निर्दिष्ट सञ्झ्यालमा प्रदर्शन
+Name[nl]=Weergeven in een opgegeven venster
+Name[nn]=Vis i oppgjeve vindauge
+Name[pa]=ਦੱਸੇ ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ
+Name[pl]=Wyświetl w zadanym oknie
+Name[pt]=Mostrar na Janela Indicada
+Name[pt_BR]=Mostrar em janela especificada
+Name[ro]=Afişează în fereastra specificată
+Name[ru]=Показывать в указанном окне
+Name[rw]=Kwerekana mu Idirishya Ryihariye
+Name[sk]=Zobraziť v zadanom okne
+Name[sl]=Prikaz v določenemu oknu
+Name[sr]=Прикажи у наведеном прозору
+Name[sr@Latn]=Prikaži u navedenom prozoru
+Name[sv]=Visa i angivet fönster
+Name[ta]=குறித்த சாளரத்தில் காட்டு
+Name[tg]=Дар тирезаи нишондода намоиш намоед
+Name[tr]=Belirtilen Pencerede Göster
+Name[uk]=Відобразити у вказаному вікні
+Name[vi]=Hiển thị trong Cửa sổ Đã định
+Name[zh_CN]=在指定的窗口中显示
+Name[zh_TW]=在指定的視窗中顯示
+NoDisplay=true
+
+[Desktop Action Root]
+Exec=kswarm.kss -root
+Name=Display in Root Window
+Name[bg]=Стартиране в главния прозорец
+Name[br]=Diskwel er prenestr gwrizienn
+Name[bs]=Prikaži u korijenskom prozoru
+Name[ca]=Mostra a la finestra arrel
+Name[cs]=Zobrazit na pozadí plochy
+Name[cy]=Dangos mewn Ffenestr Wraidd
+Name[da]=Visning i root-vindue
+Name[de]=In Hintergrundfenster anzeigen
+Name[el]=Προβολή στο βασικό παράθυρο
+Name[eo]=Montri en radika fenestro
+Name[es]=Mostrar en la ventana raíz
+Name[et]=Juuraknas näitamine
+Name[eu]=Bistaratu erro lehioan
+Name[fa]=نمایش در پنجرۀ ریشه
+Name[fi]=Näytä juuri-ikkunassa
+Name[fr]=Affichage dans la fenêtre racine
+Name[fy]=Werjefte yn haadfinster
+Name[ga]=Taispeáin sa bhFréamhfhuinneog
+Name[gl]=Mostrar na fiestra raiz
+Name[he]=הצג בחלון השורש
+Name[hi]=रूट विंडो में प्रदर्शित करें
+Name[hu]=Megjelenítés a gyökérablakban
+Name[is]=Birta í rótarglugganum
+Name[it]=Mostra sullo sfondo
+Name[ja]=ルートウィンドウで表示
+Name[ka]=ჩვენება ძირითად ფანჯარაში
+Name[lt]=Rodyti root lange
+Name[mk]=Прикажи во коренскиот прозорец
+Name[ms]=Papar dalam Tetingkap Root
+Name[nb]=Vis i root-vindu
+Name[nds]=In Hööftfinster wiesen
+Name[ne]=मूल सञ्झ्यालमा प्रदर्शन
+Name[nl]=Weergeven in hoofdvenster
+Name[nn]=Vis i rotvindauget
+Name[pa]=Root ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ
+Name[pl]=Wyświetl w oknie głównym
+Name[pt]=Mostrar na Janela de Fundo
+Name[pt_BR]=Mostrar na janela raiz
+Name[ro]=Afişează în fereastra rădăcină
+Name[ru]=Показывать в корневом окне
+Name[rw]=Kwerekana mu Idirishya Umuzi
+Name[sk]=Zobraziť v koreňovom okne
+Name[sl]=Prikaz v korenskem oknu
+Name[sr]=Прикажи у главном (root) прозору
+Name[sr@Latn]=Prikaži u glavnom (root) prozoru
+Name[sv]=Visa i rotfönstret
+Name[ta]=ஆரம்ப சாளரத்தில் காட்டு
+Name[tg]=Дар тирезаи решагӣ намоиш намоед
+Name[tr]=Kök Pencerede Göster
+Name[uk]=Відобразити в кореневому вікні
+Name[vi]=Hiển thị trong Cửa sổ Gốc
+Name[zh_CN]=在根窗口中显示
+Name[zh_TW]=在根視窗中顯示
+NoDisplay=true
diff --git a/kscreensaver/xsavers/Makefile.am b/kscreensaver/xsavers/Makefile.am
new file mode 100644
index 00000000..0d9effa4
--- /dev/null
+++ b/kscreensaver/xsavers/Makefile.am
@@ -0,0 +1,36 @@
+AM_CPPFLAGS = -UQT_NO_ASCII_CAST -DQT_CLEAN_NAMESPACE
+
+INCLUDES = $(all_includes) $(GLINC)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+if COMPILE_GL_XSAVERS
+GL_XSAVERS=kspace.kss
+endif
+
+bin_PROGRAMS = kswarm.kss $(GL_XSAVERS)
+
+BASE_SRCS = main.cpp demowin.cpp saver.cpp helpers.cpp
+
+XS_SRCS = xs_colors.c xs_hsv.c xs_visual.c
+XL_SRCS = xlock.cpp
+
+kswarm_kss_SOURCES = swarm.cpp $(BASE_SRCS) $(XL_SRCS)
+kswarm_kss_LDADD = $(LIB_KDEUI) -lm
+
+kspace_kss_SOURCES = space.cpp $(BASE_SRCS) $(XL_SRCS)
+kspace_kss_LDADD = $(LIB_KDEUI) $(GLLIB) -lm
+
+METASOURCES = AUTO
+
+noinst_HEADERS = saver.h demowin.h xlock.h swarm.h space.h \
+ xlockmore.h mode.h helpers.h \
+ xs_colors.h xs_hsv.h xs_yarandom.h xs_utils.h \
+ xs_visual.h
+
+########## Meta objects ##########
+
+desktop_DATA = KSpace.desktop KSwarm.desktop
+desktopdir = $(kde_appsdir)/System/ScreenSavers
+
+EXTRA_DIST = $(desktop_DATA)
+
diff --git a/kscreensaver/xsavers/demowin.cpp b/kscreensaver/xsavers/demowin.cpp
new file mode 100644
index 00000000..893885be
--- /dev/null
+++ b/kscreensaver/xsavers/demowin.cpp
@@ -0,0 +1,11 @@
+//-----------------------------------------------------------------------------
+//
+// Screen savers for KDE
+//
+// Copyright (c) Martin R. Jones 1999
+//
+
+#include "demowin.h"
+#include "demowin.moc"
+
+
diff --git a/kscreensaver/xsavers/demowin.h b/kscreensaver/xsavers/demowin.h
new file mode 100644
index 00000000..327b61dc
--- /dev/null
+++ b/kscreensaver/xsavers/demowin.h
@@ -0,0 +1,44 @@
+//-----------------------------------------------------------------------------
+//
+// Screen savers for KDE
+//
+// Copyright (c) Martin R. Jones 1999
+//
+
+#ifndef __DEMOWIN_H__
+#define __DEMOWIN_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+
+//----------------------------------------------------------------------------
+
+class DemoWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ DemoWindow() : QWidget()
+ {
+ setFixedSize(600, 420);
+ }
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *e)
+ {
+ if (e->ascii() == 'q')
+ {
+ kapp->quit();
+ }
+ }
+};
+
+#endif
+
diff --git a/kscreensaver/xsavers/helpers.cpp b/kscreensaver/xsavers/helpers.cpp
new file mode 100644
index 00000000..1ba67925
--- /dev/null
+++ b/kscreensaver/xsavers/helpers.cpp
@@ -0,0 +1,38 @@
+#include "helpers.h"
+
+#include <kapplication.h>
+
+void min_width(QWidget *w) {
+ w->setMinimumWidth(w->sizeHint().width());
+}
+
+void fixed_width(QWidget *w) {
+ w->setFixedWidth(w->sizeHint().width());
+}
+
+void min_height(QWidget *w) {
+ w->setMinimumHeight(w->sizeHint().height());
+}
+
+void fixed_height(QWidget *w) {
+ w->setFixedHeight(w->sizeHint().height());
+}
+
+void min_size(QWidget *w) {
+ w->setMinimumSize(w->sizeHint());
+}
+
+void fixed_size(QWidget *w) {
+ w->setFixedSize(w->sizeHint());
+}
+
+KConfig *klock_config()
+{
+ QString name( kapp->argv()[0] );
+ int slash = name.findRev( '/' );
+ if ( slash )
+ name = name.mid( slash+1 );
+
+ return new KConfig( name + "rc" );
+}
+
diff --git a/kscreensaver/xsavers/helpers.h b/kscreensaver/xsavers/helpers.h
new file mode 100644
index 00000000..948c86ef
--- /dev/null
+++ b/kscreensaver/xsavers/helpers.h
@@ -0,0 +1,23 @@
+#ifndef __HELPERS__H__
+#define __HELPERS__H__
+
+#include <qwidget.h>
+#include <kconfig.h>
+
+void min_width(QWidget *);
+void fixed_width(QWidget *);
+void min_height(QWidget *);
+void fixed_height(QWidget *);
+void min_size(QWidget *);
+void fixed_size(QWidget *);
+
+/*
+ * Use this to get a KConfig object that uses a reasonable config filename.
+ * KGlobal::config() will use the klockrc config file.
+ *
+ * Caller must delete the object when finished.
+ */
+KConfig *klock_config();
+
+#endif
+
diff --git a/kscreensaver/xsavers/main.cpp b/kscreensaver/xsavers/main.cpp
new file mode 100644
index 00000000..b264b8f5
--- /dev/null
+++ b/kscreensaver/xsavers/main.cpp
@@ -0,0 +1,108 @@
+//-----------------------------------------------------------------------------
+//
+// Screen savers for KDE
+//
+// Copyright (c) Martin R. Jones 1999
+//
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include <qcolor.h>
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kcrash.h>
+
+#include "demowin.h"
+#include "saver.h"
+
+static const char appName[] = "klock";
+static const char description[] = I18N_NOOP("KDE Screen Lock/Saver");
+static const char version[] = "2.0.0";
+
+static const KCmdLineOptions options[] =
+{
+ { "setup", I18N_NOOP("Setup screen saver"), 0 },
+ { "window-id wid", I18N_NOOP("Run in the specified XWindow"), 0 },
+ { "root", I18N_NOOP("Run in the root XWindow"), 0 },
+ { "demo", I18N_NOOP("Start screen saver in demo mode"), "default"},
+ KCmdLineLastOption
+};
+
+static void crashHandler( int /*sig*/ )
+{
+#ifdef SIGABRT
+ signal ( SIGABRT, SIG_DFL );
+#endif
+ abort();
+}
+
+//----------------------------------------------------------------------------
+
+int main(int argc, char *argv[])
+{
+ KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KLock"), description, version);
+
+ KCmdLineArgs::addCmdLineOptions(options);
+
+ KApplication app;
+
+ KCrash::setCrashHandler( crashHandler );
+
+ DemoWindow *demoWidget = 0;
+ Window saveWin = 0;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if (args->isSet("setup"))
+ {
+ setupScreenSaver();
+ exit(0);
+ }
+
+ if (args->isSet("window-id"))
+ {
+ saveWin = atol(args->getOption("window-id"));
+ }
+
+ if (args->isSet("root"))
+ {
+ saveWin = QApplication::desktop()->handle();
+ }
+
+ if (args->isSet("demo"))
+ {
+ saveWin = 0;
+ }
+
+ if (saveWin == 0)
+ {
+ demoWidget = new DemoWindow();
+ demoWidget->setBackgroundMode(QWidget::NoBackground);
+// demoWidget->setBackgroundColor(Qt::black);
+ demoWidget->show();
+ saveWin = demoWidget->winId();
+ app.setMainWidget(demoWidget);
+ app.processEvents();
+ }
+
+ startScreenSaver(saveWin);
+ app.exec();
+ stopScreenSaver();
+
+ if (demoWidget)
+ {
+ delete demoWidget;
+ }
+
+ return 0;
+}
+
diff --git a/kscreensaver/xsavers/mode.h b/kscreensaver/xsavers/mode.h
new file mode 100644
index 00000000..c2bc7f1d
--- /dev/null
+++ b/kscreensaver/xsavers/mode.h
@@ -0,0 +1,692 @@
+
+#ifndef __XLOCK_MODE_H__
+#define __XLOCK_MODE_H__
+
+/*-
+ * @(#)mode.h 4.00 97/01/01 xlockmore
+ *
+ * mode.h - mode management for xlock, the X Window System lockscreen.
+ *
+ * Copyright (c) 1991 by Patrick J. Naughton.
+ *
+ * See xlock.c for copying information.
+ *
+ * Revision History:
+ *
+ * Changes of David Bagley (bagleyd@bigfoot.com)
+ * 18-Mar-96: Ron Hitchens <ron@idiom.com>
+ * Extensive revision to define new data types for
+ * the new mode calling scheme.
+ * 02-Jun-95: Extracted out of resource.c.
+ *
+ */
+
+/*
+ * Declare external interface routines for supported screen savers.
+ */
+
+/* -------------------------------------------------------------------- */
+
+struct LockStruct_s;
+struct ModeInfo_s;
+
+typedef void (ModeHook) (struct ModeInfo_s *);
+typedef void (HookProc) (struct LockStruct_s *, struct ModeInfo_s *);
+
+typedef struct LockStruct_s {
+ char *cmdline_arg; /* mode name */
+ ModeHook *init_hook; /* func to init a mode */
+ ModeHook *callback_hook; /* func to run (tick) a mode */
+ ModeHook *release_hook; /* func to shutdown a mode */
+ ModeHook *refresh_hook; /* tells mode to repaint */
+ ModeHook *change_hook; /* user wants mode to change */
+ ModeHook *unused_hook; /* for future expansion */
+ ModeSpecOpt *msopt; /* this mode's def resources */
+ int def_delay; /* default delay for mode */
+ int def_batchcount;
+ int def_cycles;
+ int def_size;
+ float def_saturation;
+ char *desc; /* text description of mode */
+ unsigned int flags; /* state flags for this mode */
+ void *userdata; /* for use by the mode */
+} LockStruct;
+
+#define LS_FLAG_INITED 1
+
+typedef struct {
+ Display *display; /* handle to X display */
+ Screen *screenptr; /* ptr to screen info */
+ int screen; /* number of current screen */
+ int real_screen; /* for debugging */
+ int num_screens; /* number screens locked */
+ int max_screens; /* max # active screens */
+ Window window; /* handle to current window */
+ int win_width; /* width of current window */
+ int win_height; /* height of current window */
+ int win_depth; /* depth of current window */
+ Visual *visual; /* visual of current window */
+ Colormap colormap; /* default colormap of current window */
+ unsigned long black_pixel; /* pixel value for black */
+ unsigned long white_pixel; /* pixel value for white */
+ unsigned int flags; /* xlock window flags */
+ float delta3d;
+} WindowInfo;
+
+#define WI_FLAG_INFO_INITTED 0x001 /* private state flag */
+#define WI_FLAG_ICONIC 0x002
+#define WI_FLAG_MONO 0x004
+#define WI_FLAG_INWINDOW 0x008
+#define WI_FLAG_INROOT 0x010
+#define WI_FLAG_NOLOCK 0x020
+#define WI_FLAG_INSTALL 0x040
+#define WI_FLAG_DEBUG 0x080
+#define WI_FLAG_USE3D 0x100
+#define WI_FLAG_VERBOSE 0x200
+#define WI_FLAG_FULLRANDOM 0x400
+#define WI_FLAG_WIREFRAME 0x800
+#define WI_FLAG_JUST_INITTED 0x1000 /* private state flag */
+
+typedef struct {
+ long pause; /* output, set by mode */
+ long delay; /* inputs, current settings */
+ long batchcount;
+ long cycles;
+ long size;
+ float saturation;
+} RunInfo;
+
+typedef struct ModeInfo_s {
+ WindowInfo windowinfo;
+ perscreen *screeninfo;
+ RunInfo runinfo;
+ struct LockStruct_s *lockstruct;
+} ModeInfo;
+
+/* -------------------------------------------------------------------- */
+
+/*
+ * These are the public interfaces that a mode should use to obtain
+ * information about the display and other environmental parameters.
+ * Everything hangs off a ModeInfo pointer. A mode should NOT cache
+ * a ModeInfo pointer, the struct it points to is volatile. The mode
+ * can safely make a copy of the data it points to, however. But it
+ * is recommended the mode make use of the passed-in pointer and pass
+ * it along to functions it calls.
+ * Use these macros, don't look at the fields directly. The insides
+ * of the ModeInfo struct are certain to change in the future.
+ */
+
+#define MODE_IS_INITED(ls) ((ls)->flags & LS_FLAG_INITED)
+#define MODE_NOT_INITED(ls) ( ! MODE_IS_INITED(ls))
+
+#define MI_DISPLAY(mi) ((mi)->windowinfo.display)
+#define MI_SCREEN(mi) ((mi)->windowinfo.screen)
+#define MI_SCREENPTR(mi) ((mi)->windowinfo.screenptr)
+#define MI_REAL_SCREEN(mi) ((mi)->windowinfo.real_screen)
+#define MI_NUM_SCREENS(mi) ((mi)->windowinfo.num_screens)
+#define MI_MAX_SCREENS(mi) ((mi)->windowinfo.max_screens)
+#define MI_WINDOW(mi) ((mi)->windowinfo.window)
+#define MI_WIN_WIDTH(mi) ((mi)->windowinfo.win_width)
+#define MI_WIN_HEIGHT(mi) ((mi)->windowinfo.win_height)
+#define MI_WIN_DEPTH(mi) ((mi)->windowinfo.win_depth)
+#define MI_VISUAL(mi) ((mi)->windowinfo.visual)
+#define MI_COLORMAP(mi) ((mi)->windowinfo.colormap)
+#define MI_WIN_BLACK_PIXEL(mi) ((mi)->windowinfo.black_pixel)
+#define MI_WIN_WHITE_PIXEL(mi) ((mi)->windowinfo.white_pixel)
+#define MI_DELTA3D(mi) ((mi)->windowinfo.delta3d)
+#define MI_WIN_FLAGS(mi) ((mi)->windowinfo.flags)
+#define MI_WIN_SET_FLAG_STATE(mi,f,bool) ((mi)->windowinfo.flags = \
+ (bool) ? (mi)->windowinfo.flags | f \
+ : (mi)->windowinfo.flags & ~(f))
+#define MI_WIN_FLAG_IS_SET(mi,f) ((mi)->windowinfo.flags & f)
+#define MI_WIN_FLAG_NOT_SET(mi,f) ( ! MI_WIN_FLAG_IS_SET(mi,f))
+#define MI_WIN_IS_ICONIC(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_ICONIC))
+#define MI_WIN_IS_MONO(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_MONO))
+#define MI_WIN_IS_INWINDOW(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_INWINDOW))
+#define MI_WIN_IS_INROOT(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_INROOT))
+#define MI_WIN_IS_NOLOCK(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_NOLOCK))
+#define MI_WIN_IS_INSTALL(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_INSTALL))
+#define MI_WIN_IS_DEBUG(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_DEBUG))
+#define MI_WIN_IS_USE3D(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_USE3D))
+#define MI_WIN_IS_VERBOSE(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_VERBOSE))
+#define MI_WIN_IS_FULLRANDOM(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_FULLRANDOM))
+#define MI_WIN_IS_WIREFRAME(mi) (MI_WIN_FLAG_IS_SET (mi, WI_FLAG_WIREFRAME))
+
+#define MI_PERSCREEN(mi) ((mi)->screeninfo)
+#define MI_GC(mi) ((mi)->screeninfo->gc)
+#define MI_NPIXELS(mi) ((mi)->screeninfo->npixels)
+#define MI_CMAP(mi) ((mi)->screeninfo->cmap)
+#define MI_PIXELS(mi) ((mi)->screeninfo->pixels)
+#define MI_PIXEL(mi,n) ((mi)->screeninfo->pixels[n])
+
+/* are these of interest to modes? */
+#define MI_BG_COLOR(mi) ((mi)->screeninfo->bgcol)
+#define MI_FG_COLOR(mi) ((mi)->screeninfo->fgcol)
+#define MI_NONE_COLOR(mi) ((mi)->screeninfo->nonecol) /* -install */
+#define MI_RIGHT_COLOR(mi) ((mi)->screeninfo->rightcol)
+#define MI_LEFT_COLOR(mi) ((mi)->screeninfo->leftcol)
+
+#define MI_PAUSE(mi) ((mi)->runinfo.pause)
+#define MI_DELAY(mi) ((mi)->runinfo.delay)
+#define MI_BATCHCOUNT(mi) ((mi)->runinfo.batchcount)
+#define MI_CYCLES(mi) ((mi)->runinfo.cycles)
+#define MI_SIZE(mi) ((mi)->runinfo.size)
+#define MI_SATURATION(mi) ((mi)->runinfo.saturation)
+
+#define MI_LOCKSTRUCT(mi) ((mi)->lockstruct)
+#define MI_DEFDELAY(mi) ((mi)->lockstruct->def_delay)
+#define MI_DEFBATCHCOUNT(mi) ((mi)->lockstruct->def_batchcount)
+#define MI_DEFCYCLES(mi) ((mi)->lockstruct->def_cycles)
+#define MI_DEFSIZE(mi) ((mi)->lockstruct->def_size)
+#define MI_DEFSATURATION(mi) ((mi)->lockstruct->def_saturation)
+
+#define MI_NAME(mi) ((mi)->lockstruct->cmdline_arg)
+#define MI_DESC(mi) ((mi)->lockstruct->desc)
+#define MI_USERDATA(mi) ((mi)->lockstruct->userdata)
+
+/* -------------------------------------------------------------------- */
+
+extern HookProc call_init_hook;
+extern HookProc call_callback_hook;
+extern HookProc call_release_hook;
+extern HookProc call_refresh_hook;
+extern HookProc call_change_hook;
+
+extern void set_default_mode(LockStruct *);
+extern void release_last_mode(ModeInfo *);
+
+/* -------------------------------------------------------------------- */
+
+extern ModeHook init_ant;
+extern ModeHook draw_ant;
+extern ModeHook release_ant;
+extern ModeHook refresh_ant;
+extern ModeSpecOpt ant_opts;
+
+extern ModeHook init_ball;
+extern ModeHook draw_ball;
+extern ModeHook release_ball;
+extern ModeHook refresh_ball;
+extern ModeSpecOpt ball_opts;
+
+extern ModeHook init_bat;
+extern ModeHook draw_bat;
+extern ModeHook release_bat;
+extern ModeHook refresh_bat;
+extern ModeSpecOpt bat_opts;
+
+extern ModeHook init_blot;
+extern ModeHook draw_blot;
+extern ModeHook release_blot;
+extern ModeHook refresh_blot;
+extern ModeSpecOpt blot_opts;
+
+extern ModeHook init_bouboule;
+extern ModeHook draw_bouboule;
+extern ModeHook release_bouboule;
+extern ModeHook refresh_bouboule;
+extern ModeSpecOpt bouboule_opts;
+
+extern ModeHook init_bounce;
+extern ModeHook draw_bounce;
+extern ModeHook release_bounce;
+extern ModeHook refresh_bounce;
+extern ModeSpecOpt bounce_opts;
+
+extern ModeHook init_braid;
+extern ModeHook draw_braid;
+extern ModeHook release_braid;
+extern ModeHook refresh_braid;
+extern ModeSpecOpt braid_opts;
+
+extern ModeHook init_bug;
+extern ModeHook draw_bug;
+extern ModeHook release_bug;
+extern ModeHook refresh_bug;
+extern ModeSpecOpt bug_opts;
+
+extern ModeHook init_clock;
+extern ModeHook draw_clock;
+extern ModeHook release_clock;
+extern ModeHook refresh_clock;
+extern ModeSpecOpt clock_opts;
+
+extern ModeHook init_daisy;
+extern ModeHook draw_daisy;
+extern ModeHook release_daisy;
+extern ModeHook refresh_daisy;
+extern ModeSpecOpt daisy_opts;
+
+extern ModeHook init_dclock;
+extern ModeHook draw_dclock;
+extern ModeHook release_dclock;
+extern ModeHook refresh_dclock;
+extern ModeSpecOpt dclock_opts;
+
+extern ModeHook init_demon;
+extern ModeHook draw_demon;
+extern ModeHook release_demon;
+extern ModeHook refresh_demon;
+extern ModeSpecOpt demon_opts;
+
+extern ModeHook init_drift;
+extern ModeHook draw_drift;
+extern ModeHook release_drift;
+extern ModeHook refresh_drift;
+extern ModeSpecOpt drift_opts;
+
+extern ModeHook init_eyes;
+extern ModeHook draw_eyes;
+extern ModeHook release_eyes;
+extern ModeHook refresh_eyes;
+extern ModeSpecOpt eyes_opts;
+
+extern ModeHook init_flag;
+extern ModeHook draw_flag;
+extern ModeHook release_flag;
+extern ModeHook refresh_flag;
+extern ModeSpecOpt flag_opts;
+
+extern ModeHook init_flame;
+extern ModeHook draw_flame;
+extern ModeHook release_flame;
+extern ModeHook refresh_flame;
+extern ModeSpecOpt flame_opts;
+
+extern ModeHook init_forest;
+extern ModeHook draw_forest;
+extern ModeHook release_forest;
+extern ModeHook refresh_forest;
+extern ModeHook refresh_forest;
+extern ModeSpecOpt forest_opts;
+
+extern ModeHook init_fract;
+extern ModeHook draw_fract;
+extern ModeHook release_fract;
+extern ModeHook refresh_fract;
+extern ModeSpecOpt fract_opts;
+
+extern ModeHook init_galaxy;
+extern ModeHook draw_galaxy;
+extern ModeHook release_galaxy;
+extern ModeHook refresh_galaxy;
+extern ModeSpecOpt galaxy_opts;
+
+extern ModeHook init_geometry;
+extern ModeHook draw_geometry;
+extern ModeHook release_geometry;
+extern ModeHook refresh_geometry;
+extern ModeSpecOpt geometry_opts;
+
+extern ModeHook init_grav;
+extern ModeHook draw_grav;
+extern ModeHook release_grav;
+extern ModeHook refresh_grav;
+extern ModeSpecOpt grav_opts;
+
+extern ModeHook init_helix;
+extern ModeHook draw_helix;
+extern ModeHook release_helix;
+extern ModeHook refresh_helix;
+extern ModeSpecOpt helix_opts;
+
+extern ModeHook init_hop;
+extern ModeHook draw_hop;
+extern ModeHook release_hop;
+extern ModeHook refresh_hop;
+extern ModeSpecOpt hop_opts;
+
+extern ModeHook init_hyper;
+extern ModeHook draw_hyper;
+extern ModeHook release_hyper;
+extern ModeHook refresh_hyper;
+extern ModeSpecOpt hyper_opts;
+
+extern ModeHook init_ico;
+extern ModeHook draw_ico;
+extern ModeHook release_ico;
+extern ModeHook refresh_ico;
+extern ModeHook change_ico;
+extern ModeSpecOpt ico_opts;
+
+extern ModeHook init_ifs;
+extern ModeHook draw_ifs;
+extern ModeHook release_ifs;
+extern ModeSpecOpt ifs_opts;
+
+extern ModeHook init_image;
+extern ModeHook draw_image;
+extern ModeHook release_image;
+extern ModeHook refresh_image;
+extern ModeSpecOpt image_opts;
+
+extern ModeHook init_julia;
+extern ModeHook draw_julia;
+extern ModeHook release_julia;
+extern ModeHook refresh_julia;
+extern ModeSpecOpt julia_opts;
+
+extern ModeHook init_kaleid;
+extern ModeHook draw_kaleid;
+extern ModeHook release_kaleid;
+extern ModeHook refresh_kaleid;
+extern ModeSpecOpt kaleid_opts;
+
+extern ModeHook init_laser;
+extern ModeHook draw_laser;
+extern ModeHook release_laser;
+extern ModeHook refresh_laser;
+extern ModeSpecOpt laser_opts;
+
+extern ModeHook init_life;
+extern ModeHook draw_life;
+extern ModeHook release_life;
+extern ModeHook refresh_life;
+extern ModeHook change_life;
+extern ModeSpecOpt life_opts;
+
+extern ModeHook init_life1d;
+extern ModeHook draw_life1d;
+extern ModeHook release_life1d;
+extern ModeHook refresh_life1d;
+extern ModeSpecOpt life1d_opts;
+
+extern ModeHook init_life3d;
+extern ModeHook draw_life3d;
+extern ModeHook release_life3d;
+extern ModeHook refresh_life3d;
+extern ModeHook change_life3d;
+extern ModeSpecOpt life3d_opts;
+
+extern ModeHook init_lightning;
+extern ModeHook draw_lightning;
+extern ModeHook release_lightning;
+extern ModeHook refresh_lightning;
+extern ModeSpecOpt lightning_opts;
+
+extern ModeHook init_lisa;
+extern ModeHook draw_lisa;
+extern ModeHook release_lisa;
+extern ModeHook refresh_lisa;
+extern ModeHook change_lisa;
+extern ModeSpecOpt lisa_opts;
+
+extern ModeHook init_lissie;
+extern ModeHook draw_lissie;
+extern ModeHook release_lissie;
+extern ModeHook refresh_lissie;
+extern ModeSpecOpt lissie_opts;
+
+extern ModeHook init_loop;
+extern ModeHook draw_loop;
+extern ModeHook release_loop;
+extern ModeHook refresh_loop;
+extern ModeSpecOpt loop_opts;
+
+extern ModeHook init_marquee;
+extern ModeHook draw_marquee;
+extern ModeHook release_marquee;
+extern ModeHook refresh_marquee;
+extern ModeSpecOpt marquee_opts;
+
+extern ModeHook init_maze;
+extern ModeHook draw_maze;
+extern ModeHook release_maze;
+extern ModeHook refresh_maze;
+extern ModeSpecOpt maze_opts;
+
+extern ModeHook init_mountain;
+extern ModeHook draw_mountain;
+extern ModeHook release_mountain;
+extern ModeHook refresh_mountain;
+extern ModeSpecOpt mountain_opts;
+
+extern ModeHook init_nose;
+extern ModeHook draw_nose;
+extern ModeHook release_nose;
+extern ModeHook refresh_nose;
+extern ModeSpecOpt nose_opts;
+
+extern ModeHook init_pacman;
+extern ModeHook draw_pacman;
+extern ModeHook release_pacman;
+extern ModeHook refresh_pacman;
+extern ModeSpecOpt pacman_opts;
+
+extern ModeHook init_penrose;
+extern ModeHook draw_penrose;
+extern ModeHook release_penrose;
+
+#if 0
+extern ModeHook refresh_penrose; /* Needed */
+
+#endif
+extern ModeSpecOpt penrose_opts;
+
+extern ModeHook init_petal;
+extern ModeHook draw_petal;
+extern ModeHook release_petal;
+extern ModeHook refresh_petal;
+extern ModeSpecOpt petal_opts;
+
+extern ModeHook init_puzzle;
+extern ModeHook draw_puzzle;
+extern ModeHook release_puzzle;
+
+#if 0
+extern ModeHook refresh_puzzle; /* Needed */
+
+#endif
+extern ModeSpecOpt puzzle_opts;
+
+extern ModeHook init_pyro;
+extern ModeHook draw_pyro;
+extern ModeHook release_pyro;
+extern ModeHook refresh_pyro;
+extern ModeSpecOpt pyro_opts;
+
+extern ModeHook init_qix;
+extern ModeHook draw_qix;
+extern ModeHook release_qix;
+extern ModeHook refresh_qix;
+extern ModeSpecOpt qix_opts;
+
+extern ModeHook init_roll;
+extern ModeHook draw_roll;
+extern ModeHook release_roll;
+extern ModeHook refresh_roll;
+extern ModeSpecOpt roll_opts;
+
+extern ModeHook init_rotor;
+extern ModeHook draw_rotor;
+extern ModeHook release_rotor;
+extern ModeHook refresh_rotor;
+extern ModeSpecOpt rotor_opts;
+
+extern ModeHook init_shape;
+extern ModeHook draw_shape;
+extern ModeHook release_shape;
+extern ModeHook refresh_shape;
+extern ModeSpecOpt shape_opts;
+
+extern ModeHook init_slip;
+extern ModeHook draw_slip;
+extern ModeHook release_slip;
+
+#if 0
+extern ModeHook refresh_slip; /* Probably not practical */
+
+#endif
+extern ModeSpecOpt slip_opts;
+
+extern ModeHook init_sphere;
+extern ModeHook draw_sphere;
+extern ModeHook release_sphere;
+extern ModeHook refresh_sphere;
+extern ModeSpecOpt sphere_opts;
+
+extern ModeHook init_spiral;
+extern ModeHook draw_spiral;
+extern ModeHook release_spiral;
+extern ModeHook refresh_spiral;
+extern ModeSpecOpt spiral_opts;
+
+extern ModeHook init_spline;
+extern ModeHook draw_spline;
+extern ModeHook release_spline;
+extern ModeHook refresh_spline;
+extern ModeSpecOpt spline_opts;
+
+extern ModeHook init_star;
+extern ModeHook draw_star;
+extern ModeHook release_star;
+extern ModeHook refresh_star;
+extern ModeSpecOpt star_opts;
+
+extern ModeHook init_strange;
+extern ModeHook draw_strange;
+extern ModeHook release_strange;
+extern ModeSpecOpt strange_opts;
+
+extern ModeHook init_swarm;
+extern ModeHook draw_swarm;
+extern ModeHook release_swarm;
+extern ModeHook refresh_swarm;
+extern ModeSpecOpt swarm_opts;
+
+extern ModeHook init_swirl;
+extern ModeHook draw_swirl;
+extern ModeHook release_swirl;
+extern ModeHook refresh_swirl;
+extern ModeSpecOpt swirl_opts;
+
+extern ModeHook init_tri;
+extern ModeHook draw_tri;
+extern ModeHook release_tri;
+extern ModeHook refresh_tri;
+extern ModeSpecOpt tri_opts;
+
+extern ModeHook init_triangle;
+extern ModeHook draw_triangle;
+extern ModeHook release_triangle;
+extern ModeHook refresh_triangle;
+extern ModeSpecOpt triangle_opts;
+
+extern ModeHook init_tube;
+extern ModeHook draw_tube;
+extern ModeHook release_tube;
+extern ModeHook refresh_tube;
+extern ModeSpecOpt tube_opts;
+
+extern ModeHook init_turtle;
+extern ModeHook draw_turtle;
+extern ModeHook release_turtle;
+extern ModeHook refresh_turtle;
+extern ModeSpecOpt turtle_opts;
+
+extern ModeHook init_wator;
+extern ModeHook draw_wator;
+extern ModeHook release_wator;
+extern ModeHook refresh_wator;
+extern ModeSpecOpt wator_opts;
+
+extern ModeHook init_wire;
+extern ModeHook draw_wire;
+extern ModeHook release_wire;
+extern ModeHook refresh_wire;
+extern ModeSpecOpt wire_opts;
+
+extern ModeHook init_world;
+extern ModeHook draw_world;
+extern ModeHook release_world;
+extern ModeHook refresh_world;
+extern ModeSpecOpt world_opts;
+
+extern ModeHook init_worm;
+extern ModeHook draw_worm;
+extern ModeHook release_worm;
+extern ModeHook refresh_worm;
+extern ModeSpecOpt worm_opts;
+
+#if defined( USE_XPM ) || defined( USE_XPMINC )
+extern ModeHook init_cartoon;
+extern ModeHook draw_cartoon;
+extern ModeHook release_cartoon;
+extern ModeSpecOpt cartoon_opts;
+
+#endif
+
+#ifdef USE_GL
+extern ModeHook init_gears;
+extern ModeHook draw_gears;
+extern ModeHook release_gears;
+extern ModeSpecOpt gears_opts;
+
+extern ModeHook init_morph3d;
+extern ModeHook draw_morph3d;
+extern ModeHook release_morph3d;
+extern ModeHook change_morph3d;
+extern ModeSpecOpt morph3d_opts;
+
+extern ModeHook init_pipes;
+extern ModeHook draw_pipes;
+extern ModeHook release_pipes;
+extern ModeHook refresh_pipes;
+extern ModeHook change_pipes;
+extern ModeSpecOpt pipes_opts;
+
+extern ModeHook init_superquadrics;
+extern ModeHook draw_superquadrics;
+extern ModeHook release_superquadrics;
+extern ModeHook refresh_superquadrics;
+extern ModeSpecOpt superquadrics_opts;
+
+#ifdef USE_SPROINGIES
+extern ModeHook init_sproingies;
+extern ModeHook draw_sproingies;
+extern ModeHook release_sproingies;
+extern ModeHook refresh_sproingies;
+extern ModeSpecOpt sproingies_opts;
+
+#endif
+#endif
+
+#ifdef USE_HACKERS
+extern ModeHook init_fadeplot;
+extern ModeHook draw_fadeplot;
+extern ModeHook release_fadeplot;
+extern ModeHook refresh_fadeplot;
+extern ModeSpecOpt fadeplot_opts;
+
+#endif
+
+extern ModeHook init_blank;
+extern ModeHook draw_blank;
+extern ModeHook release_blank;
+extern ModeHook refresh_blank;
+extern ModeSpecOpt blank_opts;
+
+#ifdef USE_BOMB
+extern ModeHook init_bomb;
+extern ModeHook draw_bomb;
+extern ModeHook release_bomb;
+extern ModeHook refresh_bomb;
+extern ModeHook change_bomb;
+extern ModeSpecOpt bomb_opts;
+
+#endif
+
+extern ModeHook init_random;
+extern ModeHook draw_random;
+extern ModeHook release_random;
+extern ModeHook refresh_random;
+extern ModeHook change_random;
+extern ModeSpecOpt random_opts;
+
+extern LockStruct LockProcs[];
+extern int numprocs;
+
+/* -------------------------------------------------------------------- */
+
+#endif /* __XLOCK_MODE_H__ */
diff --git a/kscreensaver/xsavers/saver.cpp b/kscreensaver/xsavers/saver.cpp
new file mode 100644
index 00000000..b905d619
--- /dev/null
+++ b/kscreensaver/xsavers/saver.cpp
@@ -0,0 +1,31 @@
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kprocess.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <X11/Xlib.h>
+
+#include "saver.h"
+#include "saver.moc"
+
+//-----------------------------------------------------------------------------
+kScreenSaver::kScreenSaver(Drawable drawable) : QObject()
+{
+ Window root;
+ int ai;
+ unsigned int au;
+
+ mDrawable = drawable;
+ mGc = XCreateGC(qt_xdisplay(), mDrawable, 0, 0);
+ XGetGeometry(qt_xdisplay(), mDrawable, &root, &ai, &ai,
+ &mWidth, &mHeight, &au, &au);
+}
+
+kScreenSaver::~kScreenSaver()
+{
+ XFreeGC(qt_xdisplay(), mGc);
+}
+
+//-----------------------------------------------------------------------------
+
+
diff --git a/kscreensaver/xsavers/saver.h b/kscreensaver/xsavers/saver.h
new file mode 100644
index 00000000..4f4727d0
--- /dev/null
+++ b/kscreensaver/xsavers/saver.h
@@ -0,0 +1,28 @@
+
+#ifndef __SAVER_H__
+#define __SAVER_H__
+
+#include <qobject.h>
+#include <X11/Xlib.h>
+
+extern void startScreenSaver( Drawable d );
+extern void stopScreenSaver();
+extern int setupScreenSaver();
+
+//-----------------------------------------------------------------------------
+class kScreenSaver : public QObject
+{
+ Q_OBJECT
+public:
+ kScreenSaver( Drawable drawable );
+ virtual ~kScreenSaver();
+
+protected:
+ Drawable mDrawable;
+ GC mGc;
+ unsigned mWidth;
+ unsigned mHeight;
+};
+
+#endif
+
diff --git a/kscreensaver/xsavers/space.cpp b/kscreensaver/xsavers/space.cpp
new file mode 100644
index 00000000..f3650558
--- /dev/null
+++ b/kscreensaver/xsavers/space.cpp
@@ -0,0 +1,735 @@
+/*
+ *
+ * kStart OpenGL screensave for KDE
+ *
+ * $Id$
+ *
+ * Copyright (C) 1998 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * This program 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 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Based on star.c:
+ *
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#define LONG64
+//#define QT_CLEAN_NAMESPACE
+
+#include <qslider.h>
+#include <qlayout.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <krandomsequence.h>
+#include <kdebug.h>
+#include "xlock.h"
+#include "helpers.h"
+#ifdef HAVE_CONFIG_H
+#include "../../config.h"
+#endif
+
+#ifdef HAVE_GL
+
+#include <klocale.h>
+
+#undef index
+#include "space.h"
+#include <math.h>
+#include <X11/Intrinsic.h>
+#ifdef HAVE_GL_XMESA_H
+#include <GL/xmesa.h>
+#endif
+#include <GL/gl.h>
+#include <GL/glx.h>
+#ifdef HAVE_GL_GLUT_H
+// We don't need GLUT, but some BROKEN GLU implemenations, such as the one
+// used in SuSE Linux 6.3, do. :(
+#include <GL/glut.h>
+#endif
+#include <GL/glu.h>
+
+#ifndef PI
+#ifdef M_PI
+#define PI M_PI
+#else
+#define PI 3.141592657
+#endif
+#endif
+
+enum {
+ NORMAL = 0,
+ WEIRD = 1
+} flag = NORMAL;
+
+enum {
+ STREAK = 0,
+ CIRCLE = 1
+};
+
+#define MAXSTARS 400
+#define MAXPOS 10000
+#define MAXWARP1 10
+#define MAXANGLES 6000
+
+
+typedef struct _starRec {
+ GLint type;
+ float x[2], y[2], z[2];
+ float offsetX, offsetY, offsetR, rotation;
+} starRec;
+
+
+GLenum doubleBuffer, directRender;
+GLint windW, windH;
+
+GLint starCount = MAXSTARS / 2;
+float speed = 1.0;
+float warpinterval = 30000.0;
+GLint nitro = 0;
+starRec stars[MAXSTARS];
+float sinTable[MAXANGLES];
+
+static GLXContext glx_context;
+static KRandomSequence *rnd = 0;
+
+float Sin(float angle)
+{
+
+ return (sinTable[(GLint)angle]);
+}
+
+float Cos(float angle)
+{
+
+ return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
+}
+
+void NewStar(GLint n, GLint d)
+{
+
+ if (rnd->getLong(4) == 0) {
+ stars[n].type = CIRCLE;
+ } else {
+ stars[n].type = STREAK;
+ }
+ stars[n].x[0] = rnd->getDouble() * MAXPOS - MAXPOS / 2;
+ stars[n].y[0] = rnd->getDouble() * MAXPOS - MAXPOS / 2;
+ stars[n].z[0] = rnd->getDouble() * MAXPOS + d;
+ if (rnd->getLong(4) == 0 && flag == WEIRD) {
+ stars[n].offsetX = rnd->getDouble()* 100 - 100 / 2;
+ stars[n].offsetY = rnd->getDouble()* 100 - 100 / 2;
+ stars[n].offsetR = rnd->getDouble()* 25 - 25 / 2;
+ } else {
+ stars[n].offsetX = 0.0;
+ stars[n].offsetY = 0.0;
+ stars[n].offsetR = 0.0;
+ }
+}
+
+void RotatePoint(float *x, float *y, float rotation)
+{
+ float tmpX, tmpY;
+
+ tmpX = *x * Cos(rotation) - *y * Sin(rotation);
+ tmpY = *y * Cos(rotation) + *x * Sin(rotation);
+ *x = tmpX;
+ *y = tmpY;
+}
+
+void MoveStars(void)
+{
+ float offset;
+ GLint n;
+
+ offset = speed * 60.0;
+
+ for (n = 0; n < starCount; n++) {
+ stars[n].x[1] = stars[n].x[0];
+ stars[n].y[1] = stars[n].y[0];
+ stars[n].z[1] = stars[n].z[0];
+ stars[n].x[0] += stars[n].offsetX;
+ stars[n].y[0] += stars[n].offsetY;
+ stars[n].z[0] -= offset;
+ stars[n].rotation += stars[n].offsetR;
+ if (stars[n].rotation > MAXANGLES) {
+ stars[n].rotation = 0.0;
+ }
+ }
+}
+
+GLenum StarPoint(GLint n)
+{
+ float x0, y0, x1, y1, width;
+ GLint i;
+
+ x0 = stars[n].x[0] * windW / stars[n].z[0];
+ y0 = stars[n].y[0] * windH / stars[n].z[0];
+ RotatePoint(&x0, &y0, stars[n].rotation);
+ x0 += windW / 2.0;
+ y0 += windH / 2.0;
+
+ if (x0 >= 0.0 && x0 < windW && y0 >= 0.0 && y0 < windH) {
+ if (stars[n].type == STREAK) {
+ x1 = stars[n].x[1] * windW / stars[n].z[1];
+ y1 = stars[n].y[1] * windH / stars[n].z[1];
+ RotatePoint(&x1, &y1, stars[n].rotation);
+ x1 += windW / 2.0;
+ y1 += windH / 2.0;
+
+ glLineWidth(MAXPOS/100.0/stars[n].z[0]+1.0);
+ glColor3f((MAXWARP1-speed)/MAXWARP1, (MAXWARP1-speed)/MAXWARP1, .9);
+ if (fabs(x0-x1) < 1.0 && fabs(y0-y1) < 1.0) {
+ glBegin(GL_POINTS);
+ glVertex2f(x0, y0);
+ glEnd();
+ } else {
+ glBegin(GL_LINES);
+ glVertex2f(x0, y0);
+ glVertex2f(x1, y1);
+ glEnd();
+ }
+ } else {
+ width = MAXPOS / 10.0 / stars[n].z[0] + 1.0;
+ glColor3f(1.0, 0.0, 0.0);
+ glBegin(GL_POLYGON);
+ for (i = 0; i < 8; i++) {
+ float x = x0 + width * Cos((float)i*MAXANGLES/8.0);
+ float y = y0 + width * Sin((float)i*MAXANGLES/8.0);
+ glVertex2f(x, y);
+ };
+ glEnd();
+ }
+ return GL_TRUE;
+ } else {
+ return GL_FALSE;
+ }
+}
+
+void ShowStars(void)
+{
+ GLint n;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ for (n = 0; n < starCount; n++) {
+ if (stars[n].z[0] > speed || (stars[n].z[0] > 0.0 && speed < MAXWARP1)) {
+ if (StarPoint(n) == GL_FALSE) {
+ NewStar(n, MAXPOS);
+ }
+ } else {
+ NewStar(n, MAXPOS);
+ }
+ }
+}
+
+static void Init(void)
+{
+ float angle;
+ GLint n;
+
+ for (n = 0; n < MAXSTARS; n++) {
+ NewStar(n, 100);
+ }
+
+ angle = 0.0;
+ for (n = 0; n < MAXANGLES ; n++) {
+ sinTable[n] = sin(angle);
+ angle += PI / (MAXANGLES / 2.0);
+ }
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+
+ glDisable(GL_DITHER);
+}
+
+void reshape(int width, int height)
+{
+
+ windW = (GLint)width;
+ windH = (GLint)height;
+
+ glViewport(0, 0, windW, windH);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(-0.5, windW+0.5, -0.5, windH+0.5);
+ glMatrixMode(GL_MODELVIEW);
+
+}
+
+void Idle(void)
+{
+
+ MoveStars();
+ ShowStars();
+ if (nitro > 0) {
+ speed = (float)(nitro / 10) + 1.0;
+ if (speed > MAXWARP1) {
+ speed = MAXWARP1;
+ }
+ if (++nitro > MAXWARP1*10) {
+ nitro = -nitro;
+ }
+ } else if (nitro < 0) {
+ nitro++;
+ speed = (float)(-nitro / 10) + 1.0;
+ if (speed > MAXWARP1) {
+ speed = MAXWARP1;
+ }
+ }
+
+ glFlush();
+
+ /* if (doubleBuffer) {
+ tkSwapBuffers();
+ }*/
+}
+
+
+void
+drawSpace(Window /*window*/)
+{
+
+ /*
+ Display *display = dsp;
+ //glXMakeCurrent(display, window, mp->glx_context);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glFlush();
+ glXSwapBuffers(display, window);
+ */
+
+ Idle();
+
+}
+
+
+void release_Space(){
+
+ glXDestroyContext(dsp, glx_context);
+
+}
+
+static XVisualInfo *glVis[MAXSCREENS];
+
+int
+getVisual(XVisualInfo * wantVis, int visual_count)
+{
+ Display *display = dsp;
+ static int first;
+ int i;
+
+ if (first) {
+ for (screen = 0; screen < MAXSCREENS; screen++)
+ glVis[screen] = NULL;
+ }
+
+ if (!glVis[screen]) {
+ if (mono) {
+ /* Monochrome display - use color index mode */
+ int attribList[] = {GLX_DOUBLEBUFFER, None};
+
+ glVis[screen] = glXChooseVisual(display, screen, attribList);
+ } else {
+ int attribList[] =
+ {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 1, None};
+
+ glVis[screen] = glXChooseVisual(display, screen, attribList);
+ }
+ }
+ // Make sure we have a visual
+ if (!glVis[screen]) {
+ return (0);
+ }
+
+ /* check if GL can render into root window. */
+ for(i=0;i<visual_count;i++)
+ if ( (glVis[screen]->visual == (wantVis+i)->visual) )
+ return (1); // success
+
+ // The visual we received did not match one we asked for
+ return (0);
+}
+
+void
+initSpace(Window window)
+{
+ Display *display = dsp;
+ XWindowAttributes xwa;
+
+
+ (void) XGetWindowAttributes(dsp, window, &xwa);
+ int n;
+ XVisualInfo *wantVis, vTemplate;
+ int VisualClassWanted=-1;
+
+ vTemplate.screen = screen;
+ vTemplate.depth = xwa.depth;
+
+ if (VisualClassWanted == -1) {
+ vTemplate.c_class = DefaultVisual(display, screen)->c_class;
+ } else {
+ vTemplate.c_class = VisualClassWanted;
+ }
+
+ wantVis = XGetVisualInfo(display,
+ VisualScreenMask | VisualDepthMask | VisualClassMask,
+ &vTemplate, &n);
+
+ if (VisualClassWanted != -1 && n == 0) {
+ /* Wanted visual not found so use default */
+
+ vTemplate.c_class = DefaultVisual(display, screen)->c_class;
+
+ wantVis = XGetVisualInfo(display,
+ VisualScreenMask | VisualDepthMask | VisualClassMask,
+ &vTemplate, &n);
+ }
+ /* if User asked for color, try that first, then try mono */
+ /* if User asked for mono. Might fail on 16/24 bit displays,
+ so fall back on color, but keep the mono "look & feel". */
+
+ if (!getVisual(wantVis, n)) {
+ if (!getVisual(wantVis, n)) {
+ kdError() << i18n("GL can not render with root visual\n") << endl;
+ return;
+ }
+ }
+
+ /* PURIFY 3.0a on SunOS4 reports a 104 byte memory leak on the next line each
+ * time that morph3d mode is run in random mode. */
+
+ glx_context = glXCreateContext(display, wantVis, 0, True);
+
+ XFree((char *) wantVis);
+
+
+ glXMakeCurrent(display, window, glx_context);
+ glDrawBuffer(GL_FRONT);
+
+ if (mono) {
+ glIndexi(WhitePixel(display, screen));
+ glClearIndex(BlackPixel(display, screen));
+ }
+
+ reshape(xwa.width, xwa.height);
+ Init();
+}
+
+
+
+
+#endif
+
+#define MINSPEED 1
+#define MAXSPEED 100
+#define DEFSPEED 50
+#define MINWARP 1
+#define MAXWARP 30
+#define DEFWARP 2
+#define WARPFACTOR 100
+//-----------------------------------------------------------------------------
+
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qcolor.h>
+
+#include <kmessagebox.h>
+
+#include "space.moc"
+
+#undef Below
+
+static kSpaceSaver *saver = NULL;
+
+void startScreenSaver( Drawable d )
+{
+ if ( saver )
+ return;
+ saver = new kSpaceSaver( d );
+}
+
+void stopScreenSaver()
+{
+ if ( saver )
+ delete saver;
+ saver = NULL;
+}
+
+int setupScreenSaver()
+{
+ kSpaceSetup dlg;
+
+ return dlg.exec();
+}
+
+//-----------------------------------------------------------------------------
+
+kSpaceSaver::kSpaceSaver( Drawable drawable ) : kScreenSaver( drawable )
+{
+ rnd = new KRandomSequence();
+ readSettings();
+ counter = (int)warpinterval *WARPFACTOR;
+
+ colorContext = QColor::enterAllocContext();
+
+ initXLock( mGc );
+ initSpace( mDrawable );
+
+ timer.start( speed );
+ connect( &timer, SIGNAL( timeout() ), SLOT( slotTimeout() ) );
+}
+
+kSpaceSaver::~kSpaceSaver()
+{
+ timer.stop();
+ release_Space();
+ QColor::leaveAllocContext();
+ QColor::destroyAllocContext( colorContext );
+ delete rnd; rnd = 0;
+}
+
+void kSpaceSaver::setSpeed( int spd )
+{
+ timer.stop();
+ speed = MAXSPEED - spd ;
+ // printf("speed %d\n",speed);
+ timer.stop();
+ timer.start( speed );
+}
+
+void kSpaceSaver::setWarp( int w )
+{
+ warpinterval = w;
+ counter = (int)warpinterval;
+ initSpace( mDrawable );
+}
+
+void kSpaceSaver::readSettings()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ QString str;
+
+ str = config->readEntry( "Speed" );
+ if ( !str.isNull() )
+ speed = MAXSPEED - str.toInt();
+ else
+ speed = DEFSPEED;
+
+ warpinterval = config->readNumEntry( "WarpInterval", 15 );
+ delete config;
+}
+
+void kSpaceSaver::slotTimeout()
+{
+ //printf("%d %d \n",(int)warpinterval, MAXWARP);
+ if(warpinterval != MAXWARP){
+ if(nitro == 0)
+ counter -= speed +1;
+
+ if(counter <= 0){
+ nitro = 1;
+ counter = (int) warpinterval *WARPFACTOR;
+ }
+ }
+ else
+ nitro = 0;
+
+ drawSpace( mDrawable );
+}
+
+//-----------------------------------------------------------------------------
+
+kSpaceSetup::kSpaceSetup( QWidget *parent, const char *name )
+ : KDialogBase( parent, name, true, i18n("Setup Space Screen Saver"),
+ Ok|Cancel|Help, Ok, true )
+{
+ setButtonText( Help, i18n( "A&bout" ) );
+ readSettings();
+
+ QWidget *page = new QWidget( this );
+ setMainWidget( page );
+ QHBoxLayout *hb = new QHBoxLayout( page, 0, spacingHint() );
+ QVBoxLayout *vb = new QVBoxLayout( hb, spacingHint() );
+
+ QLabel *label;
+ QSlider *slider;
+
+ label = new QLabel( i18n("Speed:"), page );
+ vb->addWidget( label );
+
+ slider = new QSlider(MINSPEED, MAXSPEED, 10, speed, QSlider::Horizontal,
+ page );
+ vb->addWidget( slider );
+ slider->setTickmarks(QSlider::Below);
+ slider->setTickInterval(10);
+ connect( slider, SIGNAL( valueChanged( int ) ), SLOT( slotSpeed( int ) ) );
+
+ label = new QLabel( i18n("Warp interval:"), page );
+ vb->addWidget( label );
+
+ slider = new QSlider(MINWARP, MAXWARP, 3, warpinterval, Horizontal, page );
+ vb->addWidget( slider );
+ slider->setTickmarks(QSlider::Below);
+ slider->setTickInterval(3);
+ connect( slider, SIGNAL( valueChanged( int ) ), SLOT( slotWarp( int ) ) );
+
+ vb->addStrut( 150 );
+ vb->addStretch();
+
+ preview = new QWidget( page );
+ hb->addWidget( preview );
+ preview->setFixedSize( 220, 170 );
+ preview->setBackgroundColor( black );
+ preview->show(); // otherwise saver does not get correct size
+ saver = new kSpaceSaver( preview->winId() );
+}
+
+void kSpaceSetup::readSettings()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ speed = config->readNumEntry( "Speed", speed );
+
+ if ( speed > MAXSPEED )
+ speed = MAXSPEED;
+ else if ( speed < MINSPEED )
+ speed = MINSPEED;
+
+ warpinterval = config->readNumEntry( "WarpInterval", 15 );
+
+ delete config;
+}
+
+void kSpaceSetup::slotSpeed( int num )
+{
+ speed = num ;
+
+ if ( saver )
+ saver->setSpeed( speed );
+}
+
+void kSpaceSetup::slotWarp( int num )
+{
+ warpinterval = num;
+ if ( saver )
+ saver->setWarp( warpinterval );
+}
+
+void kSpaceSetup::slotOk()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ QString sspeed;
+ sspeed.setNum( speed );
+ config->writeEntry( "Speed", sspeed );
+
+ QString interval;
+ interval.setNum( (int)warpinterval );
+ config->writeEntry( "WarpInterval", interval );
+
+ config->sync();
+ delete config;
+ accept();
+}
+
+void kSpaceSetup::slotHelp()
+{
+ KMessageBox::about(this,
+ i18n("KSpace\nCopyright (c) 1998\n"
+ "Bernd Johannes Wuebben <wuebben@kde.org>"));
+}
+
+
+/*
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+ directRender = GL_TRUE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else if (strcmp(argv[i], "-dr") == 0) {
+ directRender = GL_TRUE;
+ } else if (strcmp(argv[i], "-ir") == 0) {
+ directRender = GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+
+void main(int argc, char **argv)
+{
+ GLenum type;
+
+ if (Args(argc, argv) == GL_FALSE) {
+ tkQuit();
+ }
+
+ windW = 300;
+ windH = 300;
+ tkInitPosition(0, 0, 300, 300);
+
+ type = TK_RGB;
+ type |= (doubleBuffer) ? TK_DOUBLE : TK_SINGLE;
+ type |= (directRender) ? TK_DIRECT : TK_INDIRECT;
+ tkInitDisplayMode(type);
+
+ if (tkInitWindow("Stars") == GL_FALSE) {
+ tkQuit();
+ }
+
+ Init();
+
+ tkExposeFunc(Reshape);
+ tkReshapeFunc(Reshape);
+ tkKeyDownFunc(Key);
+ tkIdleFunc(Idle);
+ tkExec();
+}
+
+*/
diff --git a/kscreensaver/xsavers/space.h b/kscreensaver/xsavers/space.h
new file mode 100644
index 00000000..6bf82c87
--- /dev/null
+++ b/kscreensaver/xsavers/space.h
@@ -0,0 +1,62 @@
+
+#ifndef __SPACE_H__
+#define __SPACE_H__
+
+#include <qtimer.h>
+#include <qptrlist.h>
+#include <kdialogbase.h>
+#include <qlineedit.h>
+#include "saver.h"
+
+class kSpaceSaver : public kScreenSaver
+{
+ Q_OBJECT
+public:
+ kSpaceSaver( Drawable drawable );
+ virtual ~kSpaceSaver();
+
+ void setSpeed( int spd );
+ void setWarp( int l );
+ void setPoints( int p );
+
+protected:
+ void readSettings();
+
+protected slots:
+ void slotTimeout();
+
+protected:
+ QTimer timer;
+ int colorContext;
+
+ int counter;
+ int speed;
+ int maxLevels;
+ int numPoints;
+};
+
+class kSpaceSetup : public KDialogBase
+{
+ Q_OBJECT
+public:
+ kSpaceSetup( QWidget *parent = NULL, const char *name = NULL );
+
+protected:
+ void readSettings();
+
+private slots:
+ void slotSpeed( int );
+ void slotWarp( int );
+ void slotOk();
+ void slotHelp();
+
+private:
+ QWidget *preview;
+ kSpaceSaver *saver;
+
+ int speed;
+ int warpinterval;
+};
+
+#endif
+
diff --git a/kscreensaver/xsavers/swarm.cpp b/kscreensaver/xsavers/swarm.cpp
new file mode 100644
index 00000000..0afae901
--- /dev/null
+++ b/kscreensaver/xsavers/swarm.cpp
@@ -0,0 +1,419 @@
+/*-
+ * swarm.c - swarm of bees for xlock, the X Window System lockscreen.
+ *
+ * Copyright (c) 1991 by Patrick J. Naughton.
+ *
+ * Revision History:
+ * 31-Aug-90: Adapted from xswarm by Jeff Butterworth. (butterwo@ncsc.org)
+ */
+
+/* Ported to kscreensaver:
+ July 1997, Emanuel Pirker <epirker@edu.uni-klu.ac.at>
+ Contact me in case of problems, not the original author!
+ Last revised: 10-Jul-97
+*/
+// layout management added 1998/04/19 by Mario Weilguni <mweilguni@kde.org>
+
+#define MAXSPEED 100
+#define MINSPEED 0
+#define DEFSPEED 50
+#define MAXBATCH 200
+#define MINBATCH 0
+#define DEFBATCH 20
+
+#include <qslider.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <krandomsequence.h>
+#include "xlock.h"
+
+#undef index
+
+#define TIMES 4 /* number of time positions recorded */
+#define BEEACC 2 /* acceleration of bees */
+#define WASPACC 5 /* maximum acceleration of wasp */
+#define BEEVEL 12 /* maximum bee velocity */
+#define WASPVEL 10 /* maximum wasp velocity */
+
+/* Macros */
+#define X(t,b) (sp->x[(t)*sp->beecount+(b)])
+#define Y(t,b) (sp->y[(t)*sp->beecount+(b)])
+#define balance_rand(v) (rnd.getLong(v)-((v)/2)) /* random number around 0 */
+
+//ModeSpecOpt swarm_opts = {0, NULL, NULL, NULL};
+
+typedef struct {
+ int pix;
+ int width;
+ int height;
+ int border; /* wasp won't go closer than this to the edge */
+ int beecount; /* number of bees */
+ XSegment segs[MAXBATCH]; /* bee lines */
+ XSegment old_segs[MAXBATCH]; /* old bee lines */
+ short x[MAXBATCH*TIMES];
+ short y[MAXBATCH*TIMES]; /* bee positions x[time][bee#] */
+ short xv[MAXBATCH];
+ short yv[MAXBATCH]; /* bee velocities xv[bee#] */
+ short wx[3];
+ short wy[3];
+ short wxv;
+ short wyv;
+} swarmstruct;
+
+static swarmstruct swarms[MAXSCREENS];
+
+void
+initswarm(Window win, KRandomSequence &rnd)
+{
+ swarmstruct *sp = &swarms[screen];
+ int b;
+ XWindowAttributes xwa;
+
+ sp->beecount = batchcount;
+ (void) XGetWindowAttributes(dsp, win, &xwa);
+ sp->width = xwa.width;
+ sp->height = xwa.height;
+
+ sp->border = (sp->width + sp->height) / 50;
+
+ /* Clear the background. */
+ XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
+ XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, sp->width, sp->height);
+
+ /* Now static data structures. epirker */
+ //if (!sp->segs) {
+ //sp->segs = (XSegment *) malloc(sizeof (XSegment) * sp->beecount);
+ //sp->old_segs = (XSegment *) malloc(sizeof (XSegment) * sp->beecount);
+ //sp->x = (short *) malloc(sizeof (short) * sp->beecount * TIMES);
+ //sp->y = (short *) malloc(sizeof (short) * sp->beecount * TIMES);
+ //sp->xv = (short *) malloc(sizeof (short) * sp->beecount);
+ //sp->yv = (short *) malloc(sizeof (short) * sp->beecount);
+ //}
+ /* Initialize point positions, velocities, etc. */
+
+ /* wasp */
+ sp->wx[0] = sp->border + rnd.getLong(sp->width - 2 * sp->border);
+ sp->wy[0] = sp->border + rnd.getLong(sp->height - 2 * sp->border);
+ sp->wx[1] = sp->wx[0];
+ sp->wy[1] = sp->wy[0];
+ sp->wxv = 0;
+ sp->wyv = 0;
+
+ /* bees */
+ for (b = 0; b < sp->beecount; b++) {
+ X(0, b) = rnd.getLong(sp->width);
+ X(1, b) = X(0, b);
+ Y(0, b) = rnd.getLong(sp->height);
+ Y(1, b) = Y(0, b);
+ sp->xv[b] = balance_rand(7);
+ sp->yv[b] = balance_rand(7);
+ }
+}
+
+
+
+void
+drawswarm(Window win, KRandomSequence &rnd)
+{
+ swarmstruct *sp = &swarms[screen];
+ int b;
+
+ /* <=- Wasp -=> */
+ /* Age the arrays. */
+ sp->wx[2] = sp->wx[1];
+ sp->wx[1] = sp->wx[0];
+ sp->wy[2] = sp->wy[1];
+ sp->wy[1] = sp->wy[0];
+ /* Accelerate */
+ sp->wxv += balance_rand(WASPACC);
+ sp->wyv += balance_rand(WASPACC);
+
+ /* Speed Limit Checks */
+ if (sp->wxv > WASPVEL)
+ sp->wxv = WASPVEL;
+ if (sp->wxv < -WASPVEL)
+ sp->wxv = -WASPVEL;
+ if (sp->wyv > WASPVEL)
+ sp->wyv = WASPVEL;
+ if (sp->wyv < -WASPVEL)
+ sp->wyv = -WASPVEL;
+
+ /* Move */
+ sp->wx[0] = sp->wx[1] + sp->wxv;
+ sp->wy[0] = sp->wy[1] + sp->wyv;
+
+ /* Bounce Checks */
+ if ((sp->wx[0] < sp->border) || (sp->wx[0] > sp->width - sp->border - 1)) {
+ sp->wxv = -sp->wxv;
+ sp->wx[0] += sp->wxv;
+ }
+ if ((sp->wy[0] < sp->border) || (sp->wy[0] > sp->height - sp->border - 1)) {
+ sp->wyv = -sp->wyv;
+ sp->wy[0] += sp->wyv;
+ }
+ /* Don't let things settle down. */
+ sp->xv[rnd.getLong(sp->beecount)] += balance_rand(3);
+ sp->yv[rnd.getLong(sp->beecount)] += balance_rand(3);
+
+ /* <=- Bees -=> */
+ for (b = 0; b < sp->beecount; b++) {
+ int distance, dx, dy;
+
+ /* Age the arrays. */
+ X(2, b) = X(1, b);
+ X(1, b) = X(0, b);
+ Y(2, b) = Y(1, b);
+ Y(1, b) = Y(0, b);
+
+ /* Accelerate */
+ dx = sp->wx[1] - X(1, b);
+ dy = sp->wy[1] - Y(1, b);
+ distance = abs(dx) + abs(dy); /* approximation */
+ if (distance == 0)
+ distance = 1;
+ sp->xv[b] += (dx * BEEACC) / distance;
+ sp->yv[b] += (dy * BEEACC) / distance;
+
+ /* Speed Limit Checks */
+ if (sp->xv[b] > BEEVEL)
+ sp->xv[b] = BEEVEL;
+ if (sp->xv[b] < -BEEVEL)
+ sp->xv[b] = -BEEVEL;
+ if (sp->yv[b] > BEEVEL)
+ sp->yv[b] = BEEVEL;
+ if (sp->yv[b] < -BEEVEL)
+ sp->yv[b] = -BEEVEL;
+
+ /* Move */
+ X(0, b) = X(1, b) + sp->xv[b];
+ Y(0, b) = Y(1, b) + sp->yv[b];
+
+ /* Fill the segment lists. */
+ sp->segs[b].x1 = X(0, b);
+ sp->segs[b].y1 = Y(0, b);
+ sp->segs[b].x2 = X(1, b);
+ sp->segs[b].y2 = Y(1, b);
+ sp->old_segs[b].x1 = X(1, b);
+ sp->old_segs[b].y1 = Y(1, b);
+ sp->old_segs[b].x2 = X(2, b);
+ sp->old_segs[b].y2 = Y(2, b);
+ }
+
+ XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
+ XDrawLine(dsp, win, Scr[screen].gc,
+ sp->wx[1], sp->wy[1], sp->wx[2], sp->wy[2]);
+ XDrawSegments(dsp, win, Scr[screen].gc, sp->old_segs, sp->beecount);
+
+ XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen));
+ XDrawLine(dsp, win, Scr[screen].gc,
+ sp->wx[0], sp->wy[0], sp->wx[1], sp->wy[1]);
+ if (!mono && Scr[screen].npixels > 2) {
+ XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[sp->pix]);
+ if (++sp->pix >= Scr[screen].npixels)
+ sp->pix = 0;
+ }
+ XDrawSegments(dsp, win, Scr[screen].gc, sp->segs, sp->beecount);
+}
+
+//-----------------------------------------------------------------------------
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qcolor.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "swarm.h"
+#include "swarm.moc"
+#include "helpers.h"
+
+#undef Below
+
+static kSwarmSaver *saver = NULL;
+
+void startScreenSaver( Drawable d )
+{
+ if ( saver )
+ return;
+ saver = new kSwarmSaver( d );
+}
+
+void stopScreenSaver()
+{
+ if ( saver )
+ delete saver;
+ saver = NULL;
+}
+
+int setupScreenSaver()
+{
+ kSwarmSetup dlg;
+
+ return dlg.exec();
+}
+
+//-----------------------------------------------------------------------------
+
+kSwarmSaver::kSwarmSaver( Drawable drawable ) : kScreenSaver( drawable )
+{
+ readSettings();
+
+ // Clear to background colour when exposed
+ XSetWindowBackground(qt_xdisplay(), mDrawable,
+ BlackPixel(qt_xdisplay(), qt_xscreen()));
+
+ colorContext = QColor::enterAllocContext();
+
+ batchcount = maxLevels;
+
+ initXLock( mGc );
+ initswarm( mDrawable, rnd );
+
+ timer.start( speed );
+ connect( &timer, SIGNAL( timeout() ), SLOT( slotTimeout() ) );
+}
+
+kSwarmSaver::~kSwarmSaver()
+{
+ timer.stop();
+ QColor::leaveAllocContext();
+ QColor::destroyAllocContext( colorContext );
+}
+
+void kSwarmSaver::setSpeed( int spd )
+{
+ timer.stop();
+ speed = MAXSPEED - spd;
+ timer.start( speed );
+}
+
+void kSwarmSaver::setLevels( int l )
+{
+ batchcount = maxLevels = l;
+ initswarm( mDrawable, rnd );
+}
+
+void kSwarmSaver::readSettings()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ speed = MAXSPEED - config->readNumEntry( "Speed", MAXSPEED - DEFSPEED );
+ maxLevels = config->readNumEntry( "MaxLevels", DEFBATCH );
+
+ delete config;
+}
+
+void kSwarmSaver::slotTimeout()
+{
+ drawswarm( mDrawable, rnd );
+}
+
+//-----------------------------------------------------------------------------
+
+kSwarmSetup::kSwarmSetup( QWidget *parent, const char *name )
+ : KDialogBase( parent, name, true, i18n( "Setup Swarm Screen Saver" ),
+ Ok|Cancel|Help, Ok, true )
+{
+ readSettings();
+
+ setButtonText( Help, i18n( "A&bout" ) );
+ QWidget *main = makeMainWidget();
+
+ QHBoxLayout *top = new QHBoxLayout( main, 0, spacingHint() );
+ QVBoxLayout *left = new QVBoxLayout(top, spacingHint());
+
+ QLabel *label = new QLabel( i18n("Speed:"), main );
+ min_size(label);
+ left->addWidget(label);
+
+ QSlider *slider = new QSlider(MINSPEED, MAXSPEED, 10, speed,
+ Horizontal, main );
+ slider->setMinimumSize( 120, 20 );
+ slider->setTickmarks(QSlider::Below);
+ slider->setTickInterval(10);
+ connect( slider, SIGNAL( valueChanged( int ) ),
+ SLOT( slotSpeed( int ) ) );
+ left->addWidget(slider);
+
+ label = new QLabel( i18n("Number of bees:"), main );
+ min_size(label);
+ left->addWidget(label);
+
+ slider = new QSlider(MINBATCH, MAXBATCH, 20, maxLevels, Horizontal, main );
+ slider->setMinimumSize( 120, 20 );
+ slider->setTickmarks(QSlider::Below);
+ slider->setTickInterval(20);
+ connect( slider, SIGNAL( valueChanged( int ) ),
+ SLOT( slotLevels( int ) ) );
+ left->addWidget(slider);
+ left->addStretch();
+
+ preview = new QWidget( main );
+ preview->setFixedSize( 220, 170 );
+ preview->setBackgroundColor( black );
+ preview->show(); // otherwise saver does not get correct size
+ saver = new kSwarmSaver( preview->winId() );
+ top->addWidget(preview);
+
+ top->addStretch();
+}
+
+void kSwarmSetup::readSettings()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ speed = config->readNumEntry( "Speed", speed );
+
+ if ( speed > MAXSPEED )
+ speed = MAXSPEED;
+ else if ( speed < MINSPEED )
+ speed = MINSPEED;
+
+ maxLevels = config->readNumEntry( "MaxLevels", DEFBATCH );
+ delete config;
+}
+
+void kSwarmSetup::slotSpeed( int num )
+{
+ speed = num;
+
+ if ( saver )
+ saver->setSpeed( speed );
+}
+
+void kSwarmSetup::slotLevels( int num )
+{
+ maxLevels = num;
+
+ if ( saver )
+ saver->setLevels( maxLevels );
+}
+
+void kSwarmSetup::slotOk()
+{
+ KConfig *config = klock_config();
+ config->setGroup( "Settings" );
+
+ QString sspeed;
+ sspeed.setNum( speed );
+ config->writeEntry( "Speed", sspeed );
+
+ QString slevels;
+ slevels.setNum( maxLevels );
+ config->writeEntry( "MaxLevels", slevels );
+
+ config->sync();
+ delete config;
+ accept();
+}
+
+void kSwarmSetup::slotHelp()
+{
+ KMessageBox::information(this,
+ i18n("Swarm\n\nCopyright (c) 1991 by Patrick J. Naughton\n\nPorted to kscreensaver by Emanuel Pirker."),
+ i18n("About Swarm"));
+}
diff --git a/kscreensaver/xsavers/swarm.h b/kscreensaver/xsavers/swarm.h
new file mode 100644
index 00000000..dd4b2f6d
--- /dev/null
+++ b/kscreensaver/xsavers/swarm.h
@@ -0,0 +1,65 @@
+//-----------------------------------------------------------------------------
+//
+// kswarm - port of "swarm" from xlock
+//
+
+#ifndef __SWARM_H__
+#define __SWARM_H__
+
+#include <qtimer.h>
+
+#include <kdialogbase.h>
+#include "saver.h"
+
+
+class kSwarmSaver : public kScreenSaver
+{
+ Q_OBJECT
+public:
+ kSwarmSaver( Drawable drawable );
+ virtual ~kSwarmSaver();
+
+ void setSpeed( int spd );
+ void setLevels( int l );
+
+protected:
+ void readSettings();
+
+protected slots:
+ void slotTimeout();
+
+protected:
+ KRandomSequence rnd;
+ QTimer timer;
+ int colorContext;
+
+ int speed;
+ int maxLevels;
+};
+
+class kSwarmSetup : public KDialogBase
+{
+ Q_OBJECT
+public:
+ kSwarmSetup( QWidget *parent = NULL, const char *name = NULL );
+
+protected:
+ void readSettings();
+
+private slots:
+ void slotSpeed( int );
+ void slotLevels( int );
+
+ void slotOk();
+ void slotHelp();
+
+private:
+ QWidget *preview;
+ kSwarmSaver *saver;
+
+ int speed;
+ int maxLevels;
+};
+
+#endif
+
diff --git a/kscreensaver/xsavers/xlock.cpp b/kscreensaver/xsavers/xlock.cpp
new file mode 100644
index 00000000..7e7634db
--- /dev/null
+++ b/kscreensaver/xsavers/xlock.cpp
@@ -0,0 +1,86 @@
+//----------------------------------------------------------------------------
+// This module contains code to interface original xlock savers to
+// kscreensave
+//
+
+#include <time.h>
+#include <qapplication.h>
+#include "xlock.h"
+
+
+int screen;
+Display *dsp;
+perscreen Scr[MAXSCREENS];
+int batchcount = 100;
+int cycles = 100;
+Bool mono = 0;
+//Bool allowroot = 0;
+char *ProgramName;
+/*
+Dr. Park's algorithm published in the Oct. '88 ACM
+"Random Number Generators: Good Ones Are Hard To Find"
+His version available at ftp://cs.wm.edu/pub/rngs.tar
+Present form by many authors.
+*/
+
+static int Seed = 1; /* This is required to be 32 bits long */
+
+/*
+ * Given an integer, this routine initializes the RNG seed.
+ */
+void SetRNG(long s)
+{
+ Seed = (int) s;
+}
+
+/*
+ * Returns an integer between 0 and 2147483647, inclusive.
+ */
+long LongRNG()
+{
+ if ((Seed = Seed % 44488 * 48271 - Seed / 44488 * 3399) < 0)
+ Seed += 2147483647;
+ return (long) (Seed - 1);
+}
+
+unsigned long
+allocpixel(Colormap cmap, const char *name, const char *def)
+{
+ XColor col;
+ XColor tmp;
+ XParseColor(dsp, cmap, name, &col);
+ if (!XAllocColor(dsp, cmap, &col))
+ {
+ fprintf(stderr, "couldn't allocate: %s, using %s instead\n", name, def);
+ XAllocNamedColor(dsp, cmap, def, &col, &tmp);
+ }
+
+ return col.pixel;
+}
+
+void initXLock( GC gc )
+{
+ SetRNG( time(NULL) );
+
+ dsp = qt_xdisplay();
+ screen = qt_xscreen();
+
+ Screen *scr = ScreenOfDisplay(dsp, screen);
+
+ Scr[0].gc = gc;
+ Scr[0].npixels = NUMCOLORS;
+ Scr[0].cmap = None;
+
+ Colormap cmap = DefaultColormapOfScreen(scr);
+ Scr[0].bgcol = allocpixel(cmap, "background", "White");
+ Scr[0].bgcol = allocpixel(cmap, "foreground", "Black");
+
+ QColor color;
+
+ for ( int i = 0; i < NUMCOLORS; i++ )
+ {
+ color.setHsv( i * 360 / NUMCOLORS, 255, 255 );
+ Scr[0].pixels[i] = color.alloc();
+ }
+}
+
diff --git a/kscreensaver/xsavers/xlock.h b/kscreensaver/xsavers/xlock.h
new file mode 100644
index 00000000..e8c2a2bb
--- /dev/null
+++ b/kscreensaver/xsavers/xlock.h
@@ -0,0 +1,229 @@
+#ifndef __XLOCK_H__
+#define __XLOCK_H__
+
+/*-
+ * @(#)xlock.h 3.3 95/09/24 xlockmore
+ *
+ * xlock.h - external interfaces for new modes and SYSV OS defines.
+ *
+ * Copyright (c) 1991 by Patrick J. Naughton.
+ *
+ * See xlock.c for copying information.
+ *
+ * Revision History:
+ *
+ * Changes of David Bagley <bagleyd@source.asset.com>
+ * 12-May-95: Added defines for SunOS's Adjunct password file
+ * Dale A. Harris <rodmur@ecst.csuchico.edu>
+ * 18-Nov-94: Modified for QNX 4.2 w/ Metrolink X server from Brian Campbell
+ * <brianc@qnx.com>.
+ * 11-Jul-94: added Bool flag: inwindow, which tells xlock to run in a
+ * window from Greg Bowering <greg@cs.adelaide.edu.au>
+ * 11-Jul-94: patch for Solaris SYR4 from Chris P. Ross <cross@eng.umd.edu>
+ * 28-Jun-94: Reorganized shadow stuff
+ * 24-Jun-94: Reorganized
+ * 22-Jun-94: Modified for VMS
+ * <Anthony.D.Clarke@Support.Hatfield.Raytheon.bae.eurokom.ie>
+ * 17-Jun-94: patched shadow passwords and bcopy and bzero for SYSV from
+ * <reggers@julian.uwo.ca>
+ * 21-Mar-94: patched the patch for AIXV3 and HP from
+ * <R.K.Lloyd@csc.liv.ac.uk>.
+ * 01-Dec-93: added patch for AIXV3 from
+ * (Tom McConnell, tmcconne@sedona.intel.com) also added a patch
+ * for HP-UX 8.0.
+ *
+ */
+
+#include <qapplication.h> // hack for qt-1.2
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Xresource.h>
+
+// added for kscreensave
+void initXLock( GC gc );
+
+
+#define MAXSCREENS 1
+#define NUMCOLORS 64
+#ifndef KERBEROS
+#define PASSLENGTH 64
+#else
+#define PASSLENGTH 120
+#endif
+#define FALLBACK_FONTNAME "fixed"
+#ifndef DEF_MFONT
+#define DEF_MFONT "-*-times-*-*-*-*-18-*-*-*-*-*-*-*"
+#endif
+#ifndef DEF_PROGRAM /* Try the -o option ;) */
+#define DEF_PROGRAM "fortune -s"
+#endif
+
+#define ICONW 64
+#define ICONH 64
+
+#if defined VMS || defined __QNX__
+#ifdef VMS
+/*#define VMS_PLAY*/
+#include <unixlib.h>
+#endif
+#endif
+
+#include <math.h>
+
+#ifndef M_E
+#define M_E 2.7182818284590452354
+#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif
+
+#if !defined (news1800) && !defined (sun386)
+#include <stdlib.h>
+#if !defined (apollo) && !defined (VMS)
+#include <unistd.h>
+#include <memory.h>
+#endif
+#endif
+#include <stdio.h>
+#include <string.h>
+
+typedef struct {
+ GC gc; /* graphics context for animation */
+ int npixels; /* number of valid entries in pixels */
+ Colormap cmap; /* current colormap */
+ unsigned long pixels[NUMCOLORS]; /* pixel values in the colormap */
+ unsigned long bgcol, fgcol; /* background and foreground pixel values */
+} perscreen;
+
+/* This stuff moved here from resource.c for the mode-specific options. */
+#define t_String 0
+#define t_Float 1
+#define t_Int 2
+#define t_Bool 3
+
+typedef struct {
+ caddr_t *var;
+ char *name;
+ char *arg_class;
+ char *def;
+ int type;
+} argtype;
+
+typedef struct {
+ char *opt;
+ char *desc;
+} OptionStruct;
+
+typedef struct {
+ int numopts;
+ XrmOptionDescRec *opts;
+ argtype *vars;
+ OptionStruct *desc;
+} ModeSpecOpt;
+/* End moved from resource.c */
+
+extern perscreen Scr[MAXSCREENS];
+extern Display *dsp;
+extern int screen;
+
+extern char *ProgramName;
+extern char *fontname;
+extern char *background;
+extern char *foreground;
+extern char *text_name;
+extern char *text_pass;
+extern char *text_info;
+extern char *text_valid;
+extern char *text_invalid;
+extern char *geometry;
+extern float saturation;
+extern int nicelevel;
+extern int delay;
+extern int batchcount;
+extern int cycles;
+extern int timeout;
+extern int lockdelay;
+#if defined(HAS_RPLAY) || defined(VMS_PLAY)
+extern char *locksound;
+extern char *infosound;
+extern char *validsound;
+/*extern char *invalidsound;*/
+#endif
+#ifdef AUTO_LOGOUT
+extern int forceLogout;
+#endif
+#ifdef LOGOUT_BUTTON
+extern int enable_button;
+extern char *logoutButtonLabel;
+extern char *logoutButtonHelp;
+extern char *logoutFailedString;
+#endif
+extern Bool usefirst;
+extern Bool mono;
+extern Bool nolock;
+extern Bool allowroot;
+extern Bool enablesaver;
+extern Bool allowaccess;
+extern Bool grabmouse;
+extern Bool echokeys;
+extern Bool verbose;
+extern Bool inwindow;
+extern Bool inroot;
+extern Bool timeelapsed;
+extern Bool install;
+extern int onepause;
+
+/* For modes with text, marquee & nose */
+extern char *program;
+extern char *messagesfile;
+extern char *messagefile;
+extern char *message;
+extern char *mfont;
+
+extern void (*callback) ();
+extern void (*init) ();
+
+extern void GetResources();
+extern void set_colormap();
+extern void fix_colormap();
+#ifdef __STDC__
+extern void error(char *, ...);
+#else
+extern void error();
+#endif
+extern void alarm_ctl();
+extern long seconds();
+
+/* For modes with text, marquee & nose */
+extern XFontStruct *get_font();
+extern char *get_words();
+extern void init_words();
+extern int is_ribbon();
+
+#ifdef LESS_THAN_AIX3_2
+#undef NULL
+#define NULL 0
+#endif /* LESS_THAN_AIX3_2 */
+
+#ifdef VMS
+#define OLD_EVENT_LOOP
+#endif
+
+#if defined(__STDC__) && (defined(__hpux) && defined(_PA_RISC1_1))
+#define MATHF
+#endif
+#ifdef MATHF
+#define SINF(n) sinf(n)
+#define COSF(n) cosf(n)
+#define FABSF(n) fabsf(n)
+#else
+#define SINF(n) ((float)sin((double)(n)))
+#define COSF(n) ((float)cos((double)(n)))
+#define FABSF(n) ((float)fabs((double)(n)))
+#endif
+
+#endif /* __XLOCK_H__ */
diff --git a/kscreensaver/xsavers/xlockmore.h b/kscreensaver/xsavers/xlockmore.h
new file mode 100644
index 00000000..496b48f2
--- /dev/null
+++ b/kscreensaver/xsavers/xlockmore.h
@@ -0,0 +1,261 @@
+#ifndef __XLOCK_XLOCK_H__
+#define __XLOCK_XLOCK_H__
+
+/*-
+ * @(#)xlock.h 4.00 97/01/01 xlockmore
+ *
+ * xlock.h - external interfaces for new modes and SYSV OS defines.
+ *
+ * Copyright (c) 1991 by Patrick J. Naughton.
+ *
+ * See xlock.c for copying information.
+ *
+ * Revision History:
+ *
+ * Changes of David Bagley <bagleyd@bigfoot.com>
+ * 12-May-95: Added defines for SunOS's Adjunct password file
+ * Dale A. Harris <rodmur@ecst.csuchico.edu>
+ * 18-Nov-94: Modified for QNX 4.2 w/ Metrolink X server from Brian Campbell
+ * <brianc@qnx.com>.
+ * 11-Jul-94: added Bool flag: inwindow, which tells xlock to run in a
+ * window from Greg Bowering <greg@cs.adelaide.edu.au>
+ * 11-Jul-94: patch for Solaris SYR4 from Chris P. Ross <cross@eng.umd.edu>
+ * 28-Jun-94: Reorganized shadow stuff
+ * 24-Jun-94: Reorganized
+ * 22-Jun-94: Modified for VMS
+ * <Anthony.D.Clarke@Support.Hatfield.Raytheon.bae.eurokom.ie>
+ * 17-Jun-94: patched shadow passwords and bcopy and bzero for SYSV from
+ * <reggers@julian.uwo.ca>
+ * 21-Mar-94: patched the patch for AIXV3 and HP from
+ * <R.K.Lloyd@csc.liv.ac.uk>.
+ * 01-Dec-93: added patch for AIXV3 from
+ * (Tom McConnell, tmcconne@sedona.intel.com) also added a patch
+ * for HP-UX 8.0.
+ *
+ */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Xresource.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* out of main.cpp */
+#define MODE_NONE 0
+#define MODE_INSTALL 1
+#define MODE_SETUP 2
+#define MODE_PREVIEW 3
+#define MODE_TEST 4
+
+
+#ifndef MAXSCREENS
+#define MAXSCREENS 3
+#endif
+#ifndef NUMCOLORS
+#define NUMCOLORS 64
+#endif
+#ifndef MESSAGELINES
+#define MESSAGELINES 40
+#endif
+#define PASSLENGTH 120
+#define FALLBACK_FONTNAME "fixed"
+#ifndef DEF_MFONT
+#define DEF_MFONT "-*-times-*-*-*-*-18-*-*-*-*-*-*-*"
+#endif
+#ifndef DEF_PROGRAM /* Try the -o option ;) */
+#define DEF_PROGRAM "fortune -s"
+#endif
+
+#ifndef DEF_NONE3D
+#define DEF_NONE3D "Black"
+#endif
+#ifndef DEF_RIGHT3D
+#define DEF_RIGHT3D "Red"
+#endif
+#ifndef DEF_LEFT3D
+#define DEF_LEFT3D "Blue"
+#endif
+#ifndef DEF_BOTH3D
+#define DEF_BOTH3D "Magenta"
+#endif
+
+#ifndef DEF_ICONW
+#define DEF_ICONW 64 /* Age old default */
+#endif
+#ifndef DEF_ICONH
+#define DEF_ICONH 64
+#endif
+
+#define MINICONW 1 /* Will not see much */
+#define MINICONH 1
+
+#ifndef MAXICONW
+#define MAXICONW 256 /* Want users to know the screen is locked */
+#endif
+#ifndef MAXICONH
+#define MAXICONH 256 /* by a particular user */
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+#ifndef ABS
+#define ABS(a) ((a<0)?(-(a)):(a))
+#endif
+
+#include <math.h>
+#ifndef M_E
+#define M_E 2.7182818284590452354
+#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif
+#if VMS
+#include <unixlib.h>
+#endif
+#include <sys/types.h>
+#if 0
+#ifndef uid_t
+#define uid_t int
+#endif
+#ifndef gid_t
+#define gid_t int
+#endif
+#ifndef pid_t
+#define pid_t int
+#endif
+#ifndef size_t
+#define size_t unsigned
+#endif
+#endif
+#include <unistd.h>
+#if HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#if HAVE_DIRENT_H
+#ifdef USE_XVMSUTILS
+#if 0
+#include "../xvmsutils/unix_types.h"
+#include "../xvmsutils/dirent.h"
+#else
+#include <X11/unix_types.h>
+#include <X11/dirent.h>
+#endif
+#else /* !USE_XVMSUTILS */
+#include <dirent.h>
+#endif /* !USE_XVMSUTILS */
+#else
+#define dirent direct
+#define NAMELEN(dirent) (dirent)->d_namelen
+#if HAVE_SYS_NDIR_H
+#include <sys/ndir.h>
+#endif
+#if HAVE_SYS_DIR_H
+#include <sys/dir.h>
+#endif
+#if HAVE_NDIR_H
+#include <ndir.h>
+#endif
+#endif
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 256 /* maximum filename length */
+#endif
+#ifndef DIRBUF
+#define DIRBUF 512 /* buffer size for fs-indep. dirs */
+#endif
+
+typedef struct {
+ GC gc; /* graphics context for animation */
+ int npixels; /* number of valid entries in pixels */
+ Colormap cmap; /* current colormap */
+ unsigned long pixels[NUMCOLORS]; /* pixel values in the colormap */
+ unsigned long bgcol, fgcol; /* background and foreground pixel values */
+ unsigned long rightcol, leftcol; /* 3D color pixel values */
+ unsigned long nonecol, bothcol;
+} perscreen;
+
+#define t_String 0
+#define t_Float 1
+#define t_Int 2
+#define t_Bool 3
+
+typedef struct {
+ caddr_t *var;
+ char *name;
+ char *classname;
+ char *def;
+ int type;
+} argtype;
+
+typedef struct {
+ char *opt;
+ char *desc;
+} OptionStruct;
+
+typedef struct {
+ int numopts;
+ XrmOptionDescRec *opts;
+ int numvarsdesc;
+ argtype *vars;
+ OptionStruct *desc;
+} ModeSpecOpt;
+
+/* this must follow definition of ModeSpecOpt */
+#include "mode.h"
+
+#define IS_XBMDONE 1 /* Only need one mono image */
+#define IS_XBM 2
+#define IS_XBMFILE 3
+#define IS_XPM 4
+#define IS_XPMFILE 5
+#define IS_RASTERFILE 6
+
+extern void getResources(int argc, char **argv);
+extern unsigned long allocPixel(Display * display, Colormap cmap,
+ char *name, char *def);
+extern void setColormap(Display * display, Window window, Colormap map,
+ Bool inwindow);
+extern void reserveColors(ModeInfo * mi, Colormap cmap,
+ unsigned long *blackpix, unsigned long *whitepix);
+extern void fixColormap(Display * display, Window window,
+ int screen, float saturation,
+ Bool mono, Bool install, Bool inroot, Bool inwindow, Bool verbose);
+extern int visualClassFromName(char *name);
+extern void showVisualInfo(XVisualInfo * wantVis);
+#ifdef USE_GL
+extern int getVisual(ModeInfo * mi, XVisualInfo * wantVis, int mono);
+#endif
+
+extern unsigned long seconds(void);
+extern void finish(void);
+extern void error(char *s1,...);
+extern void warning(char *s1,...);
+
+#ifndef HAVE_STRDUP
+extern char *strdup(char *);
+#endif
+
+#ifdef MATHF
+#define SINF(n) sinf(n)
+#define COSF(n) cosf(n)
+#define FABSF(n) fabsf(n)
+#else
+#define SINF(n) ((float)sin((double)(n)))
+#define COSF(n) ((float)cos((double)(n)))
+#define FABSF(n) ((float)fabs((double)(n)))
+#endif
+
+#endif /* __XLOCK_XLOCK_H__ */
diff --git a/kscreensaver/xsavers/xs_colors.c b/kscreensaver/xsavers/xs_colors.c
new file mode 100644
index 00000000..82dab33b
--- /dev/null
+++ b/kscreensaver/xsavers/xs_colors.c
@@ -0,0 +1,693 @@
+/* xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+/* This file contains some utility routines for randomly picking the colors
+ to hack the screen with.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Xresource.h>
+
+#include "xs_visual.h"
+#include "xs_yarandom.h"
+#include "xs_hsv.h"
+#include "xs_colors.h"
+
+/* extern char *progname; */
+
+void
+free_colors(Display *dpy, Colormap cmap, XColor *colors, int ncolors)
+{
+ int i;
+ if (ncolors > 0)
+ {
+ unsigned long *pixels = (unsigned long *)
+ malloc(sizeof(*pixels) * ncolors);
+ for (i = 0; i < ncolors; i++)
+ pixels[i] = colors[i].pixel;
+ XFreeColors (dpy, cmap, pixels, ncolors, 0L);
+ free(pixels);
+ }
+}
+
+
+void
+allocate_writable_colors (Display *dpy, Colormap cmap,
+ unsigned long *pixels, int *ncolorsP)
+{
+ int desired = *ncolorsP;
+ int got = 0;
+ int requested = desired;
+ unsigned long *new_pixels = pixels;
+
+ *ncolorsP = 0;
+ while (got < desired
+ && requested > 0)
+ {
+ if (desired - got < requested)
+ requested = desired - got;
+
+ if (XAllocColorCells (dpy, cmap, False, 0, 0, new_pixels, requested))
+ {
+ /* Got all the pixels we asked for. */
+ new_pixels += requested;
+ got += requested;
+ }
+ else
+ {
+ /* We didn't get all/any of the pixels we asked for. This time, ask
+ for half as many. (If we do get all that we ask for, we ask for
+ the same number again next time, so we only do O(log(n)) server
+ roundtrips.)
+ */
+ requested = requested / 2;
+ }
+ }
+ *ncolorsP += got;
+}
+
+
+
+void
+make_color_ramp (Display *dpy, Colormap cmap,
+ int h1, double s1, double v1, /* 0-360, 0-1.0, 0-1.0 */
+ int h2, double s2, double v2, /* 0-360, 0-1.0, 0-1.0 */
+ XColor *colors, int *ncolorsP,
+ Bool closed_p,
+ Bool allocate_p,
+ Bool writable_p)
+{
+ int i;
+ int ncolors = *ncolorsP;
+ double dh, ds, dv; /* deltas */
+
+ AGAIN:
+
+ memset (colors, 0, (*ncolorsP) * sizeof(*colors));
+
+ if (closed_p)
+ ncolors = (ncolors / 2) + 1;
+
+ /* Note: unlike other routines in this module, this function assumes that
+ if h1 and h2 are more than 180 degrees apart, then the desired direction
+ is always from h1 to h2 (rather than the shorter path.) make_uniform
+ depends on this.
+ */
+ dh = ((double)h2 - (double)h1) / ncolors;
+ ds = (s2 - s1) / ncolors;
+ dv = (v2 - v1) / ncolors;
+
+ for (i = 0; i < ncolors; i++)
+ {
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+ hsv_to_rgb ((int) (h1 + (i*dh)), (s1 + (i*ds)), (v1 + (i*dv)),
+ &colors[i].red, &colors[i].green, &colors[i].blue);
+ }
+
+ if (closed_p)
+ for (i = ncolors; i < *ncolorsP; i++)
+ colors[i] = colors[(*ncolorsP)-i];
+
+ if (!allocate_p)
+ return;
+
+ if (writable_p)
+ {
+ unsigned long *pixels = (unsigned long *)
+ malloc(sizeof(*pixels) * ((*ncolorsP) + 1));
+
+ /* allocate_writable_colors() won't do here, because we need exactly this
+ number of cells, or the color sequence we've chosen won't fit. */
+ if (! XAllocColorCells(dpy, cmap, False, 0, 0, pixels, *ncolorsP))
+ {
+ free(pixels);
+ goto FAIL;
+ }
+
+ for (i = 0; i < *ncolorsP; i++)
+ colors[i].pixel = pixels[i];
+ free (pixels);
+
+ XStoreColors (dpy, cmap, colors, *ncolorsP);
+ }
+ else
+ {
+ for (i = 0; i < *ncolorsP; i++)
+ {
+ XColor color;
+ color = colors[i];
+ if (XAllocColor (dpy, cmap, &color))
+ {
+ colors[i].pixel = color.pixel;
+ }
+ else
+ {
+ free_colors (dpy, cmap, colors, i);
+ goto FAIL;
+ }
+ }
+ }
+
+ return;
+
+ FAIL:
+ /* we weren't able to allocate all the colors we wanted;
+ decrease the requested number and try again.
+ */
+ ncolors = (ncolors > 170 ? ncolors - 20 :
+ ncolors > 100 ? ncolors - 10 :
+ ncolors > 75 ? ncolors - 5 :
+ ncolors > 25 ? ncolors - 3 :
+ ncolors > 10 ? ncolors - 2 :
+ ncolors > 2 ? ncolors - 1 :
+ 0);
+ *ncolorsP = ncolors;
+ if (ncolors > 0)
+ goto AGAIN;
+}
+
+
+#define MAXPOINTS 50 /* yeah, so I'm lazy */
+
+
+static void
+make_color_path (Display *dpy, Colormap cmap,
+ int npoints, int *h, double *s, double *v,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool writable_p)
+{
+ int i, j, k;
+ int total_ncolors = *ncolorsP;
+
+ int ncolors[MAXPOINTS]; /* number of pixels per edge */
+ double dh[MAXPOINTS]; /* distance between pixels, per edge (0 - 360.0) */
+ double ds[MAXPOINTS]; /* distance between pixels, per edge (0 - 1.0) */
+ double dv[MAXPOINTS]; /* distance between pixels, per edge (0 - 1.0) */
+
+ if (npoints == 0)
+ {
+ *ncolorsP = 0;
+ return;
+ }
+ else if (npoints == 2) /* using make_color_ramp() will be faster */
+ {
+ make_color_ramp (dpy, cmap,
+ h[0], s[0], v[0], h[1], s[1], v[1],
+ colors, ncolorsP,
+ True, /* closed_p */
+ allocate_p, writable_p);
+ return;
+ }
+ else if (npoints >= MAXPOINTS)
+ {
+ npoints = MAXPOINTS-1;
+ }
+
+ AGAIN:
+
+ {
+ double DH[MAXPOINTS]; /* Distance between H values in the shortest
+ direction around the circle, that is, the
+ distance between 10 and 350 is 20.
+ (Range is 0 - 360.0.)
+ */
+ double edge[MAXPOINTS]; /* lengths of edges in unit HSV space. */
+ double ratio[MAXPOINTS]; /* proportions of the edges (total 1.0) */
+ double circum = 0;
+ double one_point_oh = 0; /* (debug) */
+
+ for (i = 0; i < npoints; i++)
+ {
+ int j = (i+1) % npoints;
+ double d = ((double) (h[i] - h[j])) / 360;
+ if (d < 0) d = -d;
+ if (d > 0.5) d = 0.5 - (d - 0.5);
+ DH[i] = d;
+ }
+
+ for (i = 0; i < npoints; i++)
+ {
+ int j = (i+1) % npoints;
+ edge[i] = sqrt((DH[i] * DH[j]) +
+ ((s[j] - s[i]) * (s[j] - s[i])) +
+ ((v[j] - v[i]) * (v[j] - v[i])));
+ circum += edge[i];
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "\ncolors:");
+ for (i=0; i < npoints; i++)
+ fprintf(stderr, " (%d, %.3f, %.3f)", h[i], s[i], v[i]);
+ fprintf(stderr, "\nlengths:");
+ for (i=0; i < npoints; i++)
+ fprintf(stderr, " %.3f", edge[i]);
+#endif /* DEBUG */
+
+ if (circum < 0.0001)
+ goto FAIL;
+
+ for (i = 0; i < npoints; i++)
+ {
+ ratio[i] = edge[i] / circum;
+ one_point_oh += ratio[i];
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "\nratios:");
+ for (i=0; i < npoints; i++)
+ fprintf(stderr, " %.3f", ratio[i]);
+#endif /* DEBUG */
+
+ if (one_point_oh < 0.99999 || one_point_oh > 1.00001)
+ abort();
+
+ /* space the colors evenly along the circumference -- that means that the
+ number of pixels on a edge is proportional to the length of that edge
+ (relative to the lengths of the other edges.)
+ */
+ for (i = 0; i < npoints; i++)
+ ncolors[i] = total_ncolors * ratio[i];
+
+
+#ifdef DEBUG
+ fprintf(stderr, "\npixels:");
+ for (i=0; i < npoints; i++)
+ fprintf(stderr, " %d", ncolors[i]);
+ fprintf(stderr, " (%d)\n", total_ncolors);
+#endif /* DEBUG */
+
+ for (i = 0; i < npoints; i++)
+ {
+ int j = (i+1) % npoints;
+
+ if (ncolors[i] > 0)
+ {
+ dh[i] = 360 * (DH[i] / ncolors[i]);
+ ds[i] = (s[j] - s[i]) / ncolors[i];
+ dv[i] = (v[j] - v[i]) / ncolors[i];
+ }
+ }
+ }
+
+ memset (colors, 0, (*ncolorsP) * sizeof(*colors));
+
+ k = 0;
+ for (i = 0; i < npoints; i++)
+ {
+ int distance, direction;
+ distance = h[(i+1) % npoints] - h[i];
+ direction = (distance >= 0 ? -1 : 1);
+
+ if (distance > 180)
+ distance = 180 - (distance - 180);
+ else if (distance < -180)
+ distance = -(180 - ((-distance) - 180));
+ else
+ direction = -direction;
+
+#ifdef DEBUG
+ fprintf (stderr, "point %d: %3d %.2f %.2f\n",
+ i, h[i], s[i], v[i]);
+ fprintf(stderr, " h[i]=%d dh[i]=%.2f ncolors[i]=%d\n",
+ h[i], dh[i], ncolors[i]);
+#endif /* DEBUG */
+ for (j = 0; j < ncolors[i]; j++, k++)
+ {
+ double hh = (h[i] + (j * dh[i] * direction));
+ if (hh < 0) hh += 360;
+ else if (hh > 360) hh -= 0;
+ colors[k].flags = DoRed|DoGreen|DoBlue;
+ hsv_to_rgb ((int)
+ hh,
+ (s[i] + (j * ds[i])),
+ (v[i] + (j * dv[i])),
+ &colors[k].red, &colors[k].green, &colors[k].blue);
+#ifdef DEBUG
+ fprintf (stderr, "point %d+%d: %.2f %.2f %.2f %04X %04X %04X\n",
+ i, j,
+ hh,
+ (s[i] + (j * ds[i])),
+ (v[i] + (j * dv[i])),
+ colors[k].red, colors[k].green, colors[k].blue);
+#endif /* DEBUG */
+ }
+ }
+
+ /* Floating-point round-off can make us decide to use fewer colors. */
+ if (k < *ncolorsP)
+ {
+ *ncolorsP = k;
+ if (k <= 0)
+ return;
+ }
+
+ if (!allocate_p)
+ return;
+
+ if (writable_p)
+ {
+ unsigned long *pixels = (unsigned long *)
+ malloc(sizeof(*pixels) * ((*ncolorsP) + 1));
+
+ /* allocate_writable_colors() won't do here, because we need exactly this
+ number of cells, or the color sequence we've chosen won't fit. */
+ if (! XAllocColorCells(dpy, cmap, False, 0, 0, pixels, *ncolorsP))
+ {
+ free(pixels);
+ goto FAIL;
+ }
+
+ for (i = 0; i < *ncolorsP; i++)
+ colors[i].pixel = pixels[i];
+ free (pixels);
+
+ XStoreColors (dpy, cmap, colors, *ncolorsP);
+ }
+ else
+ {
+ for (i = 0; i < *ncolorsP; i++)
+ {
+ XColor color;
+ color = colors[i];
+ if (XAllocColor (dpy, cmap, &color))
+ {
+ colors[i].pixel = color.pixel;
+ }
+ else
+ {
+ free_colors (dpy, cmap, colors, i);
+ goto FAIL;
+ }
+ }
+ }
+
+ return;
+
+ FAIL:
+ /* we weren't able to allocate all the colors we wanted;
+ decrease the requested number and try again.
+ */
+ total_ncolors = (total_ncolors > 170 ? total_ncolors - 20 :
+ total_ncolors > 100 ? total_ncolors - 10 :
+ total_ncolors > 75 ? total_ncolors - 5 :
+ total_ncolors > 25 ? total_ncolors - 3 :
+ total_ncolors > 10 ? total_ncolors - 2 :
+ total_ncolors > 2 ? total_ncolors - 1 :
+ 0);
+ *ncolorsP = total_ncolors;
+ if (total_ncolors > 0)
+ goto AGAIN;
+}
+
+
+void
+make_color_loop (Display *dpy, Colormap cmap,
+ int h0, double s0, double v0, /* 0-360, 0-1.0, 0-1.0 */
+ int h1, double s1, double v1, /* 0-360, 0-1.0, 0-1.0 */
+ int h2, double s2, double v2, /* 0-360, 0-1.0, 0-1.0 */
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool writable_p)
+{
+ int h[3];
+ double s[3], v[3];
+ h[0] = h0; h[1] = h1; h[2] = h2;
+ s[0] = s0; s[1] = s1; s[2] = s2;
+ v[0] = v0; v[1] = v1; v[2] = v2;
+ make_color_path(dpy, cmap,
+ 3, h, s, v,
+ colors, ncolorsP,
+ allocate_p, writable_p);
+}
+
+
+static void
+complain (int wanted_colors, int got_colors,
+ Bool wanted_writable, Bool got_writable)
+{
+ if (wanted_writable && !got_writable)
+ fprintf(stderr,
+ "%s: wanted %d writable colors; got %d read-only colors.\n",
+ "colors (kscreensaver)", wanted_colors, got_colors);
+
+ else if (wanted_colors > (got_colors + 10))
+ /* don't bother complaining if we're within ten pixels. */
+ fprintf(stderr, "%s: wanted %d%s colors; got %d.\n",
+ "colors (kscreensaver)", wanted_colors, (got_writable ? " writable" : ""),
+ got_colors);
+}
+
+
+void
+make_smooth_colormap (Display *dpy, Visual *visual, Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p)
+{
+ int npoints;
+ int ncolors = *ncolorsP;
+ Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
+ int i;
+ int h[MAXPOINTS];
+ double s[MAXPOINTS];
+ double v[MAXPOINTS];
+ double total_s = 0;
+ double total_v = 0;
+ Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+
+ if (*ncolorsP <= 0) return;
+
+ {
+ int n = random() % 20;
+ if (n <= 5) npoints = 2; /* 30% of the time */
+ else if (n <= 15) npoints = 3; /* 50% of the time */
+ else if (n <= 18) npoints = 4; /* 15% of the time */
+ else npoints = 5; /* 5% of the time */
+ }
+
+ REPICK_ALL_COLORS:
+ for (i = 0; i < npoints; i++)
+ {
+ REPICK_THIS_COLOR:
+ h[i] = random() % 360;
+ s[i] = frand(1.0);
+ v[i] = frand(0.8) + 0.2;
+
+ /* Make sure that no two adjascent colors are *too* close together.
+ If they are, try again.
+ */
+ if (i > 0)
+ {
+ int j = (i+1 == npoints) ? 0 : (i-1);
+ double hi = ((double) h[i]) / 360;
+ double hj = ((double) h[j]) / 360;
+ double dh = hj - hi;
+ double distance;
+ if (dh < 0) dh = -dh;
+ if (dh > 0.5) dh = 0.5 - (dh - 0.5);
+ distance = sqrt ((dh * dh) +
+ ((s[j] - s[i]) * (s[j] - s[i])) +
+ ((v[j] - v[i]) * (v[j] - v[i])));
+ if (distance < 0.2)
+ goto REPICK_THIS_COLOR;
+ }
+ total_s += s[i];
+ total_v += v[i];
+ }
+
+ /* If the average saturation or intensity are too low, repick the colors,
+ so that we don't end up with a black-and-white or too-dark map.
+ */
+ if (total_s / npoints < 0.2)
+ goto REPICK_ALL_COLORS;
+ if (total_v / npoints < 0.3)
+ goto REPICK_ALL_COLORS;
+
+ /* If this visual doesn't support writable cells, don't bother trying.
+ */
+ if (wanted_writable && !has_writable_cells(screen, visual))
+ *writable_pP = False;
+
+ RETRY_NON_WRITABLE:
+ make_color_path (dpy, cmap, npoints, h, s, v, colors, &ncolors,
+ allocate_p, (writable_pP && *writable_pP));
+
+ /* If we tried for writable cells and got none, try for non-writable. */
+ if (allocate_p && *ncolorsP == 0 && *writable_pP)
+ {
+ *writable_pP = False;
+ goto RETRY_NON_WRITABLE;
+ }
+
+ if (verbose_p)
+ complain(*ncolorsP, ncolors, wanted_writable,
+ wanted_writable && *writable_pP);
+
+ *ncolorsP = ncolors;
+}
+
+
+void
+make_uniform_colormap (Display *dpy, Visual *visual, Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p)
+{
+ int ncolors = *ncolorsP;
+ Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
+ Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+
+ double S = ((double) (random() % 34) + 66) / 100.0; /* range 66%-100% */
+ double V = ((double) (random() % 34) + 66) / 100.0; /* range 66%-100% */
+
+ if (*ncolorsP <= 0) return;
+
+ /* If this visual doesn't support writable cells, don't bother trying. */
+ if (wanted_writable && !has_writable_cells(screen, visual))
+ *writable_pP = False;
+
+ RETRY_NON_WRITABLE:
+ make_color_ramp(dpy, cmap,
+ 0, S, V,
+ 359, S, V,
+ colors, &ncolors,
+ False, True, wanted_writable);
+
+ /* If we tried for writable cells and got none, try for non-writable. */
+ if (allocate_p && *ncolorsP == 0 && writable_pP && *writable_pP)
+ {
+ ncolors = *ncolorsP;
+ *writable_pP = False;
+ goto RETRY_NON_WRITABLE;
+ }
+
+ if (verbose_p)
+ complain(*ncolorsP, ncolors, wanted_writable,
+ wanted_writable && *writable_pP);
+
+ *ncolorsP = ncolors;
+}
+
+
+void
+make_random_colormap (Display *dpy, Visual *visual, Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool bright_p,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p)
+{
+ Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
+ int ncolors = *ncolorsP;
+ int i;
+ Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+
+ if (*ncolorsP <= 0) return;
+
+ /* If this visual doesn't support writable cells, don't bother trying. */
+ if (wanted_writable && !has_writable_cells(screen, visual))
+ *writable_pP = False;
+
+ for (i = 0; i < ncolors; i++)
+ {
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+ if (bright_p)
+ {
+ int H = random() % 360; /* range 0-360 */
+ double S = ((double) (random()%70) + 30)/100.0; /* range 30%-100% */
+ double V = ((double) (random()%34) + 66)/100.0; /* range 66%-100% */
+ hsv_to_rgb (H, S, V,
+ &colors[i].red, &colors[i].green, &colors[i].blue);
+ }
+ else
+ {
+ colors[i].red = random() % 0xFFFF;
+ colors[i].green = random() % 0xFFFF;
+ colors[i].blue = random() % 0xFFFF;
+ }
+ }
+
+ if (!allocate_p)
+ return;
+
+ RETRY_NON_WRITABLE:
+ if (writable_pP && *writable_pP)
+ {
+ unsigned long *pixels = (unsigned long *)
+ malloc(sizeof(*pixels) * (ncolors + 1));
+
+ allocate_writable_colors (dpy, cmap, pixels, &ncolors);
+ if (ncolors > 0)
+ for (i = 0; i < ncolors; i++)
+ colors[i].pixel = pixels[i];
+ free (pixels);
+ if (ncolors > 0)
+ XStoreColors (dpy, cmap, colors, ncolors);
+ }
+ else
+ {
+ for (i = 0; i < ncolors; i++)
+ {
+ XColor color;
+ color = colors[i];
+ if (!XAllocColor (dpy, cmap, &color))
+ break;
+ colors[i].pixel = color.pixel;
+ }
+ ncolors = i;
+ }
+
+ /* If we tried for writable cells and got none, try for non-writable. */
+ if (allocate_p && ncolors == 0 && writable_pP && *writable_pP)
+ {
+ ncolors = *ncolorsP;
+ *writable_pP = False;
+ goto RETRY_NON_WRITABLE;
+ }
+
+ if (verbose_p)
+ complain(*ncolorsP, ncolors, wanted_writable,
+ wanted_writable && *writable_pP);
+
+ *ncolorsP = ncolors;
+}
+
+
+void
+rotate_colors (Display *dpy, Colormap cmap,
+ XColor *colors, int ncolors, int distance)
+{
+ int i;
+ XColor *colors2 = (XColor *) malloc(sizeof(*colors2) * ncolors);
+ if (ncolors < 2) return;
+ distance = distance % ncolors;
+ for (i = 0; i < ncolors; i++)
+ {
+ int j = i - distance;
+ if (j >= ncolors) j -= ncolors;
+ if (j < 0) j += ncolors;
+ colors2[i] = colors[j];
+ colors2[i].pixel = colors[i].pixel;
+ }
+ XStoreColors (dpy, cmap, colors2, ncolors);
+ XFlush(dpy);
+ memcpy(colors, colors2, sizeof(*colors) * ncolors);
+ free(colors2);
+}
diff --git a/kscreensaver/xsavers/xs_colors.h b/kscreensaver/xsavers/xs_colors.h
new file mode 100644
index 00000000..61421cf5
--- /dev/null
+++ b/kscreensaver/xsavers/xs_colors.h
@@ -0,0 +1,140 @@
+/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifndef __COLORS_H__
+#define __COLORS_H__
+
+/* Like XFreeColors, but works on `XColor *' instead of `unsigned long *'
+ */
+extern void free_colors (Display *, Colormap, XColor *, int ncolors);
+
+
+/* Allocates writable, non-contiguous color cells. The number requested is
+ passed in *ncolorsP, and the number actually allocated is returned there.
+ (Unlike XAllocColorCells(), this will allocate as many as it can, instead
+ of failing if they can't all be allocated.)
+ */
+extern void allocate_writable_colors (Display *dpy, Colormap cmap,
+ unsigned long *pixels, int *ncolorsP);
+
+
+/* Generates a sequence of colors evenly spaced between the given pair
+ of HSV coordinates.
+
+ If closed_p is true, the colors will go from the first point to the
+ second then back to the first.
+
+ If allocate_p is true, the colors will be allocated from the map;
+ if enough colors can't be allocated, we will try for less, and the
+ result will be returned to ncolorsP.
+
+ If writable_p is true, writable color cells will be allocated;
+ otherwise, read-only cells will be allocated.
+ */
+extern void make_color_ramp (Display *dpy, Colormap cmap,
+ int h1, double s1, double v1,
+ int h2, double s2, double v2,
+ XColor *colors, int *ncolorsP,
+ Bool closed_p,
+ Bool allocate_p,
+ Bool writable_p);
+
+/* Generates a sequence of colors evenly spaced around the triangle
+ indicated by the thee HSV coordinates.
+
+ If allocate_p is true, the colors will be allocated from the map;
+ if enough colors can't be allocated, we will try for less, and the
+ result will be returned to ncolorsP.
+
+ If writable_p is true, writable color cells will be allocated;
+ otherwise, read-only cells will be allocated.
+ */
+extern void make_color_loop (Display *, Colormap,
+ int h1, double s1, double v1,
+ int h2, double s2, double v2,
+ int h3, double s3, double v3,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool writable_p);
+
+
+/* Allocates a hopefully-interesting colormap, which will be a closed loop
+ without any sudden transitions.
+
+ If allocate_p is true, the colors will be allocated from the map;
+ if enough colors can't be allocated, we will try for less, and the
+ result will be returned to ncolorsP. An error message will be
+ printed on stderr (if verbose_p).
+
+ If *writable_pP is true, writable color cells will be allocated;
+ otherwise, read-only cells will be allocated. If no writable cells
+ cannot be allocated, we will try to allocate unwritable cells
+ instead, and print a message on stderr to that effect (if verbose_p).
+ */
+extern void make_smooth_colormap (Display *dpy, Visual *visual,
+ Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p);
+
+/* Allocates a uniform colormap which touches each hue of the spectrum,
+ evenly spaced. The saturation and intensity are chosen randomly, but
+ will be high enough to be visible.
+
+ If allocate_p is true, the colors will be allocated from the map;
+ if enough colors can't be allocated, we will try for less, and the
+ result will be returned to ncolorsP. An error message will be
+ printed on stderr (if verbose_p).
+
+ If *writable_pP is true, writable color cells will be allocated;
+ otherwise, read-only cells will be allocated. If no writable cells
+ cannot be allocated, we will try to allocate unwritable cells
+ instead, and print a message on stderr to that effect (if verbose_p).
+ */
+extern void make_uniform_colormap (Display *dpy, Visual *visual,
+ Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p);
+
+/* Allocates a random colormap (the colors are unrelated to one another.)
+ If `bright_p' is false, the colors will be completely random; if it is
+ true, all of the colors will be bright enough to see on a black background.
+
+ If allocate_p is true, the colors will be allocated from the map;
+ if enough colors can't be allocated, we will try for less, and the
+ result will be returned to ncolorsP. An error message will be
+ printed on stderr (if verbose_p).
+
+ If *writable_pP is true, writable color cells will be allocated;
+ otherwise, read-only cells will be allocated. If no writable cells
+ cannot be allocated, we will try to allocate unwritable cells
+ instead, and print a message on stderr to that effect (if verbose_p).
+ */
+extern void make_random_colormap (Display *dpy, Visual *visual,
+ Colormap cmap,
+ XColor *colors, int *ncolorsP,
+ Bool bright_p,
+ Bool allocate_p,
+ Bool *writable_pP,
+ Bool verbose_p);
+
+
+/* Assuming that the array of colors indicates the current state of a set
+ of writable color cells, this rotates the contents of the array by
+ `distance' steps, moving the colors of cell N to cell (N - distance).
+ */
+extern void rotate_colors (Display *, Colormap,
+ XColor *, int ncolors, int distance);
+
+#endif /* __COLORS_H__ */
diff --git a/kscreensaver/xsavers/xs_hsv.c b/kscreensaver/xsavers/xs_hsv.c
new file mode 100644
index 00000000..51385d00
--- /dev/null
+++ b/kscreensaver/xsavers/xs_hsv.c
@@ -0,0 +1,81 @@
+/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+/* This file contains some utility routines for randomly picking the colors
+ to hack the screen with.
+ */
+
+/* #include "utils.h" */
+#include "xs_hsv.h"
+
+void
+hsv_to_rgb (int h, double s, double v,
+ unsigned short *r, unsigned short *g, unsigned short *b)
+{
+ double H, S, V, R, G, B;
+ double p1, p2, p3;
+ double f;
+ int i;
+
+ if (s < 0) s = 0;
+ if (v < 0) v = 0;
+ if (s > 1) s = 1;
+ if (v > 1) v = 1;
+
+ S = s; V = v;
+ H = (h % 360) / 60.0;
+ i = H;
+ f = H - i;
+ p1 = V * (1 - S);
+ p2 = V * (1 - (S * f));
+ p3 = V * (1 - (S * (1 - f)));
+ if (i == 0) { R = V; G = p3; B = p1; }
+ else if (i == 1) { R = p2; G = V; B = p1; }
+ else if (i == 2) { R = p1; G = V; B = p3; }
+ else if (i == 3) { R = p1; G = p2; B = V; }
+ else if (i == 4) { R = p3; G = p1; B = V; }
+ else { R = V; G = p1; B = p2; }
+ *r = R * 65535;
+ *g = G * 65535;
+ *b = B * 65535;
+}
+
+void
+rgb_to_hsv (unsigned short r, unsigned short g, unsigned short b,
+ int *h, double *s, double *v)
+{
+ double R, G, B, H, S, V;
+ double cmax, cmin;
+ double cmm;
+ int imax;
+ R = ((double) r) / 65535.0;
+ G = ((double) g) / 65535.0;
+ B = ((double) b) / 65535.0;
+ cmax = R; cmin = G; imax = 1;
+ if ( cmax < G ) { cmax = G; cmin = R; imax = 2; }
+ if ( cmax < B ) { cmax = B; imax = 3; }
+ if ( cmin > B ) { cmin = B; }
+ cmm = cmax - cmin;
+ V = cmax;
+ if (cmm == 0)
+ S = H = 0;
+ else
+ {
+ S = cmm / cmax;
+ if (imax == 1) H = (G - B) / cmm;
+ else if (imax == 2) H = 2.0 + (B - R) / cmm;
+ else /*if (imax == 3)*/ H = 4.0 + (R - G) / cmm;
+ if (H < 0) H += 6.0;
+ }
+ *h = (H * 60.0);
+ *s = S;
+ *v = V;
+}
diff --git a/kscreensaver/xsavers/xs_hsv.h b/kscreensaver/xsavers/xs_hsv.h
new file mode 100644
index 00000000..e0fdfb0f
--- /dev/null
+++ b/kscreensaver/xsavers/xs_hsv.h
@@ -0,0 +1,27 @@
+/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifndef __HSV_H__
+#define __HSV_H__
+
+/* Converts between RGB and HSV color spaces.
+ R, G, and B are in the range 0 - 65535;
+ H is in the range 0 - 360;
+ S and V are in the range 0.0 - 1.0.
+ */
+extern void hsv_to_rgb (int h, double s, double v,
+ unsigned short *r,
+ unsigned short *g,
+ unsigned short *b);
+extern void rgb_to_hsv (unsigned short r, unsigned short g, unsigned short b,
+ int *h, double *s, double *v);
+
+#endif /* __HSV_H__ */
diff --git a/kscreensaver/xsavers/xs_utils.h b/kscreensaver/xsavers/xs_utils.h
new file mode 100644
index 00000000..284bb86d
--- /dev/null
+++ b/kscreensaver/xsavers/xs_utils.h
@@ -0,0 +1,22 @@
+/* xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xos.h>
diff --git a/kscreensaver/xsavers/xs_visual.c b/kscreensaver/xsavers/xs_visual.c
new file mode 100644
index 00000000..ff20374a
--- /dev/null
+++ b/kscreensaver/xsavers/xs_visual.c
@@ -0,0 +1,473 @@
+/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
+ * by Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+/* This file contains some code for intelligently picking the best visual
+ (where "best" is biased in the direction of either: high color counts;
+ or: having writable color cells...)
+ */
+
+#include "xs_utils.h"
+
+#include "xs_visual.h"
+
+#include <X11/Xutil.h>
+
+/* extern char *progname; */
+
+
+#ifndef isupper
+# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
+#endif
+#ifndef _tolower
+# define _tolower(c) ((c) - 'A' + 'a')
+#endif
+
+
+static Visual *pick_best_visual (Screen *, Bool, Bool);
+static Visual *pick_mono_visual (Screen *);
+static Visual *pick_best_visual_of_class (Screen *, int);
+static Visual *id_to_visual (Screen *, int);
+static Visual *id_to_visual (Screen *screen, int id);
+
+
+#define DEFAULT_VISUAL -1
+#define BEST_VISUAL -2
+#define MONO_VISUAL -3
+#define GRAY_VISUAL -4
+#define COLOR_VISUAL -5
+#define SPECIFIC_VISUAL -6
+
+Visual *
+get_visual (Screen *screen, const char *string, Bool prefer_writable_cells,
+ Bool verbose_p)
+{
+ char *v = (string ? strdup(string) : 0);
+ char c, *tmp;
+ int vclass;
+ unsigned long id;
+ Visual *result = 0;
+
+ if (v)
+ for (tmp = v; *tmp; tmp++)
+ if (isupper (*tmp)) *tmp = _tolower (*tmp);
+
+ if (!v) vclass = BEST_VISUAL;
+ else if (!strcmp (v, "default")) vclass = DEFAULT_VISUAL;
+ else if (!strcmp (v, "best")) vclass = BEST_VISUAL;
+ else if (!strcmp (v, "mono")) vclass = MONO_VISUAL;
+ else if (!strcmp (v, "monochrome")) vclass = MONO_VISUAL;
+ else if (!strcmp (v, "gray")) vclass = GRAY_VISUAL;
+ else if (!strcmp (v, "grey")) vclass = GRAY_VISUAL;
+ else if (!strcmp (v, "color")) vclass = COLOR_VISUAL;
+ else if (!strcmp (v, "staticgray")) vclass = StaticGray;
+ else if (!strcmp (v, "staticcolor")) vclass = StaticColor;
+ else if (!strcmp (v, "truecolor")) vclass = TrueColor;
+ else if (!strcmp (v, "grayscale")) vclass = GrayScale;
+ else if (!strcmp (v, "greyscale")) vclass = GrayScale;
+ else if (!strcmp (v, "pseudocolor")) vclass = PseudoColor;
+ else if (!strcmp (v, "directcolor")) vclass = DirectColor;
+ else if (1 == sscanf (v, " %ld %c", &id, &c)) vclass = SPECIFIC_VISUAL;
+ else if (1 == sscanf (v, " 0x%lx %c", &id, &c)) vclass = SPECIFIC_VISUAL;
+ else
+ {
+ fprintf (stderr, "%s: unrecognized visual \"%s\".\n", "kscreensaver", v);
+ vclass = DEFAULT_VISUAL;
+ }
+
+ if (vclass == DEFAULT_VISUAL)
+ result = DefaultVisualOfScreen (screen);
+ else if (vclass == BEST_VISUAL)
+ result = pick_best_visual (screen, prefer_writable_cells, False);
+ else if (vclass == MONO_VISUAL)
+ {
+ result = pick_mono_visual (screen);
+ if (!result && verbose_p)
+ fprintf (stderr, "%s: no monochrome visuals.\n", "kscreensaver");
+ }
+ else if (vclass == GRAY_VISUAL)
+ {
+ if (prefer_writable_cells)
+ result = pick_best_visual_of_class (screen, GrayScale);
+ if (!result)
+ result = pick_best_visual_of_class (screen, StaticGray);
+ if (!result)
+ result = pick_best_visual_of_class (screen, GrayScale);
+ if (!result && verbose_p)
+ fprintf (stderr, "%s: no GrayScale or StaticGray visuals.\n",
+ "kscreensaver");
+ }
+ else if (vclass == COLOR_VISUAL)
+ {
+ int class;
+ /* First see if the default visual will do. */
+ result = DefaultVisualOfScreen (screen);
+ class = visual_class(screen, result);
+ if (class != TrueColor &&
+ class != PseudoColor &&
+ class != DirectColor &&
+ class != StaticColor)
+ result = 0;
+ if (result && visual_depth(screen, result) <= 1)
+ result = 0;
+
+ /* Else, find the best non-default color visual */
+ if (!result)
+ result = pick_best_visual (screen, prefer_writable_cells, True);
+
+ if (!result && verbose_p)
+ fprintf (stderr, "%s: no color visuals.\n", "kscreensaver");
+ }
+ else if (vclass == SPECIFIC_VISUAL)
+ {
+ result = id_to_visual (screen, id);
+ if (!result && verbose_p)
+ fprintf (stderr, "%s: no visual with id 0x%x.\n", "kscreensaver",
+ (unsigned int) id);
+ }
+ else
+ {
+ Visual *visual = pick_best_visual_of_class (screen, vclass);
+ if (visual)
+ result = visual;
+ else if (verbose_p)
+ fprintf (stderr, "%s: no visual of class %s.\n", "kscreensaver", v);
+ }
+
+ if (v) free (v);
+ return result;
+}
+
+Visual *
+get_visual_resource (Screen *screen, char *name, char *class,
+ Bool prefer_writable_cells)
+{
+/*
+ char *string = get_string_resource (name, class);
+ Visual *v = get_visual (screen, string, prefer_writable_cells, True);
+ if (string)
+ free(string);
+ if (v)
+ return v;
+ else
+*/
+ return DefaultVisualOfScreen (screen);
+}
+
+
+static Visual *
+pick_best_visual (Screen *screen, Bool prefer_writable_cells, Bool color_only)
+{
+ Visual *visual;
+
+ if (!prefer_writable_cells)
+ {
+ /* If we don't prefer writable cells, then the "best" visual is the one
+ on which we can allocate the largest range and number of colors.
+
+ Therefore, a TrueColor visual which is at least 16 bits deep is best.
+ (The assumption here being that a TrueColor of less than 16 bits is
+ really just a PseudoColor visual with a pre-allocated color cube.)
+
+ The next best thing is a PseudoColor visual of any type. After that
+ come the non-colormappable visuals, and non-color visuals.
+ */
+ if ((visual = pick_best_visual_of_class (screen, TrueColor)) &&
+ visual_depth (screen, visual) >= 16)
+ return visual;
+ }
+
+#define TRY_CLASS(CLASS) \
+ if ((visual = pick_best_visual_of_class (screen, CLASS)) && \
+ (!color_only || visual_depth(screen, visual) > 1)) \
+ return visual
+ TRY_CLASS(PseudoColor);
+ TRY_CLASS(TrueColor);
+ TRY_CLASS(DirectColor);
+ TRY_CLASS(StaticColor);
+ if (!color_only)
+ {
+ TRY_CLASS(GrayScale);
+ TRY_CLASS(StaticGray);
+ }
+#undef TRY_CLASS
+
+ visual = DefaultVisualOfScreen (screen);
+ if (!color_only || visual_depth(screen, visual) > 1)
+ return visual;
+ else
+ return 0;
+}
+
+static Visual *
+pick_mono_visual (Screen *screen)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count;
+
+ vi_in.depth = 1;
+ vi_in.screen = screen_number (screen);
+ vi_out = XGetVisualInfo (dpy, (VisualDepthMask | VisualScreenMask),
+ &vi_in, &out_count);
+ if (vi_out)
+ {
+ Visual *v = (out_count > 0 ? vi_out [0].visual : 0);
+ if (v && vi_out[0].depth != 1)
+ v = 0;
+ XFree ((char *) vi_out);
+ return v;
+ }
+ else
+ return 0;
+}
+
+
+static Visual *
+pick_best_visual_of_class (Screen *screen, int visual_class)
+{
+ /* The best visual of a class is the one which on which we can allocate
+ the largest range and number of colors, which means the one with the
+ greatest depth and number of cells.
+
+ (But actually, for XDaliClock, all visuals of the same class are
+ probably equivalent - either we have writable cells or we don't.)
+ */
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count;
+
+ vi_in.class = visual_class;
+ vi_in.screen = screen_number (screen);
+ vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask),
+ &vi_in, &out_count);
+ if (vi_out)
+ {
+ /* choose the 'best' one, if multiple */
+ int i, best;
+ Visual *visual;
+ for (i = 0, best = 0; i < out_count; i++)
+ /* It's better if it's deeper, or if it's the same depth with
+ more cells (does that ever happen? Well, it could...) */
+ if ((vi_out [i].depth > vi_out [best].depth) ||
+ ((vi_out [i].depth == vi_out [best].depth) &&
+ (vi_out [i].colormap_size > vi_out [best].colormap_size)))
+ best = i;
+ visual = (best < out_count ? vi_out [best].visual : 0);
+ XFree ((char *) vi_out);
+ return visual;
+ }
+ else
+ return 0;
+}
+
+static Visual *
+id_to_visual (Screen *screen, int id)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count;
+ vi_in.screen = screen_number (screen);
+ vi_in.visualid = id;
+ vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),
+ &vi_in, &out_count);
+ if (vi_out)
+ {
+ Visual *v = vi_out[0].visual;
+ XFree ((char *) vi_out);
+ return v;
+ }
+ return 0;
+}
+
+int
+visual_depth (Screen *screen, Visual *visual)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count, d;
+ vi_in.screen = screen_number (screen);
+ vi_in.visualid = XVisualIDFromVisual (visual);
+ vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
+ &vi_in, &out_count);
+ if (! vi_out) abort ();
+ d = vi_out [0].depth;
+ XFree ((char *) vi_out);
+ return d;
+}
+
+
+#if 0
+/* You very probably don't want to be using this.
+ Pixmap depth doesn't refer to the depths of pixmaps, but rather, to
+ the depth of protocol-level on-the-wire pixmap data, that is, XImages.
+ To get this info, you should be looking at XImage->bits_per_pixel
+ instead. (And allocating the data for your XImage structures by
+ multiplying ximage->bytes_per_line by ximage->height.)
+ */
+int
+visual_pixmap_depth (Screen *screen, Visual *visual)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ int vdepth = visual_depth (screen, visual);
+ int pdepth = vdepth;
+ int i, pfvc = 0;
+ XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc);
+
+ /* Return the first matching depth in the pixmap formats. If there are no
+ matching pixmap formats (which shouldn't be able to happen at all) then
+ return the visual depth instead. */
+ for (i = 0; i < pfvc; i++)
+ if (pfv[i].depth == vdepth)
+ {
+ pdepth = pfv[i].bits_per_pixel;
+ break;
+ }
+ if (pfv)
+ XFree (pfv);
+ return pdepth;
+}
+#endif /* 0 */
+
+
+int
+visual_class (Screen *screen, Visual *visual)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count, c;
+ vi_in.screen = screen_number (screen);
+ vi_in.visualid = XVisualIDFromVisual (visual);
+ vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
+ &vi_in, &out_count);
+ if (! vi_out) abort ();
+ c = vi_out [0].class;
+ XFree ((char *) vi_out);
+ return c;
+}
+
+Bool
+has_writable_cells (Screen *screen, Visual *visual)
+{
+ switch (visual_class (screen, visual))
+ {
+ case GrayScale: /* Mappable grays. */
+ case PseudoColor: /* Mappable colors. */
+ return True;
+ case StaticGray: /* Fixed grays. */
+ case TrueColor: /* Fixed colors. */
+ case StaticColor: /* (What's the difference again?) */
+ case DirectColor: /* DirectColor visuals are like TrueColor, but have
+ three colormaps - one for each component of RGB.
+ Screw it. */
+ return False;
+ default:
+ abort();
+ }
+}
+
+void
+describe_visual (FILE *f, Screen *screen, Visual *visual, Bool private_cmap_p)
+{
+ char n[10];
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count;
+ vi_in.screen = screen_number (screen);
+ vi_in.visualid = XVisualIDFromVisual (visual);
+ vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),
+ &vi_in, &out_count);
+ if (! vi_out) abort ();
+ if (private_cmap_p)
+ sprintf(n, "%3d", vi_out->colormap_size);
+ else
+ strcpy(n, "default");
+
+ fprintf (f, "0x%02x (%s depth: %2d, cmap: %s)\n",
+ (unsigned int) vi_out->visualid,
+ (vi_out->class == StaticGray ? "StaticGray, " :
+ vi_out->class == StaticColor ? "StaticColor," :
+ vi_out->class == TrueColor ? "TrueColor, " :
+ vi_out->class == GrayScale ? "GrayScale, " :
+ vi_out->class == PseudoColor ? "PseudoColor," :
+ vi_out->class == DirectColor ? "DirectColor," :
+ "UNKNOWN: "),
+ vi_out->depth, n);
+ XFree ((char *) vi_out);
+}
+
+int
+screen_number (Screen *screen)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ int i;
+ for (i = 0; i < ScreenCount (dpy); i++)
+ if (ScreenOfDisplay (dpy, i) == screen)
+ return i;
+ abort ();
+}
+
+int
+visual_cells (Screen *screen, Visual *visual)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ int out_count, c;
+ vi_in.screen = screen_number (screen);
+ vi_in.visualid = XVisualIDFromVisual (visual);
+ vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
+ &vi_in, &out_count);
+ if (! vi_out) abort ();
+ c = vi_out [0].colormap_size;
+ XFree ((char *) vi_out);
+ return c;
+}
+
+Visual *
+find_similar_visual(Screen *screen, Visual *old_visual)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XVisualInfo vi_in, *vi_out;
+ Visual *result = 0;
+ int out_count;
+
+ vi_in.screen = screen_number (screen);
+ vi_in.class = visual_class (screen, old_visual);
+ vi_in.depth = visual_depth (screen, old_visual);
+
+ /* Look for a visual of the same class and depth.
+ */
+ vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask |
+ VisualDepthMask),
+ &vi_in, &out_count);
+ if (vi_out && out_count > 0)
+ result = vi_out[0].visual;
+ if (vi_out) XFree (vi_out);
+ vi_out = 0;
+
+ /* Failing that, look for a visual of the same class.
+ */
+ if (!result)
+ {
+ vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask),
+ &vi_in, &out_count);
+ if (vi_out && out_count > 0)
+ result = vi_out[0].visual;
+ if (vi_out) XFree (vi_out);
+ vi_out = 0;
+ }
+
+ /* Failing that, return the default visual. */
+ if (!result)
+ result = DefaultVisualOfScreen (screen);
+
+ return result;
+}
diff --git a/kscreensaver/xsavers/xs_visual.h b/kscreensaver/xsavers/xs_visual.h
new file mode 100644
index 00000000..2a0b3534
--- /dev/null
+++ b/kscreensaver/xsavers/xs_visual.h
@@ -0,0 +1,27 @@
+/* xscreensaver, Copyright (c) 1993-1998 by Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifndef __VISUAL_H__
+#define __VISUAL_H__
+
+extern Visual *get_visual (Screen *, const char *name, Bool, Bool);
+extern Visual *get_visual_resource (Screen *, char *, char *, Bool);
+extern int visual_depth (Screen *, Visual *);
+/* extern int visual_pixmap_depth (Screen *, Visual *); */
+extern int visual_class (Screen *, Visual *);
+extern int visual_cells (Screen *, Visual *);
+extern int screen_number (Screen *);
+extern Visual *find_similar_visual (Screen *, Visual *old);
+extern void describe_visual (FILE *f, Screen *, Visual *, Bool private_cmap_p);
+extern Visual *get_overlay_visual (Screen *, unsigned long *pixel_return);
+extern Bool has_writable_cells (Screen *screen, Visual *visual);
+
+#endif /* __VISUAL_H__ */
diff --git a/kscreensaver/xsavers/xs_yarandom.h b/kscreensaver/xsavers/xs_yarandom.h
new file mode 100644
index 00000000..f803d23c
--- /dev/null
+++ b/kscreensaver/xsavers/xs_yarandom.h
@@ -0,0 +1,52 @@
+/* xscreensaver, Copyright (c) 1997 by Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#ifndef __YARANDOM_H__
+#define __YARANDOM_H__
+
+#undef random
+#undef rand
+#undef drand48
+#undef srandom
+#undef srand
+#undef srand48
+#undef frand
+
+#ifdef VMS
+# include "vms-gtod.h"
+#endif
+
+/* #define random() ya_random()
+ #define srandom(i) ya_rand_init(0) */
+
+extern unsigned int ya_random (void);
+extern void ya_rand_init (unsigned int);
+
+
+#if defined (__GNUC__) && (__GNUC__ >= 2)
+ /* Implement frand using GCC's statement-expression extension. */
+
+# define frand(f) \
+ ({ double tmp = (((double) random()) / \
+ (((double) ((unsigned int)~0)) / ((double) (f)))); \
+ tmp < 0 ? (-tmp) : tmp; })
+
+#else /* not GCC2 - implement frand using a global variable.*/
+
+static double _frand_tmp_;
+# define frand(f) \
+ (_frand_tmp_ = (((double) random()) / \
+ (((double) ((unsigned int)~0)) / ((double) (f)))), \
+ _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
+
+#endif /* not GCC2 */
+
+#endif /* __YARANDOM_H__ */