# FIXME: some of these definitions like the ARB_imaging subset should end up in the GL interface # # remove all enums/funcs which are not subset of all GL profiles # DropUniqVendorExtensions AMD DropUniqVendorExtensions ANGLE DropUniqVendorExtensions ARM DropUniqVendorExtensions APPLE DropUniqVendorExtensions ATI DropUniqVendorExtensions IMG DropUniqVendorExtensions QCOM DropUniqVendorExtensions NV DropUniqVendorExtensions VIV DropUniqVendorExtensions FJ IgnoreExtension GL_EXT_discard_framebuffer IgnoreExtension GL_OES_compressed_paletted_texture IgnoreExtension GL_OES_get_program_binary IgnoreExtension GL_OES_standard_derivatives IgnoreExtension GL_OES_vertex_type_10_10_10_2 IgnoreExtension GL_EXT_texture_type_2_10_10_10_REV IgnoreExtension GL_EXT_color_buffer_half_float IgnoreExtension GL_EXT_occlusion_query_boolean IgnoreExtension GL_EXT_separate_shader_objects IgnoreExtension GL_EXT_shadow_samplers IgnoreExtension GL_EXT_sRGB IgnoreExtension GL_EXT_texture_array IgnoreExtension GL_EXT_texture_rg IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture IgnoreExtension GL_EXT_debug_marker IgnoreExtension GL_EXT_debug_label IgnoreExtension GL_EXT_multisampled_render_to_texture IgnoreExtension GL_EXT_framebuffer_multisample IgnoreExtension GL_OES_texture_half_float IgnoreExtension GL_OES_vertex_half_float IgnoreExtension GL_NV_draw_buffers IgnoreExtension GL_NV_fbo_color_attachments IgnoreExtension GL_OES_vertex_array_object IgnoreExtension GL_OES_texture_3D IgnoreExtension GL_OES_surfaceless_context IgnoreExtension GL_OES_required_internalformat IgnoreExtension GL_EXT_unpack_subimage IgnoreExtension GL_KHR_debug # includes GL_STATE_RESTORE, which hasn't the QCOM suffix IgnoreExtension GL_QCOM_extended_get Ignore GL_STATE_RESTORE # above ext mightbe subsumed, ignore the aliased ones Ignore GL_ACTIVE_PROGRAM Ignore GL_ANY_SAMPLES_PASSED Ignore GL_ANY_SAMPLES_PASSED_CONSERVATIVE Ignore GL_BGRA8_EXT Ignore GL_BUFFER_OBJECT_EXT Ignore GL_COLOR_ATTACHMENT1 Ignore GL_COLOR_ATTACHMENT10 Ignore GL_COLOR_ATTACHMENT11 Ignore GL_COLOR_ATTACHMENT12 Ignore GL_COLOR_ATTACHMENT13 Ignore GL_COLOR_ATTACHMENT14 Ignore GL_COLOR_ATTACHMENT15 Ignore GL_COLOR_ATTACHMENT2 Ignore GL_COLOR_ATTACHMENT3 Ignore GL_COLOR_ATTACHMENT4 Ignore GL_COLOR_ATTACHMENT5 Ignore GL_COLOR_ATTACHMENT6 Ignore GL_COLOR_ATTACHMENT7 Ignore GL_COLOR_ATTACHMENT8 Ignore GL_COLOR_ATTACHMENT9 Ignore GL_COMPARE_REF_TO_TEXTURE Ignore GL_CONTEXT_ROBUST_ACCESS Ignore GL_CURRENT_QUERY Ignore GL_DRAW_BUFFER0 Ignore GL_DRAW_BUFFER1 Ignore GL_DRAW_BUFFER10 Ignore GL_DRAW_BUFFER11 Ignore GL_DRAW_BUFFER12 Ignore GL_DRAW_BUFFER13 Ignore GL_DRAW_BUFFER14 Ignore GL_DRAW_BUFFER15 Ignore GL_DRAW_BUFFER2 Ignore GL_DRAW_BUFFER3 Ignore GL_DRAW_BUFFER4 Ignore GL_DRAW_BUFFER5 Ignore GL_DRAW_BUFFER6 Ignore GL_DRAW_BUFFER7 Ignore GL_DRAW_BUFFER8 Ignore GL_DRAW_BUFFER9 Ignore GL_FRAGMENT_SHADER_BIT Ignore GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING Ignore GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT Ignore GL_INT_10_10_10_2 Ignore GL_MAX_COLOR_ATTACHMENTS Ignore GL_MAX_DRAW_BUFFERS Ignore GL_PROGRAM_OBJECT_EXT Ignore GL_PROGRAM_PIPELINE_BINDING Ignore GL_PROGRAM_PIPELINE_OBJECT_EXT Ignore GL_PROGRAM_SEPARABLE Ignore GL_QUERY_OBJECT_EXT Ignore GL_QUERY_RESULT Ignore GL_QUERY_RESULT_AVAILABLE Ignore GL_R32F Ignore GL_R16F Ignore GL_R8 Ignore GL_RED Ignore GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES Ignore GL_RG Ignore GL_RG32F Ignore GL_RG16F Ignore GL_RG8 Ignore GL_SAMPLER_2D_SHADOW Ignore GL_SAMPLER_EXTERNAL_OES Ignore GL_SHADER_BINARY_DMP Ignore GL_SHADER_OBJECT_EXT Ignore GL_TEXTURE_BINDING_EXTERNAL_OES Ignore GL_TEXTURE_COMPARE_FUNC Ignore GL_TEXTURE_COMPARE_MODE Ignore GL_TEXTURE_EXTERNAL_OES Ignore GL_UNPACK_ROW_LENGTH Ignore GL_UNPACK_SKIP_PIXELS Ignore GL_UNPACK_SKIP_ROWS Ignore GL_UNSIGNED_INT_10_10_10_2 Ignore GL_UNSIGNED_INT_2_10_10_10_REV Ignore GL_UNSIGNED_NORMALIZED Ignore GL_VERTEX_ARRAY_OBJECT_EXT Ignore GL_VERTEX_SHADER_BIT Ignore glFramebufferTexture2DMultisampleEXT Ignore glGetObjectLabelEXT Ignore glInsertEventMarkerEXT Ignore glLabelObjectEXT Ignore glPopGroupMarkerEXT Ignore glProgramUniform1f Ignore glProgramUniform1fv Ignore glProgramUniform1i Ignore glProgramUniform1iv Ignore glProgramUniform2f Ignore glProgramUniform2fv Ignore glProgramUniform2i Ignore glProgramUniform2iv Ignore glProgramUniform3f Ignore glProgramUniform3fv Ignore glProgramUniform3i Ignore glProgramUniform3iv Ignore glProgramUniform4f Ignore glProgramUniform4fv Ignore glProgramUniform4i Ignore glProgramUniform4iv Ignore glProgramUniformMatrix2fv Ignore glProgramUniformMatrix3fv Ignore glProgramUniformMatrix4fv Ignore glPushGroupMarkerEXT # isn't included in GL2 Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET Ignore GL_ACTIVE_ATTRIBUTE_MAX_LENGTH Ignore GL_ACTIVE_ATTRIBUTES Ignore GL_ACTIVE_UNIFORM_MAX_LENGTH Ignore GL_ACTIVE_UNIFORMS Ignore GL_ADD Ignore GL_ADD_SIGNED Ignore GL_ALPHA_SCALE Ignore GL_ALPHA_TEST Ignore GL_ALPHA_TEST_FUNC Ignore GL_ALPHA_TEST_REF Ignore GL_AMBIENT Ignore GL_AMBIENT_AND_DIFFUSE Ignore GL_AND Ignore GL_AND_INVERTED Ignore GL_AND_REVERSE Ignore GL_ATTACHED_SHADERS Ignore GL_BLEND_COLOR Ignore GL_BLEND_DST #Ignore GL_BLEND_DST_ALPHA #Ignore GL_BLEND_DST_RGB #Ignore GL_BLEND_EQUATION #Ignore GL_BLEND_EQUATION_ALPHA #Ignore GL_BLEND_EQUATION_ALPHA_OES Ignore GL_BLEND_EQUATION_OES #Ignore GL_BLEND_EQUATION_RGB #Ignore GL_BLEND_EQUATION_RGB_OES Ignore GL_BLEND_SRC #Ignore GL_BLEND_SRC_ALPHA #Ignore GL_BLEND_SRC_ALPHA_OES #Ignore GL_BLEND_SRC_RGB #Ignore GL_BLEND_SRC_RGB_OES Ignore GL_BOOL Ignore GL_BOOL_VEC2 Ignore GL_BOOL_VEC3 Ignore GL_BOOL_VEC4 Ignore GL_BUFFER_ACCESS_OES Ignore GL_CLEAR Ignore GL_CLIENT_ACTIVE_TEXTURE Ignore GL_CLIP_PLANE0 Ignore GL_CLIP_PLANE1 Ignore GL_CLIP_PLANE2 Ignore GL_CLIP_PLANE3 Ignore GL_CLIP_PLANE4 Ignore GL_CLIP_PLANE5 Ignore GL_COLOR_ARRAY Ignore GL_COLOR_ARRAY_BUFFER_BINDING Ignore GL_COLOR_ARRAY_POINTER Ignore GL_COLOR_ARRAY_SIZE Ignore GL_COLOR_ARRAY_STRIDE Ignore GL_COLOR_ARRAY_TYPE Ignore GL_COLOR_LOGIC_OP Ignore GL_COLOR_MATERIAL Ignore GL_COMBINE Ignore GL_COMBINE_ALPHA Ignore GL_COMBINE_RGB Ignore GL_COMPILE_STATUS Ignore GL_CONSTANT Ignore GL_CONSTANT_ALPHA Ignore GL_CONSTANT_ATTENUATION Ignore GL_CONSTANT_COLOR Ignore GL_COORD_REPLACE_OES Ignore GL_COPY Ignore GL_COPY_INVERTED Ignore GL_CURRENT_COLOR Ignore GL_CURRENT_NORMAL Ignore GL_CURRENT_PALETTE_MATRIX_OES Ignore GL_CURRENT_PROGRAM Ignore GL_CURRENT_TEXTURE_COORDS Ignore GL_CURRENT_VERTEX_ATTRIB Ignore GL_DECAL #Ignore GL_DECR_WRAP #Ignore GL_DECR_WRAP_OES Ignore GL_DELETE_STATUS Ignore GL_DEPTH_COMPONENT Ignore GL_DEPTH_COMPONENT24_OES Ignore GL_DEPTH_COMPONENT32_OES Ignore GL_DIFFUSE Ignore GL_DOT3_RGB Ignore GL_DOT3_RGBA Ignore GL_EMISSION Ignore GL_EQUIV Ignore GL_ES_VERSION_2_0 Ignore GL_ETC1_RGB8_OES Ignore GL_EXP Ignore GL_EXP2 #Ignore GL_FIXED_OES #Ignore GL_FIXED Ignore GL_FLAT Ignore GL_FLOAT_MAT2 Ignore GL_FLOAT_MAT3 Ignore GL_FLOAT_MAT4 Ignore GL_FLOAT_VEC2 Ignore GL_FLOAT_VEC3 Ignore GL_FLOAT_VEC4 Ignore GL_FOG Ignore GL_FOG_COLOR Ignore GL_FOG_DENSITY Ignore GL_FOG_END Ignore GL_FOG_HINT Ignore GL_FOG_MODE Ignore GL_FOG_START Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT Ignore GL_FRAGMENT_SHADER Ignore GL_FRAGMENT_SHADER_DERIVATIVE_HINT #Ignore GL_FUNC_ADD #Ignore GL_FUNC_ADD_OES #Ignore GL_FUNC_REVERSE_SUBTRACT #Ignore GL_FUNC_REVERSE_SUBTRACT_OES #Ignore GL_FUNC_SUBTRACT #Ignore GL_FUNC_SUBTRACT_OES Ignore GL_GENERATE_MIPMAP Ignore GL_HIGH_FLOAT Ignore GL_HIGH_INT #Ignore GL_IMPLEMENTATION_COLOR_READ_FORMAT #Ignore GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES #Ignore GL_IMPLEMENTATION_COLOR_READ_TYPE #Ignore GL_IMPLEMENTATION_COLOR_READ_TYPE_OES #Ignore GL_INCR_WRAP #Ignore GL_INCR_WRAP_OES Ignore GL_INFO_LOG_LENGTH Ignore GL_INT Ignore GL_INTERPOLATE Ignore GL_INT_VEC2 Ignore GL_INT_VEC3 Ignore GL_INT_VEC4 Ignore GL_LIGHT0 Ignore GL_LIGHT1 Ignore GL_LIGHT2 Ignore GL_LIGHT3 Ignore GL_LIGHT4 Ignore GL_LIGHT5 Ignore GL_LIGHT6 Ignore GL_LIGHT7 Ignore GL_LIGHTING Ignore GL_LIGHT_MODEL_AMBIENT Ignore GL_LIGHT_MODEL_TWO_SIDE Ignore GL_LINEAR_ATTENUATION Ignore GL_LINE_SMOOTH Ignore GL_LINE_SMOOTH_HINT Ignore GL_LINK_STATUS Ignore GL_LOGIC_OP_MODE Ignore GL_LOW_FLOAT Ignore GL_LOW_INT Ignore GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES Ignore GL_MATRIX_INDEX_ARRAY_OES Ignore GL_MATRIX_INDEX_ARRAY_POINTER_OES Ignore GL_MATRIX_INDEX_ARRAY_SIZE_OES Ignore GL_MATRIX_INDEX_ARRAY_STRIDE_OES Ignore GL_MATRIX_INDEX_ARRAY_TYPE_OES Ignore GL_MATRIX_MODE Ignore GL_MATRIX_PALETTE_OES Ignore GL_MAX_ARRAY_TEXTURE_LAYERS_EXT Ignore GL_MAX_CLIP_PLANES Ignore GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS Ignore GL_MAX_FRAGMENT_UNIFORM_VECTORS Ignore GL_MAX_LIGHTS Ignore GL_MAX_MODELVIEW_STACK_DEPTH Ignore GL_MAX_PALETTE_MATRICES_OES Ignore GL_MAX_PROJECTION_STACK_DEPTH Ignore GL_MAX_TEXTURE_IMAGE_UNITS Ignore GL_MAX_TEXTURE_STACK_DEPTH Ignore GL_MAX_TEXTURE_UNITS Ignore GL_MAX_VARYING_VECTORS Ignore GL_MAX_VERTEX_ATTRIBS Ignore GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS Ignore GL_MAX_VERTEX_UNIFORM_VECTORS Ignore GL_MAX_VERTEX_UNITS_OES Ignore GL_MEDIUM_FLOAT Ignore GL_MEDIUM_INT #Ignore GL_MIRRORED_REPEAT #Ignore GL_MIRRORED_REPEAT_OES Ignore GL_MODELVIEW Ignore GL_MODELVIEW_MATRIX Ignore GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES Ignore GL_MODELVIEW_STACK_DEPTH Ignore GL_MODULATE Ignore GL_MULTISAMPLE Ignore GL_NAND Ignore GL_NOOP Ignore GL_NOR Ignore GL_NORMAL_ARRAY Ignore GL_NORMAL_ARRAY_BUFFER_BINDING Ignore GL_NORMAL_ARRAY_POINTER Ignore GL_NORMAL_ARRAY_STRIDE Ignore GL_NORMAL_ARRAY_TYPE Ignore GL_NORMALIZE Ignore GL_NORMAL_MAP_OES Ignore GL_NUM_SHADER_BINARY_FORMATS Ignore GL_ONE_MINUS_CONSTANT_ALPHA Ignore GL_ONE_MINUS_CONSTANT_COLOR Ignore GL_OPERAND0_ALPHA Ignore GL_OPERAND0_RGB Ignore GL_OPERAND1_ALPHA Ignore GL_OPERAND1_RGB Ignore GL_OPERAND2_ALPHA Ignore GL_OPERAND2_RGB Ignore GL_OR Ignore GL_OR_INVERTED Ignore GL_OR_REVERSE Ignore GL_PALETTE4_R5_G6_B5_OES Ignore GL_PALETTE4_RGB5_A1_OES Ignore GL_PALETTE4_RGB8_OES Ignore GL_PALETTE4_RGBA4_OES Ignore GL_PALETTE4_RGBA8_OES Ignore GL_PALETTE8_R5_G6_B5_OES Ignore GL_PALETTE8_RGB5_A1_OES Ignore GL_PALETTE8_RGB8_OES Ignore GL_PALETTE8_RGBA4_OES Ignore GL_PALETTE8_RGBA8_OES Ignore GL_PERSPECTIVE_CORRECTION_HINT Ignore GL_PLATFORM_BINARY Ignore GL_POINT_DISTANCE_ATTENUATION Ignore GL_POINT_FADE_THRESHOLD_SIZE Ignore GL_POINT_SIZE Ignore GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES Ignore GL_POINT_SIZE_ARRAY_OES Ignore GL_POINT_SIZE_ARRAY_POINTER_OES Ignore GL_POINT_SIZE_ARRAY_STRIDE_OES Ignore GL_POINT_SIZE_ARRAY_TYPE_OES Ignore GL_POINT_SIZE_MAX Ignore GL_POINT_SIZE_MIN Ignore GL_POINT_SMOOTH Ignore GL_POINT_SMOOTH_HINT Ignore GL_POINT_SPRITE_OES Ignore GL_POSITION Ignore GL_PREVIOUS Ignore GL_PRIMARY_COLOR Ignore GL_PROJECTION Ignore GL_PROJECTION_MATRIX Ignore GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES Ignore GL_PROJECTION_STACK_DEPTH Ignore GL_QUADRATIC_ATTENUATION Ignore GL_R11F_G11F_B10F_EXT Ignore GL_REFLECTION_MAP_OES Ignore GL_RESCALE_NORMAL Ignore GL_RGBA_SIGNED_COMPONENTS_EXT Ignore GL_RGB_SCALE Ignore GL_SAMPLE_ALPHA_TO_ONE Ignore GL_SAMPLER_2D Ignore GL_SAMPLER_2D_ARRAY_EXT Ignore GL_SAMPLER_CUBE Ignore GL_SET Ignore GL_SHADE_MODEL Ignore GL_SHADER_BINARY_FORMATS Ignore GL_SHADER_COMPILER Ignore GL_SHADER_SOURCE_LENGTH Ignore GL_SHADER_TYPE Ignore GL_SHADING_LANGUAGE_VERSION Ignore GL_SHININESS Ignore GL_SMOOTH Ignore GL_SMOOTH_LINE_WIDTH_RANGE Ignore GL_SMOOTH_POINT_SIZE_RANGE Ignore GL_SPECULAR Ignore GL_SPOT_CUTOFF Ignore GL_SPOT_DIRECTION Ignore GL_SPOT_EXPONENT Ignore GL_SRC0_ALPHA Ignore GL_SRC0_RGB Ignore GL_SRC1_ALPHA Ignore GL_SRC1_RGB Ignore GL_SRC2_ALPHA Ignore GL_SRC2_RGB Ignore GL_STACK_OVERFLOW Ignore GL_STACK_UNDERFLOW Ignore GL_STENCIL_BACK_FAIL Ignore GL_STENCIL_BACK_FUNC Ignore GL_STENCIL_BACK_PASS_DEPTH_FAIL Ignore GL_STENCIL_BACK_PASS_DEPTH_PASS Ignore GL_STENCIL_BACK_REF Ignore GL_STENCIL_BACK_VALUE_MASK Ignore GL_STENCIL_BACK_WRITEMASK Ignore GL_STENCIL_INDEX Ignore GL_STENCIL_INDEX1_OES Ignore GL_STENCIL_INDEX4_OES Ignore GL_STREAM_DRAW Ignore GL_SUBTRACT Ignore GL_TEXTURE_2D_ARRAY_EXT Ignore GL_TEXTURE_2D_OES Ignore GL_TEXTURE_BINDING_2D_ARRAY_EXT Ignore GL_TEXTURE_COORD_ARRAY Ignore GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING Ignore GL_TEXTURE_COORD_ARRAY_POINTER Ignore GL_TEXTURE_COORD_ARRAY_SIZE Ignore GL_TEXTURE_COORD_ARRAY_STRIDE Ignore GL_TEXTURE_COORD_ARRAY_TYPE Ignore GL_TEXTURE_CROP_RECT_OES Ignore GL_TEXTURE_ENV Ignore GL_TEXTURE_ENV_COLOR Ignore GL_TEXTURE_ENV_MODE Ignore GL_TEXTURE_GEN_MODE_OES Ignore GL_TEXTURE_GEN_STR_OES Ignore GL_TEXTURE_MATRIX Ignore GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES Ignore GL_TEXTURE_RECTANGLE_NV_OES Ignore GL_TEXTURE_STACK_DEPTH Ignore GL_UNSIGNED_INT_10F_11F_11F_REV_EXT Ignore GL_VALIDATE_STATUS Ignore GL_VERTEX_ARRAY Ignore GL_VERTEX_ARRAY_BUFFER_BINDING Ignore GL_VERTEX_ARRAY_POINTER Ignore GL_VERTEX_ARRAY_SIZE Ignore GL_VERTEX_ARRAY_STRIDE Ignore GL_VERTEX_ARRAY_TYPE Ignore GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING Ignore GL_VERTEX_ATTRIB_ARRAY_ENABLED Ignore GL_VERTEX_ATTRIB_ARRAY_NORMALIZED Ignore GL_VERTEX_ATTRIB_ARRAY_POINTER Ignore GL_VERTEX_ATTRIB_ARRAY_SIZE Ignore GL_VERTEX_ATTRIB_ARRAY_STRIDE Ignore GL_VERTEX_ATTRIB_ARRAY_TYPE Ignore GL_VERTEX_SHADER Ignore GL_WEIGHT_ARRAY_BUFFER_BINDING_OES Ignore GL_WEIGHT_ARRAY_OES Ignore GL_WEIGHT_ARRAY_POINTER_OES Ignore GL_WEIGHT_ARRAY_SIZE_OES Ignore GL_WEIGHT_ARRAY_STRIDE_OES Ignore GL_WEIGHT_ARRAY_TYPE_OES Ignore GL_WRITE_ONLY_OES Ignore GL_XOR Ignore glIsProgram Ignore glIsShader #Ignore glUnmapBufferOES Ignore glCreateProgram Ignore glCreateShader Ignore glGetAttribLocation Ignore glGetUniformLocation Ignore glAlphaFunc Ignore glAttachShader Ignore glBindAttribLocation Ignore glBlendColor #Ignore glBlendEquation #Ignore glBlendEquationOES #Ignore glBlendEquationSeparate #Ignore glBlendEquationSeparateOES #Ignore glBlendFuncSeparate #Ignore glBlendFuncSeparateOES Ignore glClearDepthfOES Ignore glClientActiveTexture Ignore glClipPlanef Ignore glClipPlanefOES Ignore glColor4f Ignore glColor4ub Ignore glColorPointer Ignore glCompileShader Ignore glCoverageMaskNV Ignore glCoverageOperationNV Ignore glDeleteProgram Ignore glDeleteShader Ignore glDepthRangefOES Ignore glDetachShader Ignore glDisableClientState Ignore glDisableVertexAttribArray Ignore glDrawTexfOES Ignore glDrawTexfvOES Ignore glDrawTexiOES Ignore glDrawTexivOES Ignore glDrawTexsOES Ignore glDrawTexsvOES Ignore glDrawTexxvOES Ignore glEnableClientState Ignore glEnableVertexAttribArray Ignore glFogf Ignore glFogfv Ignore glFogxv Ignore glFogxvOES Ignore glFramebufferVertexAttribArrayNV Ignore glFrustumf Ignore glFrustumfOES Ignore glGetActiveAttrib Ignore glGetActiveUniform Ignore glGetAttachedShaders Ignore glGetFixedv Ignore glGetFixedvOES Ignore glGetLightfv Ignore glGetLightxv Ignore glGetLightxvOES Ignore glGetMaterialfv Ignore glGetMaterialxv Ignore glGetMaterialxvOES Ignore glGetProgramInfoLog Ignore glGetProgramiv Ignore glGetShaderInfoLog Ignore glGetShaderiv Ignore glGetShaderPrecisionFormat Ignore glGetShaderSource Ignore glGetTexEnvfv Ignore glGetTexEnviv Ignore glGetTexEnvxv Ignore glGetTexEnvxvOES Ignore glGetTexGenfvOES Ignore glGetTexGenivOES Ignore glGetTexGenxvOES Ignore glGetTexParameterxv Ignore glGetTexParameterxvOES Ignore glGetUniformfv Ignore glGetUniformiv Ignore glGetVertexAttribfv Ignore glGetVertexAttribiv Ignore glLightf Ignore glLightfv Ignore glLightModelf Ignore glLightModelfv Ignore glLightModelxv Ignore glLightModelxvOES Ignore glLightxv Ignore glLightxvOES Ignore glLinkProgram Ignore glLoadIdentity Ignore glLoadMatrixf Ignore glLogicOp Ignore glMaterialf Ignore glMaterialfv Ignore glMaterialxv Ignore glMaterialxvOES Ignore glMatrixIndexPointerOES Ignore glMatrixMode Ignore glMultiTexCoord4f Ignore glMultMatrixf Ignore glNormal3f Ignore glNormalPointer Ignore glOrthof Ignore glOrthofOES Ignore glPointParameterf Ignore glPointParameterfv Ignore glPointParameterxv Ignore glPointParameterxvOES Ignore glPointSize Ignore glPointSizePointer Ignore glReleaseShaderCompiler Ignore glRotatef Ignore glScalef Ignore glShadeModel Ignore glShaderBinary Ignore glShaderSource Ignore glStencilFuncSeparate Ignore glStencilMaskSeparate Ignore glStencilOpSeparate Ignore glTexCoordPointer Ignore glTexEnvf Ignore glTexEnvfv Ignore glTexEnvi Ignore glTexEnviv Ignore glTexEnvxv Ignore glTexEnvxvOES Ignore glTexGenfOES Ignore glTexGenfvOES Ignore glTexGeniOES Ignore glTexGenivOES Ignore glTexGenxvOES Ignore glTexParameterxv Ignore glTexParameterxvOES Ignore glTranslatef Ignore glUniform1f Ignore glUniform1fv Ignore glUniform1i Ignore glUniform1iv Ignore glUniform2f Ignore glUniform2fv Ignore glUniform2i Ignore glUniform2iv Ignore glUniform3f Ignore glUniform3fv Ignore glUniform3i Ignore glUniform3iv Ignore glUniform4f Ignore glUniform4fv Ignore glUniform4i Ignore glUniform4iv Ignore glUniformMatrix2fv Ignore glUniformMatrix3fv Ignore glUniformMatrix4fv Ignore glUseProgram Ignore glValidateProgram Ignore glVertexAttrib1f Ignore glVertexAttrib1fv Ignore glVertexAttrib2f Ignore glVertexAttrib2fv Ignore glVertexAttrib3f Ignore glVertexAttrib3fv Ignore glVertexAttrib4f Ignore glVertexAttrib4fv Ignore glVertexAttribPointer Ignore glVertexPointer Ignore glWeightPointerOES > 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
* ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
* DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
*/
#include <Windows.h>
#include <Windowsx.h>
#include <tchar.h>
#include <stdlib.h>
// NOTE: it looks like SHFullScreen and/or aygshell.dll is not available on the APX 2500 any more
// #ifdef UNDER_CE
// #include "aygshell.h"
// #endif
#include <gluegen_stdint.h>
#if !defined(__MINGW64__) && _MSC_VER <= 1500
// FIXME: Determine for which MSVC versions ..
#define strdup(s) _strdup(s)
#endif
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif //WM_MOUSEWHEEL
#ifndef WHEEL_DELTA
#define WHEEL_DELTA 120
#endif //WHEEL_DELTA
#ifndef WHEEL_PAGESCROLL
#define WHEEL_PAGESCROLL (UINT_MAX)
#endif //WHEEL_PAGESCROLL
#ifndef GET_WHEEL_DELTA_WPARAM // defined for (_WIN32_WINNT >= 0x0500)
#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
#endif
#ifndef MONITOR_DEFAULTTONULL
#define MONITOR_DEFAULTTONULL 0
#endif
#ifndef MONITOR_DEFAULTTOPRIMARY
#define MONITOR_DEFAULTTOPRIMARY 1
#endif
#ifndef MONITOR_DEFAULTTONEAREST
#define MONITOR_DEFAULTTONEAREST 2
#endif
#ifndef EDS_ROTATEDMODE
#define EDS_ROTATEDMODE 0x00000004
#endif
#ifndef DISPLAY_DEVICE_ACTIVE
#define DISPLAY_DEVICE_ACTIVE 0x00000001
#endif
#include "jogamp_newt_driver_windows_WindowsDisplay.h"
#include "jogamp_newt_driver_windows_WindowsScreen.h"
#include "jogamp_newt_driver_windows_WindowsWindow.h"
#include "MouseEvent.h"
#include "InputEvent.h"
#include "KeyEvent.h"
#include "ScreenMode.h"
#include "NewtCommon.h"
// #define VERBOSE_ON 1
// #define DEBUG_KEYS 1
#ifdef VERBOSE_ON
#define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
#else
#define DBG_PRINT(...)
#endif
#define STD_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
static jmethodID insetsChangedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID enqueueMouseEventID = NULL;
static jmethodID sendMouseEventID = NULL;
static jmethodID enqueueKeyEventID = NULL;
static jmethodID sendKeyEventID = NULL;
static jmethodID focusActionID = NULL;
static jmethodID enqueueRequestFocusID = NULL;
static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd);
typedef struct {
JNIEnv* jenv;
jobject jinstance;
} WindowUserData;
typedef struct {
UINT javaKey;
UINT windowsKey;
} KeyMapEntry;
// Static table, arranged more or less spatially.
static KeyMapEntry keyMapTable[] = {
// Modifier keys
{J_VK_CAPS_LOCK, VK_CAPITAL},
{J_VK_SHIFT, VK_SHIFT},
{J_VK_CONTROL, VK_CONTROL},
{J_VK_ALT, VK_MENU},
{J_VK_NUM_LOCK, VK_NUMLOCK},
// Miscellaneous Windows keys
{J_VK_WINDOWS, VK_LWIN},
{J_VK_WINDOWS, VK_RWIN},
{J_VK_CONTEXT_MENU, VK_APPS},
// Alphabet
{J_VK_A, 'A'},
{J_VK_B, 'B'},
{J_VK_C, 'C'},
{J_VK_D, 'D'},
{J_VK_E, 'E'},
{J_VK_F, 'F'},
{J_VK_G, 'G'},
{J_VK_H, 'H'},
{J_VK_I, 'I'},
{J_VK_J, 'J'},
{J_VK_K, 'K'},
{J_VK_L, 'L'},
{J_VK_M, 'M'},
{J_VK_N, 'N'},
{J_VK_O, 'O'},
{J_VK_P, 'P'},
{J_VK_Q, 'Q'},
{J_VK_R, 'R'},
{J_VK_S, 'S'},
{J_VK_T, 'T'},
{J_VK_U, 'U'},
{J_VK_V, 'V'},
{J_VK_W, 'W'},
{J_VK_X, 'X'},
{J_VK_Y, 'Y'},
{J_VK_Z, 'Z'},
{J_VK_0, '0'},
{J_VK_1, '1'},
{J_VK_2, '2'},
{J_VK_3, '3'},
{J_VK_4, '4'},
{J_VK_5, '5'},
{J_VK_6, '6'},
{J_VK_7, '7'},
{J_VK_8, '8'},
{J_VK_9, '9'},
{J_VK_ENTER, VK_RETURN},
{J_VK_SPACE, VK_SPACE},
{J_VK_BACK_SPACE, VK_BACK},
{J_VK_TAB, VK_TAB},
{J_VK_ESCAPE, VK_ESCAPE},
{J_VK_INSERT, VK_INSERT},
{J_VK_DELETE, VK_DELETE},
{J_VK_HOME, VK_HOME},
{J_VK_END, VK_END},
{J_VK_PAGE_UP, VK_PRIOR},
{J_VK_PAGE_DOWN, VK_NEXT},
{J_VK_CLEAR, VK_CLEAR}, // NumPad 5
// NumPad with NumLock off & extended arrows block (triangular)
{J_VK_LEFT, VK_LEFT},
{J_VK_RIGHT, VK_RIGHT},
{J_VK_UP, VK_UP},
{J_VK_DOWN, VK_DOWN},
// NumPad with NumLock on: numbers
{J_VK_NUMPAD0, VK_NUMPAD0},
{J_VK_NUMPAD1, VK_NUMPAD1},
{J_VK_NUMPAD2, VK_NUMPAD2},
{J_VK_NUMPAD3, VK_NUMPAD3},
{J_VK_NUMPAD4, VK_NUMPAD4},
{J_VK_NUMPAD5, VK_NUMPAD5},
{J_VK_NUMPAD6, VK_NUMPAD6},
{J_VK_NUMPAD7, VK_NUMPAD7},
{J_VK_NUMPAD8, VK_NUMPAD8},
{J_VK_NUMPAD9, VK_NUMPAD9},
// NumPad with NumLock on
{J_VK_MULTIPLY, VK_MULTIPLY},
{J_VK_ADD, VK_ADD},
{J_VK_SEPARATOR, VK_SEPARATOR},
{J_VK_SUBTRACT, VK_SUBTRACT},
{J_VK_DECIMAL, VK_DECIMAL},
{J_VK_DIVIDE, VK_DIVIDE},
// Functional keys
{J_VK_F1, VK_F1},
{J_VK_F2, VK_F2},
{J_VK_F3, VK_F3},
{J_VK_F4, VK_F4},
{J_VK_F5, VK_F5},
{J_VK_F6, VK_F6},
{J_VK_F7, VK_F7},
{J_VK_F8, VK_F8},
{J_VK_F9, VK_F9},
{J_VK_F10, VK_F10},
{J_VK_F11, VK_F11},
{J_VK_F12, VK_F12},
{J_VK_F13, VK_F13},
{J_VK_F14, VK_F14},
{J_VK_F15, VK_F15},
{J_VK_F16, VK_F16},
{J_VK_F17, VK_F17},
{J_VK_F18, VK_F18},
{J_VK_F19, VK_F19},
{J_VK_F20, VK_F20},
{J_VK_F21, VK_F21},
{J_VK_F22, VK_F22},
{J_VK_F23, VK_F23},
{J_VK_F24, VK_F24},
{J_VK_PRINTSCREEN, VK_SNAPSHOT},
{J_VK_SCROLL_LOCK, VK_SCROLL},
{J_VK_PAUSE, VK_PAUSE},
{J_VK_CANCEL, VK_CANCEL},
{J_VK_HELP, VK_HELP},
// Japanese
/*
{J_VK_CONVERT, VK_CONVERT},
{J_VK_NONCONVERT, VK_NONCONVERT},
{J_VK_INPUT_METHOD_ON_OFF, VK_KANJI},
{J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC},
{J_VK_KATAKANA, VK_DBE_KATAKANA},
{J_VK_HIRAGANA, VK_DBE_HIRAGANA},
{J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR},
{J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR},
{J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN},
*/
{J_VK_UNDEFINED, 0}
};
/*
Dynamic mapping table for OEM VK codes. This table is refilled
by BuildDynamicKeyMapTable when keyboard layout is switched.
(see NT4 DDK src/input/inc/vkoem.h for OEM VK_ values).
*/
typedef struct {
// OEM VK codes known in advance
UINT windowsKey;
// depends on input langauge (kbd layout)
UINT javaKey;
} DynamicKeyMapEntry;
static DynamicKeyMapEntry dynamicKeyMapTable[] = {
{0x00BA, J_VK_UNDEFINED}, // VK_OEM_1
{0x00BB, J_VK_UNDEFINED}, // VK_OEM_PLUS
{0x00BC, J_VK_UNDEFINED}, // VK_OEM_COMMA
{0x00BD, J_VK_UNDEFINED}, // VK_OEM_MINUS
{0x00BE, J_VK_UNDEFINED}, // VK_OEM_PERIOD
{0x00BF, J_VK_UNDEFINED}, // VK_OEM_2
{0x00C0, J_VK_UNDEFINED}, // VK_OEM_3
{0x00DB, J_VK_UNDEFINED}, // VK_OEM_4
{0x00DC, J_VK_UNDEFINED}, // VK_OEM_5
{0x00DD, J_VK_UNDEFINED}, // VK_OEM_6
{0x00DE, J_VK_UNDEFINED}, // VK_OEM_7
{0x00DF, J_VK_UNDEFINED}, // VK_OEM_8
{0x00E2, J_VK_UNDEFINED}, // VK_OEM_102
{0, 0}
};
// Auxiliary tables used to fill the above dynamic table. We first
// find the character for the OEM VK code using ::MapVirtualKey and
// then go through these auxiliary tables to map it to Java VK code.
typedef struct {
WCHAR c;
UINT javaKey;
} CharToVKEntry;
static const CharToVKEntry charToVKTable[] = {
{L'!', J_VK_EXCLAMATION_MARK},
{L'"', J_VK_QUOTEDBL},
{L'#', J_VK_NUMBER_SIGN},
{L'$', J_VK_DOLLAR},
{L'&', J_VK_AMPERSAND},
{L'\'', J_VK_QUOTE},
{L'(', J_VK_LEFT_PARENTHESIS},
{L')', J_VK_RIGHT_PARENTHESIS},
{L'*', J_VK_ASTERISK},
{L'+', J_VK_PLUS},
{L',', J_VK_COMMA},
{L'-', J_VK_MINUS},
{L'.', J_VK_PERIOD},
{L'/', J_VK_SLASH},
{L':', J_VK_COLON},
{L';', J_VK_SEMICOLON},
{L'<', J_VK_LESS},
{L'=', J_VK_EQUALS},
{L'>', J_VK_GREATER},
{L'@', J_VK_AT},
{L'[', J_VK_OPEN_BRACKET},
{L'\\', J_VK_BACK_SLASH},
{L']', J_VK_CLOSE_BRACKET},
{L'^', J_VK_CIRCUMFLEX},
{L'_', J_VK_UNDERSCORE},
{L'`', J_VK_BACK_QUOTE},
{L'{', J_VK_BRACELEFT},
{L'}', J_VK_BRACERIGHT},
{0x00A1, J_VK_INVERTED_EXCLAMATION_MARK},
{0x20A0, J_VK_EURO_SIGN}, // ????
{0,0}
};
// For dead accents some layouts return ASCII punctuation, while some
// return spacing accent chars, so both should be listed. NB: MS docs
// say that conversion routings return spacing accent character, not
// combining.
static const CharToVKEntry charToDeadVKTable[] = {
{L'`', J_VK_DEAD_GRAVE},
{L'\'', J_VK_DEAD_ACUTE},
{0x00B4, J_VK_DEAD_ACUTE},
{L'^', J_VK_DEAD_CIRCUMFLEX},
{L'~', J_VK_DEAD_TILDE},
{0x02DC, J_VK_DEAD_TILDE},
{0x00AF, J_VK_DEAD_MACRON},
{0x02D8, J_VK_DEAD_BREVE},
{0x02D9, J_VK_DEAD_ABOVEDOT},
{L'"', J_VK_DEAD_DIAERESIS},
{0x00A8, J_VK_DEAD_DIAERESIS},
{0x02DA, J_VK_DEAD_ABOVERING},
{0x02DD, J_VK_DEAD_DOUBLEACUTE},
{0x02C7, J_VK_DEAD_CARON}, // aka hacek
{L',', J_VK_DEAD_CEDILLA},
{0x00B8, J_VK_DEAD_CEDILLA},
{0x02DB, J_VK_DEAD_OGONEK},
{0x037A, J_VK_DEAD_IOTA}, // ASCII ???
{0x309B, J_VK_DEAD_VOICED_SOUND},
{0x309C, J_VK_DEAD_SEMIVOICED_SOUND},
{0,0}
};
// ANSI CP identifiers are no longer than this
#define MAX_ACP_STR_LEN 7
static void BuildDynamicKeyMapTable()
{
HKL hkl = GetKeyboardLayout(0);
// Will need this to reset layout after dead keys.
UINT spaceScanCode = MapVirtualKeyEx(VK_SPACE, 0, hkl);
DynamicKeyMapEntry *dynamic;
LANGID idLang = LOWORD(GetKeyboardLayout(0));
UINT codePage;
TCHAR strCodePage[MAX_ACP_STR_LEN];
// use the LANGID to create a LCID
LCID idLocale = MAKELCID(idLang, SORT_DEFAULT);
// get the ANSI code page associated with this locale
if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE,
strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 )
{
codePage = _ttoi(strCodePage);
} else {
codePage = GetACP();
}
// Entries in dynamic table that maps between Java VK and Windows
// VK are built in three steps:
// 1. Map windows VK to ANSI character (cannot map to unicode
// directly, since ::ToUnicode is not implemented on win9x)
// 2. Convert ANSI char to Unicode char
// 3. Map Unicode char to Java VK via two auxilary tables.
for (dynamic = dynamicKeyMapTable; dynamic->windowsKey != 0; ++dynamic)
{
char cbuf[2] = { '\0', '\0'};
WCHAR ucbuf[2] = { L'\0', L'\0' };
int nchars;
UINT scancode;
const CharToVKEntry *charMap;
int nconverted;
WCHAR uc;
BYTE kbdState[256];
// Defaults to J_VK_UNDEFINED
dynamic->javaKey = J_VK_UNDEFINED;
GetKeyboardState(kbdState);
kbdState[dynamic->windowsKey] |= 0x80; // Press the key.
// Unpress modifiers, since they are most likely pressed as
// part of the keyboard switching shortcut.
kbdState[VK_CONTROL] &= ~0x80;
kbdState[VK_SHIFT] &= ~0x80;
kbdState[VK_MENU] &= ~0x80;
scancode = MapVirtualKeyEx(dynamic->windowsKey, 0, hkl);
nchars = ToAsciiEx(dynamic->windowsKey, scancode, kbdState,
(WORD*)cbuf, 0, hkl);
// Auxiliary table used to map Unicode character to Java VK.
// Will assign a different table for dead keys (below).
charMap = charToVKTable;
if (nchars < 0) { // Dead key
char junkbuf[2] = { '\0', '\0'};
// Use a different table for dead chars since different layouts
// return different characters for the same dead key.
charMap = charToDeadVKTable;
// We also need to reset layout so that next translation
// is unaffected by the dead status. We do this by
// translating <SPACE> key.
kbdState[dynamic->windowsKey] &= ~0x80;
kbdState[VK_SPACE] |= 0x80;
ToAsciiEx(VK_SPACE, spaceScanCode, kbdState,
(WORD*)junkbuf, 0, hkl);
}
nconverted = MultiByteToWideChar(codePage, 0,
cbuf, 1, ucbuf, 2);
uc = ucbuf[0];
{
const CharToVKEntry *map;
for (map = charMap; map->c != 0; ++map) {
if (uc == map->c) {
dynamic->javaKey = map->javaKey;
break;
}
}
}
} // for each VK_OEM_*
}
static jint GetModifiers() {
jint modifiers = 0;
// have to do &0xFFFF to avoid runtime assert caused by compiling with
// /RTCcsu
if (HIBYTE((GetKeyState(VK_CONTROL) & 0xFFFF)) != 0) {
modifiers |= EVENT_CTRL_MASK;
}
if (HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0) {
modifiers |= EVENT_SHIFT_MASK;
}
if (HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0) {
modifiers |= EVENT_ALT_MASK;
}
if (HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0) {
modifiers |= EVENT_BUTTON1_MASK;
}
if (HIBYTE((GetKeyState(VK_MBUTTON) & 0xFFFF)) != 0) {
modifiers |= EVENT_BUTTON2_MASK;
}
if (HIBYTE((GetKeyState(VK_RBUTTON) & 0xFFFF)) != 0) {
modifiers |= EVENT_BUTTON3_MASK;
}
return modifiers;
}
static int WmChar(JNIEnv *env, jobject window, UINT character, UINT repCnt,
UINT flags, BOOL system)
{
// The Alt modifier is reported in the 29th bit of the lParam,
// i.e., it is the 13th bit of `flags' (which is HIWORD(lParam)).
BOOL alt_is_down = (flags & (1<<13)) != 0;
if (system && alt_is_down) {
if (character == VK_SPACE) {
return 1;
}
}
if (character == VK_RETURN) {
character = J_VK_ENTER;
}
(*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
(jchar) character);
return 1;
}
UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers)
{
int i, j;
// for the general case, use a bi-directional table
for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
if (keyMapTable[i].windowsKey == windowsKey) {
return keyMapTable[i].javaKey;
}
}
for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
if (dynamicKeyMapTable[j].windowsKey == windowsKey) {
if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) {
return dynamicKeyMapTable[j].javaKey;
} else {
break;
}
}
}
return J_VK_UNDEFINED;
}
static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
UINT flags, BOOL system)
{
UINT modifiers = 0, jkey = 0, character = -1;
if (wkey == VK_PROCESSKEY) {
return 1;
}
modifiers = GetModifiers();
jkey = WindowsKeyToJavaKey(wkey, modifiers);
/*
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
(*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_PRESSED,
modifiers,
(jint) jkey,
(jchar) character);
/* windows does not create a WM_CHAR for the Del key
for some reason, so we need to create the KEY_TYPED event on the
WM_KEYDOWN.
*/
if (jkey == J_VK_DELETE) {
(*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
(jchar) '\177');
}
return 0;
}
static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
UINT flags, BOOL system)
{
UINT modifiers = 0, jkey = 0, character = -1;
if (wkey == VK_PROCESSKEY) {
return 1;
}
modifiers = GetModifiers();
jkey = WindowsKeyToJavaKey(wkey, modifiers);
/*
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
(*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_RELEASED,
modifiers,
(jint) jkey,
(jchar) character);
return 0;
}
static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, jboolean force) {
HWND pHwnd, current;
pHwnd = GetParent(hwnd);
current = GetFocus();
DBG_PRINT("*** WindowsWindow: requestFocus.S parent %p, window %p, isCurrent %d\n",
(void*) pHwnd, (void*)hwnd, current==hwnd);
if( JNI_TRUE==force || current!=hwnd) {
if( JNI_TRUE==force || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) {
UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, flags);
SetForegroundWindow(hwnd); // Slightly Higher Priority
SetFocus(hwnd);// Sets Keyboard Focus To Window
if(NULL!=pHwnd) {
SetActiveWindow(hwnd);
}
DBG_PRINT("*** WindowsWindow: requestFocus.X1\n");
} else {
DBG_PRINT("*** WindowsWindow: requestFocus.X0\n");
}
}
DBG_PRINT("*** WindowsWindow: requestFocus.XX\n");
}
#if 0
static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd)
{
// being naughty here
static RECT m_insets = { 0, 0, 0, 0 };
RECT outside;
RECT inside;
POINT *rp_inside = (POINT *) (void *) &inside;
int dx, dy, dw, dh;
if (IsIconic(hwnd)) {
m_insets.left = m_insets.top = m_insets.right = m_insets.bottom = -1;
return FALSE;
}
m_insets.left = m_insets.top = m_insets.right = m_insets.bottom = 0;
GetClientRect(hwnd, &inside);
GetWindowRect(hwnd, &outside);
DBG_PRINT("*** WindowsWindow: UpdateInsets (a1) window %p, Inside CC: %d/%d - %d/%d %dx%d\n",
(void*)hwnd,
(int)inside.left, (int)inside.top, (int)inside.right, (int)inside.bottom,
(int)(inside.right - inside.left), (int)(inside.bottom - inside.top));
DBG_PRINT("*** WindowsWindow: UpdateInsets (a1) window %p, Outside SC: %d/%d - %d/%d %dx%d\n",
(void*)hwnd,
(int)outside.left, (int)outside.top, (int)outside.right, (int)outside.bottom,
(int)(outside.right - outside.left), (int)(outside.bottom - outside.top));
// xform client -> screen coord
ClientToScreen(hwnd, rp_inside);
ClientToScreen(hwnd, rp_inside+1);
DBG_PRINT("*** WindowsWindow: UpdateInsets (a2) window %p, Inside SC: %d/%d - %d/%d %dx%d\n",
(void*)hwnd,
(int)inside.left, (int)inside.top, (int)inside.right, (int)inside.bottom,
(int)(inside.right - inside.left), (int)(inside.bottom - inside.top));
m_insets.top = inside.top - outside.top;
m_insets.bottom = outside.bottom - inside.bottom;
m_insets.left = inside.left - outside.left;
m_insets.right = outside.right - inside.right;
DBG_PRINT("*** WindowsWindow: UpdateInsets (1.0) window %p, %d/%d - %d/%d %dx%d\n",
(void*)hwnd,
(int)m_insets.left, (int)m_insets.top, (int)m_insets.right, (int)m_insets.bottom,
(int)(m_insets.right-m_insets.left), (int)(m_insets.top-m_insets.bottom));
(*env)->CallVoidMethod(env, window, insetsChangedID,
m_insets.left, m_insets.top,
m_insets.right, m_insets.bottom);
return &m_insets;
}
#else
static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd)
{
// being naughty here
static RECT m_insets = { 0, 0, 0, 0 };
RECT outside;
RECT inside;
if (IsIconic(hwnd)) {
m_insets.left = m_insets.top = m_insets.right = m_insets.bottom = -1;
return FALSE;
}
m_insets.left = m_insets.top = m_insets.right = m_insets.bottom = 0;
GetClientRect(hwnd, &inside);
GetWindowRect(hwnd, &outside);
if (outside.right - outside.left > 0 && outside.bottom - outside.top > 0) {
MapWindowPoints(hwnd, 0, (LPPOINT)&inside, 2);
m_insets.top = inside.top - outside.top;
m_insets.bottom = outside.bottom - inside.bottom;
m_insets.left = inside.left - outside.left;
m_insets.right = outside.right - inside.right;
} else {
m_insets.top = -1;
}
if (m_insets.left < 0 || m_insets.top < 0 ||
m_insets.right < 0 || m_insets.bottom < 0)
{
LONG style = GetWindowLong(hwnd, GWL_STYLE);
// TODO: TDV: better undecorated checking needed
BOOL bIsUndecorated = (style & (WS_CHILD|WS_POPUP|WS_SYSMENU)) != 0;
if (!bIsUndecorated) {
/* Get outer frame sizes. */
if (style & WS_THICKFRAME) {
m_insets.left = m_insets.right =
GetSystemMetrics(SM_CXSIZEFRAME);
m_insets.top = m_insets.bottom =
GetSystemMetrics(SM_CYSIZEFRAME);
} else {
m_insets.left = m_insets.right =
GetSystemMetrics(SM_CXDLGFRAME);
m_insets.top = m_insets.bottom =
GetSystemMetrics(SM_CYDLGFRAME);
}
/* Add in title. */
m_insets.top += GetSystemMetrics(SM_CYCAPTION);
} else {
/* undo the -1 set above */
m_insets.left = m_insets.top = m_insets.right = m_insets.bottom = 0;
}
}
DBG_PRINT("*** WindowsWindow: UpdateInsets window %p, %d/%d %dx%d\n",
(void*)hwnd, (int)m_insets.left, (int)m_insets.top, (int)(m_insets.right-m_insets.left), (int)(m_insets.top-m_insets.bottom));
(*env)->CallVoidMethod(env, window, insetsChangedID,
m_insets.left, m_insets.top,
m_insets.right, m_insets.bottom);
return &m_insets;
}
#endif
static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type)
{
RECT rc;
int w, h;
BOOL isVisible = IsWindowVisible(wnd);
// make sure insets are up to date
(void)UpdateInsets(env, window, wnd);
if (type == SIZE_MINIMIZED) {
// TODO: deal with minimized window sizing
return;
}
GetClientRect(wnd, &rc);
// we report back the dimensions of the client area
w = rc.right - rc.left;
h = rc.bottom - rc.top;
DBG_PRINT("*** WindowsWindow: WmSize window %p, %dx%d, visible %d\n", (void*)wnd, w, h, isVisible);
if(isVisible) {
(*env)->CallVoidMethod(env, window, sizeChangedID, w, h, JNI_FALSE);
}
}
static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
LRESULT res = 0;
int useDefWindowProc = 0;
JNIEnv *env = NULL;
jobject window = NULL;
BOOL isKeyDown = FALSE;
WindowUserData * wud;
#ifdef DEBUG_KEYS
if ( WM_KEYDOWN == message ) {
STD_PRINT("*** WindowsWindow: wndProc window %p, 0x%X %d/%d\n", wnd, message, (int)LOWORD(lParam), (int)HIWORD(lParam));
}
#endif
#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 )
wud = (WindowUserData *) GetWindowLong(wnd, GWL_USERDATA);
#else
wud = (WindowUserData *) GetWindowLongPtr(wnd, GWLP_USERDATA);
#endif
if(NULL==wud) {
return DefWindowProc(wnd, message, wParam, lParam);
}
env = wud->jenv;
window = wud->jinstance;
// DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, 0x%X %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam));
if (NULL==window || NULL==env) {
return DefWindowProc(wnd, message, wParam, lParam);
}
switch (message) {
//
// The signal pipeline for destruction is:
// Java::DestroyWindow(wnd) _or_ window-close-button ->
// WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY
case WM_CLOSE:
(*env)->CallVoidMethod(env, window, windowDestroyNotifyID);
break;
case WM_DESTROY:
{
#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 )
SetWindowLong(wnd, GWL_USERDATA, (intptr_t) NULL);
#else
SetWindowLongPtr(wnd, GWLP_USERDATA, (intptr_t) NULL);
#endif
free(wud); wud=NULL;
(*env)->DeleteGlobalRef(env, window);
}
break;
case WM_SYSCHAR:
useDefWindowProc = WmChar(env, window, wParam,
LOWORD(lParam), HIWORD(lParam), FALSE);
break;
case WM_CHAR:
useDefWindowProc = WmChar(env, window, wParam,
LOWORD(lParam), HIWORD(lParam), TRUE);
break;
case WM_KEYDOWN:
#ifdef DEBUG_KEYS
STD_PRINT("*** WindowsWindow: windProc sending window %p -> %p, 0x%X %d/%d\n", wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam));
#endif
useDefWindowProc = WmKeyDown(env, window, wParam,
LOWORD(lParam), HIWORD(lParam), FALSE);
break;
case WM_KEYUP:
useDefWindowProc = WmKeyUp(env, window, wParam,
LOWORD(lParam), HIWORD(lParam), FALSE);
break;
case WM_SIZE:
WmSize(env, window, wnd, (UINT)wParam);
break;
case WM_SETTINGCHANGE:
if (wParam == SPI_SETNONCLIENTMETRICS) {
// make sure insets are updated, we don't need to resize the window
// because the size of the client area doesn't change
(void)UpdateInsets(env, window, wnd);
} else {
useDefWindowProc = 1;
}
break;
case WM_LBUTTONDOWN:
DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 1, (jint) 0);
useDefWindowProc = 1;
break;
case WM_LBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 1, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MBUTTONDOWN:
DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 2, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 2, (jint) 0);
useDefWindowProc = 1;
break;
case WM_RBUTTONDOWN:
DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 3, (jint) 0);
useDefWindowProc = 1;
break;
case WM_RBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 3, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MOUSEMOVE:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_MOVED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
(jint) 0, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MOUSEWHEEL: {
// need to convert the coordinates to component-relative
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
POINT eventPt;
eventPt.x = x;
eventPt.y = y;
ScreenToClient(wnd, &eventPt);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_WHEEL_MOVED,
GetModifiers(),
(jint) eventPt.x, (jint) eventPt.y,
(jint) 0, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f));
useDefWindowProc = 1;
break;
}
case WM_SETFOCUS:
(*env)->CallVoidMethod(env, window, focusChangedID, JNI_TRUE);
useDefWindowProc = 1;
break;
case WM_KILLFOCUS:
(*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE);
useDefWindowProc = 1;
break;
case WM_SHOWWINDOW:
(*env)->CallVoidMethod(env, window, visibleChangedID, wParam==TRUE?JNI_TRUE:JNI_FALSE);
break;
case WM_MOVE:
DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, (int)LOWORD(lParam), (int)HIWORD(lParam));
(*env)->CallVoidMethod(env, window, positionChangedID,
(jint)LOWORD(lParam), (jint)HIWORD(lParam));
useDefWindowProc = 1;
break;
case WM_PAINT: {
RECT r;
useDefWindowProc = 0;
if (GetUpdateRect(wnd, &r, TRUE /* erase background */)) {
/*
jint width = r.right-r.left;
jint height = r.bottom-r.top;
if (width > 0 && height > 0) {
(*env)->CallVoidMethod(env, window, windowRepaintID, r.left, r.top, width, height);
}
ValidateRect(wnd, &r);
*/
}
break;
}
case WM_ERASEBKGND:
// ignore erase background
(*env)->CallVoidMethod(env, window, windowRepaintID, 0, 0, -1, -1);
useDefWindowProc = 0;
res = 1; // OpenGL, etc .. erases the background, hence we claim to have just done this
break;
// FIXME: generate EVENT_MOUSE_ENTERED, EVENT_MOUSE_EXITED
default:
useDefWindowProc = 1;
}
if (useDefWindowProc)
return DefWindowProc(wnd, message, wParam, lParam);
return res;
}
/*
* Class: jogamp_newt_driver_windows_WindowsDisplay
* Method: DispatchMessages
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMessages0
(JNIEnv *env, jclass clazz)
{
int i = 0;
MSG msg;
BOOL gotOne;
// Periodically take a break
do {
gotOne = PeekMessage(&msg, (HWND) NULL, 0, 0, PM_REMOVE);
// DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne);
if (gotOne) {
++i;
#ifdef DEBUG_KEYS
if(WM_KEYDOWN == msg.message) {
STD_PRINT("*** WindowsWindow: DispatchMessages window %p, 0x%X %d/%d\n", msg.hwnd, msg.message, (int)LOWORD(msg.lParam), (int)HIWORD(msg.lParam));
}
#endif
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} while (gotOne && i < 100);
}
/*
* Class: jogamp_newt_driver_windows_WindowsScreen
* Method: getWidthImpl
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CXSCREEN);
}
/*
* Class: jogamp_newt_driver_windows_WindowsScreen
* Method: getHeightImpl
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getHeightImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CYSCREEN);
}
static int NewtScreen_RotationNativeCCW2NewtCCW(JNIEnv *env, int native) {
int newt;
switch (native) {
case DMDO_DEFAULT:
newt = 0;
break;
case DMDO_90:
newt = 90;
break;
case DMDO_180:
newt = 180;
break;
case DMDO_270:
newt = 270;
break;
default:
NewtCommon_throwNewRuntimeException(env, "invalid native rotation: %d", native);
break;
}
return newt;
}
static int NewtScreen_RotationNewtCCW2NativeCCW(JNIEnv *env, jint newt) {
int native;
switch (newt) {
case 0:
native = DMDO_DEFAULT;
break;
case 90:
native = DMDO_90;
break;
case 180:
native = DMDO_180;
break;
case 270:
native = DMDO_270;
break;
default:
NewtCommon_throwNewRuntimeException(env, "invalid newt rotation: %d", newt);
}
return native;
}
/*
static void NewtScreen_scanDisplayDevices() {
DISPLAY_DEVICE device;
int i = 0;
LPCTSTR name;
while(NULL != (name = NewtScreen_getDisplayDeviceName(&device, i))) {
fprintf(stderr, "*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) );
i++;
}
}*/
static LPCTSTR NewtScreen_getDisplayDeviceName(DISPLAY_DEVICE * device, int scrn_idx) {
device->cb = sizeof(DISPLAY_DEVICE);
if( FALSE == EnumDisplayDevices(NULL, scrn_idx, device, 0) ) {
DBG_PRINT("*** WindowsWindow: getDisplayDeviceName.EnumDisplayDevices(scrn_idx %d) -> FALSE\n", scrn_idx);
return NULL;
}
if( 0 == ( device->StateFlags & DISPLAY_DEVICE_ACTIVE ) ) {
DBG_PRINT("*** WindowsWindow: !DISPLAY_DEVICE_ACTIVE(scrn_idx %d)\n", scrn_idx);
return NULL;
}
return device->DeviceName;
}
static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) {
return CreateDC("DISPLAY", displayDeviceName, NULL, NULL);
}
/*
* Class: jogamp_newt_driver_windows_WindowsScreen
* Method: getScreenMode0
* Signature: (II)[I
*/
JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getScreenMode0
(JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx)
{
DISPLAY_DEVICE device;
int prop_num = NUM_SCREEN_MODE_PROPERTIES_ALL;
LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx);
if(NULL == deviceName) {
DBG_PRINT("*** WindowsWindow: getScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx);
return (*env)->NewIntArray(env, 0);
}
int devModeID;
int widthmm, heightmm;
if(-1 < mode_idx) {
// only at initialization time, where index >= 0
HDC hdc = NewtScreen_createDisplayDC(deviceName);
widthmm = GetDeviceCaps(hdc, HORZSIZE);
heightmm = GetDeviceCaps(hdc, VERTSIZE);
DeleteDC(hdc);
devModeID = (int) mode_idx;
prop_num++; // add 1st extra prop, mode_idx
} else {
widthmm = 0;
heightmm = 0;
devModeID = ENUM_CURRENT_SETTINGS;
}
DEVMODE dm;
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
if (0 == EnumDisplaySettingsEx(deviceName, devModeID, &dm, ( ENUM_CURRENT_SETTINGS == devModeID ) ? 0 : EDS_ROTATEDMODE)) {
DBG_PRINT("*** WindowsWindow: getScreenMode.EnumDisplaySettingsEx(mode_idx %d/%d) -> NULL\n", mode_idx, devModeID);
return (*env)->NewIntArray(env, 0);
}
// swap width and height, since Windows reflects rotated dimension, we don't
if (DMDO_90 == dm.dmDisplayOrientation || DMDO_270 == dm.dmDisplayOrientation) {
int tempWidth = dm.dmPelsWidth;
dm.dmPelsWidth = dm.dmPelsHeight;
dm.dmPelsHeight = tempWidth;
}
jint prop[ prop_num ];
int propIndex = 0;
if( -1 < mode_idx ) {
prop[propIndex++] = mode_idx;
}
prop[propIndex++] = 0; // set later for verification of iterator
prop[propIndex++] = dm.dmPelsWidth;
prop[propIndex++] = dm.dmPelsHeight;
prop[propIndex++] = dm.dmBitsPerPel;
prop[propIndex++] = widthmm;
prop[propIndex++] = heightmm;
prop[propIndex++] = dm.dmDisplayFrequency;
prop[propIndex++] = NewtScreen_RotationNativeCCW2NewtCCW(env, dm.dmDisplayOrientation);
prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL
jintArray properties = (*env)->NewIntArray(env, prop_num);
if (properties == NULL) {
NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", prop_num);
}
(*env)->SetIntArrayRegion(env, properties, 0, prop_num, prop);
return properties;
}
/*
* Class: jogamp_newt_driver_windows_WindowsScreen
* Method: setScreenMode0
* Signature: (IIIIII)Z
*/
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_setScreenMode0
(JNIEnv *env, jobject object, jint scrn_idx, jint width, jint height, jint bits, jint rate, jint rot)
{
DISPLAY_DEVICE device;
LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx);
if(NULL == deviceName) {
DBG_PRINT("*** WindowsWindow: setScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx);
return JNI_FALSE;
}
DEVMODE dm;
// initialize the DEVMODE structure
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
dm.dmPelsWidth = (int)width;
dm.dmPelsHeight = (int)height;
dm.dmBitsPerPel = (int)bits;
dm.dmDisplayFrequency = (int)rate;
dm.dmDisplayOrientation = NewtScreen_RotationNewtCCW2NativeCCW(env, rot);
// swap width and height, since Windows reflects rotated dimension, we don't
if ( DMDO_90 == dm.dmDisplayOrientation || DMDO_270 == dm.dmDisplayOrientation ) {
int tempWidth = dm.dmPelsWidth;
dm.dmPelsWidth = dm.dmPelsHeight;
dm.dmPelsHeight = tempWidth;
}
dm.dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
return ( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettings(&dm, 0) ) ? JNI_TRUE : JNI_FALSE ;
}
/*
* Class: jogamp_newt_driver_windows_WindowsWindow
* Method: initIDs0
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
NewtCommon_init(env);
insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V");
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V");
focusActionID = (*env)->GetMethodID(env, clazz, "focusAction", "()Z");
if (insetsChangedID == NULL ||
sizeChangedID == NULL ||
positionChangedID == NULL ||
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowRepaintID == NULL ||
enqueueMouseEventID == NULL ||
sendMouseEventID == NULL ||
enqueueKeyEventID == NULL ||
sendKeyEventID == NULL ||
focusActionID == NULL ||
enqueueRequestFocusID == NULL) {
return JNI_FALSE;
}
BuildDynamicKeyMapTable();
return JNI_TRUE;
}
/*
* Class: jogamp_newt_driver_windows_WindowsWindow
* Method: getNewtWndProc0
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_getNewtWndProc0
(JNIEnv *env, jclass clazz)
{
return (jlong) (intptr_t) wndProc;
}
/*
* Class: jogamp_newt_driver_windows_WindowsWindow
* Method: CreateWindow
*/
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWindow0
(JNIEnv *env, jobject obj,
jlong hInstance, jstring jWndClassName, jstring jWndName,
jlong parent, jlong visualID, jboolean bIsUndecorated,
jint jx, jint jy, jint defaultWidth, jint defaultHeight)
{
HWND parentWindow = (HWND) (intptr_t) parent;
const TCHAR* wndClassName = NULL;
const TCHAR* wndName = NULL;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP;
int x=(int)jx, y=(int)jy;
int width=(int)defaultWidth, height=(int)defaultHeight;
HWND window = NULL;
#ifdef UNICODE
wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName);
wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName);
#else
wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL);
wndName = (*env)->GetStringUTFChars(env, jWndName, NULL);
#endif
if(NULL!=parentWindow) {
if (!IsWindow(parentWindow)) {
DBG_PRINT("*** WindowsWindow: CreateWindow failure: Passed parentWindow %p is invalid\n", parentWindow);
return 0;
}
windowStyle |= WS_CHILD ;
} else if (bIsUndecorated) {
windowStyle |= WS_POPUP | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
} else {
windowStyle |= WS_OVERLAPPEDWINDOW;
x = CW_USEDEFAULT;
y = 0;
}
(void) visualID; // FIXME: use the visualID ..
window = CreateWindow(wndClassName, wndName, windowStyle,
x, y, width, height,
parentWindow, NULL,
(HINSTANCE) (intptr_t) hInstance,
NULL);
DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, parent %p, window %p, %d/%d %dx%d\n",
(int)GetCurrentThreadId(), parentWindow, window, x, y, width, height);
if (NULL == window) {
int lastError = (int) GetLastError();
DBG_PRINT("*** WindowsWindow: CreateWindow failure: 0x%X %d\n", lastError, lastError);
return 0;
} else {
WindowUserData * wud = (WindowUserData *) malloc(sizeof(WindowUserData));
wud->jinstance = (*env)->NewGlobalRef(env, obj);
wud->jenv = env;
#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 )
SetWindowLong(window, GWL_USERDATA, (intptr_t) wud);
#else
SetWindowLongPtr(window, GWLP_USERDATA, (intptr_t) wud);
#endif
UpdateInsets(env, obj, window);
}
#ifdef UNICODE
free((void*) wndClassName);
free((void*) wndName);
#else
(*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName);
(*env)->ReleaseStringUTFChars(env, jWndName, wndName);
#endif
return (jlong) (intptr_t) window;
}
/*
* Class: jogamp_newt_driver_windows_WindowsWindow
* Method: MonitorFromWindow
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_MonitorFromWindow0
(JNIEnv *env, jobject obj, jlong window)
{
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE)
return (jlong) (intptr_t) MonitorFromWindow((HWND) (intptr_t) window, MONITOR_DEFAULTTOPRIMARY);
#else
return 0;
#endif
}
/***
* returns bits: 1: size change, 2: pos change
*/
int NewtWindow_setVisiblePosSize(JNIEnv *env, jobject obj, HWND hwnd, jboolean top, jboolean visible,
int x, int y, int width, int height)
{
UINT flags;
HWND hWndInsertAfter;
BOOL bRes;
int iRes=0;
int wwidth = width; // final window width
int wheight = height; // final window height
DBG_PRINT("*** WindowsWindow: NewtWindow_setVisiblePosSize %d/%d %dx%d, top %d, visible %d\n",
x, y, width, height, (int)top, (int)visible);
if(JNI_TRUE == visible) {
flags = SWP_SHOWWINDOW;
} else {
flags = SWP_NOACTIVATE | SWP_NOZORDER;
}
if(0>x || 0>y ) {
flags |= SWP_NOMOVE;
} else {
iRes |= 2;
}
if(0>=width || 0>=height ) {
flags |= SWP_NOSIZE;
} else {
iRes |= 1;
}
if(JNI_TRUE == top) {
hWndInsertAfter = HWND_TOPMOST;
if ( 0 == ( flags & SWP_NOSIZE ) ) {
// since width, height are the size of the client area, we need to add insets
RECT *pInsets = UpdateInsets(env, obj, hwnd);
wwidth += pInsets->left + pInsets->right;
wheight += pInsets->top + pInsets->bottom;
}
DBG_PRINT("*** WindowsWindow: NewtWindow_setVisiblePosSize top size w/ insets: %d/%d %dx%d\n", x, y, wwidth, wheight);
} else {
hWndInsertAfter = HWND_TOP;
DBG_PRINT("*** WindowsWindow: NewtWindow_setVisiblePosSize client size: %d/%d %dx%d\n", x, y, wwidth, wheight);
}
SetWindowPos(hwnd, hWndInsertAfter, x, y, wwidth, wheight, flags);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
// we report back the size of client area
(*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height, JNI_FALSE);
return iRes;
}
/*
* Class: jogamp_newt_driver_windows_WindowsWindow
* Method: setVisible0
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setVisible0
(JNIEnv *env, jobject obj, jlong window, jboolean visible, jboolean top, jint x, jint y, jint width, jint height)
{
HWND hwnd = (HWND) (intptr_t) window;
DBG_PRINT("*** WindowsWindow: setVisible window %p, visible: %d, top %d, %d/%d %dx%d\n",
hwnd, (int)visible, (int)top, x, y, width, height);
if (visible) {
NewtWindow_setVisiblePosSize(env, obj, hwnd, top, visible, x, y, width, height);
ShowWindow(hwnd, SW_SHOW);
} else {
ShowWindow(hwnd, SW_HIDE);
}
}
static jboolean NewtWindows_setFullScreen(jboolean fullscreen)
{
int flags = 0;
DEVMODE dm;
// initialize the DEVMODE structure
ZeroMemory(&dm, sizeof(dm));