Fix scrolling functionality
[WebThing.git] / plugins / Fullscreen.cs
1 using System;
2 using Gtk;
3 using Gdk;
4 using bytex64.WebThing;
5
6 public class Fullscreen : WebThingPlugin {
7     private bool IsFullscreen = false;
8     private Gtk.Window Win;
9
10     public override void Init(WebThing wt) {
11         Win = wt.Window;
12         Win.KeyPressEvent += Win_KeyPress;
13         Win.WindowStateEvent += Win_WindowState;
14     }
15
16     private void Win_KeyPress(object o, KeyPressEventArgs e) {
17         if (e.Event.State == Gdk.ModifierType.None) {
18             switch(e.Event.Key) {
19             case Gdk.Key.F11:
20                 if (IsFullscreen) {
21                     Win.Unfullscreen();
22                 } else {
23                     Win.Fullscreen();
24                 }
25                 break;
26             }
27         }
28     }
29
30     private void Win_WindowState(object o, WindowStateEventArgs e) {
31         IsFullscreen = (e.Event.NewWindowState & WindowState.Fullscreen) != 0;
32     }
33 }